-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(segment): add default styles for ionic theme #29897
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 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7f54581
feat(segment): initial checkin of ionic style separation
brandyscarney 6ef54a5
feat(segment): add ionic theme styles
brandyscarney 73184f5
chore: build and lint
brandyscarney 4145be4
fix(segment-button): use correct position for ios
brandyscarney bdb38be
fix(segment-button): move indicator over border
brandyscarney 72205f7
test(segment): add layout test
brandyscarney 1efbdc2
chore(): add updated snapshots
brandyscarney e453b78
refactor(segment-button): update documented css variables
brandyscarney 9a15c3c
test(segment): update to consistent test titles
brandyscarney ea89e58
fix(segment-button): ensure the indicator moves properly
brandyscarney 34a33be
fix(segment-button): design improvements
brandyscarney 2117e1e
chore(): add updated snapshots
brandyscarney b74d241
fix(segment-button): update minimum heights
brandyscarney 6234434
fix(segment-button): fixed height due to padding
brandyscarney c1e7e3e
fix(segment-button): use correct gap for horizontal layout
brandyscarney 4bb0099
fix(segment-button): set background to none
brandyscarney 45b708f
chore(): add updated snapshots
brandyscarney ed0e1e9
Merge branch 'next' into ROU-10973
brandyscarney 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
107 changes: 107 additions & 0 deletions
107
core/src/components/segment-button/segment-button.ionic.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,107 @@ | ||
| @use "../../themes/ionic/ionic.globals.scss" as globals; | ||
| @use "./segment-button.common"; | ||
|
|
||
| // Ionic Segment Button | ||
| // -------------------------------------------------- | ||
|
|
||
| :host { | ||
| /** | ||
| * @prop --color-disabled: Color of the disabled segment button | ||
| */ | ||
| --background: #{globals.$ionic-color-base-white}; | ||
| --background-checked: var(--background); | ||
| --color: #{globals.$ionic-color-neutral-1000}; | ||
| --color-checked: #{globals.$ionic-color-primary-base}; | ||
| --color-disabled: #{globals.$ionic-color-neutral-500}; | ||
| --border-width: #{globals.$ionic-border-size-025}; | ||
| --border-color: #{globals.$ionic-color-neutral-300}; | ||
| --border-style: #{globals.$ionic-border-style-solid}; | ||
| --indicator-box-shadow: none; | ||
| --indicator-color: var(--color-checked); | ||
| --indicator-height: #{globals.$ionic-border-size-025}; | ||
| --indicator-transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1); | ||
| --indicator-transform: none; | ||
| --padding-top: #{globals.$ionic-space-200}; | ||
| --padding-end: #{globals.$ionic-space-200}; | ||
| --padding-bottom: #{globals.$ionic-space-200}; | ||
| --padding-start: #{globals.$ionic-space-200}; | ||
| --transition: color 0.15s linear 0s, opacity 0.15s linear 0s; | ||
|
|
||
| min-width: globals.$ionic-scale-1200; | ||
| min-height: globals.$ionic-scale-1200; | ||
| } | ||
|
|
||
| .button-native { | ||
| border-bottom: var(--border-width) var(--border-style) var(--border-color); | ||
|
|
||
| // Ensures the indicator moves correctly between segment buttons | ||
| z-index: 1; | ||
| } | ||
|
|
||
| .button-inner { | ||
| gap: globals.$ionic-space-100; | ||
thetaPC marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // Segment Button Label | ||
| // -------------------------------------------------- | ||
|
|
||
| ::slotted(ion-label) { | ||
| @include globals.typography(globals.$ionic-action-md); | ||
|
|
||
| color: var(--color); | ||
| } | ||
|
|
||
| // Segment Button Icon | ||
| // -------------------------------------------------- | ||
|
|
||
| ::slotted(ion-icon) { | ||
| width: globals.$ionic-scale-600; | ||
| height: globals.$ionic-scale-600; | ||
|
|
||
| color: var(--color); | ||
| } | ||
|
|
||
| // Segment Button: Checked | ||
| // -------------------------------------------------- | ||
|
|
||
| :host(.segment-button-checked) ::slotted(ion-label), | ||
| :host(.segment-button-checked) ::slotted(ion-icon) { | ||
| color: var(--color-checked); | ||
| } | ||
|
|
||
| // Segment Button: Disabled | ||
| // -------------------------------------------------- | ||
|
|
||
| :host(.segment-button-disabled) ::slotted(ion-label), | ||
| :host(.segment-button-disabled) ::slotted(ion-icon) { | ||
| color: var(--color-disabled); | ||
| } | ||
|
|
||
| // Segment Button: Indicator | ||
| // -------------------------------------------------- | ||
|
|
||
| .segment-button-indicator { | ||
| @include globals.position(null, 0, 0, 0); | ||
|
|
||
| // Ensures the indicator displays correctly above the border | ||
| z-index: 2; | ||
| } | ||
|
|
||
| // Segment Button Layout | ||
| // -------------------------------------------------- | ||
|
|
||
| // Segments with icons above or below the label | ||
| // should have a fixed height of 64px | ||
| :host(.segment-button-layout-icon-top), | ||
| :host(.segment-button-layout-icon-bottom) { | ||
| height: globals.$ionic-scale-1600; | ||
thetaPC marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // Segments with icons at the start or end, or with only | ||
| // icons or labels, should have a fixed height of 48px | ||
| :host(.segment-button-has-label-only), | ||
| :host(.segment-button-has-icon-only), | ||
| :host(.segment-button-layout-icon-start), | ||
| :host(.segment-button-layout-icon-end) { | ||
| height: globals.$ionic-scale-1200; | ||
| } | ||
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
83 changes: 83 additions & 0 deletions
83
core/src/components/segment-button/segment-button.native.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,83 @@ | ||
| @import "segment-button.common"; | ||
| @import "../../themes/native/native.globals"; | ||
|
|
||
| // Segment Button: Native | ||
| // -------------------------------------------------- | ||
|
|
||
| :host { | ||
| /** | ||
| * @prop --background-hover: Background of the segment button on hover | ||
| * @prop --background-focused: Background of the segment button when focused with the tab key | ||
| * | ||
| * @prop --background-hover-opacity: Opacity of the segment button background on hover | ||
| * @prop --background-focused-opacity: Opacity of the segment button background when focused with the tab key | ||
| * | ||
| * @prop --color-hover: Color of the segment button on hover | ||
| * @prop --color-focused: Color of the segment button when focused with the tab key | ||
| */ | ||
| --color: initial; | ||
| --color-hover: var(--color); | ||
| --color-checked: var(--color); | ||
| --padding-start: 0; | ||
| --padding-end: 0; | ||
| --padding-top: 0; | ||
| --padding-bottom: 0; | ||
| } | ||
|
|
||
| .button-native { | ||
| @include text-inherit(); | ||
| } | ||
|
|
||
| .button-native::after { | ||
| @include button-state(); | ||
| } | ||
|
|
||
| // Segment Button: Focused | ||
| // -------------------------------------------------- | ||
|
|
||
| :host(.ion-focused) .button-native { | ||
| color: var(--color-focused); | ||
|
|
||
| &::after { | ||
| background: var(--background-focused); | ||
|
|
||
| opacity: var(--background-focused-opacity); | ||
| } | ||
| } | ||
|
|
||
| :host(:focus) { | ||
| outline: none; | ||
| } | ||
|
|
||
| // Segment Button: Hover | ||
| // -------------------------------------------------- | ||
|
|
||
| @media (any-hover: hover) { | ||
| :host(:hover) .button-native { | ||
| color: var(--color-hover); | ||
|
|
||
| &::after { | ||
| background: var(--background-hover); | ||
|
|
||
| opacity: var(--background-hover-opacity); | ||
| } | ||
| } | ||
|
|
||
| :host(.segment-button-checked:hover) .button-native { | ||
| color: var(--color-checked); | ||
| } | ||
| } | ||
|
|
||
| // Segment Button Label | ||
| // -------------------------------------------------- | ||
|
|
||
| ::slotted(ion-label) { | ||
| line-height: 22px; | ||
| } | ||
|
|
||
| // Segment Button Ripple | ||
| // -------------------------------------------------- | ||
|
|
||
| ion-ripple-effect { | ||
| color: var(--ripple-color, var(--color-checked)); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.