Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grady
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grady Corp.
grady
Commits
78fef852
Commit
78fef852
authored
3 months ago
by
Linus Keiser
Browse files
Options
Downloads
Patches
Plain Diff
feat(sidebar): add visual item grouping for parent-child items
parent
a3efef9e
No related branches found
No related tags found
1 merge request
!312
feat/layout
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/components/SideBar.svelte
+50
-32
50 additions, 32 deletions
src/lib/components/SideBar.svelte
src/routes/(app)/+layout.svelte
+9
-10
9 additions, 10 deletions
src/routes/(app)/+layout.svelte
with
59 additions
and
42 deletions
src/lib/components/SideBar.svelte
+
50
−
32
View file @
78fef852
...
...
@@ -21,36 +21,54 @@
// let expandedIcon = $derived(expanded ? PanelRightCloseIcon : PanelRightOpenIcon);
</script>
<div>
<Navigation.Rail
expanded=
{
sidebarState
.
isOpen
}
{
classes
}
>
{
#snippet
header
()
}
<Navigation.Tile
title=
{
expandedText
}
>
<button
onclick=
{
()
=>
(
sidebarState
.
isOpen
=
!
sidebarState
.
isOpen
)
}
class=
"btn"
>
{
#if
sidebarState
.
isOpen
}
<SidebarCloseIcon
/>
{
:
else
}
<SidebarOpenIcon
/>
{
/if
}
</button>
</Navigation.Tile>
{
/snippet
}
{
#snippet tiles
()
}
<!-- TODO handle nav item children (could just use dividers for grouping) -->
{
#each
sidebarState.content.items as item, index
}
<Navigation.Tile
id=
{
index.toString
()
}
label=
{
item.title
}
labelExpanded=
{
item.description
}
href=
{
item.href
}
>
<item.icon
/>
</Navigation.Tile>
{
/each
}
{
/
snippet
}
{
#snippet
footer
()
}
<Navigation.Tile
labelExpanded=
"Settings"
href=
"/settings"
title=
"settings"
><SettingsIcon
/></Navigation.Tile
<!--<div class="flex flex-col h-full"> -->
<!-- <Navigation.Rail expanded={sidebarState.isOpen} {classes}> -->
<Navigation.Rail
expanded=
{
sidebarState
.
isOpen
}
{
classes
}
>
{
#snippet
header
()
}
<!--<button onclick={() => (sidebarState.isOpen = !sidebarState.isOpen)} class="btn"> -->
<Navigation.Tile
id=
"header-tile"
title=
{
expandedText
}
onclick=
{
(
id
)
=>
(
sidebarState
.
isOpen
=
!
sidebarState
.
isOpen
)
}
>
<ChevronRight
/>
</Navigation.Tile>
<!--</button> -->
{
/
snippet
}
{
#snippet
tiles
()
}
<!-- TODO improve visual item grouping for items with children -->
{
#each
sidebarState
.
content
.
items
as
item
,
index
}
{
#if
item
.
children
}
<hr
class=
"hr border-t-2"
/>
{
/if
}
<Navigation.Tile
id=
{
index
.
toString
()
}
label=
{
item
.
title
}
labelExpanded=
{
item
.
description
}
href=
{
item
.
href
}
>
{
/
snippet
}
</Navigation.Rail>
</div>
<item.icon
/>
</Navigation.Tile>
{
#if
item
.
children
}
{
#each
item
.
children
!
as
itemCh
,
indexCh
}
<Navigation.Tile
id=
{
index
.
toString
().
concat
(
'
-
'
,
indexCh
.
toString
())
}
label=
{
itemCh
.
title
}
labelExpanded=
{
itemCh
.
description
}
href=
{
itemCh
.
href
}
>
<itemCh.icon
/>
</Navigation.Tile>
{
/each
}
<hr
class=
"hr border-t-2"
/>
{
/if
}
{
/each
}
{
/
snippet
}
{
#snippet
footer
()
}
<Navigation.Tile
labelExpanded=
"Settings"
href=
"/settings"
title=
"settings"
><SettingsIcon
/></Navigation.Tile
>
{
/
snippet
}
</Navigation.Rail>
<!-- </div> -->
This diff is collapsed.
Click to expand it.
src/routes/(app)/+layout.svelte
+
9
−
10
View file @
78fef852
...
...
@@ -26,11 +26,11 @@
});
</script>
<div
class=
"grid-rows-
auto
[auto_1fr_auto]
grid h-screen
"
>
<!--
Top
Bar -->
<div
class=
"grid
grid
-rows-[auto_1fr_auto]"
>
<!--
Header
Bar -->
<header
bind:this=
{
headerElement
}
class=
"text-slate-50-950
sticky top-0 z-10
grid grid-cols-3 items-center gap-4 px-4 py-2 bg-primary-200-800"
class=
"text-slate-50-950 grid grid-cols-3 items-center gap-4 px-4 py-2 bg-primary-200-800"
>
<div
class=
"justify-self-start"
>
<p
class=
"text-2xl font-extrabold"
>
...
...
@@ -42,19 +42,18 @@
<div
class=
"justify-self-end"
><ThemeToggle
/></div>
</header>
<!--
Columns
-->
<div
class=
"grid
grid-cols-1 md:
grid-cols-[auto_1fr]"
>
<!--
Page
-->
<div
class=
"grid grid-cols-[auto_1fr]"
>
<!-- Side Bar (subtract header height since it's sticky, too) -->
<SideBar
classes=
"sticky top-0 col-span-1 h-[calc(100vh-{headerHeight}px)]"
/>
<!--<SideBar classes="sticky top-0 col-span-1 h-[calc(100vh-{headerHeight}px)]" /> -->
<SideBar
classes=
"sticky top-0 col-span-1 h-screen"
/>
<!-- Page Route Content -->
<main
class=
"col-span-1 space-y-4 p-2 bg-surface-200-800"
>
{
@
render
children
?.()
}
</main>
<main
class=
"col-span-1 space-y-4 p-2 bg-surface-200-800"
>
{
@
render
children
?.()
}
</main>
</div>
<!-- Footer -->
<!--
<footer class="bg-blue-500 p-4">(footer)</footer>
-->
<footer
class=
"bg-blue-500 p-4"
>
(footer)
</footer>
</div>
<style
lang=
"postcss"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment