Skip to content

Commit 1020d89

Browse files
feat(ui): add new sizes to Modal (#1128)
* introduce new sizes for Modal * fix story * correct size * add margin update story * add min to 2xl
1 parent f64aac6 commit 1020d89

3 files changed

Lines changed: 93 additions & 56 deletions

File tree

.changeset/huge-worlds-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudoperators/juno-ui-components": minor
3+
---
4+
5+
Add `xl` and `2xl` sizes to `Modal`.

packages/ui-components/src/components/Modal/Modal.component.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ const sizeClass = (size: ModalSize) => {
6363
switch (size) {
6464
case "large":
6565
return `jn:w-[40rem]`
66+
case "xl":
67+
return `jn:w-[76.75rem]`
68+
case "2xl":
69+
return `jn:w-[80%] jn:min-w-[85rem] jn:max-w-[112.5rem]`
6670
default:
6771
return `jn:w-[33.625rem]`
6872
}
@@ -226,7 +230,7 @@ export const Modal: React.FC<ModalProps> = ({
226230
)
227231
}
228232

229-
type ModalSize = "small" | "large"
233+
type ModalSize = "small" | "large" | "xl" | "2xl"
230234

231235
export interface ModalProps extends Omit<React.HTMLProps<HTMLDivElement>, "size"> {
232236
/** The title of the modal. This will be rendering as the heading of the modal, and the modal's `arial-labelledby` attribute will reference the title/heading element. If the modal does not have `title` or `heading`, use `ariaLabel` to provide an accessible name for the modal. */

packages/ui-components/src/components/Modal/Modal.stories.tsx

Lines changed: 83 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ const meta: Meta<typeof Modal> = {
7070
decorators: [
7171
(Story) => (
7272
<PortalProvider>
73-
<Story />
73+
<div className="jn:m-20 jn:flex jn:justify-center">
74+
<Story />
75+
</div>
7476
</PortalProvider>
7577
),
7678
],
@@ -116,15 +118,89 @@ export const AutoFocusDialog: Story = {
116118
},
117119
}
118120

119-
export const LargeWithTitle: Story = {
121+
const ReusableForm = () => (
122+
<Form>
123+
<FormRow>
124+
<TextInput label="First Name" id="firstname" />
125+
</FormRow>
126+
<FormRow>
127+
<TextInput label="Last Name" id="lastname" />
128+
</FormRow>
129+
<FormRow>
130+
<TextInput label="Email" id="email" type="email" />
131+
</FormRow>
132+
<FormRow>
133+
<TextInput label="Password" id="password" type="password" />
134+
</FormRow>
135+
<FormRow>
136+
<TextInput label="Retype Password" id="retype-password" type="password" />
137+
</FormRow>
138+
<FormRow>
139+
<Select label="Role">
140+
<SelectOption>Private Person</SelectOption>
141+
<SelectOption>Small Business</SelectOption>
142+
</Select>
143+
</FormRow>
144+
<FormRow>
145+
<ComboBox label="Country">
146+
<ComboBoxOption value="germany" key="DE">
147+
Germany
148+
</ComboBoxOption>
149+
<ComboBoxOption value="uk" key="UK">
150+
United Kingdom
151+
</ComboBoxOption>
152+
<ComboBoxOption value="us" key="US">
153+
USA
154+
</ComboBoxOption>
155+
</ComboBox>
156+
</FormRow>
157+
</Form>
158+
)
159+
160+
export const DefaultWithForm: Story = {
161+
render: Template,
162+
args: {
163+
title: "Default Modal Form",
164+
initialFocus: "#firstname",
165+
cancelButtonLabel: "Cancel",
166+
confirmButtonLabel: "Register now",
167+
children: <ReusableForm />,
168+
},
169+
}
170+
171+
export const LargeWithForm: Story = {
120172
render: Template,
121173
args: {
122174
size: "large",
123-
title: "Large Modal",
124-
confirmButtonLabel: "OK",
125-
// @ts-ignore
126-
closeOnConfirm: true /* Only relevant for storybook, this is not a native prop of the component! */,
127-
children: <p>A large modal with a title</p>,
175+
title: "Large Modal Form",
176+
initialFocus: "#firstname",
177+
cancelButtonLabel: "Cancel",
178+
confirmButtonLabel: "Register now",
179+
children: <ReusableForm />,
180+
},
181+
}
182+
183+
export const XLWithForm: Story = {
184+
render: Template,
185+
args: {
186+
size: "xl",
187+
title: "XL With Form",
188+
initialFocus: "#firstname",
189+
cancelButtonLabel: "Cancel",
190+
confirmButtonLabel: "Register now",
191+
children: <ReusableForm />,
192+
},
193+
}
194+
195+
export const XXLWithForm: Story = {
196+
render: Template,
197+
args: {
198+
size: "2xl",
199+
title: "2XL With Form",
200+
initialFocus: "#firstname",
201+
cancelButtonLabel: "Cancel",
202+
confirmButtonLabel: "Register now",
203+
children: <ReusableForm />,
128204
},
129205
}
130206

@@ -235,51 +311,3 @@ export const TestComboBoxInModal: Story = {
235311
),
236312
},
237313
}
238-
239-
export const ModalWithALargerForm: Story = {
240-
render: Template,
241-
args: {
242-
title: "Register",
243-
initialFocus: "#firstname",
244-
cancelButtonLabel: "Cancel",
245-
confirmButtonLabel: "Register now",
246-
children: (
247-
<Form>
248-
<FormRow>
249-
<TextInput label="First Name" id="firstname" />
250-
</FormRow>
251-
<FormRow>
252-
<TextInput label="Last Name" id="lastname" />
253-
</FormRow>
254-
<FormRow>
255-
<TextInput label="Email" id="email" type="email" />
256-
</FormRow>
257-
<FormRow>
258-
<TextInput label="Password" id="password" type="password" />
259-
</FormRow>
260-
<FormRow>
261-
<TextInput label="Retype Password" id="retype-password" type="password" />
262-
</FormRow>
263-
<FormRow>
264-
<Select label="Role">
265-
<SelectOption>Private Person</SelectOption>
266-
<SelectOption>Small Business</SelectOption>
267-
</Select>
268-
</FormRow>
269-
<FormRow>
270-
<ComboBox label="Country">
271-
<ComboBoxOption value="germany" key="DE">
272-
Germany
273-
</ComboBoxOption>
274-
<ComboBoxOption value="uk" key="UK">
275-
United Kingdom
276-
</ComboBoxOption>
277-
<ComboBoxOption value="us" key="US">
278-
USA
279-
</ComboBoxOption>
280-
</ComboBox>
281-
</FormRow>
282-
</Form>
283-
),
284-
},
285-
}

0 commit comments

Comments
 (0)