mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00

Before users had to know the exact opacity that the MD/iOS spec called for in order to change the hover or focused background color. This allows them to change the background without having to know the opacity. - changes apply to Action Sheet (Buttons), Back Button, Button, FAB Button, Item, Menu Button, Segment Button, Tab Button - greatly reduces the requirement by users to set the background hover, focused states for dark modes and custom themes, also eliminates the need to know what the hover opacity is for each based on the spec - updates the MD dark theme per their spec - adds a component guide for internal use changing Ionic components references #18279 fixes #20213 fixes #19965 BREAKING CHANGE: *Activated Class* The `activated` class that is automatically added to buttons on press has been renamed to `ion-activated`. This will be more consistent with our `ion-focused` class we add and also will reduce conflicts with user's CSS. *CSS Variables* The `--background-hover`, `--background-focused` and `--background-activated` CSS variables on components that render native buttons will now have an opacity automatically set. If you are setting any of these like the following: ``` --background-hover: rgba(44, 44, 44, 0.08); ``` You will likely not see a hover state anymore. It should be updated to only set the desired color: ``` --background-hover: rgba(44, 44, 44); ``` If the opacity desired is something other than what the spec asks for, use: ``` --background-hover: rgba(44, 44, 44); --background-hover-opacity: 1; ```
226 lines
5.8 KiB
SCSS
226 lines
5.8 KiB
SCSS
@import "./segment-button";
|
|
@import "./segment-button.ios.vars";
|
|
|
|
// iOS Segment Button
|
|
// --------------------------------------------------
|
|
|
|
:host {
|
|
--background: #{$segment-button-ios-background};
|
|
--background-checked: #{$segment-button-ios-background-checked};
|
|
--background-hover: #{$segment-button-ios-background-hover};
|
|
--background-hover-opacity: 0;
|
|
--background-focused: none;
|
|
--background-focused-opacity: 0;
|
|
--border-radius: #{$segment-button-ios-border-radius};
|
|
--border-width: #{$segment-button-ios-border-width};
|
|
--border-color: #{$segment-button-ios-border-color};
|
|
--border-style: solid;
|
|
--indicator-box-shadow: #{$segment-button-ios-box-shadow-checked};
|
|
--indicator-color: #{$segment-button-ios-indicator-color};
|
|
--indicator-height: 100%;
|
|
--indicator-transition: #{$segment-button-ios-transition-animated};
|
|
--indicator-transform: none;
|
|
--transition: #{$segment-button-ios-transition};
|
|
--padding-top: 0;
|
|
--padding-end: 13px;
|
|
--padding-bottom: 0;
|
|
--padding-start: 13px;
|
|
|
|
@include margin($segment-button-ios-margin, null, $segment-button-ios-margin, null);
|
|
|
|
position: relative;
|
|
|
|
flex-basis: 0;
|
|
flex-direction: row;
|
|
|
|
min-width: #{$segment-button-ios-min-width};
|
|
|
|
min-height: #{$segment-button-ios-min-height};
|
|
|
|
// Necessary for the z-index to work properly
|
|
transform: translate3d(0, 0, 0);
|
|
|
|
font-size: #{$segment-button-ios-font-size};
|
|
|
|
font-weight: 450;
|
|
|
|
line-height: #{$segment-button-ios-line-height};
|
|
}
|
|
|
|
|
|
// Segment Button: Borders
|
|
// --------------------------------------------------
|
|
|
|
:host::before {
|
|
@include margin(5px, 0);
|
|
|
|
transition: 160ms opacity ease-in-out;
|
|
|
|
transition-delay: 100ms;
|
|
|
|
border-left: var(--border-width) var(--border-style) var(--border-color);
|
|
|
|
content: "";
|
|
opacity: 1;
|
|
|
|
will-change: opacity;
|
|
}
|
|
|
|
:host(:first-of-type)::before {
|
|
border-left-color: transparent;
|
|
}
|
|
|
|
|
|
// Segment Button: Disabled
|
|
// --------------------------------------------------
|
|
|
|
:host(.segment-button-disabled) {
|
|
opacity: $segment-button-ios-opacity-disabled;
|
|
}
|
|
|
|
|
|
// Segment Button: Icon
|
|
// --------------------------------------------------
|
|
|
|
::slotted(ion-icon) {
|
|
font-size: $segment-button-ios-icon-size;
|
|
}
|
|
|
|
|
|
// Segment Button: Layout
|
|
// --------------------------------------------------
|
|
|
|
// Layout: icon start
|
|
:host(.segment-button-layout-icon-start) ::slotted(ion-label) {
|
|
@include margin-horizontal(2px, 0);
|
|
}
|
|
|
|
// Layout: icon end
|
|
:host(.segment-button-layout-icon-end) ::slotted(ion-label) {
|
|
@include margin-horizontal(0, 2px);
|
|
}
|
|
|
|
|
|
// Segment Button: Checked Indicator
|
|
// --------------------------------------------------
|
|
|
|
.segment-button-indicator {
|
|
@include padding(null, $segment-button-ios-margin);
|
|
@include position(0, 0, 0, 0);
|
|
}
|
|
|
|
.segment-button-indicator-background {
|
|
@include border-radius($segment-button-ios-border-radius);
|
|
|
|
background: var(--indicator-color);
|
|
}
|
|
|
|
.segment-button-indicator-background {
|
|
transition: var(--indicator-transition);
|
|
}
|
|
|
|
|
|
// Segment Button: Checked Borders
|
|
// --------------------------------------------------
|
|
|
|
:host(.segment-button-checked)::before,
|
|
:host(.segment-button-after-checked)::before {
|
|
opacity: 0;
|
|
}
|
|
|
|
|
|
// Segment Button: Checked
|
|
// --------------------------------------------------
|
|
|
|
:host(.segment-button-checked) {
|
|
z-index: -1;
|
|
}
|
|
|
|
|
|
// Segment: States
|
|
// --------------------------------------------------
|
|
|
|
:host(.ion-focused) .button-native {
|
|
opacity: $segment-button-ios-opacity-focused;
|
|
}
|
|
|
|
@media (any-hover: hover) {
|
|
// Default Segment, Hover
|
|
:host(:hover) .button-native {
|
|
opacity: $segment-button-ios-opacity-hover;
|
|
}
|
|
|
|
:host(.segment-button-checked:hover) .button-native {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
|
|
// Segment Button: Segment w/ Color
|
|
// --------------------------------------------------
|
|
|
|
// Default
|
|
:host(.in-segment-color) {
|
|
background: none;
|
|
color: $segment-button-ios-color;
|
|
}
|
|
|
|
// Indicator color on a Segment w/ color
|
|
// should not change if the variable is set
|
|
:host(.in-segment-color) .segment-button-indicator-background {
|
|
background: $segment-button-ios-indicator-color;
|
|
}
|
|
|
|
@media (any-hover: hover) {
|
|
// Toolbar with Color, Default Segment, Hover
|
|
// Toolbar with Color, Default Segment, Checked, Hover
|
|
:host(.in-segment-color:hover) .button-native,
|
|
:host(.in-segment-color.segment-button-checked:hover) .button-native {
|
|
color: $segment-button-ios-color;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Segment Button: Toolbar
|
|
// --------------------------------------------------
|
|
|
|
// Default Segment, In a Toolbar
|
|
:host(.in-toolbar:not(.in-segment-color)) {
|
|
--background-checked: #{var(--ion-toolbar-segment-background-checked, $segment-button-ios-background-checked)};
|
|
--color: var(--ion-toolbar-segment-color, var(--ion-toolbar-color), initial);
|
|
--color-checked: var(--ion-toolbar-segment-color-checked, var(--ion-toolbar-color), initial);
|
|
--indicator-color: #{var(--ion-toolbar-segment-indicator-color, $segment-button-ios-indicator-color)};
|
|
}
|
|
|
|
|
|
// Segment Button: Toolbar w/ Color
|
|
// --------------------------------------------------
|
|
|
|
// Do not use the global or local CSS variable if the toolbar has a color
|
|
:host(.in-toolbar-color) .segment-button-indicator-background {
|
|
background: #fff;
|
|
}
|
|
|
|
// Toolbar with Color, Default Segment
|
|
:host(.in-toolbar-color:not(.in-segment-color)) .button-native {
|
|
color: #{current-color(contrast)};
|
|
}
|
|
|
|
// Toolbar with Color, Default Segment, Checked
|
|
:host(.in-toolbar-color.segment-button-checked:not(.in-segment-color)) .button-native {
|
|
color: #{current-color(base)};
|
|
}
|
|
|
|
@media (any-hover: hover) {
|
|
// Toolbar with Color, Default Segment, Hover
|
|
:host(.in-toolbar-color:not(.in-segment-color):hover) .button-native {
|
|
color: #{current-color(contrast)};
|
|
}
|
|
|
|
// Toolbar with Color, Default Segment, Checked / Hover
|
|
:host(.in-toolbar-color.segment-button-checked:not(.in-segment-color):hover) .button-native {
|
|
color: #{current-color(base)};
|
|
}
|
|
}
|