react 18
This commit is contained in:
1 parent
aa2522ba0f
commit
30c496f249
18 files changed
+225
-214
No files matched your search
@@ -10,20 +10,21 @@ import { IBreadcumbsPart, IMenu } from "src/types"
|
||||
import { useRouter } from "next/router"
|
||||
import { useMobile } from "src/hooks/useMobile"
|
||||
import { Gosuslugi } from "../Gosuslugi"
|
||||
import { INavigationProps } from "@/components/Navigation"
|
||||
import { NavigationProps } from "@/components/Navigation"
|
||||
|
||||
const Navigation = dynamic<INavigationProps>(() => import("../Navigation").then(mod => mod.Navigation), {
|
||||
const Navigation = dynamic<NavigationProps>(() => import("../Navigation").then(mod => mod.Navigation), {
|
||||
ssr: false,
|
||||
})
|
||||
|
||||
export interface IAppProps {
|
||||
export type AppProps = {
|
||||
showAuthor?: boolean
|
||||
contentStyle?: React.CSSProperties
|
||||
breadcrumbs?: IBreadcumbsPart[]
|
||||
menu: IMenu[]
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const App: React.FC<IAppProps> = ({ showAuthor = false, menu, ...props }) => {
|
||||
export const App: React.FC<AppProps> = ({ showAuthor = false, menu, ...props }) => {
|
||||
const hideBreadcrumbs = useMobile()
|
||||
const router = useRouter()
|
||||
const blockStyle = {
|
||||
|
||||
@@ -7,6 +7,7 @@ export type BlockProps = {
|
||||
as?: keyof HTMLElementTagNameMap
|
||||
style?: React.CSSProperties
|
||||
direction: "horizontal" | "vertical"
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Block: React.FC<BlockProps> = ({ as = "div", style, direction, ...props }) => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import s from "./styles.module.css"
|
||||
import Link from "next/link"
|
||||
import cx from "classnames"
|
||||
import { useCallback } from "react"
|
||||
import type { MouseEvent, MouseEventHandler } from "react"
|
||||
|
||||
const sizeClass = {
|
||||
default: s.sizeDefault,
|
||||
@@ -16,6 +17,7 @@ const themeClass = {
|
||||
}
|
||||
|
||||
export type ButtonProps = {
|
||||
children?: React.ReactNode
|
||||
value?: any
|
||||
style?: React.CSSProperties
|
||||
href?: string
|
||||
@@ -29,7 +31,7 @@ export const Button: React.FC<ButtonProps> = ({ size = "default", theme = "defau
|
||||
const className = cx(s.button, sizeClass[size], themeClass[theme], {
|
||||
[s.disabled]: disabled,
|
||||
})
|
||||
const onClick = useCallback(event => {
|
||||
const onClick = useCallback<MouseEventHandler<HTMLButtonElement>>(event => {
|
||||
if (props.onClick) {
|
||||
props.onClick(props.value, event)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ const layoutClass = {
|
||||
|
||||
export type CardLayout = "simple" | "featured"
|
||||
export type CardProps = {
|
||||
children?: React.ReactNode
|
||||
style?: React.CSSProperties
|
||||
href: string
|
||||
cover: React.ReactNode
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import s from "./styles.module.css"
|
||||
|
||||
export type CardGridProps = {
|
||||
children?: React.ReactNode
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useReducedMotion } from "src/hooks/useReducedMotion"
|
||||
|
||||
export type ContentProps = {
|
||||
style?: React.CSSProperties
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Content: React.FC<ContentProps> = props => {
|
||||
|
||||
@@ -8,7 +8,7 @@ export type FileProps = FileDefinition & {
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
export const File: React.SFC<FileProps> = props => (
|
||||
export const File: React.FC<FileProps> = props => (
|
||||
<div className={s.file} style={props.style}>
|
||||
{!props.cover?.src ? null : (
|
||||
<div className={s.image}>
|
||||
|
||||
@@ -7,11 +7,12 @@ import { Block } from "../Block"
|
||||
import { Spacer } from "../Spacer"
|
||||
import { Contacts } from "../Contacts"
|
||||
|
||||
export interface IFooterProps {
|
||||
export type FooterProps = {
|
||||
showAuthor: boolean
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Footer: React.FC<IFooterProps> = props => (
|
||||
export const Footer: React.FC<FooterProps> = props => (
|
||||
<footer className={cx(s.footer, "opposite")}>
|
||||
<Block direction={"vertical"} style={{
|
||||
marginBottom: "var(--size-l)",
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import Link from "next/link"
|
||||
|
||||
export interface ActiveLinkProps {
|
||||
export type ActiveLinkProps = {
|
||||
href?: string
|
||||
activeStyle?: React.CSSProperties
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const ActiveLink: React.FC<ActiveLinkProps> = props => props.href
|
||||
|
||||
@@ -6,6 +6,7 @@ import { isPartOfPath } from "src/lib/url"
|
||||
|
||||
export type MenuItemProps = {
|
||||
href: string
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const MenuItem: React.FC<MenuItemProps> = props => {
|
||||
|
||||
@@ -8,11 +8,11 @@ import { Block } from "../Block"
|
||||
import { Spacer } from "../Spacer"
|
||||
import { useToggle } from "react-use"
|
||||
|
||||
export interface INavigationProps {
|
||||
export type NavigationProps = {
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
export const Navigation: React.FC<INavigationProps> = props => {
|
||||
export const Navigation: React.FC<NavigationProps> = props => {
|
||||
const collapseMenu = useMobile()
|
||||
const [open, toggleOpen] = useToggle(false)
|
||||
const { menu } = useContext(ConfigContext)
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import * as React from "react"
|
||||
import { useCallback, useEffect, useMemo, useState } from "react"
|
||||
|
||||
export interface ITransitionProps {
|
||||
export type TransitionProps = {
|
||||
children?: React.ReactNode
|
||||
duration: number
|
||||
extraStyle?: React.CSSProperties
|
||||
show: boolean
|
||||
}
|
||||
|
||||
export const Transition: React.FC<ITransitionProps> = props => {
|
||||
const [mounted, setMounted] = React.useState(props.show)
|
||||
const [opacity, setOpacity] = React.useState(0)
|
||||
const onTransitionEnd = React.useCallback(() => {
|
||||
export const Transition: React.FC<TransitionProps> = props => {
|
||||
const [mounted, setMounted] = useState(props.show)
|
||||
const [opacity, setOpacity] = useState(0)
|
||||
const onTransitionEnd = useCallback(() => {
|
||||
if (opacity === 0) {
|
||||
setMounted(false)
|
||||
}
|
||||
}, [opacity])
|
||||
const transition = React.useMemo(
|
||||
const transition = useMemo(
|
||||
() => `all ${props.duration}ms`,
|
||||
[props.duration]
|
||||
)
|
||||
|
||||
React.useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (!props.show) {
|
||||
setOpacity(0)
|
||||
return
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useReducedMotion } from "../../hooks/useReducedMotion"
|
||||
import { useLockBodyScroll } from "react-use"
|
||||
|
||||
export type OverlayProps = {
|
||||
children?: React.ReactNode
|
||||
show: boolean
|
||||
onClickOverlay: () => void
|
||||
style?: React.CSSProperties
|
||||
|
||||
@@ -4,6 +4,7 @@ import { PageMeta } from "../PageMeta"
|
||||
import { ITag } from "src/types"
|
||||
|
||||
export type PageProps = {
|
||||
children?: React.ReactNode
|
||||
style?: React.CSSProperties
|
||||
date?: Date
|
||||
tags: ITag[]
|
||||
|
||||
@@ -12,6 +12,7 @@ const directionClass = {
|
||||
export type Direction = 'horizontal' | 'vertical'
|
||||
|
||||
export type TagProps = {
|
||||
children?: React.ReactNode
|
||||
href: string
|
||||
direction: Direction
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export type WrapperProps = {
|
||||
footer: React.ReactNode
|
||||
style?: React.CSSProperties
|
||||
mainStyle?: React.CSSProperties
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const Wrapper: React.FC<WrapperProps> = props => (
|
||||
|
||||
Reference in new issue
Block a user