1
- import { Button , Input , Stack , Typography } from '@mui/material'
1
+ import { Button , Input , Stack , Typography , InputLabel } from '@mui/material'
2
2
import { PluginComponent } from './FieldPluginDemo'
3
3
import { useState } from 'react'
4
4
5
5
export const PreviewDimension : PluginComponent = ( props ) => {
6
6
const { data, actions } = props
7
7
8
- const label =
9
- typeof data . content === 'undefined'
10
- ? 'undefined'
11
- : JSON . stringify ( data . content )
12
-
13
8
const [ width , setWidth ] = useState ( 300 )
14
9
15
10
const handleClickMobile = ( ) => {
@@ -36,8 +31,7 @@ export const PreviewDimension: PluginComponent = (props) => {
36
31
37
32
return (
38
33
< Stack gap = { 2 } >
39
- < Typography variant = "subtitle1" > Field Value</ Typography >
40
- < Typography textAlign = "center" > { label } </ Typography >
34
+ < Typography variant = "subtitle1" > Dimension</ Typography >
41
35
< Button
42
36
variant = "outlined"
43
37
color = "secondary"
@@ -59,19 +53,30 @@ export const PreviewDimension: PluginComponent = (props) => {
59
53
>
60
54
Desktop
61
55
</ Button >
62
- < Button
63
- variant = "outlined"
64
- color = "secondary"
65
- onClick = { handleClickCustom }
56
+ < InputLabel
57
+ htmlFor = "field-plugin-custom-width"
58
+ shrink
66
59
>
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 >
75
80
</ Stack >
76
81
)
77
82
}
0 commit comments