UNPKG

@ionic/core

Version:
494 lines (451 loc) • 13.1 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 --color: Color of the radio * @prop --color-checked: Color of the checked radio * @prop --border-radius: Border radius of the radio * @prop --inner-border-radius: Border radius of the inner checked radio */ --inner-border-radius: 50%; display: inline-block; position: relative; max-width: 100%; min-height: inherit; cursor: pointer; user-select: none; z-index: 2; box-sizing: border-box; } :host(.radio-disabled) { pointer-events: none; } .radio-icon { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; contain: layout size style; } .radio-icon, .radio-inner { box-sizing: border-box; } input { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; outline: 0; clip: rect(0 0 0 0); opacity: 0; overflow: hidden; -webkit-appearance: none; -moz-appearance: none; } :host(:focus) { outline: none; } :host(.in-item) { flex: 1 1 0; width: 100%; height: 100%; } /** * Radio can be slotted * in components such as item and * toolbar which is why we do not * limit the below behavior to just ion-item. */ :host([slot=start]), :host([slot=end]) { flex: initial; width: auto; } .radio-wrapper { display: flex; position: relative; flex-grow: 1; align-items: center; justify-content: space-between; height: inherit; min-height: inherit; cursor: inherit; } .label-text-wrapper { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; } :host(.in-item) .label-text-wrapper { margin-top: 10px; margin-bottom: 10px; } :host(.in-item.radio-label-placement-stacked) .label-text-wrapper { margin-top: 10px; margin-bottom: 16px; } :host(.in-item.radio-label-placement-stacked) .native-wrapper { margin-bottom: 10px; } /** * If no label text is placed into the slot * then the element should be hidden otherwise * there will be additional margins added. */ .label-text-wrapper-hidden { display: none; } .native-wrapper { display: flex; align-items: center; } :host(.radio-justify-space-between) .radio-wrapper { justify-content: space-between; } :host(.radio-justify-start) .radio-wrapper { justify-content: start; } :host(.radio-justify-end) .radio-wrapper { justify-content: end; } :host(.radio-alignment-start) .radio-wrapper { align-items: start; } :host(.radio-alignment-center) .radio-wrapper { align-items: center; } :host(.radio-justify-space-between), :host(.radio-justify-start), :host(.radio-justify-end), :host(.radio-alignment-start), :host(.radio-alignment-center) { display: block; } /** * Label is on the left of the radio in LTR and * on the right in RTL. */ :host(.radio-label-placement-start) .radio-wrapper { flex-direction: row; } :host(.radio-label-placement-start) .label-text-wrapper { /** * The margin between the label and * the radio should be on the end * when the label sits at the start. */ -webkit-margin-start: 0; margin-inline-start: 0; -webkit-margin-end: 16px; margin-inline-end: 16px; } /** * Label is on the right of the radio in LTR and * on the left in RTL. */ :host(.radio-label-placement-end) .radio-wrapper { flex-direction: row-reverse; } /** * The margin between the label and * the radio should be on the start * when the label sits at the end. */ :host(.radio-label-placement-end) .label-text-wrapper { -webkit-margin-start: 16px; margin-inline-start: 16px; -webkit-margin-end: 0; margin-inline-end: 0; } :host(.radio-label-placement-fixed) .label-text-wrapper { /** * The margin between the label and * the radio should be on the end * when the label sits at the start. */ -webkit-margin-start: 0; margin-inline-start: 0; -webkit-margin-end: 16px; margin-inline-end: 16px; } /** * Label is on the left of the radio in LTR and * on the right in RTL. Label also has a fixed width. */ :host(.radio-label-placement-fixed) .label-text-wrapper { flex: 0 0 100px; width: 100px; min-width: 100px; } /** * Label is on top of the radio. */ :host(.radio-label-placement-stacked) .radio-wrapper { flex-direction: column; } :host(.radio-label-placement-stacked) .label-text-wrapper { transform: scale(0.75); /** * The margin between the label and * the radio should be on the bottom * when the label sits on top. */ margin-left: 0; margin-right: 0; margin-bottom: 16px; /** * Label text should not extend * beyond the bounds of the radio. */ max-width: calc(100% / 0.75); } :host(.radio-label-placement-stacked.radio-alignment-start) .label-text-wrapper { transform-origin: left top; } :host-context([dir=rtl]):host(.radio-label-placement-stacked.radio-alignment-start) .label-text-wrapper, :host-context([dir=rtl]).radio-label-placement-stacked.radio-alignment-start .label-text-wrapper { transform-origin: right top; } @supports selector(:dir(rtl)) { :host(.radio-label-placement-stacked.radio-alignment-start:dir(rtl)) .label-text-wrapper { transform-origin: right top; } } :host(.radio-label-placement-stacked.radio-alignment-center) .label-text-wrapper { transform-origin: center top; } :host-context([dir=rtl]):host(.radio-label-placement-stacked.radio-alignment-center) .label-text-wrapper, :host-context([dir=rtl]).radio-label-placement-stacked.radio-alignment-center .label-text-wrapper { transform-origin: calc(100% - center) top; } @supports selector(:dir(rtl)) { :host(.radio-label-placement-stacked.radio-alignment-center:dir(rtl)) .label-text-wrapper { transform-origin: calc(100% - center) top; } } /** * 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; * } * } */ :host { --color: rgb(var(--ion-text-color-rgb, 0, 0, 0), 0.6); --color-checked: var(--ion-color-primary, #0054e9); --border-width: 0.125rem; --border-style: solid; --border-radius: 50%; } :host(.ion-color) .radio-inner { background: var(--ion-color-base); } :host(.ion-color.radio-checked) .radio-icon { border-color: var(--ion-color-base); } .radio-icon { margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; border-radius: var(--border-radius); border-width: var(--border-width); border-style: var(--border-style); border-color: var(--color); } .radio-inner { border-radius: var(--inner-border-radius); width: calc(50% + var(--border-width)); height: calc(50% + var(--border-width)); transform: scale3d(0, 0, 0); transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1); background: var(--color-checked); } :host(.radio-checked) .radio-icon { border-color: var(--color-checked); } :host(.radio-checked) .radio-inner { transform: scale3d(1, 1, 1); } :host(.radio-disabled) .label-text-wrapper { opacity: 0.38; } :host(.radio-disabled) .native-wrapper { opacity: 0.63; } :host(.ion-focused) .radio-icon::after { border-radius: var(--inner-border-radius); display: block; position: absolute; width: 36px; height: 36px; background: var(--ion-color-primary-tint, #1a65eb); content: ""; opacity: 0.2; } .native-wrapper .radio-icon { width: 1.25rem; height: 1.25rem; }