-
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.
Signed-off-by: Guillaume Hivert <[email protected]>
- Loading branch information
Showing
8 changed files
with
80 additions
and
58 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
16 changes: 16 additions & 0 deletions
16
apps/frontend/src/frontend/view/search_input/search_input.gleam
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,16 @@ | ||
import data/msg | ||
import frontend/view/search_input/styles as s | ||
import lustre/attribute as a | ||
import lustre/event as e | ||
|
||
pub fn view(loading loading: Bool, input input: String) { | ||
s.search_input_wrapper(loading, [ | ||
s.search_input(loading, [ | ||
s.search_input_content([ | ||
a.placeholder("Search for a function, or a type"), | ||
e.on_input(msg.UpdateInput), | ||
a.value(input), | ||
]), | ||
]), | ||
]) | ||
} |
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,57 @@ | ||
import frontend/colors/palette | ||
import gleam/bool | ||
import sketch as s | ||
import sketch/lustre/extra as l | ||
import sketch/size.{px} | ||
|
||
pub fn search_input_wrapper(loading: Bool, children) { | ||
let id = "search-input-wrapper-" <> bool.to_string(loading) | ||
l.dynamic("div", [], children, id, [ | ||
s.border_radius(px(18)), | ||
s.overflow("hidden"), | ||
s.grid_area("input"), | ||
s.padding( | ||
px(case loading { | ||
True -> 4 | ||
False -> 0 | ||
}), | ||
), | ||
s.background("linear-gradient(-45deg, #4ce7ff, #c651e5, #e3d8be, #4ce7ff)"), | ||
s.property("background-size", "400% 400%"), | ||
s.transition("padding .3s"), | ||
s.animation("bg-spin 3s linear infinite"), | ||
s.animation_play_state(case loading { | ||
True -> "running" | ||
False -> "paused" | ||
}), | ||
]) | ||
} | ||
|
||
pub fn search_input(loading, children) { | ||
let id_ = "search-input-" <> bool.to_string(loading) | ||
l.dynamic("div", [], children, id_, [ | ||
s.display("flex"), | ||
s.gap(px(6)), | ||
s.border_radius(px(14)), | ||
s.color(palette.dark.charcoal), | ||
s.background(palette.dark.white), | ||
s.transition("padding .3s"), | ||
s.align_items("baseline"), | ||
s.padding( | ||
px(case loading { | ||
True -> 16 | ||
False -> 20 | ||
}), | ||
), | ||
]) | ||
} | ||
|
||
pub fn search_input_content(attributes) { | ||
l.element("input", attributes, [], [ | ||
s.appearance("none"), | ||
s.border("none"), | ||
s.outline("none"), | ||
s.width(size.percent(100)), | ||
s.line_height("1.5"), | ||
]) | ||
} |