diff --git a/src/vaadin-date-picker-styles.js b/src/vaadin-date-picker-styles.js index d3ea284d..79bc422d 100644 --- a/src/vaadin-date-picker-styles.js +++ b/src/vaadin-date-picker-styles.js @@ -1,40 +1,37 @@ -import '@polymer/polymer/lib/elements/custom-style.js'; -const $_documentContainer = document.createElement('template'); - -$_documentContainer.innerHTML = ` - -`; - -document.head.appendChild($_documentContainer.content); +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; + +registerStyles( + 'vaadin-date-picker-overlay', + css` + :host { + align-items: flex-start; + justify-content: flex-start; + } + + :host([bottom-aligned]) { + justify-content: flex-end; + } + + :host([right-aligned]) { + align-items: flex-end; + } + + :host([dir='rtl']) { + align-items: flex-end; + } + + :host([dir='rtl'][right-aligned]) { + align-items: flex-start; + } + + [part='overlay'] { + display: flex; + flex: auto; + } + + [part~='content'] { + flex: auto; + } + `, + { moduleId: 'vaadin-date-picker-overlay-styles' } +); diff --git a/src/vaadin-date-picker-text-field.js b/src/vaadin-date-picker-text-field.js index 014c6e18..781f29a7 100644 --- a/src/vaadin-date-picker-text-field.js +++ b/src/vaadin-date-picker-text-field.js @@ -4,48 +4,46 @@ Copyright (c) 2019 Vaadin Ltd. This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ */ import { TextFieldElement } from '@vaadin/vaadin-text-field/src/vaadin-text-field.js'; +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; -const $_documentContainer = document.createElement('template'); +registerStyles( + 'vaadin-date-picker-text-field', + css` + :host([dir='rtl']) [part='input-field'] { + direction: ltr; + } -$_documentContainer.innerHTML = ` - -`; - -document.head.appendChild($_documentContainer.content); /** - * The text-field element for date input. - * - * ### Styling - * - * See [`` documentation](https://github.com/vaadin/vaadin-text-field/blob/master/src/vaadin-text-field.html) - * for `` parts and available slots (prefix, suffix etc.) - * - * See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki) - * - * @extends PolymerElement - */ + * The text-field element for date input. + * + * ### Styling + * + * See [`` documentation](https://github.com/vaadin/vaadin-text-field/blob/master/src/vaadin-text-field.html) + * for `` parts and available slots (prefix, suffix etc.) + * + * See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki) + * + * @extends PolymerElement + */ class DatePickerTextFieldElement extends TextFieldElement { static get is() { return 'vaadin-date-picker-text-field'; diff --git a/theme/lumo/vaadin-date-picker-overlay-content-styles.js b/theme/lumo/vaadin-date-picker-overlay-content-styles.js index 4aa5c3ec..c8160896 100644 --- a/theme/lumo/vaadin-date-picker-overlay-content-styles.js +++ b/theme/lumo/vaadin-date-picker-overlay-content-styles.js @@ -1,220 +1,218 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-lumo-styles/color.js'; import '@vaadin/vaadin-lumo-styles/sizing.js'; import '@vaadin/vaadin-lumo-styles/spacing.js'; import '@vaadin/vaadin-lumo-styles/style.js'; import '@vaadin/vaadin-lumo-styles/typography.js'; import '@vaadin/vaadin-button/theme/lumo/vaadin-button.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + } + `, + { moduleId: 'lumo-date-picker-overlay-content' } +); diff --git a/theme/lumo/vaadin-date-picker-overlay-styles.js b/theme/lumo/vaadin-date-picker-overlay-styles.js index bd9d8451..96941e95 100644 --- a/theme/lumo/vaadin-date-picker-overlay-styles.js +++ b/theme/lumo/vaadin-date-picker-overlay-styles.js @@ -1,51 +1,50 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-lumo-styles/sizing.js'; import '@vaadin/vaadin-lumo-styles/spacing.js'; import '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + } + `, + { include: ['lumo-menu-overlay'], moduleId: 'lumo-date-picker-overlay' } +); diff --git a/theme/lumo/vaadin-date-picker-styles.js b/theme/lumo/vaadin-date-picker-styles.js index 23b1b159..f78ac343 100644 --- a/theme/lumo/vaadin-date-picker-styles.js +++ b/theme/lumo/vaadin-date-picker-styles.js @@ -1,29 +1,27 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-lumo-styles/font-icons.js'; import '@vaadin/vaadin-lumo-styles/mixins/field-button.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + } + `, + { include: ['lumo-field-button'], moduleId: 'lumo-date-picker' } +); diff --git a/theme/lumo/vaadin-date-picker-text-field-styles.js b/theme/lumo/vaadin-date-picker-text-field-styles.js index 54cdb3df..db43a1bc 100644 --- a/theme/lumo/vaadin-date-picker-text-field-styles.js +++ b/theme/lumo/vaadin-date-picker-text-field-styles.js @@ -1,21 +1,18 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-text-field/theme/lumo/vaadin-text-field.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + :host([dir='rtl']) [part='value'], + :host([dir='rtl']) [part='input-field'] ::slotted(input) { + --_lumo-text-field-overflow-mask-image: linear-gradient(to left, transparent, #000 1.25em); + } + `, + { moduleId: 'lumo-date-picker-text-field' } +); diff --git a/theme/lumo/vaadin-month-calendar-styles.js b/theme/lumo/vaadin-month-calendar-styles.js index d405f6f5..2a272314 100644 --- a/theme/lumo/vaadin-month-calendar-styles.js +++ b/theme/lumo/vaadin-month-calendar-styles.js @@ -1,149 +1,153 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-lumo-styles/color.js'; import '@vaadin/vaadin-lumo-styles/sizing.js'; import '@vaadin/vaadin-lumo-styles/spacing.js'; import '@vaadin/vaadin-lumo-styles/style.js'; import '@vaadin/vaadin-lumo-styles/typography.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; - -const $_documentContainer = html` - - +$_documentContainer.innerHTML = ` -`; +`; document.head.appendChild($_documentContainer.content); diff --git a/theme/material/vaadin-date-picker-overlay-content-styles.js b/theme/material/vaadin-date-picker-overlay-content-styles.js index 2fbcb1bd..2568c5d2 100644 --- a/theme/material/vaadin-date-picker-overlay-content-styles.js +++ b/theme/material/vaadin-date-picker-overlay-content-styles.js @@ -1,178 +1,176 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-material-styles/color.js'; import '@vaadin/vaadin-material-styles/font-icons.js'; import '@vaadin/vaadin-material-styles/typography.js'; import '@vaadin/vaadin-material-styles/shadow.js'; import '@vaadin/vaadin-button/theme/material/vaadin-button.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; - -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + background: transparent; + } + + :host([fullscreen]) { + position: absolute; + } + + /* Fullscreen Toolbar */ + + [part='overlay-header'] { + display: flex; + align-items: baseline; + position: relative; + z-index: 2; + color: var(--material-body-text-color); + background: var(--material-secondary-background-color); + border-bottom: 2px solid var(--material-primary-color); + padding: 8px; + box-shadow: var(--material-shadow-elevation-4dp); + } + + /* FIXME(platosha): fix the core styles and remove this override. */ + [part='overlay-header']:not([desktop]) { + padding-bottom: 8px; + } + + [part='label'] { + padding: 0 8px; + flex: auto; + } + + [part='clear-button'], + [part='toggle-button'] { + font-family: 'material-icons'; + font-size: var(--material-icon-font-size); + line-height: 24px; + width: 24px; + height: 24px; + text-align: center; + } + + [part='clear-button'], + [part='toggle-button'], + [part='years-toggle-button'] { + padding: 8px; + color: var(--material-secondary-text-color); + } + + [part='clear-button']:hover, + [part='toggle-button']:hover, + [part='years-toggle-button']:hover { + color: inherit; + } + + [part='clear-button']::before { + content: var(--material-icons-clear); + } + + [part='toggle-button']::before { + content: var(--material-icons-calendar); + } + + [part='years-toggle-button'] { + position: static; + padding: 4px 8px; + font-size: var(--material-body-font-size); + font-weight: 500; + line-height: 24px; + letter-spacing: 0.05em; + color: var(--material-secondary-text-color); + } + + [part='years-toggle-button']::before { + content: ''; + display: none; + } + + [part='years-toggle-button']::after { + content: var(--material-icons-play); + display: inline-block; + width: 24px; + font-family: 'material-icons'; + font-size: var(--material-icon-font-size); + line-height: 24px; + text-align: center; + transition: transform 100ms cubic-bezier(0.4, 0, 0.2, 1); + } + + :host([years-visible]) [part='years-toggle-button']::after { + transform: rotate(90deg); + } + + /* Month scroller */ + + [part='months'] { + --vaadin-infinite-scroller-item-height: 320px; + text-align: center; + } + + /* Year scroller */ + + [part='years'] { + z-index: 1; + background: var(--material-secondary-text-color); + color: var(--material-background-color); + text-align: center; + } + + [part='years']::before { + z-index: 2; + border: 0; + width: 8px; + height: 8px; + transform: translateX(-50%) rotate(-45deg); + background: var(--material-background-color); + } + + :host([years-visible]) [part='years']::after { + top: calc(20px + 16px); + height: calc(100% - 20px - 16px); + } + + [part='year-number'] { + font-size: var(--material-small-font-size); + line-height: 10px; /* NOTE(platosha): chosen to align years to months */ + } + + [part='year-separator'] { + background-color: currentColor; + width: 4px; + height: 4px; + border-radius: 50%; + margin: calc(0.5 * var(--vaadin-infinite-scroller-item-height, 80px) - 0.5 * 10px - 0.5 * 4px) auto; + } + + /* Bottom Bar */ + + [part='toolbar'] { + display: flex; + justify-content: flex-end; + padding: 8px 4px; + border-top: 1px solid var(--material-divider-color); + } + + [part='cancel-button'] { + order: 1; + } + + [part='today-button'] { + order: 2; + } + + [part='today-button'], + [part='cancel-button'] { + margin: 0 4px; + } + `, + { moduleId: 'material-date-picker-overlay-content' } +); diff --git a/theme/material/vaadin-date-picker-overlay-content.js b/theme/material/vaadin-date-picker-overlay-content.js deleted file mode 100644 index 5393c75a..00000000 --- a/theme/material/vaadin-date-picker-overlay-content.js +++ /dev/null @@ -1,2 +0,0 @@ -import './vaadin-date-picker-overlay-content-styles.js'; -import '../../src/vaadin-date-picker-overlay-content.js'; diff --git a/theme/material/vaadin-date-picker-overlay-styles.js b/theme/material/vaadin-date-picker-overlay-styles.js index 5cc86b19..234a37de 100644 --- a/theme/material/vaadin-date-picker-overlay-styles.js +++ b/theme/material/vaadin-date-picker-overlay-styles.js @@ -1,46 +1,44 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-material-styles/mixins/overlay.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); +registerStyles( + 'vaadin-date-picker-overlay', + css` + :host([fullscreen]) { + top: 0 !important; + right: 0 !important; + bottom: var(--vaadin-overlay-viewport-bottom) !important; + left: 0 !important; + align-items: stretch; + justify-content: stretch; + } + + [part='overlay'] { + overflow: hidden; + -webkit-overflow-scrolling: auto; + } + + :host(:not([fullscreen])) [part='overlay'] { + width: 360px; + max-height: 500px; + border-radius: 0 4px 4px; + } + + :host(:not([fullscreen])[right-aligned]) [part='overlay'] { + border-radius: 4px 0 4px 4px; + } + + :host(:not([fullscreen])[bottom-aligned]) [part='overlay'] { + border-radius: 4px; + } + + :host(:not([fullscreen])[show-week-numbers]) [part='overlay'] { + width: 396px; + } + + [part='content'] { + padding: 0; + } + `, + { include: ['material-overlay'], moduleId: 'material-date-picker-overlay' } +); diff --git a/theme/material/vaadin-date-picker-overlay.js b/theme/material/vaadin-date-picker-overlay.js deleted file mode 100644 index 7a11d176..00000000 --- a/theme/material/vaadin-date-picker-overlay.js +++ /dev/null @@ -1,2 +0,0 @@ -import './vaadin-date-picker-overlay-styles.js'; -import '../../src/vaadin-date-picker-overlay.js'; diff --git a/theme/material/vaadin-date-picker-styles.js b/theme/material/vaadin-date-picker-styles.js index 886885ac..45568df6 100644 --- a/theme/material/vaadin-date-picker-styles.js +++ b/theme/material/vaadin-date-picker-styles.js @@ -1,28 +1,23 @@ -import './vaadin-date-picker-overlay.js'; -import './vaadin-date-picker-overlay-content.js'; -import './vaadin-month-calendar.js'; +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-material-styles/color.js'; import '@vaadin/vaadin-material-styles/font-icons.js'; import '@vaadin/vaadin-material-styles/mixins/field-button.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + [part='toggle-button']::before { + content: var(--material-icons-calendar); + } + `, + { include: ['material-field-button'], moduleId: 'material-date-picker' } +); diff --git a/theme/material/vaadin-date-picker.js b/theme/material/vaadin-date-picker.js index fec65bdf..e7ae2989 100644 --- a/theme/material/vaadin-date-picker.js +++ b/theme/material/vaadin-date-picker.js @@ -1,3 +1,6 @@ +import './vaadin-date-picker-overlay-styles.js'; +import './vaadin-date-picker-overlay-content-styles.js'; +import './vaadin-month-calendar-styles.js'; import './vaadin-date-picker-styles.js'; import './vaadin-date-picker-text-field.js'; import '../../src/vaadin-date-picker.js'; diff --git a/theme/material/vaadin-month-calendar-styles.js b/theme/material/vaadin-month-calendar-styles.js index ba092f12..67f1760c 100644 --- a/theme/material/vaadin-month-calendar-styles.js +++ b/theme/material/vaadin-month-calendar-styles.js @@ -1,122 +1,120 @@ +import { registerStyles, css } from '@vaadin/vaadin-themable-mixin/register-styles.js'; import '@vaadin/vaadin-material-styles/color.js'; import '@vaadin/vaadin-material-styles/typography.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; - -const $_documentContainer = html` - -`; - -document.head.appendChild($_documentContainer.content); + } + + /* Selected */ + + [part='date'][selected] { + font-weight: 500; + } + + [part='date']:not([disabled])[selected]::after, + [part='date'][selected]::after { + background-color: transparent; + border-color: currentColor; + z-index: -2; + } + + /* Focused */ + + [part='date']:not([disabled])[focused], + [part='date']:not([disabled]):active { + color: var(--material-primary-contrast-color); + } + + [part='date']:not([disabled])[focused]::after, + [part='date']:not([disabled]):active::after { + opacity: 0.7; + background-color: var(--material-primary-color); + border-color: var(--material-primary-color); + z-index: -1; + } + + [part='date'][disabled] { + color: var(--material-disabled-text-color); + } + + :host([focused]) [part='date']:not([disabled])[focused]::after { + opacity: 1; + } + `, + { moduleId: 'material-date-picker-month-calendar' } +); diff --git a/theme/material/vaadin-month-calendar.js b/theme/material/vaadin-month-calendar.js deleted file mode 100644 index 9ffb034c..00000000 --- a/theme/material/vaadin-month-calendar.js +++ /dev/null @@ -1,2 +0,0 @@ -import './vaadin-month-calendar-styles.js'; -import '../../src/vaadin-month-calendar.js';