mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-26 17:20:37 +01:00
Added 'a11y' and 'source' addons to storybook as well as more stories
This commit is contained in:
parent
624ccb5b00
commit
90dfbf37e0
17 changed files with 594 additions and 6 deletions
|
@ -2,15 +2,23 @@ const rules = require('../config/webpack.rules');
|
|||
|
||||
module.exports = {
|
||||
stories: ['../stories/**/*.stories.js'],
|
||||
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
|
||||
addons: [
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addon-a11y/register',
|
||||
'@storybook/addon-storysource',
|
||||
],
|
||||
webpackFinal: async config => {
|
||||
// do mutation to the config
|
||||
console.log("config.module", config.module);
|
||||
|
||||
return {
|
||||
...config,
|
||||
module: {
|
||||
...config.module,
|
||||
rules
|
||||
rules: [
|
||||
...config.module.rules,
|
||||
...rules,
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
|
|
104
package-lock.json
generated
104
package-lock.json
generated
|
@ -1534,6 +1534,30 @@
|
|||
"integrity": "sha512-/aPsuoj/1Dw/kzhkgz+ES6TxG0zfTMGLwuK2ZG00k/iJzYHTLCE8mVU8EPqEOp/lmxPoq1C1C9RYToRKb2KEfg==",
|
||||
"dev": true
|
||||
},
|
||||
"@storybook/addon-a11y": {
|
||||
"version": "5.3.19",
|
||||
"resolved": "https://registry.npmjs.org/@storybook/addon-a11y/-/addon-a11y-5.3.19.tgz",
|
||||
"integrity": "sha512-obh2Uy8IeXU+UPQXoqT2Q0hRdAuQdfZjYdrGJ9RGoehVEzMxZlR0x1Cml5xf3u9v6+l72hi85RvA6YEGl+jKZw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@storybook/addons": "5.3.19",
|
||||
"@storybook/api": "5.3.19",
|
||||
"@storybook/client-logger": "5.3.19",
|
||||
"@storybook/components": "5.3.19",
|
||||
"@storybook/core-events": "5.3.19",
|
||||
"@storybook/theming": "5.3.19",
|
||||
"axe-core": "^3.3.2",
|
||||
"core-js": "^3.0.1",
|
||||
"global": "^4.3.2",
|
||||
"memoizerific": "^1.11.3",
|
||||
"react": "^16.8.3",
|
||||
"react-redux": "^7.0.2",
|
||||
"react-sizeme": "^2.5.2",
|
||||
"redux": "^4.0.1",
|
||||
"ts-dedent": "^1.1.0",
|
||||
"util-deprecate": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"@storybook/addon-actions": {
|
||||
"version": "5.3.19",
|
||||
"resolved": "https://registry.npmjs.org/@storybook/addon-actions/-/addon-actions-5.3.19.tgz",
|
||||
|
@ -1590,6 +1614,27 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@storybook/addon-storysource": {
|
||||
"version": "5.3.19",
|
||||
"resolved": "https://registry.npmjs.org/@storybook/addon-storysource/-/addon-storysource-5.3.19.tgz",
|
||||
"integrity": "sha512-W7mIAHuxYT+b1huaHCHLkBAh2MbeWmF8CxeBCFiOgZaYYQUTDEh018HJF8u2AqiWSouRhcfzhTnGxOo0hNRBgw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@storybook/addons": "5.3.19",
|
||||
"@storybook/components": "5.3.19",
|
||||
"@storybook/router": "5.3.19",
|
||||
"@storybook/source-loader": "5.3.19",
|
||||
"@storybook/theming": "5.3.19",
|
||||
"core-js": "^3.0.1",
|
||||
"estraverse": "^4.2.0",
|
||||
"loader-utils": "^1.2.3",
|
||||
"prettier": "^1.16.4",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-syntax-highlighter": "^11.0.2",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"util-deprecate": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"@storybook/addons": {
|
||||
"version": "5.3.19",
|
||||
"resolved": "https://registry.npmjs.org/@storybook/addons/-/addons-5.3.19.tgz",
|
||||
|
@ -2341,6 +2386,24 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@storybook/source-loader": {
|
||||
"version": "5.3.19",
|
||||
"resolved": "https://registry.npmjs.org/@storybook/source-loader/-/source-loader-5.3.19.tgz",
|
||||
"integrity": "sha512-srSZRPgEOUse8nRVnlazweB2QGp63mPqM0uofg8zYARyaYSOzkC155ymdeiHsmiBTS3X3I0FQE4+KnwiH7iLtw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@storybook/addons": "5.3.19",
|
||||
"@storybook/client-logger": "5.3.19",
|
||||
"@storybook/csf": "0.0.1",
|
||||
"core-js": "^3.0.1",
|
||||
"estraverse": "^4.2.0",
|
||||
"global": "^4.3.2",
|
||||
"loader-utils": "^1.2.3",
|
||||
"prettier": "^1.16.4",
|
||||
"prop-types": "^15.7.2",
|
||||
"regenerator-runtime": "^0.13.3"
|
||||
}
|
||||
},
|
||||
"@storybook/theming": {
|
||||
"version": "5.3.19",
|
||||
"resolved": "https://registry.npmjs.org/@storybook/theming/-/theming-5.3.19.tgz",
|
||||
|
@ -4232,6 +4295,12 @@
|
|||
"integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==",
|
||||
"dev": true
|
||||
},
|
||||
"axe-core": {
|
||||
"version": "3.5.4",
|
||||
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-3.5.4.tgz",
|
||||
"integrity": "sha512-JRuxixN5bPHre+815qnyqBQzNpRTqGxLWflvjr4REpGZ5o0WXm+ik2IS4PZ01EnacWmVRB4jCPWFiYENMiiasA==",
|
||||
"dev": true
|
||||
},
|
||||
"babel-code-frame": {
|
||||
"version": "6.26.0",
|
||||
"resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
|
||||
|
@ -13920,6 +13989,12 @@
|
|||
"integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.19.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
|
||||
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
|
||||
"dev": true
|
||||
},
|
||||
"pretty-error": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-2.1.1.tgz",
|
||||
|
@ -15136,6 +15211,19 @@
|
|||
"react-popper": "^1.3.7"
|
||||
}
|
||||
},
|
||||
"react-redux": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.0.tgz",
|
||||
"integrity": "sha512-EvCAZYGfOLqwV7gh849xy9/pt55rJXPwmYvI4lilPM5rUT/1NxuuN59ipdBksRVSvz0KInbPnp4IfoXJXCqiDA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.5.5",
|
||||
"hoist-non-react-statics": "^3.3.0",
|
||||
"loose-envify": "^1.4.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react-is": "^16.9.0"
|
||||
}
|
||||
},
|
||||
"react-sizeme": {
|
||||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/react-sizeme/-/react-sizeme-2.6.12.tgz",
|
||||
|
@ -15331,6 +15419,16 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"redux": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/redux/-/redux-4.0.5.tgz",
|
||||
"integrity": "sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"loose-envify": "^1.4.0",
|
||||
"symbol-observable": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"refractor": {
|
||||
"version": "2.10.1",
|
||||
"resolved": "https://registry.npmjs.org/refractor/-/refractor-2.10.1.tgz",
|
||||
|
@ -17656,6 +17754,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"symbol-observable": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
|
||||
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==",
|
||||
"dev": true
|
||||
},
|
||||
"symbol.prototype.description": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/symbol.prototype.description/-/symbol.prototype.description-1.0.2.tgz",
|
||||
|
|
|
@ -121,8 +121,10 @@
|
|||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/preset-react": "^7.6.3",
|
||||
"@mdi/js": "^5.0.45",
|
||||
"@storybook/addon-a11y": "^5.3.19",
|
||||
"@storybook/addon-actions": "^5.3.19",
|
||||
"@storybook/addon-links": "^5.3.19",
|
||||
"@storybook/addon-storysource": "^5.3.19",
|
||||
"@storybook/addons": "^5.3.19",
|
||||
"@storybook/react": "^5.3.19",
|
||||
"@storybook/theming": "^5.3.19",
|
||||
|
|
|
@ -2,13 +2,16 @@ import React from 'react';
|
|||
import Button from '../src/components/Button';
|
||||
import {action} from '@storybook/addon-actions';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
component: Button,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
export const Simple = () => (
|
||||
export const Basic = () => (
|
||||
<Wrapper>
|
||||
<Button onClick={action('onClick')}>
|
||||
Hello Button
|
||||
|
|
44
stories/FieldArray.stories.js
Normal file
44
stories/FieldArray.stories.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldArray from '../src/components/FieldArray';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldArray',
|
||||
component: FieldArray,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const NumberType = () => {
|
||||
const [value, setValue] = useActionState("onChange", [1,2,3]);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldArray
|
||||
type="number"
|
||||
value={value}
|
||||
length={3}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const StringType = () => {
|
||||
const [value, setValue] = useActionState("onChange", ["a", "b", "c"]);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldArray
|
||||
type="string"
|
||||
value={value}
|
||||
length={3}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
28
stories/FieldAutocomplete.stories.js
Normal file
28
stories/FieldAutocomplete.stories.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldAutocomplete from '../src/components/FieldAutocomplete';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldAutocomplete',
|
||||
component: FieldAutocomplete,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Basic = () => {
|
||||
const options = [["FOO", "foo"], ["BAR", "bar"], ["BAZ", "baz"]];
|
||||
const [value, setValue] = useActionState("onChange", "bar");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldAutocomplete
|
||||
options={options}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
39
stories/FieldCheckbox.stories.js
Normal file
39
stories/FieldCheckbox.stories.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldCheckbox from '../src/components/FieldCheckbox';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldCheckbox',
|
||||
component: FieldCheckbox,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const BasicUnchecked = () => {
|
||||
const [value, setValue] = useActionState("onChange", false);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldCheckbox
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const BasicChecked = () => {
|
||||
const [value, setValue] = useActionState("onChange", true);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldCheckbox
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
|
@ -2,14 +2,16 @@ import React from 'react';
|
|||
import {useActionState} from './helper';
|
||||
import FieldColor from '../src/components/FieldColor';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldColor',
|
||||
component: FieldColor,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Simple = () => {
|
||||
export const Basic = () => {
|
||||
const [color, setColor] = useActionState("onChange", "#ff0000");
|
||||
|
||||
return (
|
||||
|
|
55
stories/FieldDynamicArray.stories.js
Normal file
55
stories/FieldDynamicArray.stories.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldDynamicArray from '../src/components/FieldDynamicArray';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldDynamicArray',
|
||||
component: FieldDynamicArray,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const NumberType = () => {
|
||||
const [value, setValue] = useActionState("onChange", [1,2,3]);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldDynamicArray
|
||||
type="number"
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const UrlType = () => {
|
||||
const [value, setValue] = useActionState("onChange", ["http://example.com"]);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldDynamicArray
|
||||
type="url"
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const EnumType = () => {
|
||||
const [value, setValue] = useActionState("onChange", ["foo"]);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldDynamicArray
|
||||
fieldSpec={{values: {"foo": null, "bar": null, "baz": null}}}
|
||||
type="enum"
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
76
stories/FieldEnum.stories.js
Normal file
76
stories/FieldEnum.stories.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldEnum from '../src/components/FieldEnum';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldEnum',
|
||||
component: FieldEnum,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const BasicFew = () => {
|
||||
const options = ["Foo", "Bar", "Baz"];
|
||||
const [value, setValue] = useActionState("onChange", "Foo");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldEnum
|
||||
options={options}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const BasicFewWithDefault = () => {
|
||||
const options = ["Foo", "Bar", "Baz"];
|
||||
const [value, setValue] = useActionState("onChange", null);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldEnum
|
||||
options={options}
|
||||
default={"Baz"}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const BasicMany = () => {
|
||||
const options = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
|
||||
const [value, setValue] = useActionState("onChange", "a");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldEnum
|
||||
options={options}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const BasicManyWithDefault = () => {
|
||||
const options = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];
|
||||
const [value, setValue] = useActionState("onChange", "a");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldEnum
|
||||
options={options}A
|
||||
default={"h"}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
28
stories/FieldFont.stories.js
Normal file
28
stories/FieldFont.stories.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldFont from '../src/components/FieldFont';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldFont',
|
||||
component: FieldFont,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Basic = () => {
|
||||
const fonts = ["Comic Sans", "Helvectica", "Gotham"];
|
||||
const [value, setValue] = useActionState("onChange", ["Comic Sans"]);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldFont
|
||||
fonts={fonts}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
28
stories/FieldMultiInput.stories.js
Normal file
28
stories/FieldMultiInput.stories.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldMultiInput from '../src/components/FieldMultiInput';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldMultiInput',
|
||||
component: FieldMultiInput,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Basic = () => {
|
||||
const options = [["FOO", "foo"], ["BAR", "bar"], ["BAZ", "baz"]];
|
||||
const [value, setValue] = useActionState("onChange", "FOO");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldMultiInput
|
||||
options={options}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
|
@ -2,13 +2,15 @@ import React from 'react';
|
|||
import {useActionState} from './helper';
|
||||
import FieldNumber from '../src/components/FieldNumber';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldNumber',
|
||||
component: FieldNumber,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
export const Simple = () => {
|
||||
export const Basic = () => {
|
||||
const [value, setValue] = useActionState("onChange", 1);
|
||||
|
||||
return (
|
||||
|
|
29
stories/FieldSelect.stories.js
Normal file
29
stories/FieldSelect.stories.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldSelect from '../src/components/FieldSelect';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldSelect',
|
||||
component: FieldSelect,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Basic = () => {
|
||||
const options = [["FOO", "Foo"], ["BAR", "Bar"], ["BAZ", "Baz"]];
|
||||
const [value, setValue] = useActionState("onChange", "FOO");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldSelect
|
||||
options={options}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
69
stories/FieldString.stories.js
Normal file
69
stories/FieldString.stories.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldString from '../src/components/FieldString';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldString',
|
||||
component: FieldString,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Basic = () => {
|
||||
const [value, setValue] = useActionState("onChange", "Hello world");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldString
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const WithDefault = () => {
|
||||
const [value, setValue] = useActionState("onChange", null);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldString
|
||||
value={value}
|
||||
default={"Edit me..."}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const Multiline = () => {
|
||||
const [value, setValue] = useActionState("onChange", "Hello\nworld");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldString
|
||||
multi={true}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const MultilineWithDefault = () => {
|
||||
const [value, setValue] = useActionState("onChange", null);
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldString
|
||||
multi={true}
|
||||
default={"Edit\nme.."}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
29
stories/FieldSymbol.stories.js
Normal file
29
stories/FieldSymbol.stories.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldSymbol from '../src/components/FieldSymbol';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldSymbol',
|
||||
component: FieldSymbol,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Basic = () => {
|
||||
const icons = ["Bicycle", "Ski", "Ramp"];
|
||||
const [value, setValue] = useActionState("onChange", "Ski");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldSymbol
|
||||
icons={icons}
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
42
stories/FieldUrl.stories.js
Normal file
42
stories/FieldUrl.stories.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
import React from 'react';
|
||||
import {useActionState} from './helper';
|
||||
import FieldUrl from '../src/components/FieldUrl';
|
||||
import {Wrapper} from './ui';
|
||||
import {withA11y} from '@storybook/addon-a11y';
|
||||
|
||||
export default {
|
||||
title: 'FieldUrl',
|
||||
component: FieldUrl,
|
||||
decorators: [withA11y],
|
||||
};
|
||||
|
||||
|
||||
export const Valid = () => {
|
||||
const [value, setValue] = useActionState("onChange", "http://example.com");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldUrl
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
onInput={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const Invalid = () => {
|
||||
const [value, setValue] = useActionState("onChange", "foo");
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<FieldUrl
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
onInput={setValue}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in a new issue