menu with toggle updated; even icons changed
This commit is contained in:
1 parent
1181bd61fd
commit
79658002d5
10 files changed
+140
-147
No files matched your search
@@ -36,7 +36,7 @@ export const App: React.FC<IAppProps> = props => {
|
|||||||
header={(
|
header={(
|
||||||
<header>
|
<header>
|
||||||
<Navigation style={{
|
<Navigation style={{
|
||||||
marginBottom: 'var(--size-m)',
|
margin: '0 var(--size-m) var(--size-m)',
|
||||||
}} />
|
}} />
|
||||||
{hideBreadcrumbs || !props.breadcrumbs ? null : (
|
{hideBreadcrumbs || !props.breadcrumbs ? null : (
|
||||||
<Block direction={'horizontal'} style={blockStyle}>
|
<Block direction={'horizontal'} style={blockStyle}>
|
||||||
|
|||||||
@@ -2,19 +2,27 @@ import './styles.css'
|
|||||||
|
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import cx from 'classnames'
|
import cx from 'classnames'
|
||||||
|
import { useCallback } from 'react'
|
||||||
|
|
||||||
export type ButtonProps = {
|
export type ButtonProps = {
|
||||||
|
value?: any
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
href?: string
|
href?: string
|
||||||
theme?: 'default' | 'ghost'
|
theme?: 'default' | 'ghost' | 'icon'
|
||||||
size?: 'default' | 'small'
|
size?: 'default' | 'small'
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
onClick?: (value: any, event: MouseEvent) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Button: React.FC<ButtonProps> = ({ size = 'default', theme = 'default', disabled = false, ...props }) => {
|
export const Button: React.FC<ButtonProps> = ({ size = 'default', theme = 'default', disabled = false, ...props }) => {
|
||||||
const className = cx('button', theme, size, {
|
const className = cx('button', `size_${size}`, `theme_${theme}`, {
|
||||||
disabled
|
disabled
|
||||||
})
|
})
|
||||||
|
const onClick = useCallback(event => {
|
||||||
|
if (props.onClick) {
|
||||||
|
props.onClick(props.value, event)
|
||||||
|
}
|
||||||
|
}, [props.value, props.onClick])
|
||||||
|
|
||||||
if (props.href) {
|
if (props.href) {
|
||||||
return (
|
return (
|
||||||
@@ -27,7 +35,11 @@ export const Button: React.FC<ButtonProps> = ({ size = 'default', theme = 'defau
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button className={className} style={props.style}>
|
<button
|
||||||
|
className={className}
|
||||||
|
style={props.style}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
.button {
|
.button {
|
||||||
|
display: block;
|
||||||
font-size: var(--font-size-default);
|
font-size: var(--font-size-default);
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: var(--size-m);
|
|
||||||
margin-bottom: var(--size-m);
|
|
||||||
|
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
border: 1px solid var(--color-shadow);
|
border: 1px solid var(--color-shadow);
|
||||||
@@ -17,8 +16,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
margin-left: 1px;
|
margin: 1px;
|
||||||
margin-right: 1px;
|
/* margin-left: 1px;
|
||||||
|
margin-right: 1px; */
|
||||||
|
|
||||||
border: none;
|
border: none;
|
||||||
box-shadow: var(--shadow-active);
|
box-shadow: var(--shadow-active);
|
||||||
@@ -31,19 +31,23 @@
|
|||||||
color: var(--color-text-second);
|
color: var(--color-text-second);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* THEME */
|
|
||||||
|
|
||||||
.button.ghost {
|
|
||||||
border-color: rgba(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SIZE */
|
/* SIZE */
|
||||||
|
|
||||||
.button.default {
|
.button.size_default {
|
||||||
padding: var(--size-s) var(--size-m);
|
padding: var(--size-s) var(--size-m);
|
||||||
}
|
}
|
||||||
|
|
||||||
.button.small {
|
.button.size_small {
|
||||||
padding: var(--size-xs) var(--size-s);
|
padding: var(--size-xs) var(--size-s);
|
||||||
font-size: var(--font-size-second);
|
font-size: var(--font-size-second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THEME */
|
||||||
|
|
||||||
|
.button.theme_ghost {
|
||||||
|
border-color: rgba(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button.theme_icon {
|
||||||
|
padding: var(--size-xs) var(--size-xs);
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
font-size: var(--font-size-second);
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,14 +23,18 @@
|
|||||||
/* MOBILE */
|
/* MOBILE */
|
||||||
|
|
||||||
.menuItem.mobile {
|
.menuItem.mobile {
|
||||||
font-size: 1.25em;
|
font-size: var(--font-size-default);
|
||||||
color: var(--color-text-opposite);
|
|
||||||
|
|
||||||
padding: var(--size-xs) var(--size-s);
|
padding: var(--size-xs) var(--size-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.menuItem.mobile.selected {
|
.menuItem.mobile.selected {
|
||||||
background-color: var(--color-back-opposite);
|
background-color: var(--color-back-opposite);
|
||||||
|
color: var(--color-text-opposite)
|
||||||
|
}
|
||||||
|
|
||||||
|
.menuItem.mobile.selected a {
|
||||||
|
color: var(--color-text-opposite)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DESKTOP */
|
/* DESKTOP */
|
||||||
|
|||||||
@@ -1,79 +1,27 @@
|
|||||||
import * as React from 'react'
|
import './styles.css'
|
||||||
|
|
||||||
import cx from 'classnames'
|
import cx from 'classnames'
|
||||||
|
import { Button } from '../Button'
|
||||||
|
|
||||||
export interface IMenuToggleProps {
|
export interface IMenuToggleProps {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
open: boolean
|
open: boolean
|
||||||
position: 'left' | 'right'
|
|
||||||
onClick: () => void
|
onClick: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MenuToggle: React.FC<IMenuToggleProps> = props => {
|
export const MenuToggle: React.FC<IMenuToggleProps> = props => {
|
||||||
return (
|
return (
|
||||||
<div
|
<Button
|
||||||
className={cx(props.position, {
|
onClick={props.onClick}
|
||||||
open: props.open,
|
|
||||||
close: !props.open,
|
|
||||||
})}
|
|
||||||
style={props.style}
|
style={props.style}
|
||||||
|
theme={'icon'}
|
||||||
>
|
>
|
||||||
<style jsx>{`
|
<div
|
||||||
div {
|
className={cx('toggle', {
|
||||||
--hmenu-margin: 6px;
|
open: props.open,
|
||||||
--hmenu-icon-width: 32px;
|
close: !props.open,
|
||||||
--hmenu-icon-height: 32px;
|
})}
|
||||||
|
/>
|
||||||
position: absolute;
|
</Button>
|
||||||
height: var(--hmenu-icon-height);
|
|
||||||
margin: var(--hmenu-margin);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.right {
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.left {
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
display: block;
|
|
||||||
text-decoration: none;
|
|
||||||
border: none;
|
|
||||||
|
|
||||||
width: var(--hmenu-icon-width);
|
|
||||||
height: var(--hmenu-icon-height);
|
|
||||||
background-size: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
text-decoration: none;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.open a {
|
|
||||||
background-image: url(/static/graphics/hmenu-close-b.png);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.open a:hover {
|
|
||||||
background-image: url(/static/graphics/hmenu-close-hover-b.png);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.close a {
|
|
||||||
background-image: url(/static/graphics/hmenu-b.png);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.close a:hover {
|
|
||||||
background-image: url(/static/graphics/hmenu-hover-b.png);
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
onClick={props.onClick}
|
|
||||||
></a>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
.toggle {
|
||||||
|
--s: 32px;
|
||||||
|
width: var(--s);
|
||||||
|
height: var(--s);
|
||||||
|
background-size: var(--s);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle.open {
|
||||||
|
background-image: url(/static/graphics/hmenu-close-b.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle.close {
|
||||||
|
background-image: url(/static/graphics/hmenu-b.png);
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import { Menu } from '../Menu'
|
|||||||
import { Overlay } from '../Overlay'
|
import { Overlay } from '../Overlay'
|
||||||
import { useState, useCallback, useContext } from 'react'
|
import { useState, useCallback, useContext } from 'react'
|
||||||
import { ConfigContext } from 'src/context/ConfigContext'
|
import { ConfigContext } from 'src/context/ConfigContext'
|
||||||
|
import { Block } from '../Block'
|
||||||
|
import { Spacer } from '../Spacer'
|
||||||
|
|
||||||
export interface INavigationProps {
|
export interface INavigationProps {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -21,49 +23,54 @@ export const Navigation: React.FC<INavigationProps> = props => {
|
|||||||
const { menu } = useContext(ConfigContext)
|
const { menu } = useContext(ConfigContext)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav style={props.style}>
|
<>
|
||||||
<style jsx>{`
|
|
||||||
nav {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
margin-left: 1em;
|
|
||||||
margin-right: 1em;
|
|
||||||
|
|
||||||
font-size: var(--normal-font-size);
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
{collapseMenu ? (
|
|
||||||
<MenuToggle
|
|
||||||
open={open}
|
|
||||||
position={'right'}
|
|
||||||
onClick={onClick}
|
|
||||||
style={{
|
|
||||||
zIndex: 1000001,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Menu
|
|
||||||
layout={'desktop'}
|
|
||||||
items={menu}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Overlay
|
<Overlay
|
||||||
show={open}
|
show={open}
|
||||||
onClickOverlay={onClick}
|
onClickOverlay={onClick}
|
||||||
>
|
>
|
||||||
<div style={{
|
<Block direction={'horizontal'}>
|
||||||
width: '50%',
|
<Spacer />
|
||||||
margin: '50px auto',
|
<MenuToggle
|
||||||
}}>
|
open={open}
|
||||||
<Menu
|
onClick={onClick}
|
||||||
layout={'mobile'}
|
style={{
|
||||||
items={menu}
|
margin: 'var(--size-xs)'
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</Block>
|
||||||
|
<Block direction={'horizontal'} style={{
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}>
|
||||||
|
<nav style={{
|
||||||
|
width: '75%',
|
||||||
|
}}>
|
||||||
|
<Menu
|
||||||
|
layout={'mobile'}
|
||||||
|
items={menu}
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
|
</Block>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
</nav>
|
|
||||||
|
{collapseMenu ? (
|
||||||
|
<Block direction={'horizontal'}>
|
||||||
|
<Spacer />
|
||||||
|
<MenuToggle
|
||||||
|
open={open}
|
||||||
|
onClick={onClick}
|
||||||
|
style={{
|
||||||
|
margin: 'var(--size-xs)'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Block>
|
||||||
|
) : (
|
||||||
|
<nav style={props.style}>
|
||||||
|
<Menu
|
||||||
|
layout={'desktop'}
|
||||||
|
items={menu}
|
||||||
|
/>
|
||||||
|
</nav>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,46 +1,42 @@
|
|||||||
import * as React from 'react'
|
import './styles.css'
|
||||||
|
|
||||||
import { Transition } from './Transition'
|
import { Transition } from './Transition'
|
||||||
import { useReducedMotion } from '../../hooks/useReducedMotion'
|
import { useReducedMotion } from '../../hooks/useReducedMotion'
|
||||||
|
import { useCallback, useEffect } from 'react'
|
||||||
|
|
||||||
export interface IOverlayProps {
|
export interface IOverlayProps {
|
||||||
show: boolean
|
show: boolean
|
||||||
onClickOverlay: () => void
|
onClickOverlay: () => void
|
||||||
|
style?: React.CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Overlay: React.FC<IOverlayProps> = props => {
|
export const Overlay: React.FC<IOverlayProps> = props => {
|
||||||
const motionDisabled = useReducedMotion()
|
const motionDisabled = useReducedMotion()
|
||||||
const duration = motionDisabled ? 0 : 250
|
const onClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
|
||||||
const onClick = React.useCallback((event: React.MouseEvent<HTMLDivElement>) => {
|
|
||||||
if (event.target === event.currentTarget) {
|
if (event.target === event.currentTarget) {
|
||||||
props.onClickOverlay()
|
props.onClickOverlay()
|
||||||
}
|
}
|
||||||
}, [props.onClickOverlay])
|
}, [props.onClickOverlay])
|
||||||
|
const duration = motionDisabled ? 0 : 250
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (props.show) {
|
||||||
|
document.body.classList.add('noscroll')
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove('noscroll')
|
||||||
|
}
|
||||||
|
}, [props.show])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Transition
|
<Transition
|
||||||
duration={duration}
|
duration={duration}
|
||||||
show={props.show}
|
show={props.show}
|
||||||
extraStyle={{
|
|
||||||
zIndex: 1000000,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
className={'overlay'}
|
||||||
|
style={props.style}
|
||||||
>
|
>
|
||||||
<style jsx>{`
|
|
||||||
div {
|
|
||||||
position: fixed;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
overflow-y: auto;
|
|
||||||
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
|
|
||||||
{props.children}
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
.overlay {
|
||||||
|
position: fixed;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 1000000;
|
||||||
|
|
||||||
|
background-color: var(--color-back-main);
|
||||||
|
}
|
||||||
+2
-6
@@ -175,12 +175,8 @@ a.invisible {
|
|||||||
border-bottom-color: var(--color-text-opposite);
|
border-bottom-color: var(--color-text-opposite);
|
||||||
}
|
}
|
||||||
|
|
||||||
.actor {
|
.noscroll {
|
||||||
border-bottom: 1px dashed black;
|
overflow: hidden;
|
||||||
}
|
|
||||||
|
|
||||||
.actor:hover {
|
|
||||||
border-bottom: 2px solid black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 31.25em) {
|
@media (max-width: 31.25em) {
|
||||||
|
|||||||
Reference in new issue
Block a user