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>
|
||||
<Navigation style={{
|
||||
marginBottom: 'var(--size-m)',
|
||||
margin: '0 var(--size-m) var(--size-m)',
|
||||
}} />
|
||||
{hideBreadcrumbs || !props.breadcrumbs ? null : (
|
||||
<Block direction={'horizontal'} style={blockStyle}>
|
||||
|
||||
@@ -2,19 +2,27 @@ import './styles.css'
|
||||
|
||||
import Link from 'next/link'
|
||||
import cx from 'classnames'
|
||||
import { useCallback } from 'react'
|
||||
|
||||
export type ButtonProps = {
|
||||
value?: any
|
||||
style?: React.CSSProperties
|
||||
href?: string
|
||||
theme?: 'default' | 'ghost'
|
||||
theme?: 'default' | 'ghost' | 'icon'
|
||||
size?: 'default' | 'small'
|
||||
disabled?: boolean
|
||||
onClick?: (value: any, event: MouseEvent) => void
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
const onClick = useCallback(event => {
|
||||
if (props.onClick) {
|
||||
props.onClick(props.value, event)
|
||||
}
|
||||
}, [props.value, props.onClick])
|
||||
|
||||
if (props.href) {
|
||||
return (
|
||||
@@ -27,7 +35,11 @@ export const Button: React.FC<ButtonProps> = ({ size = 'default', theme = 'defau
|
||||
}
|
||||
|
||||
return (
|
||||
<button className={className} style={props.style}>
|
||||
<button
|
||||
className={className}
|
||||
style={props.style}
|
||||
onClick={onClick}
|
||||
>
|
||||
{props.children}
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
.button {
|
||||
display: block;
|
||||
font-size: var(--font-size-default);
|
||||
|
||||
text-align: center;
|
||||
margin-top: var(--size-m);
|
||||
margin-bottom: var(--size-m);
|
||||
|
||||
border-radius: 100px;
|
||||
border: 1px solid var(--color-shadow);
|
||||
@@ -17,8 +16,9 @@
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
margin-left: 1px;
|
||||
margin-right: 1px;
|
||||
margin: 1px;
|
||||
/* margin-left: 1px;
|
||||
margin-right: 1px; */
|
||||
|
||||
border: none;
|
||||
box-shadow: var(--shadow-active);
|
||||
@@ -31,19 +31,23 @@
|
||||
color: var(--color-text-second);
|
||||
}
|
||||
|
||||
/* THEME */
|
||||
|
||||
.button.ghost {
|
||||
border-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* SIZE */
|
||||
|
||||
.button.default {
|
||||
.button.size_default {
|
||||
padding: var(--size-s) var(--size-m);
|
||||
}
|
||||
|
||||
.button.small {
|
||||
.button.size_small {
|
||||
padding: var(--size-xs) var(--size-s);
|
||||
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;
|
||||
flex-wrap: wrap;
|
||||
|
||||
font-size: var(--font-size-second);
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
@@ -22,14 +23,18 @@
|
||||
/* MOBILE */
|
||||
|
||||
.menuItem.mobile {
|
||||
font-size: 1.25em;
|
||||
color: var(--color-text-opposite);
|
||||
font-size: var(--font-size-default);
|
||||
|
||||
padding: var(--size-xs) var(--size-s);
|
||||
}
|
||||
|
||||
.menuItem.mobile.selected {
|
||||
background-color: var(--color-back-opposite);
|
||||
color: var(--color-text-opposite)
|
||||
}
|
||||
|
||||
.menuItem.mobile.selected a {
|
||||
color: var(--color-text-opposite)
|
||||
}
|
||||
|
||||
/* DESKTOP */
|
||||
|
||||
@@ -1,79 +1,27 @@
|
||||
import * as React from 'react'
|
||||
import './styles.css'
|
||||
|
||||
import cx from 'classnames'
|
||||
import { Button } from '../Button'
|
||||
|
||||
export interface IMenuToggleProps {
|
||||
style?: React.CSSProperties
|
||||
open: boolean
|
||||
position: 'left' | 'right'
|
||||
onClick: () => void
|
||||
}
|
||||
|
||||
export const MenuToggle: React.FC<IMenuToggleProps> = props => {
|
||||
return (
|
||||
<div
|
||||
className={cx(props.position, {
|
||||
open: props.open,
|
||||
close: !props.open,
|
||||
})}
|
||||
<Button
|
||||
onClick={props.onClick}
|
||||
style={props.style}
|
||||
theme={'icon'}
|
||||
>
|
||||
<style jsx>{`
|
||||
div {
|
||||
--hmenu-margin: 6px;
|
||||
--hmenu-icon-width: 32px;
|
||||
--hmenu-icon-height: 32px;
|
||||
|
||||
position: absolute;
|
||||
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>
|
||||
<div
|
||||
className={cx('toggle', {
|
||||
open: props.open,
|
||||
close: !props.open,
|
||||
})}
|
||||
/>
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
@@ -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 { useState, useCallback, useContext } from 'react'
|
||||
import { ConfigContext } from 'src/context/ConfigContext'
|
||||
import { Block } from '../Block'
|
||||
import { Spacer } from '../Spacer'
|
||||
|
||||
export interface INavigationProps {
|
||||
style?: React.CSSProperties
|
||||
@@ -21,49 +23,54 @@ export const Navigation: React.FC<INavigationProps> = props => {
|
||||
const { menu } = useContext(ConfigContext)
|
||||
|
||||
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
|
||||
show={open}
|
||||
onClickOverlay={onClick}
|
||||
>
|
||||
<div style={{
|
||||
width: '50%',
|
||||
margin: '50px auto',
|
||||
}}>
|
||||
<Menu
|
||||
layout={'mobile'}
|
||||
items={menu}
|
||||
<Block direction={'horizontal'}>
|
||||
<Spacer />
|
||||
<MenuToggle
|
||||
open={open}
|
||||
onClick={onClick}
|
||||
style={{
|
||||
margin: 'var(--size-xs)'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Block>
|
||||
<Block direction={'horizontal'} style={{
|
||||
justifyContent: 'center',
|
||||
}}>
|
||||
<nav style={{
|
||||
width: '75%',
|
||||
}}>
|
||||
<Menu
|
||||
layout={'mobile'}
|
||||
items={menu}
|
||||
/>
|
||||
</nav>
|
||||
</Block>
|
||||
</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 { useReducedMotion } from '../../hooks/useReducedMotion'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
|
||||
export interface IOverlayProps {
|
||||
show: boolean
|
||||
onClickOverlay: () => void
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
export const Overlay: React.FC<IOverlayProps> = props => {
|
||||
const motionDisabled = useReducedMotion()
|
||||
const duration = motionDisabled ? 0 : 250
|
||||
|
||||
const onClick = React.useCallback((event: React.MouseEvent<HTMLDivElement>) => {
|
||||
const onClick = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (event.target === event.currentTarget) {
|
||||
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 (
|
||||
<Transition
|
||||
duration={duration}
|
||||
show={props.show}
|
||||
extraStyle={{
|
||||
zIndex: 1000000,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
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}
|
||||
</div>
|
||||
</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);
|
||||
}
|
||||
|
||||
.actor {
|
||||
border-bottom: 1px dashed black;
|
||||
}
|
||||
|
||||
.actor:hover {
|
||||
border-bottom: 2px solid black;
|
||||
.noscroll {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@media (max-width: 31.25em) {
|
||||
|
||||
Reference in new issue
Block a user