@ionic/core
Version:
Base components for Ionic
520 lines (479 loc) • 15.2 kB
CSS
/**
* Convert a font size to a dynamic font size.
* Fonts that participate in Dynamic Type should use
* dynamic font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param unit (optional) - The unit to convert to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a maximum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a minimum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* maximum and minimum font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* A heuristic that applies CSS to tablet
* viewports.
*
* Usage:
* @include tablet-viewport() {
* :host {
* background-color: green;
* }
* }
*/
/**
* A heuristic that applies CSS to mobile
* viewports (i.e. phones, not tablets).
*
* Usage:
* @include mobile-viewport() {
* :host {
* background-color: blue;
* }
* }
*/
:host {
/**
* @prop --background: Background of the segment button
* @prop --background-checked: Background of the checked segment button
*
* @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: Color of the segment button
* @prop --color-checked: Color of the checked segment button
* @prop --color-hover: Color of the segment button on hover
* @prop --color-focused: Color of the segment button when focused with the tab key
*
* @prop --border-radius: Radius of the segment button border
* @prop --border-color: Color of the segment button border
* @prop --border-style: Style of the segment button border
* @prop --border-width: Width of the segment button border
*
* @prop --margin-top: Top margin of the segment button
* @prop --margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the segment button
* @prop --margin-bottom: Bottom margin of the segment button
* @prop --margin-start: Left margin if direction is left-to-right, and right margin if direction is right-to-left of the segment button
*
* @prop --padding-top: Top padding of the segment button
* @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the segment button
* @prop --padding-bottom: Bottom padding of the segment button
* @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the segment button
*
* @prop --transition: Transition of the segment button
*
* @prop --indicator-height: Height of the indicator for the checked segment button
* @prop --indicator-box-shadow: Box shadow on the indicator for the checked segment button
* @prop --indicator-color: Color of the indicator for the checked segment button
* @prop --indicator-transition: Transition of the indicator for the checked segment button
* @prop --indicator-transform: Transform of the indicator for the checked segment button
*/
--color: initial;
--color-hover: var(--color);
--color-checked: var(--color);
--color-disabled: var(--color);
--padding-start: 0;
--padding-end: 0;
--padding-top: 0;
--padding-bottom: 0;
border-radius: var(--border-radius);
display: flex;
position: relative;
flex-direction: column;
height: auto;
background: var(--background);
color: var(--color);
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
grid-row: 1;
font-kerning: none;
}
.button-native {
border-radius: 0;
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
letter-spacing: inherit;
text-decoration: inherit;
text-indent: inherit;
text-overflow: inherit;
text-transform: inherit;
text-align: inherit;
white-space: inherit;
color: inherit;
-webkit-margin-start: var(--margin-start);
margin-inline-start: var(--margin-start);
-webkit-margin-end: var(--margin-end);
margin-inline-end: var(--margin-end);
margin-top: var(--margin-top);
margin-bottom: var(--margin-bottom);
-webkit-padding-start: var(--padding-start);
padding-inline-start: var(--padding-start);
-webkit-padding-end: var(--padding-end);
padding-inline-end: var(--padding-end);
padding-top: var(--padding-top);
padding-bottom: var(--padding-bottom);
transform: translate3d(0, 0, 0);
display: flex;
position: relative;
flex-direction: inherit;
flex-grow: 1;
align-items: center;
justify-content: center;
width: 100%;
min-width: inherit;
max-width: inherit;
height: auto;
min-height: inherit;
max-height: inherit;
transition: var(--transition);
border: none;
outline: none;
background: transparent;
contain: content;
pointer-events: none;
overflow: hidden;
z-index: 2;
}
.button-native::after {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
content: "";
opacity: 0;
}
.button-inner {
display: flex;
position: relative;
flex-flow: inherit;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 1;
}
:host(.segment-button-checked) {
background: var(--background-checked);
color: var(--color-checked);
}
:host(.segment-button-disabled) {
cursor: default;
pointer-events: none;
}
:host(.ion-focused) .button-native {
color: var(--color-focused);
}
:host(.ion-focused) .button-native::after {
background: var(--background-focused);
opacity: var(--background-focused-opacity);
}
:host(:focus) {
outline: none;
}
@media (any-hover: hover) {
:host(:hover) .button-native {
color: var(--color-hover);
}
:host(:hover) .button-native::after {
background: var(--background-hover);
opacity: var(--background-hover-opacity);
}
:host(.segment-button-checked:hover) .button-native {
color: var(--color-checked);
}
}
::slotted(ion-icon) {
flex-shrink: 0;
order: -1;
pointer-events: none;
}
::slotted(ion-label) {
display: block;
align-self: center;
max-width: 100%;
line-height: 22px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
pointer-events: none;
}
:host(.segment-button-layout-icon-top) .button-native {
flex-direction: column;
}
:host(.segment-button-layout-icon-start) .button-native {
flex-direction: row;
}
:host(.segment-button-layout-icon-end) .button-native {
flex-direction: row-reverse;
}
:host(.segment-button-layout-icon-bottom) .button-native {
flex-direction: column-reverse;
}
:host(.segment-button-layout-icon-hide) ::slotted(ion-icon) {
display: none;
}
:host(.segment-button-layout-label-hide) ::slotted(ion-label) {
display: none;
}
ion-ripple-effect {
color: var(--ripple-color, var(--color-checked));
}
.segment-button-indicator {
transform-origin: left;
position: absolute;
opacity: 0;
box-sizing: border-box;
will-change: transform, opacity;
pointer-events: none;
}
.segment-button-indicator-background {
width: 100%;
height: var(--indicator-height);
transform: var(--indicator-transform);
box-shadow: var(--indicator-box-shadow);
pointer-events: none;
}
.segment-button-indicator-animated {
transition: var(--indicator-transition);
}
:host(.segment-button-checked) .segment-button-indicator {
opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
.segment-button-indicator-background {
transform: none;
}
.segment-button-indicator-animated {
transition: none;
}
}
/**
* Convert a font size to a dynamic font size.
* Fonts that participate in Dynamic Type should use
* dynamic font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param unit (optional) - The unit to convert to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a maximum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* a minimum font size.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* Convert a font size to a dynamic font size but impose
* maximum and minimum font sizes.
* @param size - The initial font size including the unit (i.e. px or pt)
* @param minScale - The minimum scale of the font (i.e. 0.8 for a minimum 80% scale).
* @param maxScale - The maximum scale of the font (i.e. 2.5 for a maximum 250% scale).
* @param unit (optional) - The unit to convert the initial font size to. Use this if you want to
* convert to a unit other than $baselineUnit.
*/
/**
* A heuristic that applies CSS to tablet
* viewports.
*
* Usage:
* @include tablet-viewport() {
* :host {
* background-color: green;
* }
* }
*/
/**
* A heuristic that applies CSS to mobile
* viewports (i.e. phones, not tablets).
*
* Usage:
* @include mobile-viewport() {
* :host {
* background-color: blue;
* }
* }
*/
:host {
--background: none;
--background-checked: none;
--background-hover: none;
--background-hover-opacity: 0;
--background-focused: none;
--background-focused-opacity: 0;
--border-radius: 7px;
--border-width: 1px;
--border-color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.12);
--border-style: solid;
--indicator-box-shadow: 0 0 5px rgba(0, 0, 0, 0.16);
--indicator-color: var(--ion-color-step-350, var(--ion-background-color-step-350, var(--ion-background-color, #fff)));
--indicator-height: 100%;
--indicator-transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
--indicator-transform: none;
--transition: 100ms all linear;
--padding-top: 0;
--padding-end: 13px;
--padding-bottom: 0;
--padding-start: 13px;
margin-top: 2px;
margin-bottom: 2px;
position: relative;
flex-direction: row;
min-width: 70px;
min-height: 28px;
transform: translate3d(0, 0, 0);
font-size: 13px;
font-weight: 450;
line-height: 37px;
}
:host::before {
margin-left: 0;
margin-right: 0;
margin-top: 5px;
margin-bottom: 5px;
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;
}
:host(.segment-button-disabled) {
opacity: 0.3;
}
::slotted(ion-icon) {
font-size: 24px;
}
:host(.segment-button-layout-icon-start) ::slotted(ion-label) {
-webkit-margin-start: 2px;
margin-inline-start: 2px;
-webkit-margin-end: 0;
margin-inline-end: 0;
}
:host(.segment-button-layout-icon-end) ::slotted(ion-label) {
-webkit-margin-start: 0;
margin-inline-start: 0;
-webkit-margin-end: 2px;
margin-inline-end: 2px;
}
.segment-button-indicator {
-webkit-padding-start: 2px;
padding-inline-start: 2px;
-webkit-padding-end: 2px;
padding-inline-end: 2px;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.segment-button-indicator-background {
border-radius: var(--border-radius);
background: var(--indicator-color);
}
.segment-button-indicator-background {
transition: var(--indicator-transition);
}
:host(.segment-button-checked)::before,
:host(.segment-button-after-checked)::before {
opacity: 0;
}
:host(.segment-button-checked) {
z-index: -1;
}
:host(.segment-button-activated) {
--indicator-transform: scale(0.95);
}
:host(.ion-focused) .button-native {
opacity: 0.7;
}
@media (any-hover: hover) {
:host(:hover) .button-native {
opacity: 0.5;
}
:host(.segment-button-checked:hover) .button-native {
opacity: 1;
}
}
:host(.in-segment-color) {
background: none;
color: var(--ion-text-color, #000);
}
:host(.in-segment-color) .segment-button-indicator-background {
background: var(--ion-color-step-350, var(--ion-background-color-step-350, var(--ion-background-color, #fff)));
}
@media (any-hover: hover) {
:host(.in-segment-color:hover) .button-native,
:host(.in-segment-color.segment-button-checked:hover) .button-native {
color: var(--ion-text-color, #000);
}
}
:host(.in-toolbar:not(.in-segment-color)) {
--background-checked: var(--ion-toolbar-segment-background-checked, none);
--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, var(--ion-color-step-350, var(--ion-background-color-step-350, var(--ion-background-color, #fff))));
}
/**
* Use the contrast color as background since
* since the text color is the base color. Otherwise
* we will have contrast issues when using light/medium/dark
* palettes across light and dark mode.
*/
:host(.in-toolbar-color) .segment-button-indicator-background {
background: var(--ion-color-contrast);
}
:host(.in-toolbar-color:not(.in-segment-color)) .button-native {
color: var(--ion-color-contrast);
}
:host(.in-toolbar-color.segment-button-checked:not(.in-segment-color)) .button-native {
color: var(--ion-color-base);
}
@media (any-hover: hover) {
:host(.in-toolbar-color:not(.in-segment-color):hover) .button-native {
color: var(--ion-color-contrast);
}
:host(.in-toolbar-color.segment-button-checked:not(.in-segment-color):hover) .button-native {
color: var(--ion-color-base);
}
}