Skip to content

Commit 8f98703

Browse files
Improvements to navigation dropdown (#42)
1 parent 0cb48e6 commit 8f98703

2 files changed

Lines changed: 21 additions & 42 deletions

File tree

app/web/views/components/icons/icons.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const (
3131
LimitsIcon = "ph ph-prohibit text-brand"
3232
SwitchIcon = "ph ph-arrows-left-right text-brand"
3333

34-
NavUpIcon = "ph ph-caret-up"
35-
NavDownIcon = "ph ph-caret-down"
34+
NavUpIcon = "ph ph-caret-up"
35+
NavDownIcon = "ph ph-caret-down"
36+
NavUpDownIcon = "ph ph-caret-up-down"
3637

3738
SourceGitIcon = "git.svg"
3839
SourceDatabaseIcon = "ph ph-database text-sky-700"

app/web/views/shared/breadcrumb.templ

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ templ breadCrumb(crumbs []*bcItem, isHTMLRender bool) {
102102
isProjectDropdownOpen:false,
103103
isEnvironmentDropdownOpen:false,
104104
isApplicationDropdownOpen:false,
105-
select(prop, value) {
105+
select(prop, value, onlyMe) {
106+
if (onlyMe) {
107+
this[prop] = value;
108+
return;
109+
}
106110
this.closeAll()
107111
this[prop] = value;
108112
},
@@ -114,27 +118,11 @@ templ breadCrumb(crumbs []*bcItem, isHTMLRender bool) {
114118
}"
115119
x-cloak
116120
>
117-
<ol class="flex flex-wrap items-center gap-1">
121+
<ol class="flex items-center gap-2">
118122
for _, crumb := range crumbs {
119-
<li class="flex items-center justify-center gap-1">
123+
<li class="flex items-center justify-center gap-2">
120124
@breadCrumbItem(crumb, crumb.identifier, getDropdownIdentifier(crumb.identifier))
121-
<span class="self-end mb-[0.215rem] text-disabled">
122-
<svg
123-
class="rtl:rotate-180 size-2 text-substitute"
124-
aria-hidden="true"
125-
xmlns="http://www.w3.org/2000/svg"
126-
fill="none"
127-
viewBox="0 0 6 10"
128-
>
129-
<path
130-
stroke="currentColor"
131-
stroke-linecap="round"
132-
stroke-linejoin="round"
133-
stroke-width="2"
134-
d="m1 9 4-4-4-4"
135-
></path>
136-
</svg>
137-
</span>
125+
<span class="text-neutral-700">/</span>
138126
</li>
139127
}
140128
</ol>
@@ -144,29 +132,19 @@ templ breadCrumb(crumbs []*bcItem, isHTMLRender bool) {
144132

145133
templ breadCrumbItem(crumb *bcItem, identifier bcIdentifier, isDropDownOpen string) {
146134
if crumb.listUrl != "" || crumb.identifier == bcIdentifierHome {
147-
<span class="flex space-x-2">
135+
<span class="flex items-center gap-1">
148136
<a
149137
href={ crumb.url }
150138
class="link cursor-pointer"
151139
>{ crumb.name }</a>
152140
if crumb.listUrl != "" {
153-
<span class="self-end mb-[0.215rem] text-disabled">
154-
<svg
155-
class="size-2.5 text-link cursor-pointer transition-transform duration-200 ease-in-out"
156-
:class={ fmt.Sprintf("%s ? 'rotate-270' : 'rotate-90'", isDropDownOpen) }
157-
@click={ fmt.Sprintf("select('%[1]s', !%[1]s)", isDropDownOpen) }
158-
aria-hidden="true"
159-
xmlns="http://www.w3.org/2000/svg"
160-
fill="none"
161-
viewBox="0 0 6 10"
162-
>
163-
<path
164-
stroke="currentColor"
165-
stroke-linecap="round"
166-
stroke-linejoin="round"
167-
stroke-width="2"
168-
d="m1 9 4-4-4-4"
169-
></path>
141+
<span
142+
class="text-disabled cursor-pointer hover:bg-secondary"
143+
:class={ fmt.Sprintf("%s ? 'bg-secondary' : ''", isDropDownOpen) }
144+
@click={ fmt.Sprintf("select('%[1]s', !%[1]s, false)", isDropDownOpen) }
145+
>
146+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
147+
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15 12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9"></path>
170148
</svg>
171149
</span>
172150
@breadCrumbDropdown(crumb, identifier, isDropDownOpen)
@@ -180,8 +158,8 @@ templ breadCrumbItem(crumb *bcItem, identifier bcIdentifier, isDropDownOpen stri
180158
templ breadCrumbDropdown(crumb *bcItem, identifier bcIdentifier, isDropDownOpen string) {
181159
<div
182160
x-show={ isDropDownOpen }
183-
x-on:click.away={ fmt.Sprintf("select('%[1]s', false)", isDropDownOpen) }
184-
x-on:keydown.escape.window={ fmt.Sprintf("select('%[1]s', false)", isDropDownOpen) }
161+
x-on:click.away={ fmt.Sprintf("select('%[1]s', false, true)", isDropDownOpen) }
162+
x-on:keydown.escape.window={ fmt.Sprintf("select('%[1]s', false, true)", isDropDownOpen) }
185163
class="absolute top-8 z-10 w-56 min-h-max divide-y divide-divider overflow-hidden rounded border border-divider bg-primary shadow-sm"
186164
>
187165
<div

0 commit comments

Comments
 (0)