Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A server-side rendering component library for Phoenix

License

NotificationsYou must be signed in to change notification settings

surface-ui/surface

Repository files navigation

Build Status

Surface is aserver-side rendering component library that allows developers tobuildrich interactive user-interfaces, writing minimal custom JavaScript.

Built on top ofPhoenix LiveView and its component API,Surface leverages the amazing Phoenix Framework to provide afast andproductive solutionto build modern web applications.

Full documentation and live examples can be found atsurface-ui.org.

Example

# Defining the componentdefmoduleHellodouseSurface.Component@doc"Someone to say hello to"propname,:string,required:truedefrender(assigns)do~F"""    Hello, {@name}!"""endend# Using the componentdefmoduleExampledouseSurface.Componentdefrender(assigns)do~F"""    <Hello name="John Doe"/>"""endend

Features

  • An HTML-centric templating language, designed specifically to improve development experience.

  • Components as modules - they can be stateless, stateful, renderless or compile-time.

  • Declarative properties - explicitly declare the inputs (properties and events) of each component.

  • Slots - placeholders declared by a component that you can fill up withcustom content.

  • Contexts - allows a parent component to share data with its children without passing them as properties.

  • Compile-time checking of the template structure, components' properties, slots, events and more.

  • Integration with editor/tools for warnings/errors, syntax highlighting, jump-to-definition,auto-completion (soon!) and more.

Installation

Phoenix v1.7 comes with built-in support for LiveView apps. You can create a new phoenix application with:

mix phx.new my_app

Note: In case you want to add Surface to an existing Phoenix application that doesn't haveLiveView properly installed, please see Phoenix Liveview's installation instructions athexdocs.pm/phoenix_live_view/installation.html.

Addsurface to the list of dependencies inmix.exs:

defdepsdo[{:surface,"~> 0.12.0"}]end

Configuring the project usingmix surface.init

After fetching the dependencies withmix deps.get, you can run thesurface.init task toupdate the necessary files in your project.

In case you want the task to also generate a sample component for you, use can use the--demo option.A liveview using the component will be available at the/demo route.

Additionally, the task can also set up aSurface Cataloguefor your project using the--catalogue option. The catalogue will be available at/catalogue.

Note: When using the--demo and--catalogue options together, the task also generates twocatalogue examples and a playground for the sample component.

mix surface.init --demo --catalogue

Start the Phoenix server with:

mix phx.server

That's it! You can now access your application athttp://localhost:4000.

You can see the full list of options provided bysurface.init by running:

mixhelp surface.init

For further information regarding installation, including how to install Surface manually,please visit theGetting Started guide.

Migrating from previous versions

Please see theMigration Guide for details.

Tooling

License

Copyright (c) 2020, Marlus Saraiva.

Surface source code is licensed under theMIT License.

About

A server-side rendering component library for Phoenix

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp