All Projects → kimlindholm → phoenix_component_folders

kimlindholm / phoenix_component_folders

Licence: MIT license
Reusable UI components on Phoenix framework

Programming Languages

CSS
56736 projects
elixir
2628 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to phoenix component folders

aframe-colorwheel-component
A-Frame Colorwheel. Based on A-Painter and A-Frame Material 🎨🅰
Stars: ✭ 16 (-48.39%)
Mutual labels:  ui-components
Bulma.io-axure
AxureRP Library with Bulma.io components
Stars: ✭ 90 (+190.32%)
Mutual labels:  ui-components
a11y-accordion-tabs
A script for an accessible accordion tabs component
Stars: ✭ 50 (+61.29%)
Mutual labels:  ui-components
rules
One Framework to build a highly declarative and customizable UI without using templates.
Stars: ✭ 38 (+22.58%)
Mutual labels:  ui-components
phoenix bootstrap form
Bootstrap 4 Forms for Phoenix/Elixir Applications
Stars: ✭ 38 (+22.58%)
Mutual labels:  phoenix-framework
phoenix ujs
Unobtrusive vanilla js toolset to simplify Phoenix framework (and other frameworks) usage
Stars: ✭ 38 (+22.58%)
Mutual labels:  phoenix-framework
vuestic-ui
Free and Open Source UI Library for Vue 3 🤘
Stars: ✭ 1,501 (+4741.94%)
Mutual labels:  ui-components
elixir jobs
A job board to publish and find Elixir offers.
Stars: ✭ 83 (+167.74%)
Mutual labels:  phoenix-framework
open design system
Open Source Design System using Sketch. It's early days of my project.
Stars: ✭ 22 (-29.03%)
Mutual labels:  ui-components
wonder-blocks
React components for Wonder Blocks design system.
Stars: ✭ 110 (+254.84%)
Mutual labels:  ui-components
bulmil
💄 A agnostic UI components library based on Web Components, made with Bulma & Stencil.
Stars: ✭ 121 (+290.32%)
Mutual labels:  ui-components
jqlouds
☁️ An awesome yet simple plugin for jquery that let's you create clouds on the fly.
Stars: ✭ 54 (+74.19%)
Mutual labels:  ui-components
anim search bar
A flutter package that has an animated search bar with loads of customization
Stars: ✭ 28 (-9.68%)
Mutual labels:  ui-components
elixir-course
No description or website provided.
Stars: ✭ 76 (+145.16%)
Mutual labels:  phoenix-framework
wlui
wl-ui 精美易用的前端复杂组件解决方案。Beautiful and easy-to-use front-end complex component solution
Stars: ✭ 32 (+3.23%)
Mutual labels:  ui-components
SwiftUI-Color-Kit
SwiftUI Color Pickers, Gradient Pickers And All The Utilities Needed To Make Your Own!
Stars: ✭ 120 (+287.1%)
Mutual labels:  ui-components
mijin
Tailwind CSS UI components build for Vue.js / Nuxt.js
Stars: ✭ 168 (+441.94%)
Mutual labels:  ui-components
CheckMarkView
UI view which draws programmatically a checkmark with different styles
Stars: ✭ 35 (+12.9%)
Mutual labels:  ui-components
dashkit-ui
UI Components built on React.
Stars: ✭ 17 (-45.16%)
Mutual labels:  ui-components
laratify
Laravel UI Components using TailwindCSS & AlpineJS
Stars: ✭ 13 (-58.06%)
Mutual labels:  ui-components

Phoenix Component Folders

CircleCI Ebert codebeat badge

Reusable UI components on Phoenix framework

Quick tutorial and demo app

Description

If you're using Phoenix to render rich UI components (à la React or Vue), it might be more convenient to group all related code and tests into separate component folders and to make use of some view helpers:

Phoenix Component Folders Screenshot

Here's how to do it on Phoenix 1.3. If you're using version 1.2, just note some minor changes like replacing path lib/my_app_web with web.

Tutorial

Step 1: Add component_helpers.ex

Grab file component_helpers.ex and place it in new folder lib/my_app_web/components.

Step 2: Edit lib/my_app_web.ex

-  def view do
+  def view(opts \\
+      [root: "lib/my_app_web/templates",
+       namespace: MyAppWeb]) do
     quote do
-      use Phoenix.View, root: "lib/my_app_web/templates",
-                        namespace: MyAppWeb
+      use Phoenix.View, unquote(opts)

       # etc...

       import MyAppWeb.Gettext
+      import MyAppWeb.Components.ComponentHelpers
     end
   end

   # etc...

   defmacro __using__(which) when is_atom(which) do
     apply(__MODULE__, which, [])
   end
+  defmacro __using__({which, opts}) when is_atom(which) do
+    apply(__MODULE__, which, [opts])
+  end
 end

Step 3: Add View

Next, you'll need to add a view for each component namespace. For instance, as in the screen shot above, for namespace :comment_feed you'd create file lib/my_app_web/components/comment_feed/comment_feed_view.ex:

defmodule MyAppWeb.Components.CommentFeedView do
  alias MyAppWeb.Components.ComponentHelpers
  use MyAppWeb, {:view, ComponentHelpers.view_opts(:comment_feed)}
end

Done

That's it. Now you're ready to add some templates. See commits Add example components and Migrate example components to the new 1.3 directory structure for a minimal example and add controllers / channels to your UI components as needed. Let's finish up with some usage examples:

<%= c :comment_feed, :comments, assigns %>   <!-- pass all assigns from controller -->
<%= c :comment_feed, :reply_form %>          <!-- no assigns -->
<%= c :comment_feed %>                       <!-- default to index.html.eex template -->

In all the code above, remember to replace occurences of MyApp, my_app, PhoenixComponentFolders and phoenix_component_folders with your app's name.

Original Articles and Code

Demo App

Requirements

  • Phoenix 1.3.0 or later
  • Elixir 1.7 or later
  • Erlang 21 or later

Installation

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Install Node.js dependencies with cd assets && npm install
  • Start Phoenix endpoint with mix s

Now you can visit localhost:4000 from your browser.

License

See LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].