-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(picker-column): add styles, disabled and active states #28621
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions
1
core/src/components/picker-column-option/picker-column-option.ios.scss
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 @@ | ||
@import "./picker-column-option"; |
5 changes: 5 additions & 0 deletions
5
core/src/components/picker-column-option/picker-column-option.md.scss
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,5 @@ | ||
@import "./picker-column-option.scss"; | ||
|
||
:host(.option-active) button { | ||
color: current-color(base); | ||
} |
45 changes: 45 additions & 0 deletions
45
core/src/components/picker-column-option/picker-column-option.scss
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 @@ | ||
@import "../../themes/ionic.globals"; | ||
|
||
// Picker Column | ||
// -------------------------------------------------- | ||
|
||
button { | ||
@include padding(0); | ||
@include margin(0); | ||
|
||
width: 100%; | ||
|
||
height: 34px; | ||
|
||
border: 0px; | ||
|
||
outline: none; | ||
|
||
background: transparent; | ||
|
||
color: inherit; | ||
|
||
font-family: $font-family-base; | ||
|
||
font-size: inherit; | ||
|
||
line-height: 34px; | ||
|
||
text-align: inherit; | ||
|
||
text-overflow: ellipsis; | ||
|
||
white-space: nowrap; | ||
|
||
cursor: pointer; | ||
|
||
overflow: hidden; | ||
} | ||
|
||
:host(.option-disabled) { | ||
opacity: 0.4; | ||
} | ||
|
||
:host(.option-disabled) button { | ||
cursor: default; | ||
} |
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,9 +1,17 @@ | ||
import type { ComponentInterface } from '@stencil/core'; | ||
import { Component, Element, Host, Prop, State, Watch, h } from '@stencil/core'; | ||
import { inheritAttributes } from '@utils/helpers'; | ||
import { createColorClasses } from '@utils/theme'; | ||
|
||
import { getIonMode } from '../../global/ionic-global'; | ||
import type { Color } from '../../interface'; | ||
|
||
@Component({ | ||
tag: 'ion-picker-column-option', | ||
styleUrls: { | ||
ios: 'picker-column-option.ios.scss', | ||
md: 'picker-column-option.md.scss', | ||
}, | ||
shadow: true, | ||
}) | ||
export class PickerColumnOption implements ComponentInterface { | ||
|
@@ -29,6 +37,13 @@ export class PickerColumnOption implements ComponentInterface { | |
*/ | ||
@Prop() value?: any | null; | ||
|
||
/** | ||
* The color to use from your application's color palette. | ||
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. | ||
* For more information on colors, see [theming](/docs/theming/basics). | ||
*/ | ||
@Prop({ reflect: true }) color?: Color = 'primary'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is currently on the picker-column component but will be removed once picker-column-option is fully integrated. |
||
|
||
/** | ||
* The aria-label of the option has changed after the | ||
* first render and needs to be updated within the component. | ||
|
@@ -50,19 +65,17 @@ export class PickerColumnOption implements ComponentInterface { | |
} | ||
|
||
render() { | ||
const { value, disabled, ariaLabel } = this; | ||
const { color, value, disabled, ariaLabel } = this; | ||
const mode = getIonMode(this); | ||
|
||
return ( | ||
<Host> | ||
<button | ||
tabindex="-1" | ||
aria-label={ariaLabel} | ||
class={{ | ||
'picker-opt': true, | ||
'picker-opt-disabled': !!disabled, | ||
}} | ||
disabled={disabled} | ||
> | ||
<Host | ||
class={createColorClasses(color, { | ||
[mode]: true, | ||
['option-disabled']: disabled, | ||
liamdebeasi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
})} | ||
> | ||
<button tabindex="-1" aria-label={ariaLabel} disabled={disabled}> | ||
<slot>{value}</slot> | ||
</button> | ||
</Host> | ||
|
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
55 changes: 55 additions & 0 deletions
55
core/src/components/picker-column-option/test/basic/picker-column-option.e2e.ts
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,55 @@ | ||
import { expect } from '@playwright/test'; | ||
import { configs, test } from '@utils/test/playwright'; | ||
|
||
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
test.describe(title('picker-column-option: rendering'), () => { | ||
test('picker option should not have visual regressions', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-picker-column-option value="option">My Option</ion-picker-column-option> | ||
`, | ||
config | ||
); | ||
|
||
const option = page.locator('ion-picker-column-option'); | ||
|
||
await expect(option).toHaveScreenshot(screenshot('picker-column-option')); | ||
}); | ||
test('disabled picker option should not have visual regressions', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-picker-column-option disabled="true" value="option">My Option</ion-picker-column-option> | ||
`, | ||
config | ||
); | ||
|
||
const option = page.locator('ion-picker-column-option'); | ||
|
||
await expect(option).toHaveScreenshot(screenshot('disabled-picker-column-option')); | ||
}); | ||
test('active picker option should not have visual regressions', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-picker-column-option class="option-active" value="option">My Option</ion-picker-column-option> | ||
`, | ||
config | ||
); | ||
|
||
const option = page.locator('ion-picker-column-option'); | ||
|
||
await expect(option).toHaveScreenshot(screenshot('active-picker-column-option')); | ||
}); | ||
test('disabled active picker option should not have visual regressions', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-picker-column-option class="option-active" disabled="true" value="option">My Option</ion-picker-column-option> | ||
`, | ||
config | ||
); | ||
|
||
const option = page.locator('ion-picker-column-option'); | ||
|
||
await expect(option).toHaveScreenshot(screenshot('disabled-active-picker-column-option')); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+1.91 KB
...on.e2e.ts-snapshots/active-picker-column-option-ios-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
+1.87 KB
...n.e2e.ts-snapshots/active-picker-column-option-ios-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
+1.69 KB
...on.e2e.ts-snapshots/active-picker-column-option-ios-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
+1.5 KB
...ion.e2e.ts-snapshots/active-picker-column-option-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
+1.79 KB
...on.e2e.ts-snapshots/active-picker-column-option-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
+1.32 KB
...ion.e2e.ts-snapshots/active-picker-column-option-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
+1.66 KB
...-snapshots/disabled-active-picker-column-option-ios-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
+1.73 KB
...snapshots/disabled-active-picker-column-option-ios-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
+1.53 KB
...-snapshots/disabled-active-picker-column-option-ios-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
+1.33 KB
...s-snapshots/disabled-active-picker-column-option-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
+1.6 KB
...-snapshots/disabled-active-picker-column-option-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
+1.18 KB
...s-snapshots/disabled-active-picker-column-option-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
+1.66 KB
....e2e.ts-snapshots/disabled-picker-column-option-ios-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
+1.73 KB
...e2e.ts-snapshots/disabled-picker-column-option-ios-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
+1.53 KB
....e2e.ts-snapshots/disabled-picker-column-option-ios-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
+1.66 KB
...n.e2e.ts-snapshots/disabled-picker-column-option-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
+1.66 KB
....e2e.ts-snapshots/disabled-picker-column-option-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
+1.38 KB
...n.e2e.ts-snapshots/disabled-picker-column-option-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
+1.91 KB
...mn-option.e2e.ts-snapshots/picker-column-option-ios-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
+1.87 KB
...n-option.e2e.ts-snapshots/picker-column-option-ios-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
+1.69 KB
...mn-option.e2e.ts-snapshots/picker-column-option-ios-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
+1.86 KB
...umn-option.e2e.ts-snapshots/picker-column-option-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
+1.82 KB
...mn-option.e2e.ts-snapshots/picker-column-option-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
+1.52 KB
...umn-option.e2e.ts-snapshots/picker-column-option-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.
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
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.
Our existing components leave off the file extension with importing another SASS file.