-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a submenu / index on levels (#22)
- Fix #20
- Loading branch information
Showing
14 changed files
with
481 additions
and
262 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
iframe.doc-iframe(src=src, height=height) | ||
iframe.doc-iframe(src=src, height=height, title='Component rendering') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$tikui-nav-item-color-text: $tikui-color-text-dark !default; | ||
$tikui-nav-item-font-family: $tikui-font-family-main !default; | ||
$tikui-nav-item-font-size: 16px !default; | ||
$tikui-nav-item-main-font-size: 24px !default; | ||
|
||
.tikui-nav-item { | ||
display: inline-block; | ||
text-decoration: none; | ||
color: $tikui-nav-item-color-text; | ||
font-family: $tikui-nav-item-font-family; | ||
font-size: $tikui-nav-item-font-size; | ||
|
||
&:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
&.-selected { | ||
font-weight: bold; | ||
} | ||
|
||
&.-main { | ||
font-size: $tikui-nav-item-main-font-size; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/documentation/molecule/nav-vertical/_nav-vertical.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
$tikui-nav-vertical-padding: 32px !default; | ||
$tikui-nav-vertical-color-background: $tikui-color-background-secondary !default; | ||
$tikui-nav-vertical--item-spacing: 16px !default; | ||
$tikui-nav-vertical--item-level-1-spacing: 24px !default; | ||
$tikui-nav-vertical--item-indent-space: 16px !default; | ||
|
||
$levels: 1, 2, 3, 4, 5, 6; | ||
|
||
.tikui-nav-vertical { | ||
display: block; | ||
position: sticky; | ||
margin: 0; | ||
background-color: $tikui-nav-vertical-color-background; | ||
padding: $tikui-nav-vertical-padding; | ||
list-style: none; | ||
|
||
&--item { | ||
padding-bottom: $tikui-nav-vertical--item-spacing; | ||
list-style: none; | ||
|
||
&:last-child { | ||
padding-bottom: 0; | ||
} | ||
|
||
&.-level-1 { | ||
padding-bottom: $tikui-nav-vertical--item-level-1-spacing; | ||
} | ||
|
||
@each $level in $levels { | ||
&.-level-#{$level} { | ||
padding-left: ($level - 1) * $tikui-nav-vertical--item-indent-space; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const tikuiScripts = () => { | ||
const titleSelectors = (content) => [...content?.querySelectorAll('h1, h2, h3, h4, h5, h6')].filter(title => title.id) || []; | ||
|
||
const initNav = () => { | ||
const content = document.querySelector('[data-navigable]'); | ||
const titles = titleSelectors(content); | ||
|
||
if (titles.length === 0) { | ||
return; | ||
} | ||
|
||
const nav = document.createElement('div'); | ||
nav.classList.add('tikui-template-page--nav') | ||
const navVertical = document.createElement('ul'); | ||
navVertical.classList.add('tikui-nav-vertical'); | ||
|
||
titles.forEach((title, index) => { | ||
const level = title.tagName.slice(1); | ||
const item = document.createElement('a'); | ||
item.setAttribute('href', `#${title.id}`); | ||
item.innerText = title.innerText; | ||
item.classList.add('tikui-nav-item'); | ||
item.classList.add(level === '1' ? '-main' : '-child'); | ||
const slot = document.createElement('li'); | ||
slot.appendChild(item); | ||
slot.classList.add('tikui-nav-vertical--item'); | ||
slot.classList.add(`-level-${level}`); | ||
|
||
navVertical.appendChild(slot); | ||
}); | ||
|
||
nav.appendChild(navVertical); | ||
|
||
content.prepend(nav); | ||
}; | ||
|
||
const launchOnHash = launch => { | ||
const hash = location.hash; | ||
|
||
if (hash) { | ||
launch(hash.slice(1)); | ||
} | ||
} | ||
|
||
const launchOnAnchor = launch => (hash) => { | ||
const element = document.getElementById(hash); | ||
|
||
if (element) { | ||
launch(element); | ||
} | ||
} | ||
|
||
const scrollToAnchor = () => launchOnHash(launchOnAnchor((anchor) => anchor.scrollIntoView())) | ||
|
||
const init = () => { | ||
initNav(); | ||
scrollToAnchor(); | ||
} | ||
|
||
init(); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', tikuiScripts, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
$tikui-font-family-main: 'Montserrat', sans-serif !default;; | ||
$tikui-font-family-main: 'Montserrat', sans-serif !default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters