Skip to content

Commit 98ea17c

Browse files
committed
feat: reorganize the custom width on preview
1 parent 6c989d4 commit 98ea17c

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

packages/demo/src/components/PreviewDimension.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import { Button, Input, Stack, Typography } from '@mui/material'
1+
import { Button, Input, Stack, Typography, InputLabel } from '@mui/material'
22
import { PluginComponent } from './FieldPluginDemo'
33
import { useState } from 'react'
44

55
export const PreviewDimension: PluginComponent = (props) => {
66
const { data, actions } = props
77

8-
const label =
9-
typeof data.content === 'undefined'
10-
? 'undefined'
11-
: JSON.stringify(data.content)
12-
138
const [width, setWidth] = useState(300)
149

1510
const handleClickMobile = () => {
@@ -36,8 +31,7 @@ export const PreviewDimension: PluginComponent = (props) => {
3631

3732
return (
3833
<Stack gap={2}>
39-
<Typography variant="subtitle1">Field Value</Typography>
40-
<Typography textAlign="center">{label}</Typography>
34+
<Typography variant="subtitle1">Dimension</Typography>
4135
<Button
4236
variant="outlined"
4337
color="secondary"
@@ -59,19 +53,30 @@ export const PreviewDimension: PluginComponent = (props) => {
5953
>
6054
Desktop
6155
</Button>
62-
<Button
63-
variant="outlined"
64-
color="secondary"
65-
onClick={handleClickCustom}
56+
<InputLabel
57+
htmlFor="field-plugin-custom-width"
58+
shrink
6659
>
67-
Custom
68-
</Button>
69-
<Input
70-
type="number"
71-
value={width}
72-
onChange={(e) => setWidth(Number(e.target.value))}
73-
placeholder="Custom Width"
74-
/>
60+
Set custom width:
61+
</InputLabel>
62+
<Stack direction="row" spacing={2} >
63+
<Input
64+
id="field-plugin-custom-width"
65+
fullWidth
66+
type="number"
67+
value={width}
68+
onChange={(e) => setWidth(Number(e.target.value))}
69+
placeholder="Custom Width"
70+
/>
71+
<Button
72+
fullWidth
73+
variant="outlined"
74+
color="secondary"
75+
onClick={handleClickCustom}
76+
>
77+
Custom
78+
</Button>
79+
</Stack>
7580
</Stack>
7681
)
7782
}

0 commit comments

Comments
 (0)