Add content width setting to layouts
This commit is contained in:
parent
a4d808c7f2
commit
a668b55d52
|
@ -40,6 +40,7 @@ const EMPTY_LAYOUT = {
|
||||||
selected: {},
|
selected: {},
|
||||||
},
|
},
|
||||||
navigation: "Top",
|
navigation: "Top",
|
||||||
|
contentWidth: "Large",
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
text: "Home",
|
text: "Home",
|
||||||
|
@ -89,6 +90,7 @@ const BASE_LAYOUTS = [
|
||||||
selected: {},
|
selected: {},
|
||||||
},
|
},
|
||||||
navigation: "Top",
|
navigation: "Top",
|
||||||
|
contentWidth: "Large",
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
text: "Home",
|
text: "Home",
|
||||||
|
@ -136,6 +138,7 @@ const BASE_LAYOUTS = [
|
||||||
selected: {},
|
selected: {},
|
||||||
},
|
},
|
||||||
navigation: "Top",
|
navigation: "Top",
|
||||||
|
contentWidth: "Large",
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
text: "Home",
|
text: "Home",
|
||||||
|
|
|
@ -43,6 +43,13 @@
|
||||||
"key": "sticky",
|
"key": "sticky",
|
||||||
"defaultValue": false
|
"defaultValue": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "select",
|
||||||
|
"label": "Content Width",
|
||||||
|
"key": "contentWidth",
|
||||||
|
"options": ["Small", "Medium", "Large"],
|
||||||
|
"defaultValue": "Large"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "navigation",
|
"type": "navigation",
|
||||||
"label": "Links",
|
"label": "Links",
|
||||||
|
|
|
@ -12,16 +12,23 @@
|
||||||
export let navigation = "Top"
|
export let navigation = "Top"
|
||||||
export let sticky = false
|
export let sticky = false
|
||||||
export let links
|
export let links
|
||||||
|
export let contentWidth = "Large"
|
||||||
$: validLinks = links?.filter(link => link.text && link.url) || []
|
|
||||||
$: type = navigationClasses[navigation] || "none"
|
|
||||||
let mobileOpen = false
|
|
||||||
|
|
||||||
const navigationClasses = {
|
const navigationClasses = {
|
||||||
Top: "top",
|
Top: "top",
|
||||||
Left: "left",
|
Left: "left",
|
||||||
None: "none",
|
None: "none",
|
||||||
}
|
}
|
||||||
|
const widthClasses = {
|
||||||
|
Large: "l",
|
||||||
|
Medium: "m",
|
||||||
|
Small: "s",
|
||||||
|
}
|
||||||
|
|
||||||
|
$: validLinks = links?.filter(link => link.text && link.url) || []
|
||||||
|
$: typeClass = navigationClasses[navigation] || "none"
|
||||||
|
$: widthClass = widthClasses[contentWidth] || "l"
|
||||||
|
let mobileOpen = false
|
||||||
|
|
||||||
const isInternal = url => {
|
const isInternal = url => {
|
||||||
return url.startsWith("/")
|
return url.startsWith("/")
|
||||||
|
@ -36,10 +43,10 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="layout layout--{type}" use:styleable={$component.styles}>
|
<div class="layout layout--{typeClass}" use:styleable={$component.styles}>
|
||||||
{#if type !== "none"}
|
{#if typeClass !== "none"}
|
||||||
<div class="nav-wrapper" class:sticky>
|
<div class="nav-wrapper" class:sticky>
|
||||||
<div class="nav nav--{type}">
|
<div class="nav nav--{typeClass}">
|
||||||
<div class="nav-header">
|
<div class="nav-header">
|
||||||
{#if validLinks?.length}
|
{#if validLinks?.length}
|
||||||
<div class="burger">
|
<div class="burger">
|
||||||
|
@ -97,7 +104,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<div class="main">
|
<div class="main main--{widthClass}">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -157,11 +164,19 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
width: 1400px;
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 32px;
|
padding: 32px;
|
||||||
}
|
}
|
||||||
|
.main--s {
|
||||||
|
width: 800px;
|
||||||
|
}
|
||||||
|
.main--m {
|
||||||
|
width: 1100px;
|
||||||
|
}
|
||||||
|
.main--l {
|
||||||
|
width: 1400px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Nav components */
|
/* Nav components */
|
||||||
.burger {
|
.burger {
|
||||||
|
|
Loading…
Reference in New Issue