ui components updates
This commit is contained in:
1 parent
160c66a0af
commit
1d1e41adea
13 files changed
+90
-82
No files matched your search
Generated
+15
@@ -9,6 +9,7 @@
|
|||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@radix-ui/react-icons": "^1.1.1",
|
||||||
"@radix-ui/react-navigation-menu": "^1.0.0",
|
"@radix-ui/react-navigation-menu": "^1.0.0",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"date-fns": "^2.11.1",
|
"date-fns": "^2.11.1",
|
||||||
@@ -448,6 +449,14 @@
|
|||||||
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-icons": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-icons/-/react-icons-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-xc3wQC59rsFylVbSusQCrrM+6695ppF730Q6yqzhRdqDcRNWIm2R6ngpzBoSOQMcwnq4p805F+Gr7xo4fmtN1A==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.x || ^17.x || ^18.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-id": {
|
"node_modules/@radix-ui/react-id": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
||||||
@@ -4524,6 +4533,12 @@
|
|||||||
"@radix-ui/react-use-escape-keydown": "1.0.0"
|
"@radix-ui/react-use-escape-keydown": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@radix-ui/react-icons": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-icons/-/react-icons-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-xc3wQC59rsFylVbSusQCrrM+6695ppF730Q6yqzhRdqDcRNWIm2R6ngpzBoSOQMcwnq4p805F+Gr7xo4fmtN1A==",
|
||||||
|
"requires": {}
|
||||||
|
},
|
||||||
"@radix-ui/react-id": {
|
"@radix-ui/react-id": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-id/-/react-id-1.0.0.tgz",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"author": "Roman Timashev",
|
"author": "Roman Timashev",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@radix-ui/react-icons": "^1.1.1",
|
||||||
"@radix-ui/react-navigation-menu": "^1.0.0",
|
"@radix-ui/react-navigation-menu": "^1.0.0",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"date-fns": "^2.11.1",
|
"date-fns": "^2.11.1",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 137 B |
Binary file not shown.
|
Before Width: | Height: | Size: 500 B |
@@ -1,21 +1,24 @@
|
|||||||
import s from "./styles.module.css"
|
import s from "./styles.module.css"
|
||||||
|
|
||||||
import cx from "classnames"
|
import classnames from "classnames/bind"
|
||||||
import { createElement } from "react"
|
import { createElement } from "react"
|
||||||
|
|
||||||
|
const cx = classnames.bind(s)
|
||||||
|
|
||||||
export type BlockProps = {
|
export type BlockProps = {
|
||||||
as?: keyof HTMLElementTagNameMap
|
as?: keyof HTMLElementTagNameMap
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
direction: "horizontal" | "vertical"
|
direction: "horizontal" | "vertical"
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
|
align?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Block: React.FC<BlockProps> = ({ as = "div", style, direction, ...props }) => {
|
export const Block: React.FC<BlockProps> = ({ as = "div", align = false, style, direction, ...props }) => {
|
||||||
const directionClass = direction === "horizontal"
|
const directionClass = direction === "horizontal"
|
||||||
? s.horizontal
|
? s.horizontal
|
||||||
: s.vertical
|
: s.vertical
|
||||||
const newProps = {
|
const newProps = {
|
||||||
className: cx(s.block, directionClass),
|
className: cx(s.block, directionClass, { align }),
|
||||||
style,
|
style,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.block.align {
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.horizontal {
|
.horizontal {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,16 @@ import { ActiveLink } from "./ActiveLink"
|
|||||||
|
|
||||||
let cx = classnames.bind(s)
|
let cx = classnames.bind(s)
|
||||||
|
|
||||||
export type MenuLayout = "desktop" | "mobile"
|
|
||||||
|
|
||||||
export type MenuProps = {
|
export type MenuProps = {
|
||||||
layout: MenuLayout
|
vertical?: boolean
|
||||||
items: IMenu[]
|
items: IMenu[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Menu: React.FC<MenuProps> = ({ layout, items }) => {
|
export const Menu: React.FC<MenuProps> = ({ vertical = false, items }) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
return (
|
return (
|
||||||
<NavigationMenu.Root>
|
<NavigationMenu.Root>
|
||||||
<NavigationMenu.List className={cx(s.menu, layout)}>
|
<NavigationMenu.List className={cx(s.menu, { vertical })}>
|
||||||
{
|
{
|
||||||
items.map(item => {
|
items.map(item => {
|
||||||
const current = router.asPath === item.href
|
const current = router.asPath === item.href
|
||||||
|
|||||||
@@ -8,16 +8,11 @@
|
|||||||
font-size: var(--font-size-second);
|
font-size: var(--font-size-second);
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
||||||
padding: var(--size-s);
|
/* NOT VERTICAL */
|
||||||
}
|
|
||||||
|
|
||||||
/* MENU LAYOUT */
|
|
||||||
|
|
||||||
.desktop {
|
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile {
|
.vertical {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +22,7 @@
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
background-color: var(--color-back-main);
|
background-color: var(--color-back-main);
|
||||||
border-radius: var(--size-s);
|
border-radius: var(--size-s);
|
||||||
transition: box-shadow 200ms ease-in;
|
transition: box-shadow 200ms ease-in, background-color 200ms ease-in;
|
||||||
padding: var(--size-s) var(--size-s);
|
padding: var(--size-s) var(--size-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,3 +43,11 @@
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DARK THEME */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.menuItem.active:hover {
|
||||||
|
box-shadow: none;
|
||||||
|
background-color: var(--color-back);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import s from "./styles.module.css"
|
|
||||||
|
|
||||||
import cx from "classnames"
|
|
||||||
import { Button } from "@/ui/Button"
|
import { Button } from "@/ui/Button"
|
||||||
|
import { HamburgerMenuIcon, Cross1Icon } from "@radix-ui/react-icons"
|
||||||
|
|
||||||
export interface IMenuToggleProps {
|
export interface IMenuToggleProps {
|
||||||
style?: React.CSSProperties
|
style?: React.CSSProperties
|
||||||
@@ -16,12 +14,11 @@ export const MenuToggle: React.FC<IMenuToggleProps> = props => {
|
|||||||
style={props.style}
|
style={props.style}
|
||||||
theme={"icon"}
|
theme={"icon"}
|
||||||
>
|
>
|
||||||
<div
|
{props.open ? (
|
||||||
className={cx(s.toggle, {
|
<Cross1Icon width={24} height={24} />
|
||||||
[s.open]: props.open,
|
) : (
|
||||||
[s.close]: !props.open,
|
<HamburgerMenuIcon width={24} height={24} />
|
||||||
})}
|
)}
|
||||||
/>
|
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
.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);
|
|
||||||
}
|
|
||||||
@@ -17,15 +17,6 @@ export const Navigation: React.FC<NavigationProps> = props => {
|
|||||||
const [open, toggleOpen] = useToggle(false)
|
const [open, toggleOpen] = useToggle(false)
|
||||||
const { menu } = useContext(ConfigContext)
|
const { menu } = useContext(ConfigContext)
|
||||||
|
|
||||||
if (!collapseMenu) {
|
|
||||||
return (
|
|
||||||
<Menu
|
|
||||||
layout={"desktop"}
|
|
||||||
items={menu}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Overlay
|
<Overlay
|
||||||
@@ -33,8 +24,36 @@ export const Navigation: React.FC<NavigationProps> = props => {
|
|||||||
onClickOverlay={toggleOpen}
|
onClickOverlay={toggleOpen}
|
||||||
duration={250}
|
duration={250}
|
||||||
>
|
>
|
||||||
<Block direction={"horizontal"}>
|
<Block direction={"horizontal"} align style={{
|
||||||
|
padding: "var(--size-s)",
|
||||||
|
}}>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
|
<MenuToggle
|
||||||
|
open={open}
|
||||||
|
onClick={toggleOpen}
|
||||||
|
/>
|
||||||
|
</Block>
|
||||||
|
<Block direction={"horizontal"} style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
}}>
|
||||||
|
<Menu vertical
|
||||||
|
items={menu}
|
||||||
|
/>
|
||||||
|
</Block>
|
||||||
|
</Overlay>
|
||||||
|
|
||||||
|
<Block direction={"horizontal"} align style={{
|
||||||
|
padding: "var(--size-s)",
|
||||||
|
}}>
|
||||||
|
{collapseMenu ? null : (
|
||||||
|
<Menu
|
||||||
|
items={menu}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Spacer />
|
||||||
|
|
||||||
|
{!collapseMenu ? null : (
|
||||||
<MenuToggle
|
<MenuToggle
|
||||||
open={open}
|
open={open}
|
||||||
onClick={toggleOpen}
|
onClick={toggleOpen}
|
||||||
@@ -42,30 +61,7 @@ export const Navigation: React.FC<NavigationProps> = props => {
|
|||||||
margin: "var(--size-xs)",
|
margin: "var(--size-xs)",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Block>
|
)}
|
||||||
<Block direction={"horizontal"} style={{
|
|
||||||
justifyContent: "center",
|
|
||||||
}}>
|
|
||||||
<nav style={{
|
|
||||||
width: "75%",
|
|
||||||
}}>
|
|
||||||
<Menu
|
|
||||||
layout={"mobile"}
|
|
||||||
items={menu}
|
|
||||||
/>
|
|
||||||
</nav>
|
|
||||||
</Block>
|
|
||||||
</Overlay>
|
|
||||||
|
|
||||||
<Block direction={"horizontal"}>
|
|
||||||
<Spacer />
|
|
||||||
<MenuToggle
|
|
||||||
open={open}
|
|
||||||
onClick={toggleOpen}
|
|
||||||
style={{
|
|
||||||
margin: "var(--size-xs)",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Block>
|
</Block>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ h3 {
|
|||||||
|
|
||||||
--color-back-main: hsl(240, 10%, 10%);
|
--color-back-main: hsl(240, 10%, 10%);
|
||||||
--color-back: hsl(240, 10%, 15%);
|
--color-back: hsl(240, 10%, 15%);
|
||||||
|
--color-back-active: hsl(240, 10%, 20%);
|
||||||
--color-back-opposite: hsl(240, 10%, 80%);
|
--color-back-opposite: hsl(240, 10%, 80%);
|
||||||
--color-link: hsl(240, 10%, 40%);
|
--color-link: hsl(240, 10%, 40%);
|
||||||
--color-link-opposite: hsl(240, 10%, 60%);
|
--color-link-opposite: hsl(240, 10%, 60%);
|
||||||
|
|||||||
@@ -6,25 +6,21 @@
|
|||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
border-radius: 100px;
|
border-radius: var(--size-s);
|
||||||
border: 1px solid var(--color-shadow);
|
border: 1px solid var(--color-shadow);
|
||||||
|
|
||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
background-color: var(--color-back);
|
background-color: var(--color-back);
|
||||||
|
box-shadow: none;
|
||||||
transition: box-shadow 150ms;
|
transition: box-shadow 200ms ease-in, background-color 200ms ease-in;
|
||||||
|
|
||||||
outline: none;
|
outline: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
margin: 1px;
|
border-color: rgba(0, 0, 0, 0);
|
||||||
/* margin-left: 1px;
|
box-shadow: var(--shadow);
|
||||||
margin-right: 1px; */
|
|
||||||
|
|
||||||
border: none;
|
|
||||||
box-shadow: var(--shadow-active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MODIFICATORS */
|
/* MODIFICATORS */
|
||||||
@@ -52,5 +48,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.themeIcon {
|
.themeIcon {
|
||||||
|
border-color: rgba(0, 0, 0, 0);
|
||||||
padding: var(--size-xs) var(--size-xs);
|
padding: var(--size-xs) var(--size-xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DARK THEME */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.button:hover {
|
||||||
|
background-color: var(--color-back-active);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user