-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(input): add label slot #27633
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
feat(input): add label slot #27633
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f83994
feat(input): add base label slot implementation
liamdebeasi 514b677
test(input): update tests
liamdebeasi de1f128
chore(): add updated snapshots
Ionitron 1f867f2
test(input): add spec and a11y tests
liamdebeasi 5618a55
note feature is experimental
liamdebeasi 0db41b3
fix slot documentation
liamdebeasi 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
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
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
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 |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| <main> | ||
| <h1>Input - a11y</h1> | ||
|
|
||
| <ion-input><div slot="label">Slotted Label</div></ion-input><br /> | ||
| <ion-input label="my label"></ion-input><br /> | ||
| <ion-input aria-label="my aria label"></ion-input><br /> | ||
| <ion-input label="Email" label-placement="stacked" value="[email protected]"></ion-input><br /> | ||
|
|
||
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
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 |
|---|---|---|
|
|
@@ -14,17 +14,6 @@ configs().forEach(({ title, screenshot, config }) => { | |
| const input = page.locator('ion-input'); | ||
| expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-placement-start`)); | ||
| }); | ||
|
|
||
| test('long label should truncate', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <ion-input label="Email Email Email Email Email Email Email Email Email Email Email Email" value="[email protected]" label-placement="start"></ion-input> | ||
| `, | ||
| config | ||
| ); | ||
| const input = page.locator('ion-input'); | ||
| expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-placement-start-long-label`)); | ||
| }); | ||
| }); | ||
| test.describe(title('input: label placement end'), () => { | ||
| test('label should appear on the ending side of the input', async ({ page }) => { | ||
|
|
@@ -38,16 +27,6 @@ configs().forEach(({ title, screenshot, config }) => { | |
| const input = page.locator('ion-input'); | ||
| expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-placement-end`)); | ||
| }); | ||
| test('long label should truncate', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <ion-input label="Email Email Email Email Email Email Email Email Email Email Email Email" value="[email protected]" label-placement="end"></ion-input> | ||
| `, | ||
| config | ||
| ); | ||
| const input = page.locator('ion-input'); | ||
| expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-placement-end-long-label`)); | ||
| }); | ||
| }); | ||
| test.describe(title('input: label placement fixed'), () => { | ||
| test('label should appear on the starting side of the input, have a fixed width, and show ellipses', async ({ | ||
|
|
@@ -179,3 +158,32 @@ configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => { | |
| }); | ||
| }); | ||
| }); | ||
|
|
||
| configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
| test.describe(title('input: label overflow'), () => { | ||
| test('label property should be truncated with ellipses', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <ion-input label="Label Label Label Label Label" placeholder="Text Input"></ion-input> | ||
| `, | ||
| config | ||
| ); | ||
|
|
||
| const input = page.locator('ion-input'); | ||
| expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-label-truncate`)); | ||
| }); | ||
| test('label slot should be truncated with ellipses', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <ion-input placeholder="Text Input"> | ||
| <div slot="label">Label Label Label Label Label</div> | ||
| </ion-input> | ||
| `, | ||
| config | ||
| ); | ||
|
|
||
| const input = page.locator('ion-input'); | ||
| expect(await input.screenshot()).toMatchSnapshot(screenshot(`input-label-slot-truncate`)); | ||
| }); | ||
| }); | ||
| }); | ||
Binary file added
BIN
+7.38 KB
...input.e2e.ts-snapshots/input-label-slot-truncate-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.52 KB
...nput.e2e.ts-snapshots/input-label-slot-truncate-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.03 KB
...input.e2e.ts-snapshots/input-label-slot-truncate-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.38 KB
...ment/input.e2e.ts-snapshots/input-label-truncate-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.52 KB
...ent/input.e2e.ts-snapshots/input-label-truncate-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.03 KB
...ment/input.e2e.ts-snapshots/input-label-truncate-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-9.52 KB
...e2e.ts-snapshots/input-placement-end-long-label-ios-ltr-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-4.26 KB
...2e.ts-snapshots/input-placement-end-long-label-ios-ltr-Mobile-Firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-8.92 KB
...e2e.ts-snapshots/input-placement-end-long-label-ios-ltr-Mobile-Safari-linux.png
Binary file not shown.
Binary file removed
BIN
-9.47 KB
...e2e.ts-snapshots/input-placement-end-long-label-ios-rtl-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-4.3 KB
...2e.ts-snapshots/input-placement-end-long-label-ios-rtl-Mobile-Firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-8.87 KB
...e2e.ts-snapshots/input-placement-end-long-label-ios-rtl-Mobile-Safari-linux.png
Binary file not shown.
Binary file removed
BIN
-9.71 KB
....e2e.ts-snapshots/input-placement-end-long-label-md-ltr-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-4.14 KB
...e2e.ts-snapshots/input-placement-end-long-label-md-ltr-Mobile-Firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-9.08 KB
....e2e.ts-snapshots/input-placement-end-long-label-md-ltr-Mobile-Safari-linux.png
Binary file not shown.
Binary file removed
BIN
-9.66 KB
....e2e.ts-snapshots/input-placement-end-long-label-md-rtl-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-3.95 KB
...e2e.ts-snapshots/input-placement-end-long-label-md-rtl-Mobile-Firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-9.02 KB
....e2e.ts-snapshots/input-placement-end-long-label-md-rtl-Mobile-Safari-linux.png
Binary file not shown.
Binary file removed
BIN
-9.48 KB
...e.ts-snapshots/input-placement-start-long-label-ios-ltr-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-4.27 KB
....ts-snapshots/input-placement-start-long-label-ios-ltr-Mobile-Firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-8.9 KB
...e.ts-snapshots/input-placement-start-long-label-ios-ltr-Mobile-Safari-linux.png
Binary file not shown.
Binary file removed
BIN
-9.45 KB
...e.ts-snapshots/input-placement-start-long-label-ios-rtl-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-4.24 KB
....ts-snapshots/input-placement-start-long-label-ios-rtl-Mobile-Firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-8.91 KB
...e.ts-snapshots/input-placement-start-long-label-ios-rtl-Mobile-Safari-linux.png
Binary file not shown.
Binary file removed
BIN
-9.68 KB
...2e.ts-snapshots/input-placement-start-long-label-md-ltr-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-4.13 KB
...e.ts-snapshots/input-placement-start-long-label-md-ltr-Mobile-Firefox-linux.png
Diff not rendered.
Binary file removed
BIN
-9.08 KB
...2e.ts-snapshots/input-placement-start-long-label-md-ltr-Mobile-Safari-linux.png
Diff not rendered.
Binary file removed
BIN
-9.7 KB
...2e.ts-snapshots/input-placement-start-long-label-md-rtl-Mobile-Chrome-linux.png
Diff not rendered.
Binary file removed
BIN
-3.97 KB
...e.ts-snapshots/input-placement-start-long-label-md-rtl-Mobile-Firefox-linux.png
Diff not rendered.
Binary file removed
BIN
-9.07 KB
...2e.ts-snapshots/input-placement-start-long-label-md-rtl-Mobile-Safari-linux.png
Diff not rendered.
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,98 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" dir="ltr"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>Input - Slot</title> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" | ||
| /> | ||
| <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" /> | ||
| <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" /> | ||
| <script src="../../../../../scripts/testing/scripts.js"></script> | ||
| <script nomodule src="../../../../../dist/ionic/ionic.js"></script> | ||
| <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script> | ||
| <style> | ||
| .grid { | ||
| display: grid; | ||
| grid-template-columns: repeat(3, minmax(250px, 1fr)); | ||
| grid-row-gap: 20px; | ||
| grid-column-gap: 20px; | ||
| } | ||
| h2 { | ||
| font-size: 12px; | ||
| font-weight: normal; | ||
|
|
||
| color: #6f7378; | ||
|
|
||
| margin-top: 10px; | ||
| } | ||
| @media screen and (max-width: 800px) { | ||
| .grid { | ||
| grid-template-columns: 1fr; | ||
| padding: 0; | ||
| } | ||
| } | ||
|
|
||
| .required { | ||
| color: red; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <ion-app> | ||
| <ion-header> | ||
| <ion-toolbar> | ||
| <ion-title>Input - Slot</ion-title> | ||
| </ion-toolbar> | ||
| </ion-header> | ||
|
|
||
| <ion-content id="content" class="ion-padding"> | ||
| <div class="grid"> | ||
| <div class="grid-item"> | ||
| <h2>No Fill / Start</h2> | ||
| <ion-input label-placement="start" value="[email protected]"> | ||
| <div slot="label">Email <span class="required">*</span></div> | ||
| </ion-input> | ||
| </div> | ||
|
|
||
| <div class="grid-item"> | ||
| <h2>Solid / Start</h2> | ||
| <ion-input label-placement="start" fill="solid" value="[email protected]"> | ||
| <div slot="label">Email <span class="required">*</span></div> | ||
| </ion-input> | ||
| </div> | ||
|
|
||
| <div class="grid-item"> | ||
| <h2>Outline / Start</h2> | ||
| <ion-input label-placement="start" fill="outline" value="[email protected]"> | ||
| <div slot="label">Email <span class="required">*</span></div> | ||
| </ion-input> | ||
| </div> | ||
|
|
||
| <div class="grid-item"> | ||
| <h2>No Fill / Floating</h2> | ||
| <ion-input label-placement="floating" value="[email protected]"> | ||
| <div slot="label">Email <span class="required">*</span></div> | ||
| </ion-input> | ||
| </div> | ||
|
|
||
| <div class="grid-item"> | ||
| <h2>Solid / Floating</h2> | ||
| <ion-input label-placement="floating" fill="solid" value="[email protected]"> | ||
| <div slot="label">Email <span class="required">*</span></div> | ||
| </ion-input> | ||
| </div> | ||
|
|
||
| <div class="grid-item"> | ||
| <h2>Outline / Floating</h2> | ||
liamdebeasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <ion-input label-placement="floating" fill="outline" value="[email protected]"> | ||
| <div slot="label">Email <span class="required">*</span></div> | ||
| </ion-input> | ||
| </div> | ||
| </div> | ||
| </ion-content> | ||
| </ion-app> | ||
| </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
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.