+1
-1
gleam.toml
+1
-1
gleam.toml
+12
-9
src/popcicle.gleam
+12
-9
src/popcicle.gleam
···
1
1
import gleam/bool
2
2
import gleam/dynamic
3
3
import gleam/int
4
-
import gleam/io
5
4
import gleam/list
6
5
import gleam/result
7
-
import lustre
8
-
import lustre/attribute.{attribute, class}
9
-
import lustre/effect
10
-
import lustre/element.{type Element, element} as lu_element
11
-
import lustre/element/html.{div, style, text}
6
+
import lustre/attribute.{attribute}
7
+
import lustre/element.{type Element} as _
8
+
import lustre/element/html.{div, style}
12
9
import lustre/event
13
10
import plinth/browser/document
14
11
import plinth/browser/element.{get_attribute, set_attribute} as pl_element
···
85
82
css: "
86
83
div[data-popcicle-open] {
87
84
position: absolute;
88
-
z-index: 9999;
89
-
transition: all;
90
-
transition-duration: 200ms;
91
85
}
92
86
93
87
div[data-popcicle-open=\"0\"] {
···
175
169
)
176
170
}
177
171
172
+
/// A simple popcicle will add the element in the child parameter where the
173
+
/// function is called. Then when that element is pressed (show_on=popcicle.Click) or
174
+
/// hovered (show_on=popcicle.Hover), it will show the popcicle as a popover
175
+
/// positioned by the position parameter. By default the popcicle and it's
176
+
/// button comes completely unstyled and you *can* use it that way however, it
177
+
/// is highly recommened you create your own styled functions. If you don't
178
+
/// want to do that then there is a prestyled component based on shadcn/ui that
179
+
/// you can simply copy into your project: [Dropdown Menu](https://github.com/dinkelspiel/popcicle/blob/master/examples/dropdown_menu.gleam)
180
+
///
178
181
pub fn popcicle(
179
182
child: Element(a),
180
183
position: PrefferedPosition,
+4
www/priv/static/www.css
+4
www/priv/static/www.css
+1
-1
www/priv/static/www.mjs
+1
-1
www/priv/static/www.mjs
···
3119
3119
toList([
3120
3120
toList([
3121
3121
class$(
3122
-
"p-1 min-w-[8rem] outline-none shadow-md bg-white rounded-md border border-zinc-200 overflow-hidden w-56"
3122
+
"p-1 min-w-[8rem] outline-none shadow-md bg-white rounded-md border border-zinc-200 overflow-hidden w-56 transition-all duration-200"
3123
3123
)
3124
3124
]),
3125
3125
attributes