Giter VIP home page Giter VIP logo

gen_components's Introduction

GenComponents

  • Generates a set of UI heex components to start a project from.
  • Generates a component catalogue live view.
  • Uses daisyUI build on top of tailwindcss

The generated components are meant to be a point to start from. They will reside in your project space, where you can easily adjust them to your needs.

example usage

mix gen.components
mix gen.components -o other_components

Options

  • -o, --output - lowercase name of the module, that will hold the components. Defaults to components

Example

See the demo project for some examples.

To see the demo project in action:

  • checkout the project
  • cd to the components_demo gonzo project
  • run npm install in components_demo/assets
  • call mix gen.components
  • call iex -S mix phx.server
  • visit catalogue

Installation

The package can be installed by adding gen_components to your list of dependencies in mix.exs.

def deps do
  [
    {:gen_components, "~> 0.1.0", only: [:dev]},
    # optional icon package
    {:heroicons, "~> 0.5.0"}
  ]
end

The generated components are meant to be changed after being generated. So it is recommendet to add the components folder to your live reload dev config:

# Watch static and templates for browser reloading.
config :my_app_web, MyAppWeb.Endpoint,
  live_reload: [
    patterns: [
      ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"lib/my_app_web/(live|views|components)/.*(ex)$",
      ~r"lib/my_app_web/templates/.*(eex)$"
    ]
  ]

Run npm install in components_demo/assets, to use tailwind and daisyUI

Install the catalogue

Add the folowing to router.ex inside your project:

if Mix.env() == :dev do
  import MyAppWeb.ComponentsCatalogueLive
  catalogue_routes "/catalogue"
end

Install the Javascript custom components

The custom components are used to format numbers and dates in the browsers locale. To make it work add the following to your app.js

// to activate local format custom components
import "./components"

How to contribute

  1. Use the gonzo project to build your component.
  2. Adapt it to the templates

gen_components's People

Contributors

adingil avatar ouven avatar

Stargazers

 avatar  avatar Daniel Blendea avatar Logan Leger avatar

Watchers

 avatar  avatar Frank Pestke avatar  avatar  avatar

gen_components's Issues

Assigns Bug, when trying to generate new avatar upload

Branch: https://github.com/inspired-consulting/gen_components/tree/avatarUpload

When trying to generate from template, i get this mysterious error, already delete both _build dirs.

* creating lib/components_demo_web/live/components_catalogue.ex
* creating lib/components_demo_web/live/components_catalogue/alerts.ex
** (CompileError) _build/dev/lib/gen_components/priv/templates/gen.components/catalogue/components_catalogue/avatar_upload.ex:102: undefined variable "assigns"
    (elixir 1.13.4) expanding macro: Kernel.var!/1
    _build/dev/lib/gen_components/priv/templates/gen.components/catalogue/components_catalogue/avatar_upload.ex:102: (file)

@ouven can you pls help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.