-
Notifications
You must be signed in to change notification settings - Fork 19
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
1f3dee5
commit 8592157
Showing
16 changed files
with
745 additions
and
270 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { | ||
Checkbox, | ||
FormControl, | ||
FormControlLabel, | ||
FormLabel, | ||
InputLabel, | ||
MenuItem, | ||
Select, | ||
TextField, | ||
} from "@material-ui/core"; | ||
import { Dispatch, FC, SetStateAction } from "react"; | ||
import { Badge, ContentPresetName, contentPresets } from "../utils/badge"; | ||
|
||
const BadgeContent: FC<{ | ||
badge: Badge; | ||
setBadge: Dispatch<SetStateAction<Badge>>; | ||
}> = ({ badge, setBadge }) => ( | ||
<FormControl component="fieldset"> | ||
<FormLabel component="legend">Content</FormLabel> | ||
<FormControl style={{ marginTop: "16px" }}> | ||
<InputLabel id="badge-content-preset-label">Preset</InputLabel> | ||
<Select | ||
labelId="badge-content-preset-label" | ||
id="badge-content-preset-select" | ||
onChange={({ target: { value } }) => { | ||
if (value === "custom") { | ||
setBadge((b) => ({ | ||
...b, | ||
contentPreset: "custom", | ||
})); | ||
} else { | ||
const v = value as ContentPresetName; | ||
setBadge((b) => ({ | ||
...b, | ||
contentPreset: v, | ||
label: contentPresets[v].badgeLabel, | ||
value: v, | ||
})); | ||
} | ||
}} | ||
label="Preset" | ||
defaultValue={badge.contentPreset} | ||
autoWidth={true} | ||
> | ||
{Object.entries(contentPresets).map( | ||
([option, { presetLabel: display }]) => ( | ||
<MenuItem value={option} key={option}> | ||
{display} | ||
</MenuItem> | ||
) | ||
)} | ||
<MenuItem value="custom"> | ||
<em>Custom</em> | ||
</MenuItem> | ||
</Select> | ||
</FormControl> | ||
<TextField | ||
id="badge-label" | ||
label="Label" | ||
value={badge.label} | ||
onChange={(e) => setBadge((b) => ({ ...b, label: e.target.value }))} | ||
disabled={badge.contentPreset !== "custom"} | ||
style={{ marginTop: "24px" }} | ||
/> | ||
<FormControl style={{ marginTop: "24px" }}> | ||
<InputLabel id="badge-value-label">Displayed value</InputLabel> | ||
<Select | ||
labelId="badge-value-label" | ||
id="badge-value-select" | ||
value={badge.value} | ||
onChange={(e) => | ||
setBadge((b) => ({ | ||
...b, | ||
value: e.target.value as keyof typeof contentPresets, | ||
})) | ||
} | ||
label="Displayed value" | ||
defaultValue={badge.contentPreset} | ||
autoWidth={true} | ||
disabled={badge.contentPreset !== "custom"} | ||
> | ||
{Object.entries(contentPresets).map( | ||
([option, { badgeValueDisplay }]) => ( | ||
<MenuItem value={option} key={option}> | ||
{badgeValueDisplay} | ||
</MenuItem> | ||
) | ||
)} | ||
</Select> | ||
</FormControl> | ||
<FormControlLabel | ||
control={ | ||
<Checkbox | ||
checked={badge.showLogo} | ||
onChange={({ target: { checked: showLogo } }) => | ||
setBadge((b) => ({ ...b, showLogo })) | ||
} | ||
name="showLogo" | ||
color="primary" | ||
/> | ||
} | ||
style={{ marginTop: "24px" }} | ||
label="Show logo" | ||
/> | ||
</FormControl> | ||
); | ||
|
||
export default BadgeContent; |
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,48 @@ | ||
import { | ||
FormControl, | ||
FormControlLabel, | ||
FormLabel, | ||
Radio, | ||
RadioGroup, | ||
} from "@material-ui/core"; | ||
import { Dispatch, FC, SetStateAction } from "react"; | ||
import { Badge, styles } from "../utils/badge"; | ||
|
||
const BadgeStyle: FC<{ | ||
badge: Badge; | ||
setBadge: Dispatch<SetStateAction<Badge>>; | ||
}> = ({ badge, setBadge }) => ( | ||
<FormControl component="fieldset"> | ||
<FormLabel component="legend">Style</FormLabel> | ||
<RadioGroup | ||
aria-label="style" | ||
name="style" | ||
value={badge.style} | ||
onChange={({ target: { value } }) => { | ||
setBadge((b) => ({ | ||
...b, | ||
style: value as Badge["style"], | ||
})); | ||
}} | ||
style={{ marginTop: "8px" }} | ||
> | ||
{Object.entries(styles).map(([name, { width, height }]) => ( | ||
<FormControlLabel | ||
key={name} | ||
value={name} | ||
control={<Radio color="primary" />} | ||
label={ | ||
<img | ||
src={`style-${name}.svg`} | ||
alt={`badge style "${name.replace("-", " ")}"`} | ||
width={width} | ||
height={height} | ||
/> | ||
} | ||
/> | ||
))} | ||
</RadioGroup> | ||
</FormControl> | ||
); | ||
|
||
export default BadgeStyle; |
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,3 @@ | ||
.main:hover { | ||
color: #ffa116; | ||
} |
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,65 @@ | ||
import { IconDefinition } from "@fortawesome/fontawesome-svg-core"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { Box, Tooltip, Zoom } from "@material-ui/core"; | ||
import { makeStyles } from "@material-ui/core/styles"; | ||
import copy from "copy-to-clipboard"; | ||
import { FC, useEffect, useState } from "react"; | ||
import styles from "./CopyToClipboard.module.css"; | ||
|
||
const COPY_TO_CLIPBOARD = "Copy to clipboard"; | ||
|
||
const useDarkStyle = makeStyles((theme) => ({ | ||
arrow: { | ||
color: "#212121", | ||
}, | ||
tooltip: { | ||
backgroundColor: "#212121", | ||
}, | ||
})); | ||
|
||
const CopyToClipboard: FC<{ | ||
icon: IconDefinition; | ||
label: string; | ||
textToCopy: string; | ||
}> = ({ icon, label, textToCopy }) => { | ||
const [tooltipOpen, setTooltipOpen] = useState(false); | ||
const [tooltipText, setTooltipText] = useState(COPY_TO_CLIPBOARD); | ||
const classes = useDarkStyle(); | ||
|
||
useEffect(() => { | ||
const tId = setTimeout(() => { | ||
if (!tooltipOpen) setTooltipText(COPY_TO_CLIPBOARD); | ||
}, 500); | ||
return () => clearTimeout(tId); | ||
}, [tooltipOpen]); | ||
|
||
return ( | ||
<Tooltip | ||
TransitionComponent={Zoom} | ||
open={tooltipOpen} | ||
onOpen={() => setTooltipOpen(true)} | ||
onClose={() => setTooltipOpen(false)} | ||
title={tooltipText} | ||
placement="bottom" | ||
classes={classes} | ||
arrow | ||
> | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
justifyContent="center" | ||
alignItems="center" | ||
className={styles.main} | ||
onClick={() => { | ||
copy(textToCopy); | ||
setTooltipText("Copied!"); | ||
}} | ||
> | ||
<FontAwesomeIcon icon={icon} size="2x" /> | ||
<span style={{ fontWeight: 400 }}>{label}</span> | ||
</Box> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export default CopyToClipboard; |
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,47 @@ | ||
import { faGithub, faTwitter } from "@fortawesome/free-brands-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { Box, Grid, Link, Typography } from "@material-ui/core"; | ||
import { FC } from "react"; | ||
|
||
const Footer: FC = () => ( | ||
<footer> | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
alignItems="center" | ||
justifyContent="center" | ||
> | ||
<Typography variant="caption"> | ||
Built on top of <Link href="https://leetcode.com/">LeetCode.com</Link>{" "} | ||
and <Link href="https://shields.io/">Shields.io</Link> | ||
</Typography> | ||
<Grid | ||
container | ||
spacing={2} | ||
justify="center" | ||
style={{ marginTop: "-6px" }} | ||
> | ||
<Grid item> | ||
<Link | ||
href="https://github.com/cascandaliato/" | ||
color="textPrimary" | ||
aria-label="Author's GitHub profile" | ||
> | ||
<FontAwesomeIcon icon={faGithub} size="lg" /> | ||
</Link> | ||
</Grid> | ||
<Grid item> | ||
<Link | ||
href="https://twitter.com/cascandaliato" | ||
color="textPrimary" | ||
aria-label="Author's Twitter profile" | ||
> | ||
<FontAwesomeIcon icon={faTwitter} size="lg" /> | ||
</Link> | ||
</Grid> | ||
</Grid> | ||
</Box> | ||
</footer> | ||
); | ||
|
||
export default Footer; |
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,28 @@ | ||
import Document, { | ||
DocumentContext, | ||
Head, | ||
Html, | ||
Main, | ||
NextScript, | ||
} from "next/document"; | ||
|
||
class MyDocument extends Document { | ||
static async getInitialProps(ctx: DocumentContext) { | ||
const initialProps = await Document.getInitialProps(ctx); | ||
return initialProps; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Html lang="en"> | ||
<Head /> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} | ||
|
||
export default MyDocument; |
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
Oops, something went wrong.
8592157
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: