-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(select): add modal
interface to ion-select
docs
#3872
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ import SingleSelectionExample from '@site/static/usage/v8/select/basic/single-se | |
|
||
## Multiple Selection | ||
|
||
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. | ||
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. | ||
|
||
:::note | ||
|
||
|
@@ -86,7 +86,7 @@ import MultipleSelectionExample from '@site/static/usage/v8/select/basic/multipl | |
|
||
## Interfaces | ||
|
||
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. | ||
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. | ||
|
||
### Alert | ||
|
||
|
@@ -107,6 +107,12 @@ import PopoverExample from '@site/static/usage/v8/select/interfaces/popover/inde | |
|
||
<PopoverExample /> | ||
|
||
### Modal | ||
|
||
import ModalExample from '@site/static/usage/v8/select/interfaces/modal/index.md'; | ||
|
||
<ModalExample /> | ||
|
||
## Responding to Interaction | ||
|
||
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 | |
|
||
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. | ||
|
||
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 | ||
after clicking this button or if the modal is dismissed using an alternative method. | ||
Comment on lines
+170
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't update the playground despite adding this section since the "close" button isn't customizable |
||
|
||
import ButtonTextExample from '@site/static/usage/v8/select/customization/button-text/index.md'; | ||
|
||
<ButtonTextExample /> | ||
|
||
## Interface Options | ||
|
||
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. | ||
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. | ||
|
||
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. | ||
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) | ||
for the properties that each interface accepts. | ||
|
||
Note: `interfaceOptions` will not override `inputs` or `buttons` with the `alert` interface. | ||
|
||
|
@@ -207,11 +217,13 @@ import StylingSelectExample from '@site/static/usage/v8/select/customization/sty | |
|
||
### Styling Select Interface | ||
|
||
Customizing the interface dialog should be done by following the Customization section in that interface's documentation: | ||
Customizing the interface dialog should be done by following the styling sections (CSS shadow parts, CSS custom properties, and slots) in | ||
that interface's documentation: | ||
|
||
- [Alert Customization](alert.md#customization) | ||
- [Action Sheet Customization](action-sheet.md#customization) | ||
- [Popover Customization](popover.md#customization) | ||
Comment on lines
-210
to
-214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These links didn't exist anymore, so tried to update this section to point users in the right direction |
||
- [Alert](alert.md#css-shadow-parts) | ||
- [Action Sheet](action-sheet.md#css-shadow-parts) | ||
- [Popover](popover.md#css-shadow-parts) | ||
- [Modal](modal.md#css-shadow-parts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Move this before Popover so it's alphabetic. |
||
|
||
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. | ||
|
||
|
@@ -304,7 +316,7 @@ These keyboard interactions apply to all `ion-select` elements when the followin | |
|
||
Single selection keyboard interaction follows the [ARIA implementation patterns of a radio](https://www.w3.org/WAI/ARIA/apg/patterns/radio/). | ||
|
||
These keyboard interactions apply to `ion-action-sheet`, `ion-alert`, and `ion-popover` elements when the overlay is presented and focused. | ||
These keyboard interactions apply to `ion-action-sheet`, `ion-alert`, `ion-popover`, and `ion-modal` elements when the overlay is presented and focused. | ||
|
||
| Key | Description | | ||
| --------------------- | ------------------------------------------------------------ | | ||
|
@@ -321,7 +333,7 @@ These keyboard interactions apply to `ion-action-sheet`, `ion-alert`, and `ion-p | |
|
||
Multiple selection keyboard interaction follows the [ARIA implementation patterns of a checkbox](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/). | ||
|
||
These keyboard interactions apply to `ion-alert` and `ion-popover` elements when the overlay is presented and multiple selection is enabled. | ||
These keyboard interactions apply to `ion-alert`, `ion-popover`, and `ion-modal` elements when the overlay is presented and multiple selection is enabled. | ||
|
||
| Key | Description | | ||
| ------------------ | ------------------------------------------------------------ | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,14 @@ | |
<ion-select-option value="blue">Blue</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
|
||
<ion-item> | ||
<ion-select label="Modal" id="customModalSelect" interface="modal" placeholder="Select One"> | ||
<ion-select-option value="reese's">Reese's</ion-select-option> | ||
<ion-select-option value="snickers">Snickers</ion-select-option> | ||
<ion-select-option value="twix">Twix</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
Comment on lines
+53
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Move this before Popover so it's alphabetic. |
||
</ion-list> | ||
</div> | ||
</ion-content> | ||
|
@@ -78,6 +86,14 @@ | |
subHeader: 'Select your favorite color', | ||
}; | ||
customActionSheetSelect.interfaceOptions = customActionSheetOptions; | ||
|
||
const customModalSelect = document.getElementById('customModalSelect'); | ||
const customModalOptions = { | ||
header: 'Favorite Candy', | ||
breakpoints: [0, 0.5], | ||
initialBreakpoint: 0.5, | ||
}; | ||
customModalSelect.interfaceOptions = customModalOptions; | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```html | ||
<ion-list> | ||
<ion-item> | ||
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit"> | ||
<ion-select-option value="apples">Apples</ion-select-option> | ||
<ion-select-option value="oranges">Oranges</ion-select-option> | ||
<ion-select-option value="bananas">Bananas</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-list> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Select - Modal</title> | ||
<link rel="stylesheet" href="../../../common.css" /> | ||
<script src="../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@8/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@8/css/ionic.bundle.css" /> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-list> | ||
<ion-item> | ||
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit"> | ||
<ion-select-option value="apples">Apples</ion-select-option> | ||
<ion-select-option value="oranges">Oranges</ion-select-option> | ||
<ion-select-option value="bananas">Bananas</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-list> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
import angular from './angular.md'; | ||
|
||
<Playground | ||
version="8" | ||
size="400px" | ||
code={{ javascript, react, vue, angular }} | ||
src="usage/v8/select/interfaces/modal/demo.html" | ||
/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```html | ||
<ion-list> | ||
<ion-item> | ||
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit"> | ||
<ion-select-option value="apples">Apples</ion-select-option> | ||
<ion-select-option value="oranges">Oranges</ion-select-option> | ||
<ion-select-option value="bananas">Bananas</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-list> | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
```tsx | ||
import React from 'react'; | ||
import { IonList, IonItem, IonSelect, IonSelectOption } from '@ionic/react'; | ||
function Example() { | ||
return ( | ||
<IonList> | ||
<IonItem> | ||
<IonSelect aria-label="Fruit" interface="modal" placeholder="Select fruit"> | ||
<IonSelectOption value="apples">Apples</IonSelectOption> | ||
<IonSelectOption value="oranges">Oranges</IonSelectOption> | ||
<IonSelectOption value="bananas">Bananas</IonSelectOption> | ||
</IonSelect> | ||
</IonItem> | ||
</IonList> | ||
); | ||
} | ||
export default Example; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
```html | ||
<template> | ||
<ion-list> | ||
<ion-item> | ||
<ion-select aria-label="Fruit" interface="modal" placeholder="Select fruit"> | ||
<ion-select-option value="apples">Apples</ion-select-option> | ||
<ion-select-option value="oranges">Oranges</ion-select-option> | ||
<ion-select-option value="bananas">Bananas</ion-select-option> | ||
</ion-select> | ||
</ion-item> | ||
</ion-list> | ||
</template> | ||
|
||
<script> | ||
import { IonList, IonItem, IonSelect, IonSelectOption } from '@ionic/vue'; | ||
import { defineComponent } from 'vue'; | ||
|
||
export default defineComponent({ | ||
components: { IonList, IonItem, IonSelect, IonSelectOption }, | ||
}); | ||
</script> | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Move this before Popover so it's alphabetic.