UNPKG

@ionic/core

Version:
342 lines (313 loc) • 9.35 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 popover * @prop --box-shadow: Box shadow of the popover * * @prop --min-width: Minimum width of the popover * @prop --width: Width of the popover * @prop --max-width: Maximum width of the popover * * @prop --min-height: Minimum height of the popover * @prop --height: Height of the popover * @prop --max-height: Maximum height of the popover * * @prop --backdrop-opacity: Opacity of the backdrop * * @prop --offset-x: The amount to move the popover by on the x-axis * @prop --offset-y: The amount to move the popover by on the y-axis */ --background: var(--ion-background-color, #fff); --min-width: 0; --min-height: 0; --max-width: auto; --height: auto; --offset-x: 0px; --offset-y: 0px; left: 0; right: 0; top: 0; bottom: 0; display: flex; position: fixed; align-items: center; justify-content: center; outline: none; color: var(--ion-text-color, #000); z-index: 1001; } /** * With nested popovers, only the popover that * was first presented has a popover. This is the * parent popover and allows us to easily * track all nested popovers from a single backdrop. * As a result, nested popovers do not have backdrops * and their container should not be clickable. * This ensures that users can click the parent backdrop * while still interacting with the nested popover inner * content. */ :host(.popover-nested) { pointer-events: none; } :host(.popover-nested) .popover-wrapper { pointer-events: auto; } :host(.overlay-hidden) { display: none; } .popover-wrapper { z-index: 10; } .popover-content { display: flex; position: absolute; flex-direction: column; width: var(--width); min-width: var(--min-width); max-width: var(--max-width); height: var(--height); min-height: var(--min-height); max-height: var(--max-height); background: var(--background); box-shadow: var(--box-shadow); overflow: auto; z-index: 10; } ::slotted(.popover-viewport) { --ion-safe-area-top: 0px; --ion-safe-area-right: 0px; --ion-safe-area-bottom: 0px; --ion-safe-area-left: 0px; display: flex; flex-direction: column; } :host(.popover-nested.popover-side-left) { --offset-x: 5px; } :host(.popover-nested.popover-side-right) { --offset-x: -5px; } :host(.popover-nested.popover-side-start) { --offset-x: 5px; } :host-context([dir=rtl]):host(.popover-nested.popover-side-start), :host-context([dir=rtl]).popover-nested.popover-side-start { --offset-x: -5px; } @supports selector(:dir(rtl)) { :host(.popover-nested.popover-side-start:dir(rtl)) { --offset-x: -5px; } } :host(.popover-nested.popover-side-end) { --offset-x: -5px; } :host-context([dir=rtl]):host(.popover-nested.popover-side-end), :host-context([dir=rtl]).popover-nested.popover-side-end { --offset-x: 5px; } @supports selector(:dir(rtl)) { :host(.popover-nested.popover-side-end:dir(rtl)) { --offset-x: 5px; } } /** * 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 { --width: 200px; --max-height: 90%; --box-shadow: none; --backdrop-opacity: var(--ion-backdrop-opacity, 0.08); } :host(.popover-desktop) { --box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.12); } .popover-content { border-radius: 10px; } :host(.popover-desktop) .popover-content { border: 0.5px solid var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6)); } .popover-arrow { display: block; position: absolute; width: 20px; height: 10px; overflow: hidden; /* * Required for the arrow to render above the backdrop. * Otherwise, the arrow will appear slightly transparent. * The value is set to 11 since it's the minimum value that * will allow the arrow to render above the backdrop. */ z-index: 11; } .popover-arrow::after { top: 3px; border-radius: 3px; position: absolute; width: 14px; height: 14px; transform: rotate(45deg); background: var(--background); content: ""; z-index: 10; } .popover-arrow::after { inset-inline-start: 3px; } :host(.popover-bottom) .popover-arrow { top: auto; bottom: -10px; } :host(.popover-bottom) .popover-arrow::after { top: -6px; } :host(.popover-side-left) .popover-arrow { transform: rotate(90deg); } :host(.popover-side-right) .popover-arrow { transform: rotate(-90deg); } :host(.popover-side-top) .popover-arrow { transform: rotate(180deg); } :host(.popover-side-start) .popover-arrow { transform: rotate(90deg); } :host-context([dir=rtl]):host(.popover-side-start) .popover-arrow, :host-context([dir=rtl]).popover-side-start .popover-arrow { transform: rotate(-90deg); } @supports selector(:dir(rtl)) { :host(.popover-side-start:dir(rtl)) .popover-arrow { transform: rotate(-90deg); } } :host(.popover-side-end) .popover-arrow { transform: rotate(-90deg); } :host-context([dir=rtl]):host(.popover-side-end) .popover-arrow, :host-context([dir=rtl]).popover-side-end .popover-arrow { transform: rotate(90deg); } @supports selector(:dir(rtl)) { :host(.popover-side-end:dir(rtl)) .popover-arrow { transform: rotate(90deg); } } .popover-arrow, .popover-content { opacity: 0; } @supports (backdrop-filter: blur(0)) { :host(.popover-translucent) .popover-content, :host(.popover-translucent) .popover-arrow::after { background: rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8); backdrop-filter: saturate(180%) blur(20px); } }