Skip to content

docs(select): update icon playgrounds to use addIcons usage #3752

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

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ In most cases, [Icon](./icon.md) components placed in these slots should have `a
If slot content is meant to be interacted with, it should be wrapped in an interactive element such as a [Button](./button.md). This ensures that the content can be tabbed to.
:::

import StartEndSlots from '@site/static/usage/v7/select/start-end-slots/index.md';
import StartEndSlots from '@site/static/usage/v8/select/start-end-slots/index.md';

<StartEndSlots />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```ts
import { Component } from '@angular/core';

import { addIcons } from 'ionicons';
import { eye, leaf } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
})
export class ExampleComponent {
constructor() {
/**
* Any icons you want to use in your application
* can be registered in app.component.ts and then
* referenced by name anywhere in your application.
*/
addIcons({ eye, leaf });
}
}
```
10 changes: 8 additions & 2 deletions static/usage/v7/select/start-end-slots/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Select</title>
<link rel="stylesheet" href="../../../common.css" />
<script src="../../../common.js"></script>
<link rel="stylesheet" href="../../common.css" />
<script src="../../common.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/ionic.esm.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@7/css/ionic.bundle.css" />

<style>
ion-list {
width: 300px;
}
</style>
</head>

<body>
Expand Down
30 changes: 25 additions & 5 deletions static/usage/v7/select/start-end-slots/index.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
import Playground from '@site/src/components/global/Playground';

import javascript from './javascript.md';
import javascript_index_html from './javascript/index_html.md';
import javascript_index_ts from './javascript/index_ts.md';

import react from './react.md';
import vue from './vue.md';
import angular from './angular.md';

import angular_example_component_html from './angular/example_component_html.md';
import angular_example_component_ts from './angular/example_component_ts.md';

<Playground
version="7"
code={{
javascript,
javascript: {
files: {
'index.html': javascript_index_html,
'index.ts': javascript_index_ts,
},
dependencies: {
ionicons: '7.4.0',
},
},
react,
vue,
angular,
angular: {
files: {
'src/app/example.component.html': angular_example_component_html,
'src/app/example.component.ts': angular_example_component_ts,
},
dependencies: {
ionicons: '7.4.0',
},
},
}}
src="usage/v7/select/start-end-slots/demo.html"
size="300px"
src="usage/v7/select/start-end-slots/demo.html"
/>
35 changes: 35 additions & 0 deletions static/usage/v7/select/start-end-slots/javascript/index_ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```ts
import { defineCustomElements } from '@ionic/core/loader';

import { addIcons } from 'ionicons';
import { eye, leaf } from 'ionicons/icons';

/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css';
import '@ionic/core/css/structure.css';
import '@ionic/core/css/typography.css';

/* Optional CSS utils that can be commented out */
import '@ionic/core/css/padding.css';
import '@ionic/core/css/float-elements.css';
import '@ionic/core/css/text-alignment.css';
import '@ionic/core/css/text-transformation.css';
import '@ionic/core/css/flex-utils.css';
import '@ionic/core/css/display.css';

/* Theme variables */
import './theme/variables.css';

/**
* On Ionicons 7.2+ these icons
* get mapped to a kebab-case key.
* Alternatively, developers can do:
* addIcons({ 'eye': eye, 'leaf': leaf });
*/
addIcons({ eye, leaf });

defineCustomElements();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```html
<ion-list>
<ion-item>
<ion-select labelPlacement="stacked" label="Favorite fruit" value="apple">
<ion-icon slot="start" name="leaf" aria-hidden="true"></ion-icon>
<ion-select-option value="apple">Apple</ion-select-option>
<ion-select-option value="banana">Banana</ion-select-option>
<ion-select-option value="orange">Orange</ion-select-option>
<ion-button fill="clear" slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="eye" aria-hidden="true"></ion-icon>
</ion-button>
</ion-select>
</ion-item>
</ion-list>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```ts
import { Component } from '@angular/core';

import { addIcons } from 'ionicons';
import { eye, leaf } from 'ionicons/icons';

@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
})
export class ExampleComponent {
constructor() {
/**
* Any icons you want to use in your application
* can be registered in app.component.ts and then
* referenced by name anywhere in your application.
*/
addIcons({ eye, leaf });
}
}
```
40 changes: 40 additions & 0 deletions static/usage/v8/select/start-end-slots/demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Select</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" />

<style>
ion-list {
width: 300px;
}
</style>
</head>

<body>
<ion-app>
<ion-content>
<div class="container">
<ion-list>
<ion-item>
<ion-select label-placement="stacked" label="Favorite fruit" value="apple">
<ion-icon slot="start" name="leaf" aria-hidden="true"></ion-icon>
<ion-select-option value="apple">Apple</ion-select-option>
<ion-select-option value="banana">Banana</ion-select-option>
<ion-select-option value="orange">Orange</ion-select-option>
<ion-button fill="clear" slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="eye" aria-hidden="true"></ion-icon>
</ion-button>
</ion-select>
</ion-item>
</ion-list>
</div>
</ion-content>
</ion-app>
</body>
</html>
38 changes: 38 additions & 0 deletions static/usage/v8/select/start-end-slots/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Playground from '@site/src/components/global/Playground';

import javascript_index_html from './javascript/index_html.md';
import javascript_index_ts from './javascript/index_ts.md';

import react from './react.md';
import vue from './vue.md';

import angular_example_component_html from './angular/example_component_html.md';
import angular_example_component_ts from './angular/example_component_ts.md';

<Playground
version="8"
code={{
javascript: {
files: {
'index.html': javascript_index_html,
'index.ts': javascript_index_ts,
},
dependencies: {
ionicons: '7.4.0',
},
},
react,
vue,
angular: {
files: {
'src/app/example.component.html': angular_example_component_html,
'src/app/example.component.ts': angular_example_component_ts,
},
dependencies: {
ionicons: '7.4.0',
},
},
}}
size="300px"
src="usage/v8/select/start-end-slots/demo.html"
/>
15 changes: 15 additions & 0 deletions static/usage/v8/select/start-end-slots/javascript/index_html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```html
<ion-list>
<ion-item>
<ion-select label-placement="stacked" label="Favorite fruit" value="apple">
<ion-icon slot="start" name="leaf" aria-hidden="true"></ion-icon>
<ion-select-option value="apple">Apple</ion-select-option>
<ion-select-option value="banana">Banana</ion-select-option>
<ion-select-option value="orange">Orange</ion-select-option>
<ion-button fill="clear" slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="eye" aria-hidden="true"></ion-icon>
</ion-button>
</ion-select>
</ion-item>
</ion-list>
```
46 changes: 46 additions & 0 deletions static/usage/v8/select/start-end-slots/javascript/index_ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
```ts
import { defineCustomElements } from '@ionic/core/loader';

