diff --git a/lib/salad_ui.ex b/lib/salad_ui.ex
index 1c858f4..ae00544 100644
--- a/lib/salad_ui.ex
+++ b/lib/salad_ui.ex
@@ -49,6 +49,15 @@ defmodule SaladUI do
import SaladUI.Tabs
import SaladUI.Textarea
import SaladUI.Tooltip
+ import SaladUI.Collapsible
+ import SaladUI.Chart
+ import SaladUI.AlertDialog
+ import SaladUI.Popover
+ import SaladUI.Accordion
+ import SaladUI.RadioGroup
+ import SaladUI.ToggleGroup
+ import SaladUI.Toggle
+ import SaladUI.Sidebar
end
end
end
diff --git a/lib/salad_ui/helpers.ex b/lib/salad_ui/helpers.ex
index b61864d..958a5b2 100644
--- a/lib/salad_ui/helpers.ex
+++ b/lib/salad_ui/helpers.ex
@@ -162,8 +162,9 @@ defmodule SaladUI.Helpers do
|> Map.keys()
|> Enum.map(fn variant_key ->
# Get the variant value from input or use default
- variant_value = Map.get(class_input, variant_key) ||
- Map.get(default_variants, variant_key)
+ variant_value =
+ Map.get(class_input, variant_key) ||
+ Map.get(default_variants, variant_key)
# Get the variant options map
variant_options = Map.get(variants, variant_key, %{})
@@ -175,8 +176,26 @@ defmodule SaladUI.Helpers do
|> Enum.join(" ")
end
+ @doc """
+ This function build css style string from map of css style
+
+ ## Examples
+ ```elixir
+ css_style = %{
+ "background-color": "red",
+ "color": "white",
+ "font-size": "16px",
+ }
+ style(css_style)
+
+ # => "background-color: red; color: white; font-size: 16px;"
+ ```
+ """
+ def style(css_map) do
+ Enum.map_join(css_map, "; ", fn {k, v} -> "#{k}: #{v}" end) <> ";"
+ end
# Translate error message
# borrowed from https://github.com/petalframework/petal_components/blob/main/lib/petal_components/field.ex#L414
diff --git a/lib/salad_ui/slidebar.ex b/lib/salad_ui/sidebar.ex
similarity index 72%
rename from lib/salad_ui/slidebar.ex
rename to lib/salad_ui/sidebar.ex
index e62e954..97c6f6d 100644
--- a/lib/salad_ui/slidebar.ex
+++ b/lib/salad_ui/sidebar.ex
@@ -6,12 +6,44 @@ defmodule SaladUI.Sidebar do
import SaladUI.Input
import SaladUI.Separator
import SaladUI.Sheet
+ import SaladUI.Skeleton
import SaladUI.Tooltip
@sidebar_width "16rem"
@sidebar_width_mobile "18rem"
@sidebar_width_icon "3rem"
+
+ @doc """
+ Render
+ """
+ attr(:class, :string, default: nil)
+ attr(:rest, :global)
+ slot(:inner_block, required: true)
+
+ def sidebar_provider(assigns) do
+ assigns = assign(assigns, %{sidebar_width: @sidebar_width, sidebar_width_icon: @sidebar_width_icon})
+ ~H"""
+
+ <%= render_slot(@inner_block) %>
+
+ """
+ end
+
@doc """
Render
"""
@@ -72,7 +104,6 @@ defmodule SaladUI.Sidebar do
data-variant={@variant}
data-side={@side}
>
- {/* This is what handles the sidebar gap on desktop */}
+ <%= render_slot(@inner_block) %>
"""
end
@@ -231,7 +264,7 @@ defmodule SaladUI.Sidebar do
attr(:class, :string, default: nil)
attr(:rest, :global)
- def assigns do
+ def sidebar_footer(assigns) do
~H"""
"""
@@ -313,6 +346,7 @@ defmodule SaladUI.Sidebar do
@doc """
Render
+ TODO: class merge not work well here
"""
attr(:class, :string, default: nil)
attr(:rest, :global)
@@ -323,11 +357,11 @@ defmodule SaladUI.Sidebar do