-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(toggle): add helperText and errorText section #4033
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
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
def00f6
docs(toggle): add helperText and errorText section
thetaPC 74feb87
chore(toggle): run lint
thetaPC b741840
chore(toggle): use dev build
thetaPC 927c64f
Update static/usage/v8/toggle/helper-error/demo.html
thetaPC 1510b82
Update static/usage/v8/toggle/helper-error/javascript.md
thetaPC 1842e6e
Update static/usage/v8/toggle/helper-error/react.md
thetaPC ec266be
Update static/usage/v8/toggle/helper-error/vue.md
thetaPC 46dbaef
Update static/usage/v8/toggle/helper-error/angular/example_component_…
thetaPC 1db35be
Update static/usage/v8/toggle/helper-error/angular/example_component_…
thetaPC e36e941
chore(toggle): run lint
thetaPC 517c08c
fix(toggle): use correct label text
thetaPC 5f40e6d
chore(toggle): remove dev build
thetaPC 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
Update static/usage/v8/toggle/helper-error/vue.md
Co-authored-by: Brandy Smith <brandyscarney@users.noreply.github.com>
- Loading branch information
commit ec266bef6bc6053263778839257cb328d9873e05
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,47 @@ | ||
| ```html | ||
| <template> | ||
| <form @submit.prevent="submit"> | ||
| <ion-toggle | ||
| v-model="wifi" | ||
| helper-text="This needs to be enabled" | ||
| error-text="This field is required" | ||
| @ionChange="validateToggle" | ||
| :class="{ 'ion-valid': isValid, 'ion-invalid': isValid === false, 'ion-touched': isTouched }" | ||
| > | ||
| Wi-Fi | ||
| </ion-toggle> | ||
|
|
||
| <br /> | ||
|
|
||
| <ion-button type="submit" size="small">Submit</ion-button> | ||
| </form> | ||
| <ion-toggle | ||
| v-model="wifi" | ||
| helper-text="Enable to connect to available networks" | ||
| error-text="Must be enabled to access the internet" | ||
| justify="space-between" | ||
| @ionChange="validateToggle" | ||
| :class="{ | ||
| 'ion-valid': isValid, | ||
| 'ion-invalid': isValid === false, | ||
| 'ion-touched': isTouched, | ||
| }" | ||
| > | ||
| Wi-Fi | ||
| </ion-toggle> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import { defineComponent, ref } from 'vue'; | ||
| import { IonToggle, IonButton, ToggleCustomEvent } from '@ionic/vue'; | ||
|
|
||
| export default defineComponent({ | ||
| components: { | ||
| IonToggle, | ||
| IonButton, | ||
| }, | ||
| setup() { | ||
| const wifi = ref(false); | ||
| const isTouched = ref(false); | ||
| const isValid = ref<boolean | undefined>(); | ||
| import { defineComponent, ref } from 'vue'; | ||
| import { IonToggle, IonButton, ToggleCustomEvent } from '@ionic/vue'; | ||
|
|
||
| const validateToggle = (event: ToggleCustomEvent<{ checked: boolean }>) => { | ||
| isTouched.value = true; | ||
| isValid.value = event.detail.checked; | ||
| }; | ||
| export default defineComponent({ | ||
| components: { | ||
| IonToggle, | ||
| IonButton, | ||
| }, | ||
| setup() { | ||
| const wifi = ref(true); | ||
| const isTouched = ref(false); | ||
| const isValid = ref<boolean | undefined>(); | ||
|
|
||
| const submit = () => { | ||
| validateToggle({ detail: { checked: wifi.value } } as ToggleCustomEvent<{ checked: boolean }>); | ||
| }; | ||
| const validateToggle = (event: ToggleCustomEvent<{ checked: boolean }>) => { | ||
| isTouched.value = true; | ||
| isValid.value = event.detail.checked; | ||
| }; | ||
|
|
||
| return { | ||
| wifi, | ||
| isTouched, | ||
| isValid, | ||
| validateToggle, | ||
| submit, | ||
| }; | ||
| }, | ||
| }); | ||
| return { | ||
| wifi, | ||
| isTouched, | ||
| isValid, | ||
| validateToggle, | ||
| }; | ||
| }, | ||
| }); | ||
| </script> | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.