UNPKG

@ionic/core

Version:
574 lines (526 loc) • 17 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 button * @prop --background-activated: Background of the button when pressed. Note: setting this will interfere with the Material Design ripple. * @prop --background-activated-opacity: Opacity of the button when pressed * @prop --background-focused: Background of the button when focused with the tab key * @prop --background-focused-opacity: Opacity of the button when focused with the tab key * @prop --background-hover: Background of the button on hover * @prop --background-hover-opacity: Opacity of the background on hover * * @prop --color: Text color of the button * @prop --color-activated: Text color of the button when pressed * @prop --color-focused: Text color of the button when focused with the tab key * @prop --color-hover: Text color of the button when hover * * @prop --transition: Transition of the button * * @prop --border-radius: Border radius of the button * @prop --border-width: Border width of the button * @prop --border-style: Border style of the button * @prop --border-color: Border color of the button * * @prop --ripple-color: Color of the button ripple effect * * @prop --box-shadow: Box shadow of the button * @prop --opacity: Opacity of the button * * @prop --padding-top: Top padding of the button * @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button * @prop --padding-bottom: Bottom padding of the button * @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button */ --overflow: hidden; --ripple-color: currentColor; --border-width: initial; --border-color: initial; --border-style: initial; --color-activated: var(--color); --color-focused: var(--color); --color-hover: var(--color); --box-shadow: none; display: inline-block; width: auto; color: var(--color); font-family: var(--ion-font-family, inherit); text-align: center; text-decoration: none; white-space: normal; user-select: none; vertical-align: top; vertical-align: -webkit-baseline-middle; font-kerning: none; } :host(.button-disabled) { cursor: default; opacity: 0.5; pointer-events: none; } :host(.button-solid) { --background: var(--ion-color-primary, #0054e9); --color: var(--ion-color-primary-contrast, #fff); } :host(.button-outline) { --border-color: var(--ion-color-primary, #0054e9); --background: transparent; --color: var(--ion-color-primary, #0054e9); } :host(.button-clear) { --border-width: 0; --background: transparent; --color: var(--ion-color-primary, #0054e9); } :host(.button-block) { display: block; } :host(.button-block) .button-native { margin-left: 0; margin-right: 0; width: 100%; clear: both; contain: content; } :host(.button-block) .button-native::after { clear: both; } :host(.button-full) { display: block; } :host(.button-full) .button-native { margin-left: 0; margin-right: 0; width: 100%; contain: content; } :host(.button-full:not(.button-round)) .button-native { border-radius: 0; border-right-width: 0; border-left-width: 0; } .button-native { border-radius: var(--border-radius); -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; -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); 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; display: flex; position: relative; align-items: center; width: 100%; height: 100%; min-height: inherit; transition: var(--transition); border-width: var(--border-width); border-style: var(--border-style); border-color: var(--border-color); outline: none; background: var(--background); line-height: 1; box-shadow: var(--box-shadow); contain: layout style; cursor: pointer; opacity: var(--opacity); overflow: var(--overflow); z-index: 0; box-sizing: border-box; appearance: none; } .button-native::-moz-focus-inner { border: 0; } .button-inner { display: flex; position: relative; flex-flow: row nowrap; flex-shrink: 0; align-items: center; justify-content: center; width: 100%; height: 100%; z-index: 1; } ::slotted([slot=start]), ::slotted([slot=end]) { flex-shrink: 0; } ::slotted(ion-icon) { font-size: 1.35em; pointer-events: none; } ::slotted(ion-icon[slot=start]) { -webkit-margin-start: -0.3em; margin-inline-start: -0.3em; -webkit-margin-end: 0.3em; margin-inline-end: 0.3em; margin-top: 0; margin-bottom: 0; } ::slotted(ion-icon[slot=end]) { -webkit-margin-start: 0.3em; margin-inline-start: 0.3em; -webkit-margin-end: -0.2em; margin-inline-end: -0.2em; margin-top: 0; margin-bottom: 0; } ion-ripple-effect { color: var(--ripple-color); } .button-native::after { left: 0; right: 0; top: 0; bottom: 0; position: absolute; content: ""; opacity: 0; } :host(.ion-focused) { color: var(--color-focused); } :host(.ion-focused) .button-native::after { background: var(--background-focused); opacity: var(--background-focused-opacity); } @media (any-hover: hover) { :host(:hover) { color: var(--color-hover); } :host(:hover) .button-native::after { background: var(--background-hover); opacity: var(--background-hover-opacity); } } :host(.ion-activated) { color: var(--color-activated); } :host(.ion-activated) .button-native::after { background: var(--background-activated); opacity: var(--background-activated-opacity); } :host(.button-solid.ion-color) .button-native { background: var(--ion-color-base); color: var(--ion-color-contrast); } :host(.button-outline.ion-color) .button-native { border-color: var(--ion-color-base); background: transparent; color: var(--ion-color-base); } :host(.button-clear.ion-color) .button-native { background: transparent; color: var(--ion-color-base); } :host(.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native { color: var(--ion-toolbar-color, var(--color)); } :host(.button-outline.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native { border-color: var(--ion-toolbar-color, var(--color, var(--border-color))); } :host(.button-solid.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native { background: var(--ion-toolbar-color, var(--background)); color: var(--ion-toolbar-background, var(--color)); } /** * 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 { --border-radius: 4px; --padding-top: 8px; --padding-bottom: 8px; --padding-start: 1.1em; --padding-end: 1.1em; --transition: box-shadow 280ms cubic-bezier(.4, 0, .2, 1), background-color 15ms linear, color 15ms linear; -webkit-margin-start: 2px; margin-inline-start: 2px; -webkit-margin-end: 2px; margin-inline-end: 2px; margin-top: 4px; margin-bottom: 4px; min-height: 36px; font-size: 0.875rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; } :host(.button-solid) { --background-activated: transparent; --background-hover: var(--ion-color-primary-contrast, #fff); --background-focused: var(--ion-color-primary-contrast, #fff); --background-activated-opacity: 0; --background-focused-opacity: .24; --background-hover-opacity: .08; --box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12); } :host(.button-solid.ion-activated) { --box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12); } :host(.button-outline) { --border-width: 2px; --border-style: solid; --box-shadow: none; --background-activated: transparent; --background-focused: var(--ion-color-primary, #0054e9); --background-hover: var(--ion-color-primary, #0054e9); --background-activated-opacity: 0; --background-focused-opacity: .12; --background-hover-opacity: .04; } :host(.button-outline.ion-activated.ion-color) .button-native { background: transparent; } :host(.button-clear) { --background-activated: transparent; --background-focused: var(--ion-color-primary, #0054e9); --background-hover: var(--ion-color-primary, #0054e9); --background-activated-opacity: 0; --background-focused-opacity: .12; --background-hover-opacity: .04; } :host(.button-round) { --border-radius: 999px; --padding-top: 0; --padding-start: 26px; --padding-end: 26px; --padding-bottom: 0; } :host(.button-large) { --padding-top: 14px; --padding-start: 1em; --padding-end: 1em; --padding-bottom: 14px; min-height: 2.8em; font-size: 1.25rem; } :host(.button-small) { --padding-top: 4px; --padding-start: 0.9em; --padding-end: 0.9em; --padding-bottom: 4px; min-height: 2.1em; font-size: 0.8125rem; } :host(.button-strong) { font-weight: bold; } :host(.button-has-icon-only) { --padding-top: 0; --padding-bottom: var(--padding-top); --padding-end: var(--padding-top); --padding-start: var(--padding-end); min-width: clamp(30px, 2.86em, 60px); min-height: clamp(30px, 2.86em, 60px); } ::slotted(ion-icon[slot=icon-only]) { /** * The values were provided through MD design, * large and small are based on the iOS sizes. * min font size: 15px, default font size: 22.4px, max font size: 43px * * Since the `ion-button` uses `rem` for the font size, we can't * just pass the desired icon font size in `em` to the ` * dynamic-font-clamp`. Instead, we need to adjust the base size * to account for the ion-button` font size. * * For example, if the default font size of `ion-button` is 14px * (derived from rem) and the default font size of the icon is * 22.4px, then the base size would need to be increased. */ font-size: clamp(15.104px, 1.6em, 43.008px); } :host(.button-small.button-has-icon-only) { min-width: clamp(23px, 2.16em, 54px); min-height: clamp(23px, 2.16em, 54px); } :host(.button-small) ::slotted(ion-icon[slot=icon-only]) { /** * The values were provided through MD design, * large and small are based on the iOS sizes. * min font size: 12px, default font size: 16px, max font size: 40px * * Since the `ion-button` uses `rem` for the font size, we can't * just pass the desired icon font size in `em` to the ` * dynamic-font-clamp`. Instead, we need to adjust the base size * to account for the ion-button` font size. * * For example, if the default font size of `ion-button` is 13px * (derived from rem) and the default font size of the icon is * 16px, then the base size would need to be increased. */ font-size: clamp(13.002px, 1.23125em, 40.385px); } :host(.button-large.button-has-icon-only) { min-width: clamp(46px, 2.5em, 78px); min-height: clamp(46px, 2.5em, 78px); } :host(.button-large) ::slotted(ion-icon[slot=icon-only]) { /** * The values were provided through MD design, * large and small are based on the iOS sizes. * min font size: 15px, default font size: 28px, max font size: 43px * * Since the `ion-button` uses `rem` for the font size, we can't * just pass the desired icon font size in `em` to the ` * dynamic-font-clamp`. Instead, we need to adjust the base size * to account for the ion-button` font size. * * For example, if the default font size of `ion-button` is 20px * (derived from rem) and the default font size of the icon is * 28px, then the base size would need to be increased. */ font-size: clamp(15.008px, 1.4em, 43.008px); } /** * Only allow overriding of opacity here * as developers should not be overriding * colors when using the color prop. */ :host(.button-solid.ion-color.ion-focused) .button-native::after { background: var(--ion-color-contrast); } :host(.button-clear.ion-color.ion-focused) .button-native::after, :host(.button-outline.ion-color.ion-focused) .button-native::after { background: var(--ion-color-base); } @media (any-hover: hover) { :host(.button-solid.ion-color:hover) .button-native::after { background: var(--ion-color-contrast); } :host(.button-clear.ion-color:hover) .button-native::after, :host(.button-outline.ion-color:hover) .button-native::after { background: var(--ion-color-base); } } :host(.button-outline.ion-activated.in-toolbar:not(.ion-color):not(.in-toolbar-color)) .button-native { background: var(--ion-toolbar-background, var(--color)); color: var(--ion-toolbar-color, var(--background), var(--ion-color-primary-contrast, #fff)); }