")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -252,12 +174,12 @@ func buttonItem(item DropdownItem) templ.Component {
return templ_7745c5c3_Err
}
}
- var templ_7745c5c3_Var14 string
- templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(item.Label)
+ var templ_7745c5c3_Var6 string
+ templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.Label)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `gropdown-content-item.templ`, Line: 47, Col: 14}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `gropdown-content-item.templ`, Line: 45, Col: 14}
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -271,97 +193,3 @@ func buttonItem(item DropdownItem) templ.Component {
return templ_7745c5c3_Err
})
}
-
-func divider() templ.Component {
- return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
- templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
- if !templ_7745c5c3_IsBuffer {
- templ_7745c5c3_Buffer = templ.GetBuffer()
- defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
- }
- ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var15 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var15 == nil {
- templ_7745c5c3_Var15 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- var templ_7745c5c3_Var16 = []any{gddContent_ItemDivider()}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var16...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if !templ_7745c5c3_IsBuffer {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
- }
- return templ_7745c5c3_Err
- })
-}
-
-func gddContent_Item() templ.CSSClass {
- var templ_7745c5c3_CSSBuilder strings.Builder
- templ_7745c5c3_CSSBuilder.WriteString(`position:relative;`)
- templ_7745c5c3_CSSBuilder.WriteString(`display:flex;`)
- templ_7745c5c3_CSSBuilder.WriteString(`width:100%;`)
- templ_7745c5c3_CSSBuilder.WriteString(`text-decoration:none;`)
- templ_7745c5c3_CSSBuilder.WriteString(`gap:var(--gdd-item-icon-space);`)
- templ_7745c5c3_CSSBuilder.WriteString(`padding:var(--gdd-item-py) var(--gdd-item-px);`)
- templ_7745c5c3_CSSBuilder.WriteString(`color:var(--gdd-item-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`font-family:var(--gdd-item-font-family);`)
- templ_7745c5c3_CSSBuilder.WriteString(`font-size:var(--gdd-item-font-size);`)
- templ_7745c5c3_CSSBuilder.WriteString(`line-height:var(--gdd-item-line-height);`)
- templ_7745c5c3_CSSBuilder.WriteString(`letter-spacing:var(--gdd-item-letter-spacing);`)
- templ_7745c5c3_CSSBuilder.WriteString(`background-color:var(--gdd-item-bg-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-width:var(--gdd-item-border-width);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-style:var(--gdd-item-border-style);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-color:var(--gdd-item-border-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-radius:var(--gdd-item-border-radius);`)
- templ_7745c5c3_CSSID := templ.CSSID(`gddContent_Item`, templ_7745c5c3_CSSBuilder.String())
- return templ.ComponentCSSClass{
- ID: templ_7745c5c3_CSSID,
- Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`),
- }
-}
-
-func gddContent_ItemIcon() templ.CSSClass {
- var templ_7745c5c3_CSSBuilder strings.Builder
- templ_7745c5c3_CSSBuilder.WriteString(`display:inline-flex;`)
- templ_7745c5c3_CSSBuilder.WriteString(`align-items:center;`)
- templ_7745c5c3_CSSBuilder.WriteString(`flex-shrink:0;`)
- templ_7745c5c3_CSSBuilder.WriteString(`width:1.25em;`)
- templ_7745c5c3_CSSBuilder.WriteString(`height:1.25em;`)
- templ_7745c5c3_CSSID := templ.CSSID(`gddContent_ItemIcon`, templ_7745c5c3_CSSBuilder.String())
- return templ.ComponentCSSClass{
- ID: templ_7745c5c3_CSSID,
- Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`),
- }
-}
-
-func gddContent_ItemDivider() templ.CSSClass {
- var templ_7745c5c3_CSSBuilder strings.Builder
- templ_7745c5c3_CSSBuilder.WriteString(`height:0;`)
- templ_7745c5c3_CSSBuilder.WriteString(`margin:0.125rem 0;`)
- templ_7745c5c3_CSSBuilder.WriteString(`overflow:hidden;`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-top:var(--gdd-item-divider-width) var(--gdd-item-divider-style) var(--gdd-item-divider-color);`)
- templ_7745c5c3_CSSID := templ.CSSID(`gddContent_ItemDivider`, templ_7745c5c3_CSSBuilder.String())
- return templ.ComponentCSSClass{
- ID: templ_7745c5c3_CSSID,
- Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`),
- }
-}
diff --git a/gropdown-content.templ b/gropdown-content.templ
index 305875b..56d5886 100644
--- a/gropdown-content.templ
+++ b/gropdown-content.templ
@@ -1,39 +1,13 @@
package gropdown
-templ content(dropdown *Dropdown) {
+templ Content() {
- for _, item := range dropdown.Items {
- @contentItem(item)
- }
+ { children... }
}
-
-css gddContent() {
- position: absolute;
- z-index: 10;
- overflow: hidden;
- list-style: none;
- width: var(--gdd-content-w);
- max-width: var(--gdd-content-max-w);
- margin: var(--gdd-content-my) var(--gdd-content-mx);
- padding: var(--gdd-content-py) var(--gdd-content-px);
- background-color: var(--gdd-content-bg-color);
- border-width: var(--gdd-content-border-width);
- border-style: var(--gdd-content-border-style);
- border-color: var(--gdd-content-border-color);
- border-radius: var(--gdd-content-border-radius);
- transition: opacity var(--gdd-content-animation-duration) var(--gdd-content-animation-timing-function);
- animation-duration: var(--gdd-content-animation-duration);
- animation-direction: var(--gdd-content-animation-direction);
- animation-timing-function: var(--gdd-content-animation-timing-function);
-}
diff --git a/gropdown-content_templ.go b/gropdown-content_templ.go
index f109c5b..7e574ab 100644
--- a/gropdown-content_templ.go
+++ b/gropdown-content_templ.go
@@ -9,9 +9,8 @@ import "github.com/a-h/templ"
import "context"
import "io"
import "bytes"
-import "strings"
-func content(dropdown *Dropdown) templ.Component {
+func Content() templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
@@ -24,75 +23,40 @@ func content(dropdown *Dropdown) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- var templ_7745c5c3_Var2 = []any{gddContent()}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- if dropdown.Open {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" data-state=\"open\"")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- } else {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" data-state=\"close\"")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(">")
+ templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- for _, item := range dropdown.Items {
- templ_7745c5c3_Err = contentItem(item).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
@@ -103,29 +67,3 @@ func content(dropdown *Dropdown) templ.Component {
return templ_7745c5c3_Err
})
}
-
-func gddContent() templ.CSSClass {
- var templ_7745c5c3_CSSBuilder strings.Builder
- templ_7745c5c3_CSSBuilder.WriteString(`position:absolute;`)
- templ_7745c5c3_CSSBuilder.WriteString(`z-index:10;`)
- templ_7745c5c3_CSSBuilder.WriteString(`overflow:hidden;`)
- templ_7745c5c3_CSSBuilder.WriteString(`list-style:none;`)
- templ_7745c5c3_CSSBuilder.WriteString(`width:var(--gdd-content-w);`)
- templ_7745c5c3_CSSBuilder.WriteString(`max-width:var(--gdd-content-max-w);`)
- templ_7745c5c3_CSSBuilder.WriteString(`margin:var(--gdd-content-my) var(--gdd-content-mx);`)
- templ_7745c5c3_CSSBuilder.WriteString(`padding:var(--gdd-content-py) var(--gdd-content-px);`)
- templ_7745c5c3_CSSBuilder.WriteString(`background-color:var(--gdd-content-bg-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-width:var(--gdd-content-border-width);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-style:var(--gdd-content-border-style);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-color:var(--gdd-content-border-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-radius:var(--gdd-content-border-radius);`)
- templ_7745c5c3_CSSBuilder.WriteString(`transition:opacity var(--gdd-content-animation-duration) var(--gdd-content-animation-timing-function);`)
- templ_7745c5c3_CSSBuilder.WriteString(`animation-duration:var(--gdd-content-animation-duration);`)
- templ_7745c5c3_CSSBuilder.WriteString(`animation-direction:var(--gdd-content-animation-direction);`)
- templ_7745c5c3_CSSBuilder.WriteString(`animation-timing-function:var(--gdd-content-animation-timing-function);`)
- templ_7745c5c3_CSSID := templ.CSSID(`gddContent`, templ_7745c5c3_CSSBuilder.String())
- return templ.ComponentCSSClass{
- ID: templ_7745c5c3_CSSID,
- Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`),
- }
-}
diff --git a/gropdown-css.templ b/gropdown-css.templ
index 19f5129..dd4a4e1 100644
--- a/gropdown-css.templ
+++ b/gropdown-css.templ
@@ -66,8 +66,8 @@ templ GropdownCSS() {
--gdd-primary-lightest: var(--gdd-primary-10);
--gdd-primary-lighter: var(--gdd-primary-20);
- --gdd-primary-light: var(--gdd-primary-40);
- --gdd-primary-dark: var(--gdd-primary-60);
+ --gdd-primary-light: var(--gdd-primary-30);
+ --gdd-primary-dark: var(--gdd-primary-70);
--gdd-primary-darker: var(--gdd-primary-80);
--gdd-primary-darkest: var(--gdd-primary-90);
@@ -221,20 +221,118 @@ templ GropdownCSS() {
}
}
- /* ******************* */
- /* Dropdown Container */
- /* ******************* */
- div[data-position="top"] ul[class*="gddContent"] {
+ /* ********************************************* *
+ * Dropdown Container
+ * ********************************************* */
+ .gdd_gropdown_container {
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ font-smooth: auto;
+ position: relative;
+ display: inline-block;
+ }
+
+ /* ********************************************* *
+ * Dropdown Button
+ * ********************************************* */
+ .gdd_button {
+ cursor: pointer;
+ min-width: var(--gdd-button-min-w);
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: var(--gdd-button-icon-space);
+ margin: 0;
+ padding: var(--gdd-button-py) var(--gdd-button-px);
+ color: var(--gdd-button-color);
+ border-width: var(--gdd-button-border-width);
+ border-style: var(--gdd-button-border-style);
+ border-color: var(--gdd-button-border-color);
+ border-radius: var(--gdd-button-border-radius);
+ background-color: var(--gdd-button-bg-color);
+ font-family: var(--gdd-button-font-family);
+ font-size: var(--gdd-button-font-size);
+ font-weight: var(--gdd-button-font-weight);
+ line-height: var(--gdd-button-line-height);
+ letter-spacing: var(--gdd-button-letter-spacing);
+ text-transform: none;
+ text-decoration-line: var(--_text-decoration-line);
+ transition: var(--gdd-button-transition-property) var(--gdd-button-transition-duration) var(--gdd-button-transition-timing-function);
+ }
+
+ .gdd_button:hover {
+ color: var(--gdd-button-color-hover);
+ background-color: var(--gdd-button-bg-color-hover);
+ }
+
+ .gdd_button:focus,
+ .gdd_button:focus-visible {
+ color: var(--gdd-button-color-hover);
+ background-color: var(--gdd-button-bg-color-hover);
+ outline: var(--gdd-button-ring-color) var(--gdd-button-ring-style) var(--gdd-button-ring-width);
+ outline-offset: var(--gdd-button-ring-offset);
+ }
+
+ .gdd_button_icon {
+ display: inline-flex;
+ align-items: center;
+ flex-shrink: 0;
+ width: 1em;
+ height: 1em;
+ }
+
+ .gdd_button_icon_only {
+ min-width: 2.5rem;
+ padding: 0;
+ width: 2.5rem;
+ height: 2.5rem;
+ border-radius: 1e5px;
+ aspect-ratio: 1;
+ }
+
+ /* Apply animations based on classes */
+ .iconToOpen {
+ animation: var(--gdd-button-animation-open-name) 0.3s ease forwards;
+ }
+
+ .iconToClose {
+ animation: var(--gdd-button-animation-close-name) 0.3s ease forwards;
+ }
+
+ /* ********************************************* *
+ * Dropdown Content
+ * ********************************************* */
+ .gdd_content {
+ position: absolute;
+ z-index: 10;
+ overflow: hidden;
+ list-style: none;
+ width: var(--gdd-content-w);
+ max-width: var(--gdd-content-max-w);
+ margin: var(--gdd-content-my) var(--gdd-content-mx);
+ padding: var(--gdd-content-py) var(--gdd-content-px);
+ background-color: var(--gdd-content-bg-color);
+ border-width: var(--gdd-content-border-width);
+ border-style: var(--gdd-content-border-style);
+ border-color: var(--gdd-content-border-color);
+ border-radius: var(--gdd-content-border-radius);
+ transition: opacity var(--gdd-content-animation-duration) var(--gdd-content-animation-timing-function);
+ animation-duration: var(--gdd-content-animation-duration);
+ animation-direction: var(--gdd-content-animation-direction);
+ animation-timing-function: var(--gdd-content-animation-timing-function);
+ }
+
+ [data-position="top"] .gdd_content {
top: auto;
bottom: 100%;
}
- div[data-position="bottom"] ul[class*="gddContent"] {
+ [data-position="bottom"] .gdd_content {
top: 100%;
bottom: auto;
}
- div[data-position="left"] ul[class*="gddContent"] {
+ [data-position="left"] .gdd_content {
--gdd-content-my: 0;
--gdd-content-mx: 0.25rem;
inset-inline-end: 100%;
@@ -242,7 +340,7 @@ templ GropdownCSS() {
bottom: auto;
}
- div[data-position="right"] ul[class*="gddContent"] {
+ [data-position="right"] .gdd_content {
--gdd-content-my: 0;
--gdd-content-mx: 0.25rem;
inset-inline-start: 100%;
@@ -250,71 +348,86 @@ templ GropdownCSS() {
bottom: auto;
}
- /* ******************* */
- /* Dropdown Button */
- /* ******************* */
-
- /* Apply animations based on classes */
- .iconToOpen {
- animation: var(--gdd-button-animation-open-name) 0.3s ease forwards;
+ .gdd_content[data-state="open"] {
+ visibility: visible;
+ opacity: 1;
+ animation-name: var(--gdd-content-animation-name);
}
- .iconToClose {
- animation: var(--gdd-button-animation-close-name) 0.3s ease forwards;
+ .gdd_content[data-state="close"] {
+ visibility: hidden;
+ opacity: 0;
}
- button[class^="gddButton"]:hover,
- button[class^="gddButton"]:focus {
- color: var(--gdd-button-color-hover);
- background-color: var(--gdd-button-bg-color-hover);
- }
+ /* ********************************************* *
+ * Dropdown Content Item
+ * ********************************************* */
+ .gdd_content_item {
+ position: relative;
+ display: flex;
+ width: 100%;
+ text-decoration: none;
+ gap: var(--gdd-item-icon-space);
+ padding: var(--gdd-item-py) var(--gdd-item-px);
+ color: var(--gdd-item-color);
+ font-family: var(--gdd-item-font-family);
+ font-size: var(--gdd-item-font-size);
+ line-height: var(--gdd-item-line-height);
+ letter-spacing: var(--gdd-item-letter-spacing);
+ background-color: var(--gdd-item-bg-color);
+ border-width: var(--gdd-item-border-width);
+ border-style: var(--gdd-item-border-style);
+ border-color: var(--gdd-item-border-color);
+ border-radius: var(--gdd-item-border-radius);
+ }
- button[class^="gddButton"]:focus,
- button[class^="gddButton"]:focus-visible {
- outline: var(--gdd-button-ring-color) var(--gdd-button-ring-style) var(--gdd-button-ring-width);
- outline-offset: var(--gdd-button-ring-offset);
+ .gdd_content_item[href^="http"] {
+ padding-right: 1.25em;
}
- /* ******************* */
- /* Dropdown Content */
- /* ******************* */
- ul[class*="gddContent"][data-state="open"] {
- visibility: visible;
- opacity: 1;
- animation-name: var(--gdd-content-animation-name);
+ .gdd_content_item:hover {
+ color: var(--gdd-item-color-hover);
+ background-color: var(--gdd-item-bg-color-hover);
}
- ul[class*="gddContent"][data-state="close"] {
- visibility: hidden;
- opacity: 0;
+ .gdd_content_item:focus,
+ .gdd_content_item:focus-visible {
+ color: var(--gdd-item-color-hover);
+ background-color: var(--gdd-item-bg-color-hover);
+ outline: var(--gdd-item-ring-color) var(--gdd-item-ring-style) var(--gdd-item-ring-width);
+ outline-offset: var(--gdd-item-ring-offset);
}
- /* ******************* */
- /* Dropdown Item */
- /* ******************* */
- a[class^="gddContent_Item"][href^="http"] {
- padding-right: 1.25em;
+ .gdd_content_item_icon {
+ display: inline-flex;
+ align-items: center;
+ flex-shrink: 0;
+ width: 1.25em;
+ height: 1.25em;
}
- a[class^="gddContent_Item"]:hover,
- a[class^="gddContent_Item"]:focus,
- button[class^="gddContent_Item"]:hover,
- button[class^="gddContent_Item"]:focus {
- color: var(--gdd-item-color-hover);
- background-color: var(--gdd-item-bg-color-hover);
+ .gdd_content_divider {
+ height: 0;
+ margin: 0.125rem 0;
+ overflow: hidden;
+ border-top: var(--gdd-item-divider-width) var(--gdd-item-divider-style) var(--gdd-item-divider-color);
}
- a[class^="gddContent_Item"]:focus,
- a[class^="gddContent_Item"]:focus-visible,
- button[class^="gddContent_Item"]:focus,
- button[class^="gddContent_Item"]:focus-visible {
- outline: var(--gdd-item-ring-color) var(--gdd-item-ring-style) var(--gdd-item-ring-width);
- outline-offset: var(--gdd-item-ring-offset);
+ .gdd_sr_only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ white-space: nowrap;
+ border-width: 0;
}
- /* ******************* */
- /* Animations */
- /* ******************* */
+ /* ********************************************* *
+ * Animations
+ * ********************************************* */
@keyframes fadeIn {
from {
opacity: 0;
@@ -346,15 +459,3 @@ templ GropdownCSS() {
}
}
-
-css gttSrOnly() {
- position: absolute;
- width: 1px;
- height: 1px;
- padding: 0;
- margin: -1px;
- overflow: hidden;
- clip: rect(0, 0, 0, 0);
- white-space: nowrap;
- border-width: 0;
-}
diff --git a/gropdown-css_templ.go b/gropdown-css_templ.go
index febb381..d1916d1 100644
--- a/gropdown-css_templ.go
+++ b/gropdown-css_templ.go
@@ -9,7 +9,6 @@ import "github.com/a-h/templ"
import "context"
import "io"
import "bytes"
-import "strings"
func GropdownCSS() templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
@@ -24,7 +23,7 @@ func GropdownCSS() templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -34,21 +33,3 @@ func GropdownCSS() templ.Component {
return templ_7745c5c3_Err
})
}
-
-func gttSrOnly() templ.CSSClass {
- var templ_7745c5c3_CSSBuilder strings.Builder
- templ_7745c5c3_CSSBuilder.WriteString(`position:absolute;`)
- templ_7745c5c3_CSSBuilder.WriteString(`width:1px;`)
- templ_7745c5c3_CSSBuilder.WriteString(`height:1px;`)
- templ_7745c5c3_CSSBuilder.WriteString(`padding:0;`)
- templ_7745c5c3_CSSBuilder.WriteString(`margin:-1px;`)
- templ_7745c5c3_CSSBuilder.WriteString(`overflow:hidden;`)
- templ_7745c5c3_CSSBuilder.WriteString(`clip:rect(0, 0, 0, 0);`)
- templ_7745c5c3_CSSBuilder.WriteString(`white-space:nowrap;`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-width:0;`)
- templ_7745c5c3_CSSID := templ.CSSID(`gttSrOnly`, templ_7745c5c3_CSSBuilder.String())
- return templ.ComponentCSSClass{
- ID: templ_7745c5c3_CSSID,
- Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`),
- }
-}
diff --git a/gropdown-divider.templ b/gropdown-divider.templ
new file mode 100644
index 0000000..e51d856
--- /dev/null
+++ b/gropdown-divider.templ
@@ -0,0 +1,6 @@
+package gropdown
+
+// Divider indicates whether the item is a divider.
+templ Divider() {
+
+}
diff --git a/gropdown-divider_templ.go b/gropdown-divider_templ.go
new file mode 100644
index 0000000..02fe7e2
--- /dev/null
+++ b/gropdown-divider_templ.go
@@ -0,0 +1,36 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.663
+package gropdown
+
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
+import "github.com/a-h/templ"
+import "context"
+import "io"
+import "bytes"
+
+// Divider indicates whether the item is a divider.
+func Divider() templ.Component {
+ return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if !templ_7745c5c3_IsBuffer {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
+ }
+ return templ_7745c5c3_Err
+ })
+}
diff --git a/gropdown-js.templ b/gropdown-js.templ
index 7e987ed..b592dbe 100644
--- a/gropdown-js.templ
+++ b/gropdown-js.templ
@@ -1,54 +1,21 @@
package gropdown
-script GropdownJS(dropdown *Dropdown) {
- // Utility function to check if a value is null or undefined
- function isNullish(value) {
- return value === null || value === undefined;
- }
-
- // Utility function to checks if a given value is of boolean type and has a value of `true` or `false`.
- function isBool(value) {
- return typeof value === 'boolean' && (value === true || value === false);
- }
-
- // Utility function to check if a given string is a single character.
- function isChar(txt) {
- const charsRegex = /\S/;
- return txt.length === 1 && charsRegex.test(txt);
- }
-
- /**
- * Extracts a string ID from the aria-label attribute of the provided HTML element.
- * @param {HTMLElement} node - The HTML element from which to extract the ID.
- * @returns {string} The extracted string ID, or an empty string if no aria-label attribute is present.
- */
- function getIdFromAriaLabel(node) {
- const ariaLabel = node.getAttribute('aria-label')
-
- if (ariaLabel) {
- return ariaLabel.trim().toLowerCase().replace(/[\s/]/g, '-')
- }
-
- return ''
- }
-
- /**
- * Generates a component ID based on the provided node\'s role and aria-label attributes.
- * @param {HTMLElement} node - The HTML element for which to generate the component ID.
- * @returns {string} The generated component ID.
- */
- function getComponentId(node) {
- const role = node.getAttribute('role');
- const ariaLabel = node.getAttribute('aria-label');
-
- if (role && ariaLabel) {
- return `${role}-${ariaLabel.toLowerCase().replace(/\s+/g, '-')}`
- } else if (role) {
- return role
- } else {
- return ''
- }
- }
+script GropdownJS(configMap *ConfigMap) {
+ // Utility function to check if a value is null or undefined
+ function isNullish(value) {
+ return value === null || value === undefined;
+ }
+
+ // Utility function to checks if a given value is of boolean type and has a value of `true` or `false`.
+ function isBool(value) {
+ return typeof value === 'boolean' && (value === true || value === false);
+ }
+
+ // Utility function to check if a given string is a single character.
+ function isChar(txt) {
+ const charsRegex = /\S/;
+ return txt.length === 1 && charsRegex.test(txt);
+ }
/**
* The `ComponentFocusManager` class provides focus management for components with multiple
@@ -296,7 +263,7 @@ script GropdownJS(dropdown *Dropdown) {
function a11yActions(node, options) {
let open = options?.open
const animated = options?.animated
- const componentId = getComponentId(node)
+ const componentId = node.getAttribute("id");
const focusManager = new ComponentFocusManager(componentId)
const listGroups = {}
const firstChars = {}
@@ -366,13 +333,10 @@ script GropdownJS(dropdown *Dropdown) {
open = !open
const ariaExpanded = open ? 'true' : 'false'
node
- .querySelector('[class*="gddButton"]')
+ .querySelector('.gdd_button')
.setAttribute('aria-expanded', ariaExpanded)
- const container = node.closest('[class*="gddContainer"]')
- if (!container) return
-
- const ulElement = container.querySelector('ul[role="menu"]')
+ const ulElement = node.querySelector('ul[role="menu"]')
if (!ulElement) return
const currentState = ulElement.getAttribute('data-state')
@@ -393,6 +357,7 @@ script GropdownJS(dropdown *Dropdown) {
node.focus()
}
+ /** ***************** START - Event Handlers ******************************************** */
// Button click event handler.
const onButtonClick = (e) => {
e.stopPropagation()
@@ -483,46 +448,46 @@ script GropdownJS(dropdown *Dropdown) {
const target = e.currentTarget
target.focus()
}
+ /** ***************** END - Event Handlers ******************************************** */
+ const dropdownBtn = node.querySelector(".gdd_button")
+ if (options?.enabled) {
initialize()
-
- const dropdownBtn = node.querySelector('[class*="gddButton"]')
- if (options?.enabled) {
- node.addEventListener('click', onButtonClick)
- node.addEventListener('keydown', onButtonKeydown)
-
- const menuItemNodes = Array.from(node.querySelectorAll('[role="menuitem"]'))
-
- menuItemNodes.forEach((item) => {
- item.addEventListener('keydown', onItemKeydown)
- item.addEventListener('mouseover', onItemMouseOver)
- item.addEventListener('click', onItemClick)
- listGroups[componentId].push(item)
-
- const extractFirstChar = (item) => {
- const textContent = item.textContent?.split('\n').pop().trim();
- const firstChar = textContent ? textContent.trim().toLowerCase()[0] : null;
- return firstChar;
- };
- const contentFirstChar = extractFirstChar(item)
- if (contentFirstChar) firstChars[componentId].push(contentFirstChar)
-
- if (!firstItem[componentId]) {
- firstItem[componentId] = item
- }
- lastItem[componentId] = item
- })
-
- focusManager.items = listGroups
- focusManager.firstChars = firstChars
- focusManager.firstItem = firstItem
- focusManager.lastItem = lastItem
-
- // set the focus on the button when open by default.
- if (open) {
- dropdownBtn.focus()
+ node.addEventListener('click', onButtonClick)
+ node.addEventListener('keydown', onButtonKeydown)
+
+ const menuItemNodes = Array.from(node.querySelectorAll('[role="menuitem"]'))
+
+ menuItemNodes.forEach((item) => {
+ item.addEventListener('keydown', onItemKeydown)
+ item.addEventListener('mouseover', onItemMouseOver)
+ item.addEventListener('click', onItemClick)
+ listGroups[componentId].push(item)
+
+ const extractFirstChar = (item) => {
+ const textContent = item.textContent?.split('\n').pop().trim();
+ const firstChar = textContent ? textContent.trim().toLowerCase()[0] : null;
+ return firstChar;
+ };
+ const contentFirstChar = extractFirstChar(item)
+ if (contentFirstChar) firstChars[componentId].push(contentFirstChar)
+
+ if (!firstItem[componentId]) {
+ firstItem[componentId] = item
}
- }
+ lastItem[componentId] = item
+ })
+
+ focusManager.items = listGroups
+ focusManager.firstChars = firstChars
+ focusManager.firstItem = firstItem
+ focusManager.lastItem = lastItem
+
+ // set the focus on the button when open by default.
+ if (open) {
+ dropdownBtn.focus()
+ }
+ }
}
/**
@@ -557,13 +522,18 @@ script GropdownJS(dropdown *Dropdown) {
document.body.addEventListener('click', clickOutsideAction);
document.addEventListener('DOMContentLoaded', function () {
- const dropdownContainers = document.querySelectorAll('[class*="gddContainer"]')
- for (let i = 0; i < dropdownContainers.length; i++) {
- a11yActions(dropdownContainers[i], {
- enabled: true,
- open: dropdown.Open,
- animated: dropdown.Animation,
- })
- }
+ // Loop over all tabber components in the page and initialise them.
+ for (const key in configMap.Data) {
+ const gropdownConfig = configMap.Data[key];
+ const containerNode = document.getElementById(`gropdown-container-${key}`);
+
+ if (containerNode !== null) {
+ a11yActions(containerNode, {
+ enabled: true,
+ open: gropdownConfig.Open,
+ animated: gropdownConfig.Animation,
+ })
+ }
+ }
});
}
diff --git a/gropdown-js_templ.go b/gropdown-js_templ.go
index 084dce5..f449915 100644
--- a/gropdown-js_templ.go
+++ b/gropdown-js_templ.go
@@ -7,57 +7,24 @@ package gropdown
import "github.com/a-h/templ"
-func GropdownJS(dropdown *Dropdown) templ.ComponentScript {
+func GropdownJS(configMap *ConfigMap) templ.ComponentScript {
return templ.ComponentScript{
- Name: `__templ_GropdownJS_c0e9`,
- Function: `function __templ_GropdownJS_c0e9(dropdown){// Utility function to check if a value is null or undefined
- function isNullish(value) {
- return value === null || value === undefined;
- }
-
- // Utility function to checks if a given value is of boolean type and has a value of ` + "`" + `true` + "`" + ` or ` + "`" + `false` + "`" + `.
- function isBool(value) {
- return typeof value === 'boolean' && (value === true || value === false);
- }
-
- // Utility function to check if a given string is a single character.
- function isChar(txt) {
- const charsRegex = /\S/;
- return txt.length === 1 && charsRegex.test(txt);
- }
-
- /**
- * Extracts a string ID from the aria-label attribute of the provided HTML element.
- * @param {HTMLElement} node - The HTML element from which to extract the ID.
- * @returns {string} The extracted string ID, or an empty string if no aria-label attribute is present.
- */
- function getIdFromAriaLabel(node) {
- const ariaLabel = node.getAttribute('aria-label')
-
- if (ariaLabel) {
- return ariaLabel.trim().toLowerCase().replace(/[\s/]/g, '-')
- }
-
- return ''
- }
-
- /**
- * Generates a component ID based on the provided node\'s role and aria-label attributes.
- * @param {HTMLElement} node - The HTML element for which to generate the component ID.
- * @returns {string} The generated component ID.
- */
- function getComponentId(node) {
- const role = node.getAttribute('role');
- const ariaLabel = node.getAttribute('aria-label');
-
- if (role && ariaLabel) {
- return ` + "`" + `${role}-${ariaLabel.toLowerCase().replace(/\s+/g, '-')}` + "`" + `
- } else if (role) {
- return role
- } else {
- return ''
- }
- }
+ Name: `__templ_GropdownJS_c9d1`,
+ Function: `function __templ_GropdownJS_c9d1(configMap){// Utility function to check if a value is null or undefined
+ function isNullish(value) {
+ return value === null || value === undefined;
+ }
+
+ // Utility function to checks if a given value is of boolean type and has a value of ` + "`" + `true` + "`" + ` or ` + "`" + `false` + "`" + `.
+ function isBool(value) {
+ return typeof value === 'boolean' && (value === true || value === false);
+ }
+
+ // Utility function to check if a given string is a single character.
+ function isChar(txt) {
+ const charsRegex = /\S/;
+ return txt.length === 1 && charsRegex.test(txt);
+ }
/**
* The ` + "`" + `ComponentFocusManager` + "`" + ` class provides focus management for components with multiple
@@ -305,7 +272,7 @@ func GropdownJS(dropdown *Dropdown) templ.ComponentScript {
function a11yActions(node, options) {
let open = options?.open
const animated = options?.animated
- const componentId = getComponentId(node)
+ const componentId = node.getAttribute("id");
const focusManager = new ComponentFocusManager(componentId)
const listGroups = {}
const firstChars = {}
@@ -375,13 +342,10 @@ func GropdownJS(dropdown *Dropdown) templ.ComponentScript {
open = !open
const ariaExpanded = open ? 'true' : 'false'
node
- .querySelector('[class*="gddButton"]')
+ .querySelector('.gdd_button')
.setAttribute('aria-expanded', ariaExpanded)
- const container = node.closest('[class*="gddContainer"]')
- if (!container) return
-
- const ulElement = container.querySelector('ul[role="menu"]')
+ const ulElement = node.querySelector('ul[role="menu"]')
if (!ulElement) return
const currentState = ulElement.getAttribute('data-state')
@@ -402,6 +366,7 @@ func GropdownJS(dropdown *Dropdown) templ.ComponentScript {
node.focus()
}
+ /** ***************** START - Event Handlers ******************************************** */
// Button click event handler.
const onButtonClick = (e) => {
e.stopPropagation()
@@ -492,46 +457,46 @@ func GropdownJS(dropdown *Dropdown) templ.ComponentScript {
const target = e.currentTarget
target.focus()
}
+ /** ***************** END - Event Handlers ******************************************** */
+ const dropdownBtn = node.querySelector(".gdd_button")
+ if (options?.enabled) {
initialize()
-
- const dropdownBtn = node.querySelector('[class*="gddButton"]')
- if (options?.enabled) {
- node.addEventListener('click', onButtonClick)
- node.addEventListener('keydown', onButtonKeydown)
-
- const menuItemNodes = Array.from(node.querySelectorAll('[role="menuitem"]'))
-
- menuItemNodes.forEach((item) => {
- item.addEventListener('keydown', onItemKeydown)
- item.addEventListener('mouseover', onItemMouseOver)
- item.addEventListener('click', onItemClick)
- listGroups[componentId].push(item)
-
- const extractFirstChar = (item) => {
- const textContent = item.textContent?.split('\n').pop().trim();
- const firstChar = textContent ? textContent.trim().toLowerCase()[0] : null;
- return firstChar;
- };
- const contentFirstChar = extractFirstChar(item)
- if (contentFirstChar) firstChars[componentId].push(contentFirstChar)
-
- if (!firstItem[componentId]) {
- firstItem[componentId] = item
- }
- lastItem[componentId] = item
- })
-
- focusManager.items = listGroups
- focusManager.firstChars = firstChars
- focusManager.firstItem = firstItem
- focusManager.lastItem = lastItem
-
- // set the focus on the button when open by default.
- if (open) {
- dropdownBtn.focus()
+ node.addEventListener('click', onButtonClick)
+ node.addEventListener('keydown', onButtonKeydown)
+
+ const menuItemNodes = Array.from(node.querySelectorAll('[role="menuitem"]'))
+
+ menuItemNodes.forEach((item) => {
+ item.addEventListener('keydown', onItemKeydown)
+ item.addEventListener('mouseover', onItemMouseOver)
+ item.addEventListener('click', onItemClick)
+ listGroups[componentId].push(item)
+
+ const extractFirstChar = (item) => {
+ const textContent = item.textContent?.split('\n').pop().trim();
+ const firstChar = textContent ? textContent.trim().toLowerCase()[0] : null;
+ return firstChar;
+ };
+ const contentFirstChar = extractFirstChar(item)
+ if (contentFirstChar) firstChars[componentId].push(contentFirstChar)
+
+ if (!firstItem[componentId]) {
+ firstItem[componentId] = item
}
- }
+ lastItem[componentId] = item
+ })
+
+ focusManager.items = listGroups
+ focusManager.firstChars = firstChars
+ focusManager.firstItem = firstItem
+ focusManager.lastItem = lastItem
+
+ // set the focus on the button when open by default.
+ if (open) {
+ dropdownBtn.focus()
+ }
+ }
}
/**
@@ -566,17 +531,22 @@ func GropdownJS(dropdown *Dropdown) templ.ComponentScript {
document.body.addEventListener('click', clickOutsideAction);
document.addEventListener('DOMContentLoaded', function () {
- const dropdownContainers = document.querySelectorAll('[class*="gddContainer"]')
- for (let i = 0; i < dropdownContainers.length; i++) {
- a11yActions(dropdownContainers[i], {
- enabled: true,
- open: dropdown.Open,
- animated: dropdown.Animation,
- })
- }
+ // Loop over all tabber components in the page and initialise them.
+ for (const key in configMap.Data) {
+ const gropdownConfig = configMap.Data[key];
+ const containerNode = document.getElementById(` + "`" + `gropdown-container-${key}` + "`" + `);
+
+ if (containerNode !== null) {
+ a11yActions(containerNode, {
+ enabled: true,
+ open: gropdownConfig.Open,
+ animated: gropdownConfig.Animation,
+ })
+ }
+ }
});
}`,
- Call: templ.SafeScript(`__templ_GropdownJS_c0e9`, dropdown),
- CallInline: templ.SafeScriptInline(`__templ_GropdownJS_c0e9`, dropdown),
+ Call: templ.SafeScript(`__templ_GropdownJS_c9d1`, configMap),
+ CallInline: templ.SafeScriptInline(`__templ_GropdownJS_c9d1`, configMap),
}
}
diff --git a/gropdown-list.templ b/gropdown-list.templ
deleted file mode 100644
index 3574cc4..0000000
--- a/gropdown-list.templ
+++ /dev/null
@@ -1,31 +0,0 @@
-package gropdown
-
-templ itemsList(dropdown *Dropdown) {
-
- for _, item := range dropdown.Items {
- @entry(item)
- }
-
-}
-
-css gddUL() {
- overflow: hidden;
- list-style: none;
- width: var(--gdd-list-w);
- max-width: var(--gdd-list-max-w);
- margin: var(--gdd-list-my) var(--gdd-list-mx);
- padding: var(--gdd-list-py) var(--gdd-list-px);
- background-color: var(--gdd-list-bg-color);
- border-width: var(--gdd-list-border-width);
- border-style: var(--gdd-list-border-style);
- border-color: var(--gdd-list-border-color);
- border-radius: var(--gdd-list-border-radius);
-}
diff --git a/gropdown-list_templ.go b/gropdown-list_templ.go
deleted file mode 100644
index 96d49b4..0000000
--- a/gropdown-list_templ.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// Code generated by templ - DO NOT EDIT.
-
-// templ: version: v0.2.663
-package gropdown
-
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
-
-import "github.com/a-h/templ"
-import "context"
-import "io"
-import "bytes"
-import "strings"
-
-func itemsList(dropdown *Dropdown) templ.Component {
- return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
- templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
- if !templ_7745c5c3_IsBuffer {
- templ_7745c5c3_Buffer = templ.GetBuffer()
- defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
- }
- ctx = templ.InitializeContext(ctx)
- templ_7745c5c3_Var1 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var1 == nil {
- templ_7745c5c3_Var1 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- var templ_7745c5c3_Var2 = []any{gddUL()}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- for _, item := range dropdown.Items {
- templ_7745c5c3_Err = entry(item).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- if !templ_7745c5c3_IsBuffer {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
- }
- return templ_7745c5c3_Err
- })
-}
-
-func gddUL() templ.CSSClass {
- var templ_7745c5c3_CSSBuilder strings.Builder
- templ_7745c5c3_CSSBuilder.WriteString(`overflow:hidden;`)
- templ_7745c5c3_CSSBuilder.WriteString(`list-style:none;`)
- templ_7745c5c3_CSSBuilder.WriteString(`width:var(--gdd-list-w);`)
- templ_7745c5c3_CSSBuilder.WriteString(`max-width:var(--gdd-list-max-w);`)
- templ_7745c5c3_CSSBuilder.WriteString(`margin:var(--gdd-list-my) var(--gdd-list-mx);`)
- templ_7745c5c3_CSSBuilder.WriteString(`padding:var(--gdd-list-py) var(--gdd-list-px);`)
- templ_7745c5c3_CSSBuilder.WriteString(`background-color:var(--gdd-list-bg-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-width:var(--gdd-list-border-width);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-style:var(--gdd-list-border-style);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-color:var(--gdd-list-border-color);`)
- templ_7745c5c3_CSSBuilder.WriteString(`border-radius:var(--gdd-list-border-radius);`)
- templ_7745c5c3_CSSID := templ.CSSID(`gddUL`, templ_7745c5c3_CSSBuilder.String())
- return templ.ComponentCSSClass{
- ID: templ_7745c5c3_CSSID,
- Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`),
- }
-}
diff --git a/gropdown.go b/gropdown.go
deleted file mode 100644
index e379e84..0000000
--- a/gropdown.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package gropdown
-
-import "github.com/a-h/templ"
-
-// DropdownBuilder is used to construct Dropdown instances with options.
-type DropdownBuilder struct {
- dropdown *Dropdown
-}
-
-func (b *DropdownBuilder) Dropdown() *Dropdown {
- return b.dropdown
-}
-
-// NewDropdownBuilder creates a new DropdownBuilder instance with default settings.
-func NewDropdownBuilder() *DropdownBuilder {
- return &DropdownBuilder{dropdown: &Dropdown{
- Open: false,
- Animation: true,
- Position: Bottom,
- }}
-}
-
-// SetOpen sets the Open field of the dropdown.
-func (b *DropdownBuilder) SetOpen(open bool) *DropdownBuilder {
- b.dropdown.Open = open
- return b
-}
-
-// SetAnimation sets the animations for the dropdown button icon when open/close.
-func (b *DropdownBuilder) SetAnimation(animation bool) *DropdownBuilder {
- b.dropdown.Animation = animation
- return b
-}
-
-func (b *DropdownBuilder) SetPosition(position Position) *DropdownBuilder {
- b.dropdown.Position = position
- return b
-}
-
-// WithButton sets the Button field of the dropdown.
-func (b *DropdownBuilder) WithButton(button DropdownButton) *DropdownBuilder {
- b.dropdown.Button = button
- return b
-}
-
-// WithItems sets the Items field of the dropdown.
-func (b *DropdownBuilder) WithItems(items []DropdownItem) *DropdownBuilder {
- b.dropdown.Items = items
- return b
-}
-
-// Render constructs and returns a templ.Component representing the dropdown.
-func (b *DropdownBuilder) Render() templ.Component {
- return container(b.dropdown)
-}
diff --git a/gropdown.templ b/gropdown.templ
index e4dbb67..02f180e 100644
--- a/gropdown.templ
+++ b/gropdown.templ
@@ -1,19 +1,13 @@
package gropdown
-templ container(dropdown *Dropdown) {
+import "fmt"
+
+templ Root(id string) {
- @button(dropdown.Button)
- @content(dropdown)
+ { children... }
}
-
-css gddContainer() {
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- font-smooth: auto;
- position: relative;
- display: inline-block;
-}
diff --git a/gropdown_templ.go b/gropdown_templ.go
index dbb2b84..714e6d1 100644
--- a/gropdown_templ.go
+++ b/gropdown_templ.go
@@ -9,9 +9,10 @@ import "github.com/a-h/templ"
import "context"
import "io"
import "bytes"
-import "strings"
-func container(dropdown *Dropdown) templ.Component {
+import "fmt"
+
+func Root(id string) templ.Component {
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
if !templ_7745c5c3_IsBuffer {
@@ -24,34 +25,29 @@ func container(dropdown *Dropdown) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- var templ_7745c5c3_Var2 = []any{gddContainer()}
- templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("