UNPKG

@ionic/core

Version:
506 lines (464 loc) • 15 kB
/** * 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: var(--color-checked); --background-focused: var(--color-checked); --background-activated-opacity: 0; --background-focused-opacity: .12; --background-hover-opacity: .04; --color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.6); --color-checked: var(--ion-color-primary, #0054e9); --indicator-box-shadow: none; --indicator-color: var(--color-checked); --indicator-height: 2px; --indicator-transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1); --indicator-transform: none; --padding-top: 0; --padding-end: 16px; --padding-bottom: 0; --padding-start: 16px; --transition: color 0.15s linear 0s, opacity 0.15s linear 0s; min-width: 90px; min-height: 48px; border-width: var(--border-width); border-style: var(--border-style); border-color: var(--border-color); font-size: 14px; font-weight: 500; letter-spacing: 0.06em; line-height: 40px; text-transform: uppercase; } :host(.segment-button-disabled) { opacity: 0.3; } :host(.in-segment-color) { background: none; color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.6); } :host(.in-segment-color) ion-ripple-effect { color: var(--ion-color-base); } :host(.in-segment-color) .segment-button-indicator-background { background: var(--ion-color-base); } :host(.in-segment-color.segment-button-checked) .button-native { color: var(--ion-color-base); } :host(.in-segment-color.ion-focused) .button-native::after { background: var(--ion-color-base); } @media (any-hover: hover) { :host(.in-segment-color:hover) .button-native { color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.6); } :host(.in-segment-color:hover) .button-native::after { background: var(--ion-color-base); } :host(.in-segment-color.segment-button-checked:hover) .button-native { color: var(--ion-color-base); } } :host(.in-toolbar:not(.in-segment-color)) { --background: var(--ion-toolbar-segment-background, none); --background-checked: var(--ion-toolbar-segment-background-checked, none); --color: var(--ion-toolbar-segment-color, rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.6)); --color-checked: var(--ion-toolbar-segment-color-checked, var(--ion-color-primary, #0054e9)); --indicator-color: var(--ion-toolbar-segment-color-checked, var(--color-checked)); } :host(.in-toolbar-color:not(.in-segment-color)) .button-native { color: rgba(var(--ion-color-contrast-rgb), 0.6); } :host(.in-toolbar-color.segment-button-checked:not(.in-segment-color)) .button-native { color: var(--ion-color-contrast); } @media (any-hover: hover) { :host(.in-toolbar-color:not(.in-segment-color)) .button-native::after { background: var(--ion-color-contrast); } } ::slotted(ion-icon) { margin-top: 12px; margin-bottom: 12px; font-size: 24px; } ::slotted(ion-label) { margin-top: 12px; margin-bottom: 12px; } :host(.segment-button-layout-icon-top) ::slotted(ion-label), :host(.segment-button-layout-icon-bottom) ::slotted(ion-icon) { margin-top: 0; } :host(.segment-button-layout-icon-top) ::slotted(ion-icon), :host(.segment-button-layout-icon-bottom) ::slotted(ion-label) { margin-bottom: 0; } :host(.segment-button-layout-icon-start) ::slotted(ion-label) { -webkit-margin-start: 8px; margin-inline-start: 8px; -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: 8px; margin-inline-end: 8px; } :host(.segment-button-has-icon-only) ::slotted(ion-icon) { margin-top: 12px; margin-bottom: 12px; } :host(.segment-button-has-label-only) ::slotted(ion-label) { margin-top: 12px; margin-bottom: 12px; } .segment-button-indicator { left: 0; right: 0; bottom: 0; } .segment-button-indicator-background { background: var(--indicator-color); } :host(.in-toolbar:not(.in-segment-color)) .segment-button-indicator-background { background: var(--ion-toolbar-segment-indicator-color, var(--indicator-color)); } :host(.in-toolbar-color:not(.in-segment-color)) .segment-button-indicator-background { background: var(--ion-color-contrast); }