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
48589d49
Commit
48589d49
authored
3 months ago
by
Linus Keiser
Browse files
Options
Downloads
Patches
Plain Diff
simplify layout (bars fixed instead of sticky with scrolling main content)
parent
3d70c738
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
+10
-19
10 additions, 19 deletions
src/lib/components/SideBar.svelte
src/routes/(app)/+layout.svelte
+30
-31
30 additions, 31 deletions
src/routes/(app)/+layout.svelte
with
40 additions
and
50 deletions
src/lib/components/SideBar.svelte
+
10
−
19
View file @
48589d49
...
@@ -13,36 +13,27 @@
...
@@ -13,36 +13,27 @@
import
{
sidebarState
}
from
'
$lib/stores/layout.svelte
'
;
import
{
sidebarState
}
from
'
$lib/stores/layout.svelte
'
;
import
{
Navigation
}
from
'
@skeletonlabs/skeleton-svelte
'
;
import
{
Navigation
}
from
'
@skeletonlabs/skeleton-svelte
'
;
let
{
classes
=
'
sticky top-0 col-span-1 h-screen
'
}:
{
classes
?:
string
}
=
$props
();
//
let { classes = 'sticky top-0 col-span-1 h-screen' }: { classes?: string } = $props();
let
expandedText
=
$derived
(
sidebarState
.
isOpen
?
'
Collapse
'
:
'
Expand
'
);
//
let expandedText = $derived(sidebarState.isOpen ? 'Collapse' : 'Expand');
// let expandedIcon = $derived(expanded ? PanelRightCloseIcon : PanelRightOpenIcon);
// let expandedIcon = $derived(expanded ? PanelRightCloseIcon : PanelRightOpenIcon);
</script>
</script>
<!-- TODO ensure active tile stays active after page reload -->
<!-- TODO ensure active tile stays active after page reload -->
<Navigation.Rail
<Navigation.Rail
expanded=
{
sidebarState
.
isOpen
}
>
expanded=
{
sidebarState
.
isOpen
}
height=
"h-screen"
base=
""
classes=
"sticky top-0 col-span-1 "
>
{
#snippet
header
()
}
{
#snippet
header
()
}
<!-- TODO improve collapse/expand button styling and positioning -->
<!-- TODO improve collapse/expand button styling and positioning -->
<!--<div>
<button
onclick=
{
()
=>
(
sidebarState
.
isOpen
=
!
sidebarState
.
isOpen
)
}
class=
"btn btn-sm w-full"
>
<button onclick={() => (sidebarState.isOpen = !sidebarState.isOpen)} class="btn btn-sm">
{
#if
sidebarState
.
isOpen
}
{#if sidebarState.isOpen}
<ChevronLeft
/>
<ChevronLeft />
{
:
else
}
{:else}
<ChevronRight
/>
<ChevronRight />
{
/if
}
{/if}
</button>
</button>
</div>
-->
<Navigation.Tile
id=
"header-tile"
title=
"Home"
labelExpanded=
"Home"
href=
"/"
>
<Navigation.Tile
id=
"header-tile"
title=
"Home"
labelExpanded=
"Home"
href=
"/"
>
<HomeIcon
/>
<HomeIcon
/>
</Navigation.Tile>
</Navigation.Tile>
<!--</button> -->
{
/snippet
}
{
/snippet
}
{
#snippet tiles
()
}
{
#snippet tiles
()
}
<!-- TODO improve visual item grouping for items with children -->
<!-- TODO improve visual item grouping for items with children -->
...
...
This diff is collapsed.
Click to expand it.
src/routes/(app)/+layout.svelte
+
30
−
31
View file @
48589d49
<script
lang=
"ts"
>
<script
lang=
"ts"
>
import
{
page
}
from
'
$app/state
'
;
import
SideBar
from
'
$lib/components/SideBar.svelte
'
;
import
SideBar
from
'
$lib/components/SideBar.svelte
'
;
import
ThemeToggle
from
'
$lib/components/ThemeToggle.svelte
'
;
import
ThemeToggle
from
'
$lib/components/ThemeToggle.svelte
'
;
import
{
onMount
}
from
'
svelte
'
;
let
{
children
}
=
$props
();
let
{
children
}
=
$props
();
let
headerElement
:
HTMLElement
|
null
=
null
;
//
let headerElement: HTMLElement | null = null;
let
headerHeight
:
number
|
null
=
$state
(
null
);
//
let headerHeight: number | null = $state(null);
onMount
(()
=>
{
//
onMount(() => {
const
updateHeaderHeight
=
()
=>
{
//
const updateHeaderHeight = () => {
if
(
headerElement
!==
null
)
{
//
if (headerElement !== null) {
headerHeight
=
headerElement
.
offsetHeight
;
//
headerHeight = headerElement.offsetHeight;
}
//
}
};
//
};
updateHeaderHeight
();
//
updateHeaderHeight();
window
.
addEventListener
(
'
resize
'
,
updateHeaderHeight
);
//
window.addEventListener('resize', updateHeaderHeight);
return
()
=>
{
//
return () => {
window
.
removeEventListener
(
'
resize
'
,
updateHeaderHeight
);
//
window.removeEventListener('resize', updateHeaderHeight);
};
//
};
});
//
});
</script>
</script>
<div
class=
"grid grid-rows-[auto_1fr_auto]"
>
<div
class=
"grid
h-screen
grid-rows-[auto_1fr_auto]"
>
<!-- Header
Bar
-->
<!-- Header -->
<header
<header
bind:this=
{
headerElement
}
class=
"text-slate-50-950 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"
>
<div
class=
"justify-self-start"
>
...
@@ -41,20 +38,22 @@
...
@@ -41,20 +38,22 @@
<div
class=
"justify-self-center text-xl"
>
(Page Title/breadcrumbs?)
</div>
<div
class=
"justify-self-center text-xl"
>
(Page Title/breadcrumbs?)
</div>
<div
class=
"justify-self-end"
><ThemeToggle
/></div>
<div
class=
"justify-self-end"
><ThemeToggle
/></div>
</header>
</header>
<!--<nav>(subheader/trail nav)</nav>-->
<!-- Page -->
<div
class=
"grid grid-cols-[auto_1fr]"
>
<!-- Grid Columns -->
<!-- Side Bar (subtract header height since it's sticky, too) -->
<div
class=
"grid grid-cols-1 overflow-hidden md:grid-cols-[auto_1fr]"
>
<!--<SideBar classes="sticky top-0 col-span-1 h-[calc(100vh-{headerHeight}px)]" /> -->
<!-- Sidebar -->
<!-- TODO change for small screen sizes -->
<aside
class=
"sticky top-0 col-span-1 h-screen bg-yellow-500 p-4"
>
(sidebar)
</aside>
<!-- h-full? apply h-screen if sticky -->
<SideBar
/>
<!-- Page Route Content -->
<main
class=
"col-span-1 space-y-4 p-2 bg-surface-200-800"
>
{
@
render
children
?.()
}
</main>
<!-- main + footer container (so that the footer scrolls into view after main) -->
<main
class=
"space-y-4 overflow-y-auto p-4 bg-surface-200-800"
>
{
@
render
children
?.()
}
</main>
</div>
</div>
<!-- Footer -->
<!-- Footer -->
<footer
class=
"bg-blue-500 p-4"
>
(footer)
</footer>
<!--
<footer class="bg-blue-500 p-4">(footer)</footer>
-->
</div>
</div>
<style
lang=
"postcss"
>
<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