Skip to content

Commit f6d2b18

Browse files
committed
recipes
1 parent a6b5a25 commit f6d2b18

29 files changed

+566
-459
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
"dependencies": {
1616
"@emotion/css": "^11.7.1",
1717
"@mui/material": "^5.2.8",
18+
"@mui/styles": "^5.2.3",
1819
"expose-loader": "^3.1.0",
1920
"jquery": "^3.6.0",
2021
"react": "^17.0.1",
21-
"react-declarative": "^1.6.6",
22+
"react-declarative": "^1.6.7",
2223
"react-dom": "^17.0.1"
2324
},
2425
"scripts": {

src/components/FieldTemplate.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { action } from '@storybook/addon-actions';
44
import { Container, CssBaseline, Box } from '@mui/material';
55

6-
import { OneTyped, TypedField } from 'react-declarative';
6+
import { OneTyped, TypedField, ModalProvider } from 'react-declarative';
77

88
interface IFieldTemplateProps {
99
field: TypedField;
@@ -12,18 +12,20 @@ interface IFieldTemplateProps {
1212
export const FieldTemplate = ({
1313
field,
1414
}: IFieldTemplateProps) => (
15-
<Container>
16-
<CssBaseline />
17-
<Box p={1}>
18-
<OneTyped
19-
fields={[field]}
20-
focus={action('focus')}
21-
blur={action('blur')}
22-
change={action('change')}
23-
invalidity={action('invalidity')}
24-
ready={action('ready')}
25-
fallback={action('fallback')}
26-
/>
27-
</Box>
28-
</Container>
15+
<ModalProvider>
16+
<Container>
17+
<CssBaseline />
18+
<Box p={1}>
19+
<OneTyped
20+
fields={[field]}
21+
focus={action('focus')}
22+
blur={action('blur')}
23+
change={action('change')}
24+
invalidity={action('invalidity')}
25+
ready={action('ready')}
26+
fallback={action('fallback')}
27+
/>
28+
</Box>
29+
</Container>
30+
</ModalProvider>
2931
);

src/components/LayoutTemplate.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { action } from '@storybook/addon-actions';
44
import { Container, CssBaseline, Box } from '@mui/material';
55

6-
import { OneTyped, TypedField } from 'react-declarative';
6+
import { OneTyped, TypedField, ModalProvider } from 'react-declarative';
77

88
interface ILayoutTemplateProps {
99
fields: TypedField[];
@@ -12,18 +12,20 @@ interface ILayoutTemplateProps {
1212
export const LayoutTemplate = ({
1313
fields,
1414
}: ILayoutTemplateProps) => (
15-
<Container>
16-
<CssBaseline />
17-
<Box p={1}>
18-
<OneTyped
19-
fields={fields}
20-
focus={action('focus')}
21-
blur={action('blur')}
22-
change={action('change')}
23-
invalidity={action('invalidity')}
24-
ready={action('ready')}
25-
fallback={action('fallback')}
26-
/>
27-
</Box>
28-
</Container>
15+
<ModalProvider>
16+
<Container>
17+
<CssBaseline />
18+
<Box p={1}>
19+
<OneTyped
20+
fields={fields}
21+
focus={action('focus')}
22+
blur={action('blur')}
23+
change={action('change')}
24+
invalidity={action('invalidity')}
25+
ready={action('ready')}
26+
fallback={action('fallback')}
27+
/>
28+
</Box>
29+
</Container>
30+
</ModalProvider>
2931
);
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import * as React from 'react';
2+
3+
import { makeStyles } from '@mui/styles';
4+
import { Theme } from '@mui/material';
5+
6+
import Box from "@mui/material/Box";
7+
import Avatar from "@mui/material/Avatar";
8+
import Grid from "@mui/material/Grid";
9+
import Button from "@mui/material/Button";
10+
import Typography from "@mui/material/Typography";
11+
12+
const useStyles = makeStyles((theme: Theme) => ({
13+
root: {
14+
alignItems: 'center',
15+
display: 'flex',
16+
paddingBottom: theme.spacing(2),
17+
},
18+
avatar: {
19+
height: 64,
20+
marginRight: theme.spacing(2),
21+
width: 64
22+
},
23+
avaterWrapper: {
24+
height: '100%',
25+
},
26+
content: {
27+
width: '100%',
28+
},
29+
}));
30+
31+
export const AvatarPicker = () => {
32+
const classes = useStyles();
33+
return (
34+
<Box className={classes.root}>
35+
<Box className={classes.avaterWrapper}>
36+
<Avatar
37+
className={classes.avatar}
38+
imgProps={{
39+
crossOrigin: 'anonymous'
40+
}}
41+
/>
42+
</Box>
43+
<div className={classes.content}>
44+
<Grid
45+
container
46+
spacing={1}
47+
>
48+
<Grid item>
49+
<Button
50+
color="primary"
51+
size="small"
52+
type="button"
53+
variant="outlined"
54+
>
55+
Upload new picture
56+
</Button>
57+
</Grid>
58+
<Grid item>
59+
<Button
60+
color="primary"
61+
size="small"
62+
type="button"
63+
variant="text"
64+
>
65+
Delete
66+
</Button>
67+
</Grid>
68+
<Grid item xs />
69+
<Grid item>
70+
<Button
71+
color="secondary"
72+
size="small"
73+
type="button"
74+
variant="outlined"
75+
>
76+
Verification
77+
</Button>
78+
</Grid>
79+
</Grid>
80+
<Typography
81+
color="textSecondary"
82+
variant="caption"
83+
>
84+
Recommended dimensions: 200x200, maximum file size: 5MB
85+
</Typography>
86+
</div>
87+
</Box>
88+
);
89+
};
90+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as React from 'react';
2+
3+
import { makeStyles } from '@mui/styles';
4+
import { Theme } from '@mui/material';
5+
6+
import Button from "@mui/material/Button";
7+
import Box from "@mui/material/Box";
8+
9+
import { useConfirm } from 'react-declarative';
10+
11+
const useStyles = makeStyles({
12+
root: {
13+
height: 45,
14+
},
15+
})
16+
17+
export const RemoveAccount = () => {
18+
const classes = useStyles();
19+
20+
const pickConfirm = useConfirm({
21+
title: 'Disable account',
22+
msg: 'Your accound will be shedule for removal. Are you sure you want to continue?',
23+
});
24+
25+
const handleClick = () => pickConfirm().then((result) => {
26+
if (result) {
27+
alert('bang!');
28+
}
29+
});
30+
31+
return (
32+
<Box className={classes.root}>
33+
<Button
34+
color="primary"
35+
size="small"
36+
type="button"
37+
variant="outlined"
38+
onClick={handleClick}
39+
>
40+
Remove account
41+
</Button>
42+
</Box>
43+
);
44+
};

src/stories/Fields/Checkbox.stories.tsx renamed to src/stories/One/Fields/Checkbox.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Checkbox = FieldTemplate.bind({});
66

src/stories/Fields/Combo.stories.tsx renamed to src/stories/One/Fields/Combo.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Combo = FieldTemplate.bind({});
66

src/stories/Fields/Items.stories.tsx renamed to src/stories/One/Fields/Items.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Items = FieldTemplate.bind({});
66

src/stories/Fields/Line.stories.tsx renamed to src/stories/One/Fields/Line.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Line = FieldTemplate.bind({});
66

src/stories/Fields/Progress.stories.tsx renamed to src/stories/One/Fields/Progress.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Progress = FieldTemplate.bind({});
66

src/stories/Fields/Radio.stories.tsx renamed to src/stories/One/Fields/Radio.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Radio = FieldTemplate.bind({});
66

src/stories/Fields/Rating.stories.tsx renamed to src/stories/One/Fields/Rating.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Rating = FieldTemplate.bind({});
66

src/stories/Fields/Slider.stories.tsx renamed to src/stories/One/Fields/Slider.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Slider = FieldTemplate.bind({});
66

src/stories/Fields/Switch.stories.tsx renamed to src/stories/One/Fields/Switch.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Switch = FieldTemplate.bind({});
66

src/stories/Fields/Textfield.stories.tsx renamed to src/stories/One/Fields/Textfield.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Textfield = FieldTemplate.bind({});
66

src/stories/Fields/Typography.stories.tsx renamed to src/stories/One/Fields/Typography.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FieldType, TypedField } from 'react-declarative';
22

3-
import { FieldTemplate } from '../../components/FieldTemplate';
3+
import { FieldTemplate } from '../../../components/FieldTemplate';
44

55
export const Typography = FieldTemplate.bind({});
66

0 commit comments

Comments
 (0)