UNPKG

@ionic/core

Version:
674 lines (629 loc) • 17.5 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 alert * * @prop --min-width: Minimum width of the alert * @prop --width: Width of the alert * @prop --max-width: Maximum width of the alert * * @prop --min-height: Minimum height of the alert * @prop --height: Height of the alert * @prop --max-height: Maximum height of the alert * * @prop --backdrop-opacity: Opacity of the backdrop */ --min-width: 250px; --width: auto; --min-height: auto; --height: auto; --max-height: 90%; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; left: 0; right: 0; top: 0; bottom: 0; display: flex; position: absolute; align-items: center; justify-content: center; outline: none; font-family: var(--ion-font-family, inherit); contain: strict; touch-action: none; user-select: none; z-index: 1001; } :host(.overlay-hidden) { display: none; } :host(.alert-top) { padding-top: 50px; align-items: flex-start; } .alert-wrapper { display: flex; 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); contain: content; opacity: 0; z-index: 10; } .alert-title { margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; } .alert-sub-title { margin-left: 0; margin-right: 0; margin-top: 5px; margin-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; font-weight: normal; } /** * Alert has a maximum height in scenarios * such as the MD alert on tablet devices. * As a result, we need to make sure the inner * containers can scroll otherwise content * may be cut off. */ .alert-message, .alert-input-group { box-sizing: border-box; -webkit-overflow-scrolling: touch; overflow-y: auto; overscroll-behavior-y: contain; } .alert-checkbox-label, .alert-radio-label { /** * This allows long words to wrap to the next line * instead of flowing outside of the container. * * The "anywhere" keyword should be used instead * of the "break-word" keyword since the parent * container is using flexbox. Flex relies on min-content and * max-content intrinsic sizes to structure the layout. Flex will * wrap content only until it reaches its min-content intrinsic size * which in this case is equal to the longest word in this container. * "break-word" does not shrink the min-content intrinsic size * of the flex item which causes the long word to still overflow. * "anywhere" on the other hand does shrink the min-content * intrinsic size which allows the long word to wrap to the next line. */ overflow-wrap: anywhere; } /** * Scrollbars on mobile devices will be hidden. * Users can still scroll the content by swiping. * If a user has a fine pointing device, such as a * mouse or trackpad, then scrollbars will be * visible. This allows users to scroll the * content with their pointing device. * Otherwise, the user would have to use the * keyboard to navigate through the options. * This may not be intuitive for users who * are not familiar with keyboard navigation. */ @media (any-pointer: coarse) { .alert-checkbox-group::-webkit-scrollbar, .alert-radio-group::-webkit-scrollbar, .alert-message::-webkit-scrollbar { display: none; } } .alert-input { padding-left: 0; padding-right: 0; padding-top: 10px; padding-bottom: 10px; width: 100%; border: 0; background: inherit; font: inherit; box-sizing: border-box; } .alert-button-group { display: flex; flex-direction: row; width: 100%; } .alert-button-group-vertical { flex-direction: column; flex-wrap: nowrap; } .alert-button { margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; display: block; border: 0; font-size: 0.875rem; line-height: 1.25rem; z-index: 0; } .alert-button.ion-focused, .alert-tappable.ion-focused { background: var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6)); } .alert-button-inner { display: flex; flex-flow: row nowrap; flex-shrink: 0; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: inherit; } .alert-input-disabled, .alert-checkbox-button-disabled .alert-button-inner, .alert-radio-button-disabled .alert-button-inner { cursor: default; opacity: 0.5; pointer-events: none; } .alert-tappable { 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: flex; width: 100%; border: 0; background: transparent; font-size: inherit; line-height: initial; text-align: start; appearance: none; contain: content; } .alert-button, .alert-checkbox, .alert-input, .alert-radio { outline: none; } .alert-radio-icon, .alert-checkbox-icon, .alert-checkbox-inner { box-sizing: border-box; } textarea.alert-input { min-height: 37px; resize: 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; * } * } */ /** * 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; * } * } */ /** * Large display requirements for MD Alert: * 1. Maintain a minimum of 48px distance from the leading and * trailing edges of the screen. (48px * 2 = 96px) * 2. The width can increase up to 560px. * 3. The height can increase up to 560px. * Source: https://m2.material.io/components/dialogs#behavior */ :host { --background: var(--ion-overlay-background-color, var(--ion-background-color, #fff)); --max-width: 280px; --backdrop-opacity: var(--ion-backdrop-opacity, 0.32); font-size: 0.875rem; } .alert-wrapper { border-radius: 4px; box-shadow: 0 11px 15px -7px rgba(0, 0, 0, 0.2), 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12); } .alert-head { -webkit-padding-start: 23px; padding-inline-start: 23px; -webkit-padding-end: 23px; padding-inline-end: 23px; padding-top: 20px; padding-bottom: 15px; text-align: start; } .alert-title { color: var(--ion-text-color, #000); font-size: 1.25rem; font-weight: 500; } .alert-sub-title { color: var(--ion-text-color, #000); font-size: 1rem; } .alert-message, .alert-input-group { -webkit-padding-start: 24px; padding-inline-start: 24px; -webkit-padding-end: 24px; padding-inline-end: 24px; padding-top: 20px; padding-bottom: 20px; color: var(--ion-color-step-550, var(--ion-text-color-step-450, #737373)); } .alert-message { font-size: 1rem; } /** * MD Alerts on tablets can expand vertically up to * a total maximum height. We only want to set a max-height * on mobile phones. */ @media screen and (max-width: 767px) { .alert-message { max-height: 266px; } } .alert-message:empty { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; } .alert-head + .alert-message { padding-top: 0; } .alert-input { margin-left: 0; margin-right: 0; margin-top: 5px; margin-bottom: 5px; border-bottom: 1px solid var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9)); color: var(--ion-text-color, #000); } .alert-input::placeholder { color: var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999))); font-family: inherit; font-weight: inherit; } .alert-input::-ms-clear { display: none; } .alert-input:focus { margin-bottom: 4px; border-bottom: 2px solid var(--ion-color-primary, #0054e9); } .alert-radio-group, .alert-checkbox-group { position: relative; border-top: 1px solid var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9)); border-bottom: 1px solid var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9)); overflow: auto; } /** * MD Alerts on tablets can expand vertically up to * a total maximum height. We only want to set a max-height * on mobile phones. */ @media screen and (max-width: 767px) { .alert-radio-group, .alert-checkbox-group { max-height: 266px; } } .alert-tappable { position: relative; min-height: 48px; } .alert-radio-label { -webkit-padding-start: 52px; padding-inline-start: 52px; -webkit-padding-end: 26px; padding-inline-end: 26px; padding-top: 13px; padding-bottom: 13px; flex: 1; color: var(--ion-color-step-850, var(--ion-text-color-step-150, #262626)); font-size: 1rem; } .alert-radio-icon { top: 0; border-radius: 50%; display: block; position: relative; width: 20px; height: 20px; border-width: 2px; border-style: solid; border-color: var(--ion-color-step-550, var(--ion-background-color-step-550, #737373)); } .alert-radio-icon { inset-inline-start: 26px; } .alert-radio-inner { top: 3px; border-radius: 50%; position: absolute; width: 10px; height: 10px; transform: scale3d(0, 0, 0); transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1); background-color: var(--ion-color-primary, #0054e9); } .alert-radio-inner { inset-inline-start: 3px; } [aria-checked=true] .alert-radio-label { color: var(--ion-color-step-850, var(--ion-text-color-step-150, #262626)); } [aria-checked=true] .alert-radio-icon { border-color: var(--ion-color-primary, #0054e9); } [aria-checked=true] .alert-radio-inner { transform: scale3d(1, 1, 1); } .alert-checkbox-label { -webkit-padding-start: 53px; padding-inline-start: 53px; -webkit-padding-end: 26px; padding-inline-end: 26px; padding-top: 13px; padding-bottom: 13px; flex: 1; width: calc(100% - 53px); color: var(--ion-color-step-850, var(--ion-text-color-step-150, #262626)); font-size: 1rem; } .alert-checkbox-icon { top: 0; border-radius: 2px; position: relative; width: 16px; height: 16px; border-width: 2px; border-style: solid; border-color: var(--ion-color-step-550, var(--ion-background-color-step-550, #737373)); contain: strict; } .alert-checkbox-icon { inset-inline-start: 26px; } [aria-checked=true] .alert-checkbox-icon { border-color: var(--ion-color-primary, #0054e9); background-color: var(--ion-color-primary, #0054e9); } [aria-checked=true] .alert-checkbox-inner { top: 0; position: absolute; width: 6px; height: 10px; transform: rotate(45deg); border-width: 2px; border-top-width: 0; border-left-width: 0; border-style: solid; border-color: var(--ion-color-primary-contrast, #fff); } [aria-checked=true] .alert-checkbox-inner { inset-inline-start: 3px; } .alert-button-group { -webkit-padding-start: 8px; padding-inline-start: 8px; -webkit-padding-end: 8px; padding-inline-end: 8px; padding-top: 8px; padding-bottom: 8px; box-sizing: border-box; flex-wrap: wrap-reverse; justify-content: flex-end; } .alert-button { border-radius: 2px; -webkit-margin-start: 0; margin-inline-start: 0; -webkit-margin-end: 8px; margin-inline-end: 8px; margin-top: 0; margin-bottom: 0; -webkit-padding-start: 10px; padding-inline-start: 10px; -webkit-padding-end: 10px; padding-inline-end: 10px; padding-top: 10px; padding-bottom: 10px; position: relative; background-color: transparent; color: var(--ion-color-primary, #0054e9); font-weight: 500; text-align: end; text-transform: uppercase; overflow: hidden; } .alert-button-inner { justify-content: flex-end; } /** * MD alerts should scale up to 560px x 560px * on tablet dimensions. */ @media screen and (min-width: 768px) { :host { --max-width: min(100vw - 96px, 560px); --max-height: min(100vh - 96px, 560px); } }