Repository navigation
docs(input-otp): document helper and error text, input labels, and fo… #4809
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
Open
ShaneK
wants to merge
1
commit into
feature-9.1
Choose a base branch
from
FW-7910
base: feature-9.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
static/usage/v9/input-otp/helper-error/angular/example_component_html.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ```html | ||
| <ion-input-otp | ||
| type="text" | ||
| inputmode="numeric" | ||
| helperText="Enter the code sent to your email" | ||
| errorText="Enter all 4 digits" | ||
| ngModel | ||
| required | ||
| minlength="4" | ||
| ></ion-input-otp> | ||
| ``` |
13 changes: 13 additions & 0 deletions
13
static/usage/v9/input-otp/helper-error/angular/example_component_ts.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ```ts | ||
| import { Component } from '@angular/core'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { IonInputOtp } from '@ionic/angular'; | ||
|
|
||
| @Component({ | ||
| selector: 'app-example', | ||
| templateUrl: 'example.component.html', | ||
| styleUrls: ['example.component.css'], | ||
| imports: [IonInputOtp, FormsModule], | ||
| }) | ||
| export class ExampleComponent {} | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Input OTP</title> | ||
| <link rel="stylesheet" href="../../common.css" /> | ||
| <script src="../../common.js"></script> | ||
| <script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@9/dist/ionic/ionic.esm.js"></script> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@9/css/ionic.bundle.css" /> | ||
| </head> | ||
|
|
||
| <body> | ||
| <ion-app> | ||
| <ion-content> | ||
| <div class="container"> | ||
| <ion-input-otp | ||
| helper-text="Enter the code sent to your email" | ||
| error-text="Enter all 4 digits" | ||
| ></ion-input-otp> | ||
| </div> | ||
| </ion-content> | ||
| </ion-app> | ||
|
|
||
| <script> | ||
| const inputOtp = document.querySelector('ion-input-otp'); | ||
|
|
||
| inputOtp.addEventListener('ionInput', (event) => validate(event)); | ||
| inputOtp.addEventListener('ionBlur', () => markTouched()); | ||
|
|
||
| const validate = (event) => { | ||
| const value = event.detail.value ?? ''; | ||
|
|
||
| inputOtp.classList.remove('ion-valid'); | ||
| inputOtp.classList.remove('ion-invalid'); | ||
|
|
||
| value.length === 4 ? inputOtp.classList.add('ion-valid') : inputOtp.classList.add('ion-invalid'); | ||
| }; | ||
|
|
||
| const markTouched = () => { | ||
| inputOtp.classList.add('ion-touched'); | ||
| }; | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| 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_example_component_html from './angular/example_component_html.md'; | ||
| import angular_example_component_ts from './angular/example_component_ts.md'; | ||
|
|
||
| <Playground | ||
| version="9" | ||
| code={{ | ||
| javascript, | ||
| react, | ||
| vue, | ||
| angular: { | ||
| files: { | ||
| 'src/app/example.component.html': angular_example_component_html, | ||
| 'src/app/example.component.ts': angular_example_component_ts, | ||
| }, | ||
| }, | ||
| }} | ||
| src="usage/v9/input-otp/helper-error/demo.html" | ||
| size="200px" | ||
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ```html | ||
| <ion-input-otp helper-text="Enter the code sent to your email" error-text="Enter all 4 digits"></ion-input-otp> | ||
|
|
||
| <script> | ||
| const inputOtp = document.querySelector('ion-input-otp'); | ||
|
|
||
| inputOtp.addEventListener('ionInput', (event) => validate(event)); | ||
| inputOtp.addEventListener('ionBlur', () => markTouched()); | ||
|
|
||
| const validate = (event) => { | ||
| const value = event.detail.value ?? ''; | ||
|
|
||
| inputOtp.classList.remove('ion-valid'); | ||
| inputOtp.classList.remove('ion-invalid'); | ||
|
|
||
| value.length === 4 ? inputOtp.classList.add('ion-valid') : inputOtp.classList.add('ion-invalid'); | ||
| }; | ||
|
|
||
| const markTouched = () => { | ||
| inputOtp.classList.add('ion-touched'); | ||
| }; | ||
| </script> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| ```tsx | ||
| import React, { useState } from 'react'; | ||
| import { IonInputOtp } from '@ionic/react'; | ||
|
|
||
| function Example() { | ||
| const [isTouched, setIsTouched] = useState(false); | ||
| const [isValid, setIsValid] = useState<boolean>(); | ||
|
|
||
| const validate = (value: string) => { | ||
| setIsValid(value.length === 4); | ||
| }; | ||
|
|
||
| const markTouched = () => { | ||
| setIsTouched(true); | ||
| }; | ||
|
|
||
| return ( | ||
| <IonInputOtp | ||
| className={`${isValid && 'ion-valid'} ${isValid === false && 'ion-invalid'} ${isTouched && 'ion-touched'}`} | ||
| helperText="Enter the code sent to your email" | ||
| errorText="Enter all 4 digits" | ||
| onIonInput={(event) => validate(event.detail.value ?? '')} | ||
| onIonBlur={() => markTouched()} | ||
| ></IonInputOtp> | ||
| ); | ||
| } | ||
| export default Example; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ```html | ||
| <template> | ||
| <ion-input-otp | ||
| ref="inputOtp" | ||
| helper-text="Enter the code sent to your email" | ||
| error-text="Enter all 4 digits" | ||
| @ionInput="validate" | ||
| @ionBlur="markTouched" | ||
| ></ion-input-otp> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { IonInputOtp } from '@ionic/vue'; | ||
| import { ref } from 'vue'; | ||
|
|
||
| const inputOtp = ref(); | ||
|
|
||
| const validate = (event) => { | ||
| const value = event.detail.value ?? ''; | ||
|
|
||
| inputOtp.value.$el.classList.remove('ion-valid'); | ||
| inputOtp.value.$el.classList.remove('ion-invalid'); | ||
|
|
||
| value.length === 4 | ||
| ? inputOtp.value.$el.classList.add('ion-valid') | ||
| : inputOtp.value.$el.classList.add('ion-invalid'); | ||
| }; | ||
|
|
||
| const markTouched = () => { | ||
| inputOtp.value.$el.classList.add('ion-touched'); | ||
| }; | ||
| </script> | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.