Skip to content

Commit 776d6af

Browse files
tanner-reitsTanner Reits
authored and
Tanner Reits
committed
docs(select): add modal interface to ion-select docs (#3872)
* docs(select): update select docs for modal interface * fix(select): point playground to correct demo
1 parent d1f0b7c commit 776d6af

File tree

13 files changed

+202
-10
lines changed

13 files changed

+202
-10
lines changed

docs/api/select.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import SingleSelectionExample from '@site/static/usage/v8/select/basic/single-se
7070

7171
## Multiple Selection
7272

73-
By adding the `multiple` attribute to select, users are able to select multiple options. When multiple options can be selected, the alert or popover overlay presents users with a checkbox styled list of options. The select component's value receives an array of all of the selected option values.
73+
By adding the `multiple` attribute to select, users are able to select multiple options. When multiple options can be selected, the alert, popover, or modal overlay presents users with a checkbox styled list of options. The select component's value receives an array of all of the selected option values.
7474

7575
:::note
7676

@@ -86,7 +86,7 @@ import MultipleSelectionExample from '@site/static/usage/v8/select/basic/multipl
8686

8787
## Interfaces
8888

89-
By default, select uses [ion-alert](alert.md) to open up the overlay of options in an alert. The interface can be changed to use [ion-action-sheet](action-sheet.md) or [ion-popover](popover.md) by passing `action-sheet` or `popover`, respectively, to the `interface` property. Read on to the other sections for the limitations of the different interfaces.
89+
By default, select uses [ion-alert](alert.md) to open up the overlay of options in an alert. The interface can be changed to use [ion-action-sheet](action-sheet.md), [ion-popover](popover.md), or [ion-modal](modal.md) by passing `action-sheet`, `popover`, or `modal`, respectively, to the `interface` property. Read on to the other sections for the limitations of the different interfaces.
9090

9191
### Alert
9292

@@ -107,6 +107,12 @@ import PopoverExample from '@site/static/usage/v8/select/interfaces/popover/inde
107107

108108
<PopoverExample />
109109

110+
### Modal
111+
112+
import ModalExample from '@site/static/usage/v8/select/interfaces/modal/index.md';
113+
114+
<ModalExample />
115+
110116
## Responding to Interaction
111117

112118
The main ways of handling user interaction with the select are the `ionChange`, `ionDismiss`, and `ionCancel` events. See [Events](#events) for more details on these and other events that select fires.
@@ -161,15 +167,19 @@ The alert supports two buttons: `Cancel` and `OK`. Each button's text can be cus
161167

162168
The `action-sheet` and `popover` interfaces do not have an `OK` button, clicking on any of the options will automatically close the overlay and select that value. The `popover` interface does not have a `Cancel` button, clicking on the backdrop will close the overlay.
163169

170+
The `modal` interface has a single `Close` button in the header. This button is only responsible for dismissing the modal. Any selections made will persist
171+
after clicking this button or if the modal is dismissed using an alternative method.
172+
164173
import ButtonTextExample from '@site/static/usage/v8/select/customization/button-text/index.md';
165174

166175
<ButtonTextExample />
167176

168177
## Interface Options
169178

170-
Since select uses the alert, action sheet and popover interfaces, options can be passed to these components through the `interfaceOptions` property. This can be used to pass a custom header, subheader, css class, and more.
179+
Since select uses the alert, action sheet, popover, and modal interfaces, options can be passed to these components through the `interfaceOptions` property. This can be used to pass a custom header, subheader, css class, and more.
171180

172-
See the [ion-alert docs](alert.md), [ion-action-sheet docs](action-sheet.md), and [ion-popover docs](popover.md) for the properties that each interface accepts.
181+
See the [ion-alert docs](alert.md), [ion-action-sheet docs](action-sheet.md), [ion-popover docs](popover.md), and [ion-modal docs](modal.md)
182+
for the properties that each interface accepts.
173183

174184
Note: `interfaceOptions` will not override `inputs` or `buttons` with the `alert` interface.
175185

@@ -207,11 +217,13 @@ import StylingSelectExample from '@site/static/usage/v8/select/customization/sty
207217

208218
### Styling Select Interface
209219

210-
Customizing the interface dialog should be done by following the Customization section in that interface's documentation:
220+
Customizing the interface dialog should be done by following the styling sections (CSS shadow parts, CSS custom properties, and slots) in
221+
that interface's documentation:
211222

212-
- [Alert Customization](alert.md#customization)
213-
- [Action Sheet Customization](action-sheet.md#customization)
214-
- [Popover Customization](popover.md#customization)
223+
- [Alert](alert.md#css-shadow-parts)
224+
- [Action Sheet](action-sheet.md#css-shadow-parts)
225+
- [Popover](popover.md#css-shadow-parts)
226+
- [Modal](modal.md#css-shadow-parts)
215227

216228
However, the Select Option does set a class for easier styling and allows for the ability to pass a class to the overlay option, see the [Select Options documentation](select-option.md) for usage examples of customizing options.
217229

@@ -304,7 +316,7 @@ These keyboard interactions apply to all `ion-select` elements when the followin
304316

305317
Single selection keyboard interaction follows the [ARIA implementation patterns of a radio](https://www.w3.org/WAI/ARIA/apg/patterns/radio/).
306318

307-
These keyboard interactions apply to `ion-action-sheet`, `ion-alert`, and `ion-popover` elements when the overlay is presented and focused.
319+
These keyboard interactions apply to `ion-action-sheet`, `ion-alert`, `ion-popover`, and `ion-modal` elements when the overlay is presented and focused.
308320

309321
| Key | Description |
310322
| --------------------- | ------------------------------------------------------------ |
@@ -321,7 +333,7 @@ These keyboard interactions apply to `ion-action-sheet`, `ion-alert`, and `ion-p
321333

322334
Multiple selection keyboard interaction follows the [ARIA implementation patterns of a checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/).
323335

324-
These keyboard interactions apply to `ion-alert` and `ion-popover` elements when the overlay is presented and multiple selection is enabled.
336+
These keyboard interactions apply to `ion-alert`, `ion-popover`, and `ion-modal` elements when the overlay is presented and multiple selection is enabled.
325337

326338
| Key | Description |
327339
| ------------------ | ------------------------------------------------------------ |

static/usage/v8/select/customization/interface-options/angular/example_component_html.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,13 @@
2828
<ion-select-option value="blue">Blue</ion-select-option>
2929
</ion-select>
3030
</ion-item>
31+
32+
<ion-item>
33+
<ion-select label="Modal" [interfaceOptions]="customModalOptions" interface="modal" placeholder="Select One">
34+
<ion-select-option value="reese's">Reese's</ion-select-option>
35+
<ion-select-option value="snickers">Snickers</ion-select-option>
36+
<ion-select-option value="twix">Twix</ion-select-option>
37+
</ion-select>
38+
</ion-item>
3139
</ion-list>
3240
```

static/usage/v8/select/customization/interface-options/angular/example_component_ts.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ export class ExampleComponent {
2323
header: 'Colors',
2424
subHeader: 'Select your favorite color',
2525
};
26+
27+
customModalOptions = {
28+
header: 'Favorite Candy',
29+
breakpoints: [0, 0.5],
30+
initialBreakpoint: 0.5,
31+
};
2632
}
2733
```

static/usage/v8/select/customization/interface-options/demo.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
<ion-select-option value="blue">Blue</ion-select-option>
5050
</ion-select>
5151
</ion-item>
52+
53+
<ion-item>
54+
<ion-select label="Modal" id="customModalSelect" interface="modal" placeholder="Select One">
55+
<ion-select-option value="reese's">Reese's</ion-select-option>
56+
<ion-select-option value="snickers">Snickers</ion-select-option>
57+
<ion-select-option value="twix">Twix</ion-select-option>
58+
</ion-select>
59+
</ion-item>
5260
</ion-list>
5361
</div>
5462
</ion-content>
@@ -78,6 +86,14 @@
7886
subHeader: 'Select your favorite color',
7987
};
8088
customActionSheetSelect.interfaceOptions = customActionSheetOptions;
89+
90+
const customModalSelect = document.getElementById('customModalSelect');
91+
const customModalOptions = {
92+
header: 'Favorite Candy',
93+
breakpoints: [0, 0.5],
94+
initialBreakpoint: 0.5,
95+
};
96+
customModalSelect.interfaceOptions = customModalOptions;
8197
</script>
8298
</body>
8399
</html>

static/usage/v8/select/customization/interface-options/javascript.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
<ion-select-option value="blue">Blue</ion-select-option>
2424
</ion-select>
2525
</ion-item>
26+
27+
<ion-item>
28+
<ion-select label="Modal" id="customModalSelect" interface="modal" placeholder="Select One">
29+
<ion-select-option value="reese's">Reese's</ion-select-option>
30+
<ion-select-option value="snickers">Snickers</ion-select-option>
31+
<ion-select-option value="twix">Twix</ion-select-option>
32+
</ion-select>
33+
</ion-item>
2634
</ion-list>
2735

2836
<script>
@@ -49,5 +57,13 @@
4957
subHeader: 'Select your favorite color',
5058
};
5159
customActionSheetSelect.interfaceOptions = customActionSheetOptions;
60+
61+
const customModalSelect = document.getElementById('customModalSelect');
62+
const customModalOptions = {
63+
header: 'Favorite Candy',
64+
breakpoints: [0, 0.5],
65+
initialBreakpoint: 0.5,
66+
};
67+
customModalSelect.interfaceOptions = customModalOptions;
5268
</script>
5369
```

static/usage/v8/select/customization/interface-options/react.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ function Example() {
2020
subHeader: 'Select your favorite color',
2121
};
2222

23+
const customModalOptions = {
24+
header: 'Favorite Candy',
25+
breakpoints: [0, 0.5],
26+
initialBreakpoint: 0.5,
27+
};
28+
2329
return (
2430
<IonList>
2531
<IonItem>
@@ -50,6 +56,14 @@ function Example() {
5056
<IonSelectOption value="blue">Blue</IonSelectOption>
5157
</IonSelect>
5258
</IonItem>
59+
60+
<IonItem>
61+
<IonSelect label="Modal" interfaceOptions={customModalOptions} interface="modal" placeholder="Select One">
62+
<IonSelectOption value="reese's">Reese's</IonSelectOption>
63+
<IonSelectOption value="snickers">Snickers</IonSelectOption>
64+
<IonSelectOption value="twix">Twix</IonSelectOption>
65+
</IonSelect>
66+
</IonItem>
5367
</IonList>
5468
);
5569
}

static/usage/v8/select/customization/interface-options/vue.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
<ion-select-option value="blue">Blue</ion-select-option>
3535
</ion-select>
3636
</ion-item>
37+
38+
<ion-item>
39+
<ion-select label="Modal" :interface-options="customModalOptions" interface="modal" placeholder="Select One">
40+
<ion-select-option value="reese's">Reese's</ion-select-option>
41+
<ion-select-option value="snickers">Snickers</ion-select-option>
42+
<ion-select-option value="twix">Twix</ion-select-option>
43+
</ion-select>
44+
</ion-item>
3745
</ion-list>
3846
</template>
3947

@@ -62,10 +70,17 @@
6270
subHeader: 'Select your favorite color',
6371
};
6472
73+
const customModalOptions = {
74+
header: 'Favorite Candy',
75+
breakpoints: [0, 0.5],
76+
initialBreakpoint: 0.5,
77+
};
78+
6579
return {
6680
customAlertOptions,
6781
customPopoverOptions,
6882
customActionSheetOptions,
83+
customModalOptions,
6984
};
7085
},
7186
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```html
2+
<ion-list>
3+
<ion-item>
4+
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit">
5+
<ion-select-option value="apples">Apples</ion-select-option>
6+
<ion-select-option value="oranges">Oranges</ion-select-option>
7+
<ion-select-option value="bananas">Bananas</ion-select-option>
8+
</ion-select>
9+
</ion-item>
10+
</ion-list>
11+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Select - Modal</title>
7+
<link rel="stylesheet" href="../../../common.css" />
8+
<script src="../../../common.js"></script>
9+
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script>
10+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" />
11+
</head>
12+
13+
<body>
14+
<ion-app>
15+
<ion-content>
16+
<div class="container">
17+
<ion-list>
18+
<ion-item>
19+
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit">
20+
<ion-select-option value="apples">Apples</ion-select-option>
21+
<ion-select-option value="oranges">Oranges</ion-select-option>
22+
<ion-select-option value="bananas">Bananas</ion-select-option>
23+
</ion-select>
24+
</ion-item>
25+
</ion-list>
26+
</div>
27+
</ion-content>
28+
</ion-app>
29+
</body>
30+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Playground from '@site/src/components/global/Playground';
2+
3+
import javascript from './javascript.md';
4+
import react from './react.md';
5+
import vue from './vue.md';
6+
import angular from './angular.md';
7+
8+
<Playground
9+
version="8"
10+
size="400px"
11+
code={{ javascript, react, vue, angular }}
12+
src="usage/v8/select/interfaces/modal/demo.html"
13+
/>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
```html
2+
<ion-list>
3+
<ion-item>
4+
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit">
5+
<ion-select-option value="apples">Apples</ion-select-option>
6+
<ion-select-option value="oranges">Oranges</ion-select-option>
7+
<ion-select-option value="bananas">Bananas</ion-select-option>
8+
</ion-select>
9+
</ion-item>
10+
</ion-list>
11+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```tsx
2+
import React from 'react';
3+
import { IonList, IonItem, IonSelect, IonSelectOption } from '@ionic/react';
4+
function Example() {
5+
return (
6+
<IonList>
7+
<IonItem>
8+
<IonSelect aria-label="Fruit" interface="modal" placeholder="Select fruit">
9+
<IonSelectOption value="apples">Apples</IonSelectOption>
10+
<IonSelectOption value="oranges">Oranges</IonSelectOption>
11+
<IonSelectOption value="bananas">Bananas</IonSelectOption>
12+
</IonSelect>
13+
</IonItem>
14+
</IonList>
15+
);
16+
}
17+
export default Example;
18+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```html
2+
<template>
3+
<ion-list>
4+
<ion-item>
5+
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit">
6+
<ion-select-option value="apples">Apples</ion-select-option>
7+
<ion-select-option value="oranges">Oranges</ion-select-option>
8+
<ion-select-option value="bananas">Bananas</ion-select-option>
9+
</ion-select>
10+
</ion-item>
11+
</ion-list>
12+
</template>
13+
14+
<script>
15+
import { IonList, IonItem, IonSelect, IonSelectOption } from '@ionic/vue';
16+
import { defineComponent } from 'vue';
17+
18+
export default defineComponent({
19+
components: { IonList, IonItem, IonSelect, IonSelectOption },
20+
});
21+
</script>
22+
```

0 commit comments

Comments
 (0)