diff --git a/docs/api/textarea.md b/docs/api/textarea.md index 0ca8898a18b..5e34e78a72a 100644 --- a/docs/api/textarea.md +++ b/docs/api/textarea.md @@ -123,7 +123,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/textarea/start-end-slots/index.md'; +import StartEndSlots from '@site/static/usage/v8/textarea/start-end-slots/index.md'; diff --git a/static/usage/v7/textarea/start-end-slots/angular.md b/static/usage/v7/textarea/start-end-slots/angular/example_component_html.md similarity index 100% rename from static/usage/v7/textarea/start-end-slots/angular.md rename to static/usage/v7/textarea/start-end-slots/angular/example_component_html.md diff --git a/static/usage/v7/textarea/start-end-slots/angular/example_component_ts.md b/static/usage/v7/textarea/start-end-slots/angular/example_component_ts.md new file mode 100644 index 00000000000..899f7a826a3 --- /dev/null +++ b/static/usage/v7/textarea/start-end-slots/angular/example_component_ts.md @@ -0,0 +1,22 @@ +```ts +import { Component } from '@angular/core'; + +import { addIcons } from 'ionicons'; +import { eye, lockClosed } 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, lockClosed }); + } +} +``` diff --git a/static/usage/v7/textarea/start-end-slots/demo.html b/static/usage/v7/textarea/start-end-slots/demo.html index cab3d77636d..7bef1042da2 100644 --- a/static/usage/v7/textarea/start-end-slots/demo.html +++ b/static/usage/v7/textarea/start-end-slots/demo.html @@ -4,8 +4,8 @@ Textarea - - + + diff --git a/static/usage/v7/textarea/start-end-slots/index.md b/static/usage/v7/textarea/start-end-slots/index.md index d84b6df8c0f..3c38ebe27cb 100644 --- a/static/usage/v7/textarea/start-end-slots/index.md +++ b/static/usage/v7/textarea/start-end-slots/index.md @@ -1,17 +1,37 @@ 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'; diff --git a/static/usage/v7/textarea/start-end-slots/javascript.md b/static/usage/v7/textarea/start-end-slots/javascript/index_html.md similarity index 100% rename from static/usage/v7/textarea/start-end-slots/javascript.md rename to static/usage/v7/textarea/start-end-slots/javascript/index_html.md diff --git a/static/usage/v7/textarea/start-end-slots/javascript/index_ts.md b/static/usage/v7/textarea/start-end-slots/javascript/index_ts.md new file mode 100644 index 00000000000..dadf539a88f --- /dev/null +++ b/static/usage/v7/textarea/start-end-slots/javascript/index_ts.md @@ -0,0 +1,35 @@ +```ts +import { defineCustomElements } from '@ionic/core/loader'; + +import { addIcons } from 'ionicons'; +import { eye, lockClosed } 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, 'lock-closed': lockClosed }); + */ +addIcons({ eye, lockClosed }); + +defineCustomElements(); +``` diff --git a/static/usage/v8/textarea/start-end-slots/angular/example_component_html.md b/static/usage/v8/textarea/start-end-slots/angular/example_component_html.md new file mode 100644 index 00000000000..ce0988fefec --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/angular/example_component_html.md @@ -0,0 +1,12 @@ +```html + + + + + + + + + + +``` diff --git a/static/usage/v8/textarea/start-end-slots/angular/example_component_ts.md b/static/usage/v8/textarea/start-end-slots/angular/example_component_ts.md new file mode 100644 index 00000000000..899f7a826a3 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/angular/example_component_ts.md @@ -0,0 +1,22 @@ +```ts +import { Component } from '@angular/core'; + +import { addIcons } from 'ionicons'; +import { eye, lockClosed } 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, lockClosed }); + } +} +``` diff --git a/static/usage/v8/textarea/start-end-slots/demo.html b/static/usage/v8/textarea/start-end-slots/demo.html new file mode 100644 index 00000000000..6020ec56cf8 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/demo.html @@ -0,0 +1,31 @@ + + + + + + Textarea + + + + + + + + + +
+ + + + + + + + + + +
+
+
+ + diff --git a/static/usage/v8/textarea/start-end-slots/index.md b/static/usage/v8/textarea/start-end-slots/index.md new file mode 100644 index 00000000000..642afb631b6 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/index.md @@ -0,0 +1,37 @@ +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'; + + diff --git a/static/usage/v8/textarea/start-end-slots/javascript/index_html.md b/static/usage/v8/textarea/start-end-slots/javascript/index_html.md new file mode 100644 index 00000000000..a666863d413 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/javascript/index_html.md @@ -0,0 +1,12 @@ +```html + + + + + + + + + + +``` diff --git a/static/usage/v8/textarea/start-end-slots/javascript/index_ts.md b/static/usage/v8/textarea/start-end-slots/javascript/index_ts.md new file mode 100644 index 00000000000..6c69dc0bbc0 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/javascript/index_ts.md @@ -0,0 +1,46 @@ +```ts +import { defineCustomElements } from '@ionic/core/loader'; + +import { addIcons } from 'ionicons'; +import { eye, lockClosed } 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, 'lock-closed': lockClosed }); + */ +addIcons({ eye, lockClosed }); + +defineCustomElements(); +``` diff --git a/static/usage/v8/textarea/start-end-slots/react.md b/static/usage/v8/textarea/start-end-slots/react.md new file mode 100644 index 00000000000..469f6bd8f84 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/react.md @@ -0,0 +1,21 @@ +```tsx +import React from 'react'; +import { IonButton, IonIcon, IonItem, IonList, IonTextarea } from '@ionic/react'; +import { eye, lockClosed } from 'ionicons/icons'; + +function Example() { + return ( + + + + + + + + + + + ); +} +export default Example; +``` diff --git a/static/usage/v8/textarea/start-end-slots/vue.md b/static/usage/v8/textarea/start-end-slots/vue.md new file mode 100644 index 00000000000..629240c1456 --- /dev/null +++ b/static/usage/v8/textarea/start-end-slots/vue.md @@ -0,0 +1,33 @@ +```html + + + +``` diff --git a/versioned_docs/version-v7/api/textarea.md b/versioned_docs/version-v7/api/textarea.md index bb1f80ba681..aca893c93c1 100644 --- a/versioned_docs/version-v7/api/textarea.md +++ b/versioned_docs/version-v7/api/textarea.md @@ -113,6 +113,22 @@ import ClearOnEditPlayground from '@site/static/usage/v7/textarea/clear-on-edit/ +## Start and End Slots (experimental) + +The `start` and `end` slots can be used to place icons, buttons, or prefix/suffix text on either side of the textarea. + +Note that this feature is considered experimental because it relies on a simulated version of [Web Component slots](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots). As a result, the simulated behavior may not exactly match the native slot behavior. + +:::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/textarea/start-end-slots/index.md'; + + + ## Migrating from Legacy Textarea Syntax A simpler textarea syntax was introduced in Ionic 7.0. This new syntax reduces the boilerplate required to setup an textarea, resolves accessibility issues, and improves the developer experience.