-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c94d43
commit 392aac8
Showing
20 changed files
with
162 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ComponentProps } from "react"; | ||
|
||
export interface BoxProps extends ComponentProps<"div"> {} | ||
|
||
export function Box(props: BoxProps) { | ||
const { children, ...rest } = props; | ||
|
||
return <div {...rest}>{children}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Box, type BoxProps } from "./Box"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.root { | ||
display: flex; | ||
gap: var(--flex-gap, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CSSProperties } from "react"; | ||
import { Box, BoxProps } from "../Box"; | ||
import styles from "./Flex.module.scss"; | ||
import clsx from "clsx"; | ||
|
||
export interface FlexProps extends BoxProps { | ||
gap?: string; | ||
} | ||
|
||
export function Flex(props: FlexProps) { | ||
const { gap, children, className, style, ...rest } = props; | ||
|
||
const variables = { | ||
"--flex-gap": gap, | ||
} as CSSProperties; | ||
|
||
return ( | ||
<Box | ||
className={clsx(styles["root"], className)} | ||
style={{ | ||
...variables, | ||
...style, | ||
}} | ||
{...rest} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Flex } from "./Flex"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.root { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--stack-gap, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CSSProperties } from "react"; | ||
import { Box, BoxProps } from "../Box"; | ||
import styles from "./Stack.module.scss"; | ||
import clsx from "clsx"; | ||
|
||
export interface StackProps extends BoxProps { | ||
gap?: string; | ||
} | ||
|
||
export function Stack(props: StackProps) { | ||
const { children, gap = "15px", className, style, ...rest } = props; | ||
|
||
const variables = { | ||
"--stack-gap": gap, | ||
} as CSSProperties; | ||
|
||
return ( | ||
<Box | ||
className={clsx(styles["root"], className)} | ||
style={{ | ||
...variables, | ||
...style, | ||
}} | ||
{...rest} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/components/utils/ErrorFallback/ErrorFallback.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.root { | ||
position: fixed; | ||
left: 50%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
display: flex; | ||
flex-direction: column; | ||
gap: 15px; | ||
} | ||
|
||
.nav { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 15px; | ||
} | ||
|
||
.icon { | ||
width: 50px; | ||
height: 50px; | ||
} | ||
|
||
.title { | ||
font-size: 24px; | ||
font-weight: 700; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Button } from "@/components/core"; | ||
import { FallbackProps } from "react-error-boundary"; | ||
import styles from "./ErrorFallback.module.scss"; | ||
import { Icon } from "@/components/core/Icon"; | ||
import SolarPlanet2BoldDuotone from "~icons/solar/planet-2-bold-duotone"; | ||
import { Textarea } from "@/components/core/Textarea"; | ||
import { Flex } from "@/components/core/Flex"; | ||
import RestartBold from "~icons/solar/restart-bold"; | ||
|
||
export function ErrorFallback(props: FallbackProps) { | ||
const { error, resetErrorBoundary } = props; | ||
|
||
return ( | ||
<div className={styles["root"]}> | ||
<div className={styles["nav"]}> | ||
<Icon | ||
icon={<SolarPlanet2BoldDuotone />} | ||
className={styles["icon"]} | ||
/> | ||
<h2 className={styles["title"]}>好像出了点问题</h2> | ||
</div> | ||
<Textarea value={error.stack} width="50vw" height="50vh" /> | ||
<Flex className={styles["actions"]}> | ||
<Button onClick={resetErrorBoundary} icon={<RestartBold />}> | ||
重置 | ||
</Button> | ||
<Button onClick={() => console.log(error)}>查看错误信息</Button> | ||
</Flex> | ||
</div> | ||
); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters