UNPKG

@ionic/core

Version:
429 lines (395 loc) • 11.7 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 searchbar input * @prop --box-shadow: Box shadow of the searchbar input * @prop --border-radius: Border radius of the searchbar input * @prop --cancel-button-color: Color of the searchbar cancel button * @prop --clear-button-color: Color of the searchbar clear button * @prop --color: Color of the searchbar text * @prop --icon-color: Color of the searchbar icon * @prop --placeholder-color: Color of the searchbar placeholder * @prop --placeholder-font-style: Font style of the searchbar placeholder * @prop --placeholder-font-weight: Font weight of the searchbar placeholder * @prop --placeholder-opacity: Opacity of the searchbar placeholder */ --placeholder-color: initial; --placeholder-font-style: initial; --placeholder-font-weight: initial; --placeholder-opacity: var(--ion-placeholder-opacity, 0.6); -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; display: flex; position: relative; align-items: center; width: 100%; color: var(--color); font-family: var(--ion-font-family, inherit); box-sizing: border-box; } :host(.ion-color) { color: var(--ion-color-contrast); } :host(.ion-color) .searchbar-input { background: var(--ion-color-base); } :host(.ion-color) .searchbar-clear-button, :host(.ion-color) .searchbar-cancel-button, :host(.ion-color) .searchbar-search-icon { color: inherit; } .searchbar-search-icon { color: var(--icon-color); pointer-events: none; } .searchbar-input-container { display: block; position: relative; flex-shrink: 1; width: 100%; } .searchbar-input { 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; border-radius: var(--border-radius); display: block; width: 100%; min-height: inherit; border: 0; outline: none; background: var(--background); font-family: inherit; box-shadow: var(--box-shadow); box-sizing: border-box; appearance: none; } .searchbar-input::placeholder { color: var(--placeholder-color); font-family: inherit; font-style: var(--placeholder-font-style); font-weight: var(--placeholder-font-weight); opacity: var(--placeholder-opacity); } .searchbar-input::-webkit-search-cancel-button, .searchbar-input::-ms-clear { display: none; } .searchbar-cancel-button { margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; display: none; height: 100%; border: 0; outline: none; color: var(--cancel-button-color); cursor: pointer; appearance: none; } .searchbar-cancel-button > div { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; } .searchbar-clear-button { margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; display: none; min-height: 0; outline: none; color: var(--clear-button-color); appearance: none; } /** * Normally, we would not want to use :focus * here because that would mean tapping the button * on mobile would focus it (and keep it focused). * However, the clear button always disappears after * being activated, so we never get to that state. */ .searchbar-clear-button:focus { opacity: 0.5; } :host(.searchbar-has-value.searchbar-should-show-clear) .searchbar-clear-button { display: block; } :host(.searchbar-disabled) { cursor: default; opacity: 0.4; pointer-events: 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: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.07); --border-radius: 10px; --box-shadow: none; --cancel-button-color: var(--ion-color-primary, #0054e9); --clear-button-color: var(--ion-color-step-600, var(--ion-text-color-step-400, #666666)); --color: var(--ion-text-color, #000); --icon-color: var(--ion-color-step-600, var(--ion-text-color-step-400, #666666)); -webkit-padding-start: 12px; padding-inline-start: 12px; -webkit-padding-end: 12px; padding-inline-end: 12px; padding-top: 12px; padding-bottom: 12px; min-height: 60px; contain: content; } .searchbar-input-container { min-height: 36px; } .searchbar-search-icon { -webkit-margin-start: calc(50% - 60px); margin-inline-start: calc(50% - 60px); top: 0; position: absolute; width: 1.375rem; height: 100%; contain: strict; } .searchbar-search-icon { inset-inline-start: 5px; } .searchbar-input { -webkit-padding-start: 0px; padding-inline-start: 0px; -webkit-padding-end: 0px; padding-inline-end: 0px; padding-top: 6px; padding-bottom: 6px; height: 100%; font-size: 1.0625rem; font-weight: 400; contain: strict; } /** * We should only account for the clear button * if the clear button is actually visible. Otherwise * long text in an input can get cut off when it does not need to. */ :host(.searchbar-has-value.searchbar-should-show-clear) .searchbar-input { -webkit-padding-start: 1.75rem; padding-inline-start: 1.75rem; -webkit-padding-end: 1.75rem; padding-inline-end: 1.75rem; } .searchbar-clear-button { top: 0; background-position: center; position: absolute; width: 1.875rem; height: 100%; border: 0; background-color: transparent; } .searchbar-clear-button { inset-inline-end: 0; } .searchbar-clear-icon { width: 1.125rem; height: 100%; } .searchbar-cancel-button { -webkit-padding-start: 12px; padding-inline-start: 12px; -webkit-padding-end: 0; padding-inline-end: 0; padding-top: 0; padding-bottom: 0; flex-shrink: 0; background-color: transparent; font-size: 17px; } :host(.searchbar-left-aligned) .searchbar-search-icon { -webkit-margin-start: 0; margin-inline-start: 0; } :host(.searchbar-left-aligned) .searchbar-input { -webkit-padding-start: 1.875rem; padding-inline-start: 1.875rem; } :host(.searchbar-has-focus) .searchbar-cancel-button, :host(.searchbar-should-show-cancel) .searchbar-cancel-button, :host(.searchbar-animated) .searchbar-cancel-button { display: block; } :host(.searchbar-animated) .searchbar-search-icon, :host(.searchbar-animated) .searchbar-input { transition: all 300ms ease; } :host(.searchbar-animated.searchbar-has-focus) .searchbar-cancel-button, :host(.searchbar-animated.searchbar-should-show-cancel) .searchbar-cancel-button { opacity: 1; pointer-events: auto; } :host(.searchbar-animated) .searchbar-cancel-button { -webkit-margin-end: -100%; margin-inline-end: -100%; transform: translate3d(0, 0, 0); transition: all 300ms ease; opacity: 0; pointer-events: none; } :host(.searchbar-no-animate) .searchbar-search-icon, :host(.searchbar-no-animate) .searchbar-input, :host(.searchbar-no-animate) .searchbar-cancel-button { transition-duration: 0ms; } :host(.ion-color) .searchbar-cancel-button { color: var(--ion-color-base); } @media (any-hover: hover) { :host(.ion-color) .searchbar-cancel-button:hover { color: var(--ion-color-tint); } } :host-context(ion-toolbar) { padding-top: 1px; padding-bottom: 15px; min-height: 52px; } :host-context(ion-toolbar.ion-color):not(.ion-color) { color: inherit; } :host-context(ion-toolbar.ion-color):not(.ion-color) .searchbar-cancel-button { color: currentColor; } :host-context(ion-toolbar.ion-color) .searchbar-search-icon { color: currentColor; opacity: 0.5; } :host-context(ion-toolbar.ion-color):not(.ion-color) .searchbar-input { background: rgba(var(--ion-color-contrast-rgb), 0.07); color: currentColor; } :host-context(ion-toolbar.ion-color):not(.ion-color) .searchbar-clear-button { color: currentColor; opacity: 0.5; }