-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
423 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import gleam/string | ||
import lustre/attribute.{type Attribute, class, type_} | ||
import lustre/element.{type Element} | ||
import lustre/element/html.{div, input, label} | ||
|
||
pub type Colors { | ||
Neutral | ||
Primary | ||
Secondary | ||
Success | ||
Info | ||
Warning | ||
Danger | ||
} | ||
|
||
pub fn switch( | ||
attributes: List(Attribute(a)), | ||
children: List(Element(a)), | ||
) -> Element(a) { | ||
label( | ||
[ | ||
class( | ||
"inline-flex items-center gap-4 cursor-pointer has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50", | ||
), | ||
], | ||
[ | ||
input([type_("checkbox"), class("sr-only peer"), ..attributes]), | ||
div( | ||
[ | ||
class( | ||
[ | ||
"relative rounded-full", | ||
"peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full", | ||
"after:absolute after:top-0.5 after:start-0.5 after:rounded-full after:transition-all", | ||
] | ||
|> string.join(" "), | ||
), | ||
], | ||
[], | ||
), | ||
..children | ||
], | ||
) | ||
} | ||
|
||
pub fn solid(color: Colors) -> Attribute(a) { | ||
case color { | ||
Neutral -> | ||
"[&:checked+div]:bg-neutral [&:checked+div]:after:bg-neutral-foreground" | ||
Primary -> | ||
"[&:checked+div]:bg-primary [&:checked+div]:after:bg-primary-foreground" | ||
Secondary -> | ||
"[&:checked+div]:bg-secondary [&:checked+div]:after:bg-secondary-foreground" | ||
Success -> | ||
"[&:checked+div]:bg-success [&:checked+div]:after:bg-success-foreground" | ||
Info -> "[&:checked+div]:bg-info [&:checked+div]:after:bg-info-foreground" | ||
Warning -> | ||
"[&:checked+div]:bg-warning [&:checked+div]:after:bg-warning-foreground" | ||
Danger -> | ||
"[&:checked+div]:bg-danger [&:checked+div]:after:bg-danger-foreground" | ||
} | ||
|> string.append(" [&+div]:bg-neutral [&+div]:after:bg-neutral-foreground") | ||
|> class | ||
} | ||
|
||
pub fn outlined(color: Colors) -> Attribute(a) { | ||
case color { | ||
Neutral -> | ||
"[&:checked+div]:outline-neutral [&:checked+div]:after:bg-neutral" | ||
Primary -> | ||
"[&:checked+div]:outline-primary [&:checked+div]:after:bg-primary" | ||
Secondary -> | ||
"[&:checked+div]:outline-secondary [&:checked+div]:after:bg-secondary" | ||
Success -> | ||
"[&:checked+div]:outline-success [&:checked+div]:after:bg-success" | ||
Info -> "[&:checked+div]:outline-info [&:checked+div]:after:bg-info" | ||
Warning -> | ||
"[&:checked+div]:outline-warning [&:checked+div]:after:bg-warning" | ||
Danger -> "[&:checked+div]:outline-danger [&:checked+div]:after:bg-danger" | ||
} | ||
|> string.append( | ||
" [&+div]:outline [&+div]:outline-2 [&+div]:outline-neutral [&+div]:bg-neutral-foreground [&+div]:after:bg-neutral", | ||
) | ||
|> class | ||
} | ||
|
||
pub fn ghost(color: Colors) -> Attribute(a) { | ||
case color { | ||
Neutral -> | ||
"[&:checked+div]:ring-neutral [&:checked+div]:bg-neutral [&:checked+div]:after:bg-neutral-foreground" | ||
Primary -> | ||
"[&:checked+div]:ring-primary [&:checked+div]:bg-primary [&:checked+div]:after:bg-primary-foreground" | ||
Secondary -> | ||
"[&:checked+div]:ring-secondary [&:checked+div]:bg-secondary [&:checked+div]:after:bg-secondary-foreground" | ||
Success -> | ||
"[&:checked+div]:ring-success [&:checked+div]:bg-success [&:checked+div]:after:bg-success-foreground" | ||
Info -> | ||
"[&:checked+div]:ring-info [&:checked+div]:bg-info [&:checked+div]:after:bg-info-foreground" | ||
Warning -> | ||
"[&:checked+div]:ring-warning [&:checked+div]:bg-warning [&:checked+div]:after:bg-warning-foreground" | ||
Danger -> | ||
"[&:checked+div]:ring-danger [&:checked+div]:bg-danger [&:checked+div]:after:bg-danger-foreground" | ||
} | ||
|> string.append( | ||
" [&+div]:ring [&+div]:ring-2 [&+div]:ring-neutral [&+div]:bg-neutral-foreground [&+div]:after:bg-neutral [&+div]:after:bg-neutral", | ||
) | ||
|> class | ||
} | ||
|
||
pub fn sm() -> Attribute(a) { | ||
class( | ||
"[&+div]:text-sm [&+div]:w-9 [&+div]:h-5 [&+div]:after:h-4 [&+div]:after:w-4 [&:enabled+div]:hover:after:w-5 [&:checked:enabled+div]:hover:after:w-4", | ||
) | ||
} | ||
|
||
pub fn md() -> Attribute(a) { | ||
class( | ||
"[&+div]:text-md [&+div]:w-11 [&+div]:h-6 [&+div]:after:h-5 [&+div]:after:w-5 [&:enabled+div]:hover:after:w-6 [&:checked:enabled+div]:hover:after:w-5", | ||
) | ||
} | ||
|
||
pub fn lg() -> Attribute(a) { | ||
class( | ||
"[&+div]:text-lg [&+div]:w-[3.25rem] [&+div]:h-7 [&+div]:after:h-6 [&+div]:after:w-6 [&:enabled+div]:hover:after:w-7 [&:checked:enabled+div]:hover:after:w-6", | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
import components/ui/breadcrumbs.{breadcrumbs} | ||
import components/ui/link.{a} | ||
import lustre/attribute.{class} | ||
import components/ui/switch.{switch} | ||
import lustre/attribute.{class, disabled} | ||
import lustre/element.{type Element, text} | ||
import lustre/element/html.{div} | ||
import lustre/ui/icon | ||
|
||
pub fn demo() -> Element(a) { | ||
div([class("flex flex-col items-center gap-4")], [ | ||
breadcrumbs( | ||
[breadcrumbs.light(breadcrumbs.Neutral), breadcrumbs.md()], | ||
icon.chevron_right([class("w-4")]), | ||
[ | ||
a([], [icon.home([class("w-4")]), text("Home")]), | ||
a([], [icon.input([class("w-4")]), text("Music")]), | ||
a([], [icon.person([class("w-4")]), text("Artist")]), | ||
a([], [icon.card_stack_minus([class("w-4")]), text("Album")]), | ||
a([], [icon.heart([class("w-4")]), text("Songs")]), | ||
], | ||
), | ||
div([class("flex flex-wrap gap-4 items-center justify-center w-full")], [ | ||
switch([switch.solid(switch.Neutral), switch.sm(), disabled(True)], [ | ||
text("Disabled"), | ||
]), | ||
switch([switch.outlined(switch.Neutral), switch.sm(), disabled(True)], [ | ||
text("Disabled"), | ||
]), | ||
switch([switch.ghost(switch.Neutral), switch.sm(), disabled(True)], [ | ||
text("Disabled"), | ||
]), | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.