Skip to content

Commit 1f24f7e

Browse files
committed
Fix typescript and lint errors in stories and storybook config
1 parent 8d17c5a commit 1f24f7e

File tree

9 files changed

+51
-35
lines changed

9 files changed

+51
-35
lines changed

.github/CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Example:
2929
└── components
3030
└── Button
3131
├── index.tsx
32+
├── index.test.tsx
3233
└── button.stories.tsx
3334
3435
```

.github/PULL_REQUEST_TEMPLATE.md

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
<!-- Add the code that is necessary to test your change in the Playground-->
1414

15-
1615
<details>
1716
<summary>Add this code in <code>react/playground/Playground.tsx</code>:</summary>
1817

.storybook/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const path = require('path');
1+
const path = require('path')
22

33
const custom = require('../config/webpack.config.js')
44

.storybook/manager.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {addons} from '@storybook/addons';
2-
import {create} from '@storybook/theming';
1+
import { addons } from '@storybook/addons'
2+
import { create } from '@storybook/theming'
33

44
addons.setConfig({
55
panelPosition: 'bottom',
@@ -16,10 +16,9 @@ addons.setConfig({
1616
// Typography
1717
fontBase: '"Fabriga", sans-serif',
1818
fontCode: 'monospace',
19-
2019

2120
brandTitle: 'VTEX Styleguide',
2221
brandUrl: '/',
2322
brandImage: null,
2423
}),
25-
});
24+
})

.storybook/preview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ addParameters({
1010
},
1111
})
1212

13-
addDecorator(story => (<div style={{padding: '10px'}}>{story()}</div>)) // Add padding in the canvas
13+
addDecorator(story => (<div style={{padding: '10px'}}>{story()}</div>))

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"prepare": "yarn --cwd react --ignore-scripts",
3030
"postreleasy": "vtex publish --public --verbose",
3131
"storybook": "start-storybook -p 6006",
32-
"build-storybook": "build-storybook"
32+
"build:storybook": "build-storybook"
3333
},
3434
"devDependencies": {
3535
"@babel/cli": "^7.5.5",

react/components/Button/button.stories.tsx

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
import React from 'react'
22
import { withA11y } from '@storybook/addon-a11y'
3-
import { withKnobs, text, boolean, select } from "@storybook/addon-knobs"
3+
import { withKnobs, text, boolean, select } from '@storybook/addon-knobs'
44
import { action } from '@storybook/addon-actions'
55

66
import Button from '.'
77

88
export default {
99
title: 'Components|Button',
1010
component: Button,
11-
decorators: [withA11y, withKnobs]
11+
decorators: [withA11y, withKnobs],
1212
}
1313

14-
const variations = ['primary', 'secondary', 'tertiary', 'danger', 'danger-tertiary', 'inverted-tertiary']
14+
const variations = [
15+
'primary',
16+
'secondary',
17+
'tertiary',
18+
'danger',
19+
'danger-tertiary',
20+
'inverted-tertiary',
21+
]
1522
const sizes = ['small', 'regular', 'large']
1623

1724
export const Default = () => (
1825
<Button
26+
type="button"
1927
variation={select('Variation', variations, 'primary')}
2028
isLoading={boolean('Is loading', false)}
2129
disabled={boolean('Disabled', false)}
@@ -24,14 +32,12 @@ export const Default = () => (
2432
onClick={action('button-click')}
2533
onFocus={action('button-focus')}
2634
>
27-
{text("Label", "With a text")}
35+
{text('Label', 'With a text')}
2836
</Button>
2937
)
3038

3139
export const withLoadingState = () => (
32-
<Button
33-
isLoading={true}
34-
>
40+
<Button type="button" isLoading>
3541
Loading
3642
</Button>
3743
)
@@ -40,16 +46,21 @@ export const withDiffentVariations = () => (
4046
<>
4147
{variations.map(variation => (
4248
<>
43-
<Button variation={variation}>{variation}</Button>
44-
<br/>
45-
<br/>
49+
<Button type="button" variation={variation}>
50+
{variation}
51+
</Button>
52+
<br />
53+
<br />
4654
</>
4755
))}
4856
</>
4957
)
5058

5159
export const withOnMouseEvents = () => (
5260
<Button
61+
type="button"
62+
onFocus={() => null}
63+
onBlur={() => null}
5364
onMouseDown={action('button-on-mouse-down')}
5465
onMouseEnter={action('button-on-mouse-enter')}
5566
onMouseOver={action('button-on-mouse-over')}
@@ -65,9 +76,11 @@ export const withDifferentSizes = () => (
6576
<>
6677
{sizes.map(size => (
6778
<>
68-
<Button size={size}>{size}</Button>
69-
<br/>
70-
<br/>
79+
<Button type="button" size={size}>
80+
{size}
81+
</Button>
82+
<br />
83+
<br />
7184
</>
7285
))}
7386
</>
+12-13
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
import React from 'react'
2-
import { withKnobs, text, boolean, select, number } from "@storybook/addon-knobs"
2+
import { withKnobs, text, select, number } from '@storybook/addon-knobs'
33

4+
import { Position } from './TooltipPopup'
45
import Tooltip from '.'
56
import Button from '../Button'
67

78
export default {
89
title: 'Components|Tooltip',
910
component: Tooltip,
10-
decorators: [withKnobs]
11+
decorators: [withKnobs],
1112
}
1213

13-
const positions = ['top', 'left', 'right', 'bottom']
14+
const positions: Position[] = ['top', 'left', 'right', 'bottom']
1415

1516
export const Default = () => (
1617
<Tooltip
1718
label={text('Label', 'Tooltip Label')}
1819
trigger={select('Trigger', ['click', 'hover', 'focus'], 'hover')}
19-
wordBreak={select('Word Break', ['normal', 'break-all', 'keep-all', 'break-word'], 'normal')}
20-
position={select('Position', positions, 'left')}
20+
wordBreak={select(
21+
'Word Break',
22+
['normal', 'break-all', 'keep-all', 'break-word'],
23+
'normal'
24+
)}
25+
position={select('Position', positions, 'left') ?? ''}
2126
delay={number('Delay(ms)', 0)}
22-
fallbackPosition={select('Fallback Position', positions, 'right')}
27+
fallbackPosition={select('Fallback Position', positions, 'right') ?? ''}
2328
>
24-
<Button>Button</Button>
25-
</Tooltip>
26-
)
27-
28-
export const AlwaysVisible = () => (
29-
<Tooltip label="Tooltip Label" trigger="focus">
30-
<Button autoFocus={true}>Button with focus</Button>
29+
<Button type="button">Button</Button>
3130
</Tooltip>
3231
)

react/tsconfig.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"typeRoots": ["node_modules/@types"],
77
"types": ["node", "jest"]
88
},
9-
"include": ["./typings/*.d.ts", "./**/*.tsx", "./**/*.ts", "./**/*.stories.tsx"],
9+
"include": [
10+
"./typings/*.d.ts",
11+
"./**/*.tsx",
12+
"./**/*.ts",
13+
"./**/*.stories.tsx"
14+
],
1015
"exclude": ["node_modules", "*.md"]
1116
}

0 commit comments

Comments
 (0)