michelson/salad_ui

Phoenix Liveview component library inspired by shadcn UI

โ˜… 0Forks 0GitHub โ†—Compare

Project website โ†—

README

A collection of Live View components inspired by shadcn



Tests Module Version Hex Docs Total Download Last Updated

๐Ÿšง V1 is under development, for V0 source code, checkout branch v0

Buy Me a Coffee at ko-fi.com

Installation

  1. Add salad_ui to your mix.exs
def deps do
  [
    {:salad_ui, "~> 0.14"},
  ]
end
  1. Add TwMerge.Cache to application.ex
children = [
    ...,
    TwMerge.Cache
]
  1. Setup salad_ui

3.1 Using salad_ui as part of your project:

This way you can install only components that you want to use or you want to edit SaladUI's component source code to fit your need. If you just want to use SaladUI's components, see Using as library below.

  • Init Salad UI in your project
#> cd your_project
#> mix salad.init

# install some components
#> mix salad.add label button

3.2 Using salad_ui as a library:

  • Init Salad UI in your project with option --as-lib
#> cd your_project
#> mix salad.init --as-lib
  • Using in your project
defmodule MyModule do
    # import any component you need
    import SaladUI.Button

    def render(_) do
      ~H"""
      <.button>Click me</.button>
      """
    end
end

More configuration

  1. Custom error translate function
config :salad_ui, :error_translator_function, {MyAppWeb.CoreComponents, :translate_error}

๐Ÿ› ๏ธ Development

Here is how to start develop SaladUI on local machine.

  1. Clone this repo
  2. Clone https://github.com/bluzky/salad_storybook in the same directory with Salad UI
  3. Start storybook
cd salad_storybook
mix phx.server

Unit Testing

In your project folder make sure the dependencies are installed by running mix deps.get, then once completed you can run:

  • mix test to run tests once or,
  • mix test.watch to watch file and run tests on file changes.

To run the failing tests only, just run mix test.watch --stale.

It's also important to note that you must format your code with mix format before sending a pull request, otherwise the build in github will fail.

List of components

Component v0 v1
Accordion โœ… โœ…
Alert โœ… โœ…
Alert Dialog โœ… โœ…
Avatar โœ… โœ…
Badge โœ… โœ…
Breadcrumb โœ… โœ…
Button โœ… โœ…
Card โœ… โœ…
Carousel โŒ
Checkbox โœ… โœ…
Collapsible โœ… โœ…
Combobox โŒ
Command โŒ โœ… @ilyabayel
Context Menu โŒ
Dialog โœ… โœ…
Drawer โŒ
Dropdown Menu โœ…
Form โœ… โœ…
Hover Card โœ… โœ…
Input โœ… โœ…
Input OTP โŒ
Label โœ… โœ…
Pagination โœ… โœ…
Popover โœ… โœ…
Progress โœ… โœ…
Radio Group โœ… โœ…
Scroll Area โœ… โœ…
Select โœ… โœ…
Separator โœ… โœ…
Sheet โœ… โœ…
Skeleton โœ… โœ…
Slider โœ… โœ…
Switch โœ… โœ…
Table โœ… โœ…
Tabs โœ… โœ…
Textarea โœ… โœ…
Tooltip โœ… โœ…

๐ŸŒŸ Contributors

๐Ÿ˜˜ Credits

This project could not be available without these awesome works:

  • tailwind css an awesome css utility project
  • turboprop I borrow code from here for merging tailwinds classes
  • shadcn/ui which this project is inspired from
  • Phoenix Framework of course

Contributors

bluzkykamarolyilyabayeldarwin67DamascenoVlukaszsamsonpierrelegallrodlobozfeng19selenilegzeashkan117edennisfelixyzforestbmalumMiguel-Herrero

Issues