import { addIcons } from 'ionicons';
import { eye, leaf } from 'ionicons/icons';

/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css';
import '@ionic/core/css/structure.css';
import '@ionic/core/css/typography.css';

/* Optional CSS utils that can be commented out */
import '@ionic/core/css/padding.css';
import '@ionic/core/css/float-elements.css';
import '@ionic/core/css/text-alignment.css';
import '@ionic/core/css/text-transformation.css';
import '@ionic/core/css/flex-utils.css';
import '@ionic/core/css/display.css';

/**
* Ionic Dark Theme
* -----------------------------------------------------
* For more information, please see:
* https://ionicframework.com/docs/theming/dark-mode
*/

// import '@ionic/core/css/palettes/dark.always.css';
// import '@ionic/core/css/palettes/dark.class.css';
import '@ionic/core/css/palettes/dark.system.css';

/* Theme variables */
import './theme/variables.css';

/**
* On Ionicons 7.2+ these icons
* get mapped to a kebab-case key.
* Alternatively, developers can do:
* addIcons({ 'eye': eye, 'leaf': leaf });
*/
addIcons({ eye, leaf });

defineCustomElements();
```
24 changes: 24 additions & 0 deletions static/usage/v8/select/start-end-slots/react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
```tsx
import React from 'react';
import { IonButton, IonIcon, IonItem, IonList, IonSelect, IonSelectOption } from '@ionic/react';
import { eye, leaf } from 'ionicons/icons';

function Example() {
return (
<IonList>
<IonItem>
<IonSelect labelPlacement="stacked" label="Favorite fruit" value="apple">
<IonIcon slot="start" icon={leaf} aria-hidden="true"></IonIcon>
<IonSelectOption value="apple">Apple</IonSelectOption>
<IonSelectOption value="banana">Banana</IonSelectOption>
<IonSelectOption value="orange">Orange</IonSelectOption>
<IonButton fill="clear" slot="end" aria-label="Show/hide password">
<IonIcon slot="icon-only" icon={eye} aria-hidden="true"></IonIcon>
</IonButton>
</IonSelect>
</IonItem>
</IonList>
);
}
export default Example;
```
37 changes: 37 additions & 0 deletions static/usage/v8/select/start-end-slots/vue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
```html
<template>
<ion-list>
<ion-item>
<ion-select label-placement="stacked" label="Favorite fruit" value="apple">
<ion-icon slot="start" :icon="leaf" aria-hidden="true"></ion-icon>
<ion-select-option value="apple">Apple</ion-select-option>
<ion-select-option value="banana">Banana</ion-select-option>
<ion-select-option value="orange">Orange</ion-select-option>
<ion-button fill="clear" slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" :icon="eye" aria-hidden="true"></ion-icon>
</ion-button>
</ion-select>
</ion-item>
</ion-list>
</template>

<script lang="ts">
import { IonButton, IonIcon, IonItem, IonList, IonSelect, IonSelectOption } from '@ionic/vue';
import { eye, leaf } from 'ionicons/icons';
import { defineComponent } from 'vue';

export default defineComponent({
components: {
IonButton,
IonIcon,
IonItem,
IonList,
IonSelect,
IonSelectOption,
},
setup() {
return { eye, leaf };
},
});
</script>
```
14 changes: 14 additions & 0 deletions versioned_docs/version-v7/api/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,20 @@ import InterfaceOptionsExample from '@site/static/usage/v7/select/customization/

<InterfaceOptionsExample />

## Start and End Slots

The `start` and `end` slots can be used to place icons, buttons, or prefix/suffix text on either side of the select. If the slot content is clicked, the select will not open.

:::note
In most cases, [Icon](./icon.md) components placed in these slots should have `aria-hidden="true"`. See the [Icon accessibility docs](https://ionicframework.com/docs/api/icon#accessibility) for more information.

If slot content is meant to be interacted with, it should be wrapped in an interactive element such as a [Button](./button.md). This ensures that the content can be tabbed to.
:::

import StartEndSlots from '@site/static/usage/v7/select/start-end-slots/index.md';

<StartEndSlots />

## Customization

There are two units that make up the Select component and each need to be styled separately. The `ion-select` element is represented on the view by the selected value(s), or placeholder if there is none, and dropdown icon. The interface, which is defined in the [Interfaces](#interfaces) section above, is the dialog that opens when clicking on the `ion-select`. The interface contains all of the options defined by adding `ion-select-option` elements. The following sections will go over the differences between styling these.
Expand Down