Skip to content

Commit c9ca871

Browse files
committed
feat(SHAPE-7911): add modalSize object to the toggleModal message
1 parent 749d767 commit c9ca871

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

packages/cli/templates/react/src/components/FieldPluginExample/ModalToggle.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { FunctionComponent } from 'react'
22

33
const ModalToggle: FunctionComponent<{
44
isModalOpen: boolean
5-
setModalOpen: (isModalOpen: boolean) => void
5+
setModalOpen: (
6+
isModalOpen: boolean,
7+
modalSize?: { width: string; height: string },
8+
) => void
69
}> = ({ isModalOpen, setModalOpen }) => {
710
return (
811
<div>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ export const createPluginActions: CreatePluginActions = ({
6969
// TODO remove side-effect, making functions in this file pure.
7070
// perhaps only show this message in development mode?
7171
console.debug(
72-
`Plugin received a message from container of an unknown action type "${
73-
data.action
72+
`Plugin received a message from container of an unknown action type "${data.action
7473
}". You may need to upgrade the version of the @storyblok/field-plugin library. Full message: ${JSON.stringify(
7574
data,
7675
)}`,
@@ -107,15 +106,15 @@ export const createPluginActions: CreatePluginActions = ({
107106
)
108107
})
109108
},
110-
setModalOpen: (isModalOpen) => {
109+
setModalOpen: (isModalOpen: boolean, modalSize?: { width: string, height: string }) => {
111110
return new Promise((resolve) => {
112111
const callbackId = pushCallback('stateChanged', (message) =>
113112
resolve(
114113
pluginStateFromStateChangeMessage(message, validateContent),
115114
),
116115
)
117116
postToContainer(
118-
modalChangeMessage({ uid, callbackId, status: isModalOpen }),
117+
modalChangeMessage({ uid, callbackId, status: isModalOpen, modalSize }),
119118
)
120119
})
121120
},

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { isMessageToContainer, MessageToContainer } from './MessageToContainer'
33

44
export type ModalChangeMessage = MessageToContainer<'toggleModal'> & {
55
status: boolean
6+
modalSize?: { width: string; height: string }
67
}
78
export const isModalChangeMessage = (obj: unknown): obj is ModalChangeMessage =>
89
isMessageToContainer(obj) &&
@@ -11,7 +12,7 @@ export const isModalChangeMessage = (obj: unknown): obj is ModalChangeMessage =>
1112
typeof obj.status === 'boolean'
1213

1314
export const modalChangeMessage = (
14-
options: Pick<ModalChangeMessage, 'uid' | 'callbackId' | 'status'>,
15+
options: Pick<ModalChangeMessage, 'uid' | 'callbackId' | 'status' | 'modalSize'>,
1516
): ModalChangeMessage => ({
1617
action: 'plugin-changed',
1718
event: 'toggleModal',

0 commit comments

Comments
 (0)