@ionic/core
Version:
Base components for Ionic
838 lines (768 loc) • 21.6 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: The primary background of the datetime component.
* @prop --background-rgb: The primary background of the datetime component in RGB format.
* @prop --title-color: The text color of the title.
*
* @prop --wheel-highlight-background: The background of the highlight under the selected
* item when using a wheel style layout, or in the month/year picker for grid style layouts.
* @prop --wheel-highlight-border-radius: The border radius of the highlight under the selected
* item when using a wheel style layout, or in the month/year picker for grid style layouts.
* @prop --wheel-fade-background-rgb: The color of the gradient covering non-selected items
* when using a wheel style layout, or in the month/year picker for grid style layouts. Must
* be in RGB format, e.g. `255, 255, 255`.
*/
display: flex;
flex-flow: column;
background: var(--background);
overflow: hidden;
}
:host(.datetime-size-fixed) {
width: auto;
height: auto;
}
:host(.datetime-size-fixed:not(.datetime-prefer-wheel)) {
max-width: 350px;
}
/**
* This ensures that the picker is appropriately
* sized and never truncates the text.
*/
:host(.datetime-size-fixed.datetime-prefer-wheel) {
min-width: 350px;
max-width: max-content;
}
:host(.datetime-size-cover) {
width: 100%;
}
:host .calendar-body,
:host .datetime-year {
opacity: 0;
}
:host(:not(.datetime-ready)) .datetime-year {
position: absolute;
pointer-events: none;
}
:host(.datetime-ready) .calendar-body {
opacity: 1;
}
:host(.datetime-ready) .datetime-year {
display: none;
opacity: 1;
}
/**
* Changing the physical order of the
* picker columns in the DOM is added
* work, so we just use `order` instead.
*
* The picker automatically configures
* the text alignment, so when switching
* the order we need to manually switch
* the text alignment too.
*/
:host .wheel-order-year-first .day-column {
order: 3;
text-align: end;
}
:host .wheel-order-year-first .month-column {
order: 2;
text-align: end;
}
:host .wheel-order-year-first .year-column {
order: 1;
text-align: start;
}
/**
* This allows the calendar to take
* up 100% of the remaining height.
* On iOS, if there are more than
* 5 rows of dates, the dates should
* be resized to fit into this
* container.
*/
:host .datetime-calendar,
:host .datetime-year {
display: flex;
flex: 1 1 auto;
flex-flow: column;
}
:host(.show-month-and-year) .datetime-year {
display: flex;
}
:host(.show-month-and-year) .calendar-next-prev,
:host(.show-month-and-year) .calendar-days-of-week,
:host(.show-month-and-year) .calendar-body,
:host(.show-month-and-year) .datetime-time {
display: none;
}
:host(.month-year-picker-open) .datetime-footer {
display: none;
}
:host(.datetime-disabled) {
pointer-events: none;
}
:host(.datetime-disabled) .calendar-days-of-week,
:host(.datetime-disabled) .datetime-time {
opacity: 0.4;
}
:host(.datetime-readonly) {
pointer-events: none;
/**
* Allow user to navigate months
* while in readonly mode
*/
/**
* Disabled buttons should have full opacity
* in readonly mode
*/
}
:host(.datetime-readonly) .calendar-action-buttons,
:host(.datetime-readonly) .calendar-body,
:host(.datetime-readonly) .datetime-year {
pointer-events: initial;
}
:host(.datetime-readonly) .calendar-day[disabled]:not(.calendar-day-constrained),
:host(.datetime-readonly) .datetime-action-buttons ion-button[disabled] {
opacity: 1;
}
/**
* Title should not wrap
* to the next line and should
* show ellipsis instead.
*/
:host .datetime-header .datetime-title {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
:host .datetime-action-buttons.has-clear-button {
width: 100%;
}
:host .datetime-action-buttons ion-buttons {
display: flex;
justify-content: space-between;
}
/**
* The confirm and clear buttons are grouped in a
* container so that they appear on the end opposite
* of the cancel button.
* We use display: flex so that the
* wrapper only takes up as much
* height as it needs.
*/
.datetime-action-buttons .datetime-action-buttons-container {
display: flex;
}
/**
* Date/Year button should be on
* the opposite side of the component
* as the Next/Prev buttons
*/
:host .calendar-action-buttons {
display: flex;
justify-content: space-between;
}
:host .calendar-action-buttons ion-button {
--background: transparent;
}
:host .calendar-days-of-week {
display: grid;
grid-template-columns: repeat(7, 1fr);
text-align: center;
}
.calendar-days-of-week .day-of-week {
/**
* Center the days of the week within each cell
* if the container size is changed as a result
* of Dynamic Type.
*/
-webkit-margin-start: auto;
margin-inline-start: auto;
-webkit-margin-end: auto;
margin-inline-end: auto;
margin-top: 0;
margin-bottom: 0;
}
:host .calendar-body {
/**
* Show all calendar months inline
* and allow them to take up 100% of
* the free space. Do not use CSS Grid
* here as there are issues with nested grid
* on older browsers.
*/
display: flex;
flex-grow: 1;
scroll-snap-type: x mandatory;
/**
* Need to explicitly set overflow-y: hidden
* for older implementations of scroll snapping.
*/
overflow-x: scroll;
overflow-y: hidden;
scrollbar-width: none;
/**
* Hide blue outline on calendar body
* when it is focused.
*/
outline: none;
}
:host .calendar-body .calendar-month {
display: flex;
flex-flow: column;
/**
* Swiping should snap to at
* most one month at a time.
*/
scroll-snap-align: start;
scroll-snap-stop: always;
flex-shrink: 0;
width: 100%;
}
:host .calendar-body .calendar-month-disabled {
/**
* Disables swipe gesture snapping for scroll-snap containers
*/
scroll-snap-align: none;
}
/**
* Hide scrollbars on Chrome and Safari
*/
:host .calendar-body::-webkit-scrollbar {
display: none;
}
:host .calendar-body .calendar-month-grid {
/**
* Create 7 columns for
* 7 days in a week.
*/
display: grid;
grid-template-columns: repeat(7, 1fr);
}
:host .calendar-day-wrapper {
display: flex;
align-items: center;
justify-content: center;
min-width: 0;
min-height: 0;
overflow: visible;
}
/**
* Center the day text vertically
* and horizontally within its grid cell.
*/
.calendar-day {
border-radius: 50%;
-webkit-padding-start: 0px;
padding-inline-start: 0px;
-webkit-padding-end: 0px;
padding-inline-end: 0px;
padding-top: 0px;
padding-bottom: 0px;
-webkit-margin-start: 0px;
margin-inline-start: 0px;
-webkit-margin-end: 0px;
margin-inline-end: 0px;
margin-top: 0px;
margin-bottom: 0px;
display: flex;
position: relative;
align-items: center;
justify-content: center;
border: none;
outline: none;
background: none;
color: currentColor;
font-family: var(--ion-font-family, inherit);
cursor: pointer;
appearance: none;
z-index: 0;
}
:host .calendar-day[disabled] {
pointer-events: none;
opacity: 0.4;
}
.calendar-day:focus {
background: rgba(var(--ion-color-base-rgb), 0.2);
box-shadow: 0px 0px 0px 4px rgba(var(--ion-color-base-rgb), 0.2);
}
:host .datetime-time {
display: flex;
justify-content: space-between;
}
:host(.datetime-presentation-time) .datetime-time {
padding-left: 0;
padding-right: 0;
padding-top: 0;
padding-bottom: 0;
}
:host ion-popover {
--height: 200px;
}
:host .time-header {
display: flex;
align-items: center;
}
:host .time-body {
border-radius: 8px;
-webkit-padding-start: 12px;
padding-inline-start: 12px;
-webkit-padding-end: 12px;
padding-inline-end: 12px;
padding-top: 6px;
padding-bottom: 6px;
display: flex;
border: none;
background: var(--ion-color-step-300, var(--ion-background-color-step-300, #edeef0));
color: var(--ion-text-color, #000);
font-family: inherit;
font-size: inherit;
cursor: pointer;
appearance: none;
}
:host .time-body-active {
color: var(--ion-color-base);
}
:host(.in-item) {
position: static;
}
:host(.show-month-and-year) .calendar-action-buttons .calendar-month-year-toggle {
color: var(--ion-color-base);
}
.calendar-month-year {
min-width: 0;
}
.calendar-month-year-toggle {
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;
position: relative;
border: 0;
outline: none;
background: transparent;
cursor: pointer;
z-index: 1;
}
.calendar-month-year-toggle::after {
left: 0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
content: "";
opacity: 0;
transition: opacity 15ms linear, background-color 15ms linear;
z-index: -1;
}
.calendar-month-year-toggle.ion-focused::after {
background: currentColor;
}
.calendar-month-year-toggle:disabled {
opacity: 0.3;
pointer-events: none;
}
.calendar-month-year-toggle ion-icon {
-webkit-padding-start: 4px;
padding-inline-start: 4px;
-webkit-padding-end: 0;
padding-inline-end: 0;
padding-top: 0;
padding-bottom: 0;
flex-shrink: 0;
}
.calendar-month-year-toggle #toggle-wrapper {
display: inline-flex;
align-items: center;
}
ion-picker {
--highlight-background: var(--wheel-highlight-background);
--highlight-border-radius: var(--wheel-highlight-border-radius);
--fade-background-rgb: var(--wheel-fade-background-rgb);
}
/**
* 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: var(--ion-color-light, #f4f5f8);
--background-rgb: var(--ion-color-light-rgb, 244, 245, 248);
--title-color: var(--ion-color-step-600, var(--ion-text-color-step-400, #666666));
}
:host(.datetime-presentation-date-time:not(.datetime-prefer-wheel)),
:host(.datetime-presentation-time-date:not(.datetime-prefer-wheel)),
:host(.datetime-presentation-date:not(.datetime-prefer-wheel)) {
min-height: 350px;
}
:host .datetime-header {
-webkit-padding-start: 16px;
padding-inline-start: 16px;
-webkit-padding-end: 16px;
padding-inline-end: 16px;
padding-top: 16px;
padding-bottom: 16px;
border-bottom: 0.55px solid var(--ion-color-step-200, var(--ion-background-color-step-200, #cccccc));
font-size: min(0.875rem, 22.4px);
}
:host .datetime-header .datetime-title {
color: var(--title-color);
}
:host .datetime-header .datetime-selected-date {
margin-top: 10px;
}
.calendar-month-year-toggle {
-webkit-padding-start: 16px;
padding-inline-start: 16px;
-webkit-padding-end: 16px;
padding-inline-end: 16px;
padding-top: 0px;
padding-bottom: 0px;
min-height: 44px;
font-size: min(1rem, 25.6px);
font-weight: 600;
}
.calendar-month-year-toggle.ion-focused::after {
opacity: 0.15;
}
.calendar-month-year-toggle #toggle-wrapper {
-webkit-margin-start: 0;
margin-inline-start: 0;
-webkit-margin-end: 8px;
margin-inline-end: 8px;
margin-top: 10px;
margin-bottom: 10px;
}
:host .calendar-action-buttons .calendar-month-year-toggle ion-icon,
:host .calendar-action-buttons ion-buttons ion-button {
color: var(--ion-color-base);
}
:host .calendar-action-buttons ion-buttons {
padding-left: 0;
padding-right: 0;
padding-top: 8px;
padding-bottom: 0;
}
:host .calendar-action-buttons ion-buttons ion-button {
margin-left: 0;
margin-right: 0;
margin-top: 0;
margin-bottom: 0;
}
:host .calendar-days-of-week {
-webkit-padding-start: 8px;
padding-inline-start: 8px;
-webkit-padding-end: 8px;
padding-inline-end: 8px;
padding-top: 0;
padding-bottom: 0;
color: var(--ion-color-step-300, var(--ion-text-color-step-700, #b3b3b3));
font-size: min(0.75rem, 19.2px);
font-weight: 600;
line-height: 24px;
text-transform: uppercase;
}
@supports (border-radius: mod(1px, 1px)) {
.calendar-days-of-week .day-of-week {
/**
* When the computed font size is 24px
* we want the days of the week to only
* show the first letter of each day.
*
* We use the modulus operator to ensure
* that any font size less than 24px is
* unchanged (i.e. 16 % 24 = 16). If the
* font size is 24px then the remainder
* will be 0.
*/
/**
* From here, we scale the remainder to get
* a width value larger than 20px.
* We then clamp the width to have a max width
* of 100% so that each element does not appear
* too wide if $width is a very large number.
*
* When the font size is >=24px then $remainder
* will be 0px. This results in $width being 0px
* since 0px * 10 is still 0px. We set a minimum
* width of 20px below so that the days of the
* week still show when the font size is >=24px
* and have a fixed width of 20px.
*
* The days of the week text on iOS have a maximum font size
* that is no larger than 20px, so setting a minimum width
* of 20px ensures that the text will always fit. (See font-size
* declaration in the .calendar-days-of-week block).
*/
width: clamp(20px, calc(mod(min(1rem, 24px), 24px) * 10), 100%);
/**
* We show the first letter of the week
* by setting the width small such that all other
* letters wrap to the next line. While we do have
* overflow: hidden to visually hide the overflowing
* text, we need to explicitly set the height of the
* container too otherwise it will increase as the text wraps.
*/
height: 24px;
/**
* The above width will cause
* all the other letters to overflow
* to other lines. The below code hides
* those additional letters so only
* the first letter is shown.
*/
overflow: hidden;
}
.calendar-day {
/**
* We use the modulus operator to ensure
* that any font size less than 24px is
* unchanged (i.e. 16 % 24 = 16). If the
* font size is 24px then the remainder
* will be 0.
*/
/**
* From here, we scale the remainder. The purpose of
* scaling the remainder is to get a border radius
* large enough such that the element's
* shape is a circle.
*
* Note that when the font size is 24px
* then the remainder will be 0, so $radius
* will still be zero.
*/
/**
* In the event that $radius is 0
* we use max() to ensure a minimum
* border radius of 8px which will
* give the day button the rounded
* rectangle appearance.
* For font sizes smaller than 24px
* the border radius will give a circle appearance.
*/
border-radius: max(8px, mod(min(1rem, 24px), 24px) * 10);
}
}
/**
* iOS <17 has a bug where the result of mod() is
* used incorrectly if used inside of another CSS function such
* as calc(). The first set of @support checks accounts for iOS <17.
* We check -webkit-named-image to ensure that non-WebKit browsers are ignored.
* The second set of @support checks account for all other browsers that
* do not support mod() yet.
*/
@supports ((border-radius: mod(1px, 1px)) and (background: -webkit-named-image(apple-pay-logo-black)) and (not (contain-intrinsic-size: none))) or (not (border-radius: mod(1px, 1px))) {
.calendar-days-of-week .day-of-week {
width: auto;
height: auto;
overflow: initial;
}
.calendar-day {
border-radius: 32px;
}
}
:host .calendar-body .calendar-month .calendar-month-grid {
/**
* We need to apply the padding to
* each month grid item otherwise
* older versions of WebKit will consider
* this padding a snapping point if applied
* on .calendar-month
*/
-webkit-padding-start: 8px;
padding-inline-start: 8px;
-webkit-padding-end: 8px;
padding-inline-end: 8px;
padding-top: 8px;
padding-bottom: 8px;
align-items: center;
height: calc(100% - 16px);
}
:host .calendar-day-wrapper {
-webkit-padding-start: 4px;
padding-inline-start: 4px;
-webkit-padding-end: 4px;
padding-inline-end: 4px;
padding-top: 4px;
padding-bottom: 4px;
height: 0;
min-height: 1rem;
}
:host .calendar-day {
width: 40px;
min-width: 40px;
height: 40px;
font-size: min(1.25rem, 32px);
}
.calendar-day.calendar-day-active {
background: rgba(var(--ion-color-base-rgb), 0.2);
font-size: min(1.375rem, 35.2px);
}
/**
* Day that today but not selected
* should have ion-color for text color.
*/
:host .calendar-day.calendar-day-today {
color: var(--ion-color-base);
}
/**
* Day that is not today but
* is selected should have ion-color for
* text color and be bolder.
*/
:host .calendar-day.calendar-day-active {
color: var(--ion-color-base);
font-weight: 600;
}
/**
* Day that is selected and is today
* should have base background color
* with contrast text.
*/
:host .calendar-day.calendar-day-today.calendar-day-active {
background: var(--ion-color-base);
color: var(--ion-color-contrast);
}
:host .datetime-time {
-webkit-padding-start: 16px;
padding-inline-start: 16px;
-webkit-padding-end: 16px;
padding-inline-end: 16px;
padding-top: 8px;
padding-bottom: 16px;
font-size: min(1rem, 25.6px);
}
:host .datetime-time .time-header {
font-weight: 600;
}
:host .datetime-buttons {
-webkit-padding-start: 8px;
padding-inline-start: 8px;
-webkit-padding-end: 8px;
padding-inline-end: 8px;
padding-top: 8px;
padding-bottom: 8px;
border-top: 0.55px solid var(--ion-color-step-200, var(--ion-background-color-step-200, #cccccc));
}
:host .datetime-buttons ::slotted(ion-buttons),
:host .datetime-buttons ion-buttons {
display: flex;
align-items: center;
justify-content: space-between;
}
:host .datetime-action-buttons {
width: 100%;
}