Skip to content

Commit dfa43fb

Browse files
committed
added story
1 parent 59be45a commit dfa43fb

File tree

6 files changed

+42
-14
lines changed

6 files changed

+42
-14
lines changed

site/src/components/CopyButton/CopyButton.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Button from "@material-ui/core/Button"
1+
import IconButton from "@material-ui/core/Button"
22
import { makeStyles } from "@material-ui/core/styles"
33
import Tooltip from "@material-ui/core/Tooltip"
44
import Check from "@material-ui/icons/Check"
@@ -45,16 +45,14 @@ export const CopyButton: React.FC<CopyButtonProps> = ({
4545
return (
4646
<Tooltip title="Copy to Clipboard" placement="top">
4747
<div className={combineClasses([styles.copyButtonWrapper, wrapperClassName])}>
48-
<Button
48+
<IconButton
4949
className={combineClasses([styles.copyButton, buttonClassName])}
5050
onClick={copyToClipboard}
5151
size="small"
52-
startIcon={
53-
isCopied ? <Check className={styles.fileCopyIcon} /> : <FileCopyIcon className={styles.fileCopyIcon} />
54-
}
5552
>
56-
{ctaCopy && ctaCopy}
57-
</Button>
53+
{isCopied ? <Check className={styles.fileCopyIcon} /> : <FileCopyIcon className={styles.fileCopyIcon} />}
54+
{ctaCopy && <div className={styles.buttonCopy}>{ctaCopy}</div>}
55+
</IconButton>
5856
</div>
5957
</Tooltip>
6058
)
@@ -80,4 +78,7 @@ const useStyles = makeStyles((theme) => ({
8078
width: 20,
8179
height: 20,
8280
},
81+
buttonCopy: {
82+
marginLeft: theme.spacing(1),
83+
},
8384
}))

site/src/components/RuntimeErrorState/RuntimeErrorReport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { makeStyles } from "@material-ui/core/styles"
22
import React from "react"
33
import { CodeBlock } from "../CodeBlock/CodeBlock"
4-
import { createCtas } from "./ReportButtons"
4+
import { createCtas } from "./createCtas"
55

66
const Language = {
77
reportLoading: "Generating crash report...",
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { ComponentMeta, Story } from "@storybook/react"
2+
import React from "react"
3+
import { RuntimeErrorState, RuntimeErrorStateProps } from "./RuntimeErrorState"
4+
5+
const error = new Error("An error occurred")
6+
7+
export default {
8+
title: "components/RuntimeErrorState",
9+
component: RuntimeErrorState,
10+
argTypes: {
11+
error: {
12+
defaultValue: error,
13+
},
14+
},
15+
} as ComponentMeta<typeof RuntimeErrorState>
16+
17+
const Template: Story<RuntimeErrorStateProps> = (args) => <RuntimeErrorState {...args} />
18+
19+
export const Errored = Template.bind({})
20+
Errored.parameters = {
21+
// The RuntimeErrorState is noisy for chromatic, because it renders an actual error
22+
// along with the stacktrace - and the stacktrace includes the full URL of
23+
// scripts in the stack. This is problematic, because every deployment uses
24+
// a different URL, causing the validation to fail.
25+
chromatic: { disableSnapshot: true },
26+
}
27+
28+
Errored.args = {
29+
error,
30+
}

site/src/components/RuntimeErrorState/RuntimeErrorState.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Language = {
1515
link: "send it to us.",
1616
}
1717

18-
interface RuntimeErrorStateProps {
18+
export interface RuntimeErrorStateProps {
1919
error: Error
2020
}
2121

site/src/components/RuntimeErrorState/ReportButtons.tsx renamed to site/src/components/RuntimeErrorState/createCtas.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ const useStyles = makeStyles((theme) => ({
5959
marginLeft: 0,
6060
flex: theme.spacing(1),
6161
textTransform: "uppercase",
62-
fontSize: theme.typography.button.fontSize,
62+
fontSize: theme.typography.fontSize,
6363
},
6464

6565
copyButton: {
6666
width: "100%",
6767
marginRight: theme.spacing(1),
6868
backgroundColor: theme.palette.primary.main,
6969
textTransform: "uppercase",
70-
fontSize: theme.typography.button.fontSize,
70+
fontSize: theme.typography.fontSize,
7171
},
7272
}))

site/src/theme/palettes.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,4 @@ export const darkPalette: PaletteOptions = {
3737
success: {
3838
main: "#6BBE00",
3939
},
40-
error: {
41-
main: "#DD4764",
42-
},
4340
}

0 commit comments

Comments
 (0)