mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Use dropdown for collapsed sidebar menu
This commit is contained in:
parent
322af644c7
commit
3abe935245
|
@ -4,8 +4,26 @@ import classNames from 'classnames'
|
||||||
import { window } from 'browser-monads'
|
import { window } from 'browser-monads'
|
||||||
|
|
||||||
import Link from './link'
|
import Link from './link'
|
||||||
|
import Dropdown from './dropdown'
|
||||||
import classes from '../styles/sidebar.module.sass'
|
import classes from '../styles/sidebar.module.sass'
|
||||||
|
|
||||||
|
const DropdownNavigation = ({ items, defaultValue }) => {
|
||||||
|
return (
|
||||||
|
<div className={classes.dropdown}>
|
||||||
|
<Dropdown className={classes.dropdownSelect} defaultValue={defaultValue}>
|
||||||
|
<option disabled>Select page...</option>
|
||||||
|
{items.map((section, i) =>
|
||||||
|
section.items.map(({ text, url }, j) => (
|
||||||
|
<option value={url} key={j}>
|
||||||
|
{section.label} › {text}
|
||||||
|
</option>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Dropdown>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const Sidebar = ({ items, pageMenu, slug }) => {
|
const Sidebar = ({ items, pageMenu, slug }) => {
|
||||||
const [initialized, setInitialized] = useState(false)
|
const [initialized, setInitialized] = useState(false)
|
||||||
const [activeSection, setActiveSection] = useState(null)
|
const [activeSection, setActiveSection] = useState(null)
|
||||||
|
@ -27,6 +45,7 @@ const Sidebar = ({ items, pageMenu, slug }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<menu className={classNames('sidebar', classes.root)}>
|
<menu className={classNames('sidebar', classes.root)}>
|
||||||
|
<DropdownNavigation items={items} defaultValue={slug} />
|
||||||
{items.map((section, i) => (
|
{items.map((section, i) => (
|
||||||
<ul className={classes.section} key={i}>
|
<ul className={classes.section} key={i}>
|
||||||
<li className={classNames('h0', classes.label)}>{section.label}</li>
|
<li className={classNames('h0', classes.label)}>{section.label}</li>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.root
|
.root
|
||||||
|
--dropdown-text-color: var(--color-front)
|
||||||
font: inherit
|
font: inherit
|
||||||
background: transparent
|
background: transparent
|
||||||
border: none
|
border: none
|
||||||
|
@ -11,5 +12,5 @@
|
||||||
padding: 0 1.4em 0 0.5em
|
padding: 0 1.4em 0 0.5em
|
||||||
|
|
||||||
&:-moz-focusring
|
&:-moz-focusring
|
||||||
text-shadow: 0 0 0 var(--color-theme)
|
text-shadow: 0 0 0 var(--dropdown-text-color)
|
||||||
color: transparent
|
color: transparent
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
padding-right: 2rem
|
padding-right: 2rem
|
||||||
|
|
||||||
.dropdown
|
.dropdown
|
||||||
|
--dropdown-text-color: var(--color-theme)
|
||||||
font-family: var(--font-secondary)
|
font-family: var(--font-secondary)
|
||||||
font-size: 1.6rem
|
font-size: 1.6rem
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
|
|
|
@ -7,27 +7,14 @@ $crumb-bar: 2px
|
||||||
overflow-y: auto
|
overflow-y: auto
|
||||||
font: var(--font-size-md)/var(--line-height-md) var(--font-primary)
|
font: var(--font-size-md)/var(--line-height-md) var(--font-primary)
|
||||||
|
|
||||||
@include breakpoint(min, md)
|
.dropdown
|
||||||
.root
|
padding: 1rem 0
|
||||||
@include scroll-shadow(var(--color-back), var(--color-shadow), var(--height-nav))
|
border-bottom: 1px solid var(--color-subtle)
|
||||||
position: fixed
|
width: 100%
|
||||||
top: 0
|
|
||||||
left: 0
|
|
||||||
width: var(--width-sidebar)
|
|
||||||
height: calc(100vh - 3px)
|
|
||||||
flex: 0 0 var(--width-sidebar)
|
|
||||||
padding-top: calc(var(--height-nav) + 1.5rem)
|
|
||||||
z-index: 10
|
|
||||||
padding-bottom: 5rem
|
|
||||||
|
|
||||||
@include breakpoint(max, sm)
|
.dropdown-select
|
||||||
.root
|
width: 100%
|
||||||
flex: 100%
|
padding-left: 1rem
|
||||||
width: 100%
|
|
||||||
margin-top: var(--height-nav)
|
|
||||||
display: flex
|
|
||||||
flex-flow: row wrap
|
|
||||||
width: 100%
|
|
||||||
|
|
||||||
.section
|
.section
|
||||||
margin-bottom: var(--spacing-sm)
|
margin-bottom: var(--spacing-sm)
|
||||||
|
@ -35,16 +22,6 @@ $crumb-bar: 2px
|
||||||
& > *
|
& > *
|
||||||
padding: 0 2rem 0.35rem
|
padding: 0 2rem 0.35rem
|
||||||
|
|
||||||
@include breakpoint(max, sm)
|
|
||||||
.section
|
|
||||||
flex: 1 1 0
|
|
||||||
padding: 1.25rem 0
|
|
||||||
border-bottom: 1px solid var(--color-subtle)
|
|
||||||
margin: 0
|
|
||||||
|
|
||||||
&:not(:last-child)
|
|
||||||
border-right: 1px solid var(--color-subtle)
|
|
||||||
|
|
||||||
.label
|
.label
|
||||||
color: var(--color-dark)
|
color: var(--color-dark)
|
||||||
font: bold var(--font-size-lg)/var(--line-height-md) var(--font-secondary)
|
font: bold var(--font-size-lg)/var(--line-height-md) var(--font-secondary)
|
||||||
|
@ -113,6 +90,28 @@ $crumb-bar: 2px
|
||||||
&:after
|
&:after
|
||||||
background: var(--color-dark)
|
background: var(--color-dark)
|
||||||
|
|
||||||
@include breakpoint(max, sm)
|
@include breakpoint(min, md)
|
||||||
.crumbs
|
.root
|
||||||
|
@include scroll-shadow(var(--color-back), var(--color-shadow), var(--height-nav))
|
||||||
|
position: fixed
|
||||||
|
top: 0
|
||||||
|
left: 0
|
||||||
|
width: var(--width-sidebar)
|
||||||
|
height: calc(100vh - 3px)
|
||||||
|
flex: 0 0 var(--width-sidebar)
|
||||||
|
padding-top: calc(var(--height-nav) + 1.5rem)
|
||||||
|
z-index: 10
|
||||||
|
padding-bottom: 5rem
|
||||||
|
|
||||||
|
.dropdown
|
||||||
|
display: none
|
||||||
|
|
||||||
|
@include breakpoint(max, sm)
|
||||||
|
.root
|
||||||
|
flex: 100%
|
||||||
|
width: 100%
|
||||||
|
margin-top: var(--height-nav)
|
||||||
|
display: block
|
||||||
|
|
||||||
|
.section
|
||||||
display: none
|
display: none
|
||||||
|
|
Loading…
Reference in New Issue
Block a user