Simple to use, styleable popovers for Lustre

feat: move some styling to popcicle from global css

Changed files
+20 -13
examples
src
www
priv
static
src
popcicle
components
+1 -1
examples/dropdown_menu.gleam
··· 18 18 list.flatten([ 19 19 [ 20 20 class( 21 - "p-1 min-w-[8rem] outline-none shadow-md bg-white rounded-md border border-zinc-200 overflow-hidden w-56", 21 + "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", 22 22 ), 23 23 ], 24 24 attributes,
+1 -1
gleam.toml
··· 1 1 name = "popcicle" 2 - version = "1.0.1" 2 + version = "1.0.2" 3 3 target = "javascript" 4 4 description = "Simple to use, styleable popovers for Lustre" 5 5 licences = ["Apache-2.0"]
+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
··· 803 803 transition-duration: 150ms; 804 804 } 805 805 806 + .duration-200 { 807 + transition-duration: 200ms; 808 + } 809 + 806 810 .hover\:bg-zinc-100:hover { 807 811 --tw-bg-opacity: 1; 808 812 background-color: rgb(244 244 245 / var(--tw-bg-opacity));
+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
+1 -1
www/src/popcicle/components/dropdown_menu.gleam
··· 18 18 list.flatten([ 19 19 [ 20 20 class( 21 - "p-1 min-w-[8rem] outline-none shadow-md bg-white rounded-md border border-zinc-200 overflow-hidden w-56", 21 + "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", 22 22 ), 23 23 ], 24 24 attributes,