-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate custom docs components to typescript
- Loading branch information
1 parent
c9febf3
commit 4a37fba
Showing
17 changed files
with
157 additions
and
84 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
import * as React from "react"; | ||
import styles from "./styles.module.css"; | ||
|
||
type ColorProps = { | ||
hex: string; | ||
}; | ||
|
||
const Color = (props: React.PropsWithChildren<ColorProps>): JSX.Element => { | ||
const { hex } = props; | ||
return ( | ||
<div className={styles.colorCode}> | ||
<span style={{ backgroundColor: hex }} className={styles.color} /> | ||
<span className={styles.code}>{hex}</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Color; |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
import * as React from "react"; | ||
|
||
type DatetimeProps = { | ||
year?: boolean; | ||
}; | ||
|
||
const Datetime = ( | ||
props: React.PropsWithChildren<DatetimeProps> | ||
): JSX.Element => { | ||
const { year } = props; | ||
const date = new Date(); | ||
const granularity = year ? date.getFullYear() : date.toString(); | ||
return <span {...props}>{granularity}</span>; | ||
}; | ||
|
||
export default Datetime; |
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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
import React from "react"; | ||
import * as React from "react"; | ||
import clsx from "clsx"; | ||
import styles from "./fonts.module.css"; | ||
|
||
export default ({ name }) => { | ||
type FontProps = { | ||
name: string; | ||
}; | ||
|
||
const Font = (props: React.PropsWithChildren<FontProps>): JSX.Element => { | ||
const { name } = props; | ||
const fontClass = { Nunito: "fontBody", "Fira Code": "fontMono" }; | ||
return ( | ||
<a href={`https://fonts.google.com/specimen/${name.split(" ").join("+")}`}> | ||
<span className={clsx(styles.font, styles[fontClass[name]])}>{name}</span> | ||
</a> | ||
); | ||
}; | ||
|
||
export default Font; |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
import * as React from "react"; | ||
import styles from "./styles.module.css"; | ||
|
||
const JSXCode = (props: React.ComponentProps<"span">): JSX.Element => { | ||
return <span className={styles.code} {...props} />; | ||
}; | ||
|
||
export default JSXCode; |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import * as React from "react"; | ||
|
||
type MiniNodeProps = { | ||
newLine: boolean; | ||
}; | ||
|
||
const MiniNote = ( | ||
props: React.PropsWithChildren<MiniNodeProps> | ||
): JSX.Element => { | ||
const { newLine, children } = props; | ||
return ( | ||
<> | ||
{newLine && <br />} | ||
<span | ||
style={{ | ||
fontSize: "var(--ifm-font-size-sm)", | ||
color: "var(--ifm-blockquote-color)", | ||
display: "inline-block", | ||
fontStyle: "italic", | ||
}} | ||
> | ||
{children} | ||
</span> | ||
</> | ||
); | ||
}; | ||
|
||
export default MiniNote; |
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 * as React from "react"; | ||
import styles from "./styles.module.css"; | ||
|
||
const Native = (props: React.ComponentProps<"span">): JSX.Element => { | ||
const { children } = props; | ||
return <span className={styles.Native}>{children}</span>; | ||
}; | ||
|
||
export default Native; |
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
import * as React from "react"; | ||
import Link from "@docusaurus/Link"; | ||
|
||
import type { LinkProps } from "@docusaurus/Link"; | ||
|
||
const PageLink = (props: React.PropsWithChildren<LinkProps>): JSX.Element => { | ||
return <Link style={{ textDecoration: "unset" }} {...props} />; | ||
}; | ||
|
||
export default PageLink; |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
import * as React from "react"; | ||
import { useMemo } from "react"; | ||
import Code from "./JSXCode"; | ||
|
||
const PATTERN_MAP = { | ||
aspath_asdot: String.raw`^(\^|^\_)((\d+\.\d+)\_|(\d+\.\d+)\$|(\d+\.\d+)\(\_\.\+\_\))+$`, | ||
aspath_asplain: String.raw`^(\^|^\_)(\d+\_|\d+\$|\d+\(\_\.\+\_\))+$`, | ||
community_decimal: String.raw`^[0-9]{1,10}$`, | ||
community_extended: String.raw`^([0-9]{0,5})\:([0-9]{1,5})$`, | ||
community_large: String.raw`^([0-9]{1,10})\:([0-9]{1,10})\:[0-9]{1,10}$`, | ||
}; | ||
|
||
type RegexPatternProps = { | ||
pattern: keyof typeof PATTERN_MAP; | ||
}; | ||
|
||
const RegexPattern = ( | ||
props: React.PropsWithChildren<RegexPatternProps> | ||
): JSX.Element => { | ||
const { pattern } = props; | ||
const thisPattern = useMemo<string>(() => PATTERN_MAP[pattern], [pattern]); | ||
return <Code>'{thisPattern}'</Code>; | ||
}; | ||
|
||
export default RegexPattern; |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
import * as React from "react"; | ||
|
||
const Required = (): JSX.Element => { | ||
return ( | ||
<span style={{ color: "var(--ifm-color-danger)", display: "inline-block" }}> | ||
* | ||
</span> | ||
); | ||
}; | ||
|
||
export default Required; |
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 |
---|---|---|
@@ -1,25 +1,31 @@ | ||
.code { | ||
background-color: var(--ifm-code-background); | ||
color: var(--ifm-code-color); | ||
font-family: var(--ifm-font-family-monospace); | ||
font-size: var(--ifm-code-font-size); | ||
border-radius: var(--ifm-code-border-radius); | ||
margin: 0; | ||
padding: var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal); | ||
font-style: normal; | ||
background-color: var(--ifm-code-background); | ||
color: var(--ifm-code-color); | ||
font-family: var(--ifm-font-family-monospace); | ||
font-size: var(--ifm-code-font-size); | ||
border-radius: var(--ifm-code-border-radius); | ||
margin: 0; | ||
padding: var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal); | ||
font-style: normal; | ||
} | ||
|
||
.color { | ||
border-radius: var(--ifm-global-radius); | ||
display: inline-flex; | ||
height: 1.5rem; | ||
width: 1.5rem; | ||
margin-right: 0.5rem; | ||
padding: var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal); | ||
border-radius: var(--ifm-global-radius); | ||
display: inline-flex; | ||
height: 1.5rem; | ||
width: 1.5rem; | ||
margin-right: 0.5rem; | ||
padding: var(--ifm-code-padding-vertical) var(--ifm-code-padding-horizontal); | ||
} | ||
|
||
.colorCode { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.Native { | ||
/* color: var(--ifm-link-color); */ | ||
color: var(--ifm-color-success); | ||
font-weight: bold; | ||
} |