@ionic/core
Version:
Base components for Ionic
372 lines (357 loc) • 11.9 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 button
* @prop --background-focused: Background of the button when focused with the tab key
* @prop --background-focused-opacity: Opacity of the button background 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-focused: Text color of the button when focused with the tab key
* @prop --color-hover: Text color of the button on hover
*
* @prop --min-width: Minimum width of the button
* @prop --min-height: Minimum height of the button
*
* @prop --transition: Transition of the button
*
* @prop --border-radius: Border radius of the button
*
* @prop --ripple-color: Color of the button ripple effect
*
* @prop --opacity: Opacity of the button
*
* @prop --margin-top: Top margin of the button
* @prop --margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the button
* @prop --margin-bottom: Bottom margin of the button
* @prop --margin-start: Left margin if direction is left-to-right, and right margin if direction is right-to-left 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
*
* @prop --icon-margin-top: Top margin of the button icon
* @prop --icon-margin-end: Right margin if direction is left-to-right, and left margin if direction is right-to-left of the button icon
* @prop --icon-margin-bottom: Bottom margin of the button icon
* @prop --icon-margin-start: Left margin if direction is left-to-right, and right margin if direction is right-to-left of the button icon
*
* @prop --icon-padding-top: Top padding of the button icon
* @prop --icon-padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the button icon
* @prop --icon-padding-bottom: Bottom padding of the button icon
* @prop --icon-padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the button icon
*
* @prop --icon-font-size: Font size of the button icon
* @prop --icon-font-weight: Font weight of the button icon
*/
--background: transparent;
--color-focused: currentColor;
--color-hover: currentColor;
--icon-margin-top: 0;
--icon-margin-bottom: 0;
--icon-padding-top: 0;
--icon-padding-end: 0;
--icon-padding-bottom: 0;
--icon-padding-start: 0;
--margin-top: 0;
--margin-end: 0;
--margin-bottom: 0;
--margin-start: 0;
--min-width: auto;
--min-height: auto;
--padding-top: 0;
--padding-end: 0;
--padding-bottom: 0;
--padding-start: 0;
--opacity: 1;
--ripple-color: currentColor;
--transition: background-color, opacity 100ms linear;
display: none;
min-width: var(--min-width);
min-height: var(--min-height);
color: var(--color);
font-family: var(--ion-font-family, inherit);
text-align: center;
text-decoration: none;
text-overflow: ellipsis;
text-transform: none;
white-space: nowrap;
user-select: none;
font-kerning: none;
}
ion-ripple-effect {
color: var(--ripple-color);
}
:host(.ion-color) .button-native {
color: var(--ion-color-base);
}
:host(.show-back-button) {
display: block;
}
:host(.back-button-disabled) {
cursor: default;
opacity: 0.5;
pointer-events: none;
}
.button-native {
border-radius: var(--border-radius);
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-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);
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: block;
position: relative;
width: 100%;
height: 100%;
min-height: inherit;
transition: var(--transition);
border: 0;
outline: none;
background: var(--background);
line-height: 1;
cursor: pointer;
opacity: var(--opacity);
overflow: hidden;
user-select: none;
z-index: 0;
appearance: none;
}
.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;
}
ion-icon {
-webkit-padding-start: var(--icon-padding-start);
padding-inline-start: var(--icon-padding-start);
-webkit-padding-end: var(--icon-padding-end);
padding-inline-end: var(--icon-padding-end);
padding-top: var(--icon-padding-top);
padding-bottom: var(--icon-padding-bottom);
-webkit-margin-start: var(--icon-margin-start);
margin-inline-start: var(--icon-margin-start);
-webkit-margin-end: var(--icon-margin-end);
margin-inline-end: var(--icon-margin-end);
margin-top: var(--icon-margin-top);
margin-bottom: var(--icon-margin-bottom);
display: inherit;
font-size: var(--icon-font-size);
font-weight: var(--icon-font-weight);
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);
}
.button-native::after {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
content: "";
opacity: 0;
}
@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(.ion-color.ion-focused) .button-native {
color: var(--ion-color-base);
}
@media (any-hover: hover) {
:host(.ion-color:hover) .button-native {
color: var(--ion-color-base);
}
}
:host(.in-toolbar:not(.in-toolbar-color)) {
color: var(--ion-toolbar-color, 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 {
--background-hover: transparent;
--background-hover-opacity: 1;
--background-focused: currentColor;
--background-focused-opacity: .1;
--border-radius: 4px;
--color: var(--ion-color-primary, #0054e9);
--icon-margin-end: 1px;
--icon-margin-start: -4px;
/**
* The icon should be sized relative
* to the size of the text which is
* why we use em here instead of rem.
* This allows developers to override
* the text font size while ensuring that
* the icon is sized relative to that.
*/
--icon-font-size: 1.6em;
--min-height: 32px;
/**
* Main content should be prioritized over the back
* button which is why a maximum font size is applied.
* Also, we want the text to remain readable
* so a minimum font size is applied.
* Using 1.294 instead of 1.3 aligns the text
* with the icon a bit nicer in Firefox.
*/
font-size: clamp(17px, 1.0625rem, 21.998px);
}
.button-native {
transform: translateZ(0);
overflow: visible;
z-index: 99;
}
:host(.ion-activated) .button-native {
opacity: 0.4;
}
@media (any-hover: hover) {
:host(:hover) {
opacity: 0.6;
}
}