Skip to content

Commit 9bbe664

Browse files
committed
feat: create the dimension type
1 parent 98ea17c commit 9bbe664

File tree

3 files changed

+19
-29
lines changed

3 files changed

+19
-29
lines changed

packages/field-plugin/src/createFieldPlugin/FieldPluginActions.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
ModalSize,
66
PromptAIPayload,
77
PromptAIResponse,
8+
Dimension,
89
} from '../messaging'
910
import type { FieldPluginData } from './FieldPluginData'
1011

@@ -21,20 +22,7 @@ export type RequestUserContext = () => Promise<UserData>
2122
export type SelectAsset = () => Promise<Asset>
2223
export type Initialize<Content> = () => Promise<FieldPluginData<Content>>
2324
export type SetPreviewWidth = (
24-
previewWidth:
25-
| {
26-
tag: 'desktop'
27-
}
28-
| {
29-
tag: 'tablet'
30-
}
31-
| {
32-
tag: 'mobile'
33-
}
34-
| {
35-
tag: 'custom'
36-
width: number
37-
},
25+
previewWidth: Dimension
3826
) => Promise<void>
3927

4028
export type FieldPluginActions<Content> = {

packages/field-plugin/src/messaging/pluginMessage/pluginToContainerMessage/PreviewDimensionChangeMessage.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ import {
88
optionalGuard,
99
} from 'pure-parse'
1010

11+
export type Dimension =
12+
| {
13+
tag: 'desktop'
14+
}
15+
| {
16+
tag: 'tablet'
17+
}
18+
| {
19+
tag: 'mobile'
20+
}
21+
| {
22+
tag: 'custom'
23+
width: number
24+
}
25+
1126
export type PreviewDimensionChangeMessage =
1227
MessageToContainer<'previewDimension'> & {
13-
data:
14-
| {
15-
tag: 'desktop'
16-
}
17-
| {
18-
tag: 'tablet'
19-
}
20-
| {
21-
tag: 'mobile'
22-
}
23-
| {
24-
tag: 'custom'
25-
width: number
26-
}
28+
data: Dimension
2729
}
2830
export const isPreviewDimensionChangeMessage =
2931
objectGuard<PreviewDimensionChangeMessage>({

packages/sandbox/src/components/FieldPluginSandbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ export const FieldPluginSandbox: FunctionComponent = () => {
545545
</Accordion>
546546
<Accordion defaultExpanded>
547547
<AccordionSummary>
548-
<Typography variant="h3">Data</Typography>
548+
<Typography variant="h3">Editor Preview</Typography>
549549
</AccordionSummary>
550550
<AccordionDetails>
551551
<PreviewDimension previewDimension={previewDimension} />

0 commit comments

Comments
 (0)