Skip to content

Commit 2020923

Browse files
committed
Add documentation and example for Admin Modal component
1 parent 954201a commit 2020923

File tree

8 files changed

+88
-9
lines changed

8 files changed

+88
-9
lines changed

.changeset/small-roses-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': patch
3+
---
4+
5+
Add documentation for Admin Modal
23.2 KB
Loading

packages/ui-extensions/src/docs/shared/components/Modal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const data: SharedReferenceEntityTemplateSchema = {
55
description:
66
'Use modal to display content in a overlay. This component is useful for creating a distraction-free experience, such as a confirmation dialog or a settings panel.',
77
category: 'Polaris web components',
8-
subCategory: 'Overlay',
8+
subCategory: 'Overlays',
99
related: [],
1010
};
1111

packages/ui-extensions/src/surfaces/admin/components.d.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6041,8 +6041,17 @@ export type RequiredAlignedModalProps = Required<ModalProps$1>;
60416041
export interface ModalProps
60426042
extends Pick<
60436043
RequiredAlignedModalProps,
6044-
'accessibilityLabel' | 'heading' | 'padding' | 'size'
6044+
| 'accessibilityLabel'
6045+
| 'heading'
6046+
| 'padding'
6047+
| 'size'
6048+
| 'hideOverlay'
6049+
| 'showOverlay'
6050+
| 'toggleOverlay'
60456051
> {
6052+
/**
6053+
* Adjust the size of the Modal.
6054+
*/
60466055
size: Extract<
60476056
ModalProps$1['size'],
60486057
'small-100' | 'small' | 'base' | 'large' | 'large-100'
@@ -6129,13 +6138,13 @@ export interface ModalJSXProps
61296138
*
61306139
* Only a `Button` with a variant of `primary` is allowed.
61316140
*/
6132-
primaryAction: ComponentChild;
6141+
primaryAction?: ComponentChild;
61336142
/**
61346143
* The secondary actions to perform.
61356144
*
61366145
* Only `ButtonGroup` or `Button` with a variant of `secondary` or `auto` are allowed.
61376146
*/
6138-
secondaryActions: ComponentChild;
6147+
secondaryActions?: ComponentChild;
61396148
onHide?: ((event: CallbackEvent<typeof tagName$z>) => void) | null;
61406149
onShow?: ((event: CallbackEvent<typeof tagName$z>) => void) | null;
61416150
onAfterHide?: ((event: CallbackEvent<typeof tagName$z>) => void) | null;
@@ -7853,13 +7862,13 @@ export interface ModalSlots {
78537862
*
78547863
* Only a `Button` with a variant of `primary` is allowed.
78557864
*/
7856-
'primary-action': HTMLElement;
7865+
'primary-action'?: HTMLElement;
78577866
/**
78587867
* The secondary actions to perform.
78597868
*
78607869
* Only `ButtonGroup` or `Button` with a variant of `secondary` or `auto` are allowed.
78617870
*/
7862-
'secondary-actions': HTMLElement;
7871+
'secondary-actions'?: HTMLElement;
78637872
}
78647873

78657874
export interface MoneyFieldEvents {

packages/ui-extensions/src/surfaces/admin/components/Modal.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ export type RequiredAlignedModalProps = Required<ModalProps$1>;
1616
export interface ModalProps
1717
extends Pick<
1818
RequiredAlignedModalProps,
19-
'accessibilityLabel' | 'heading' | 'padding' | 'size'
19+
| 'accessibilityLabel'
20+
| 'heading'
21+
| 'padding'
22+
| 'size'
23+
| 'hideOverlay'
24+
| 'showOverlay'
25+
| 'toggleOverlay'
2026
> {
27+
/**
28+
* Adjust the size of the Modal.
29+
*/
2130
size: Extract<
2231
ModalProps$1['size'],
2332
'small-100' | 'small' | 'base' | 'large' | 'large-100'
@@ -205,13 +214,13 @@ export interface ModalJSXProps
205214
*
206215
* Only a `Button` with a variant of `primary` is allowed.
207216
*/
208-
primaryAction: ComponentChild;
217+
primaryAction?: ComponentChild;
209218
/**
210219
* The secondary actions to perform.
211220
*
212221
* Only `ButtonGroup` or `Button` with a variant of `secondary` or `auto` are allowed.
213222
*/
214-
secondaryActions: ComponentChild;
223+
secondaryActions?: ComponentChild;
215224
onHide?: ((event: CallbackEvent<typeof tagName>) => void) | null;
216225
onShow?: ((event: CallbackEvent<typeof tagName>) => void) | null;
217226
onAfterHide?: ((event: CallbackEvent<typeof tagName>) => void) | null;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {AdminReferenceEntityTemplateSchema} from '../../docs-types';
2+
import sharedContent from '../../../../docs/shared/components/Modal';
3+
4+
const data: AdminReferenceEntityTemplateSchema = {
5+
...sharedContent,
6+
thumbnail: '/assets/templated-apis-screenshots/admin/components/modal.png',
7+
isVisualComponent: true,
8+
definitions: [
9+
{
10+
title: 'Properties',
11+
description: '',
12+
type: 'Modal',
13+
},
14+
{
15+
title: 'Events',
16+
description:
17+
'Learn more about [registering events](/docs/api/app-home/using-polaris-components#event-handling).',
18+
type: 'ModalEvents',
19+
},
20+
{
21+
title: 'Slots',
22+
description: '',
23+
type: 'ModalSlots',
24+
},
25+
],
26+
defaultExample: {
27+
codeblock: {
28+
title: 'Code',
29+
tabs: [
30+
{
31+
code: './examples/default.html',
32+
language: 'preview',
33+
layout: 'alignStart',
34+
},
35+
],
36+
},
37+
},
38+
};
39+
40+
export default data;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<s-button commandFor="modal">Open</s-button>
2+
3+
<s-modal id="modal" heading="Reach more shoppers with Instagram product tags">
4+
<s-paragraph>
5+
Use Instagram posts to share your products with millions of people.
6+
Let shoppers buy from your store without leaving Instagram.
7+
</s-paragraph>
8+
9+
<s-button slot="secondary-actions" commandFor="modal" command="--hide">
10+
Learn more
11+
</s-button>
12+
<s-button slot="primary-action" variant="primary" commandFor="modal" command="--hide">
13+
Add Instagram
14+
</s-button>
15+
</s-modal>

packages/ui-extensions/src/surfaces/admin/components/StandardComponents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type StandardComponents =
2525
| 'Link'
2626
| 'ListItem'
2727
| 'Menu'
28+
| 'Modal'
2829
| 'MoneyField'
2930
| 'NumberField'
3031
| 'Option'

0 commit comments

Comments
 (0)