|
6 | 6 | import { html, PolymerElement } from '@polymer/polymer/polymer-element.js'; |
7 | 7 | import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js'; |
8 | 8 | import { processTemplates } from '@vaadin/component-base/src/templates.js'; |
9 | | -import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; |
| 9 | +import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; |
10 | 10 | import { OverlayMixin } from './vaadin-overlay-mixin.js'; |
| 11 | +import { overlayStyles } from './vaadin-overlay-styles.js'; |
| 12 | + |
| 13 | +registerStyles('vaadin-overlay', overlayStyles, { moduleId: 'vaadin-overlay-styles' }); |
11 | 14 |
|
12 | 15 | /** |
13 | 16 | * `<vaadin-overlay>` is a Web Component for creating overlays. The content of the overlay |
@@ -76,71 +79,6 @@ import { OverlayMixin } from './vaadin-overlay-mixin.js'; |
76 | 79 | class Overlay extends OverlayMixin(ThemableMixin(DirMixin(PolymerElement))) { |
77 | 80 | static get template() { |
78 | 81 | return html` |
79 | | - <style> |
80 | | - :host { |
81 | | - z-index: 200; |
82 | | - position: fixed; |
83 | | -
|
84 | | - /* Despite of what the names say, <vaadin-overlay> is just a container |
85 | | - for position/sizing/alignment. The actual overlay is the overlay part. */ |
86 | | -
|
87 | | - /* Default position constraints: the entire viewport. Note: themes can |
88 | | - override this to introduce gaps between the overlay and the viewport. */ |
89 | | - top: 0; |
90 | | - right: 0; |
91 | | - bottom: var(--vaadin-overlay-viewport-bottom); |
92 | | - left: 0; |
93 | | -
|
94 | | - /* Use flexbox alignment for the overlay part. */ |
95 | | - display: flex; |
96 | | - flex-direction: column; /* makes dropdowns sizing easier */ |
97 | | - /* Align to center by default. */ |
98 | | - align-items: center; |
99 | | - justify-content: center; |
100 | | -
|
101 | | - /* Allow centering when max-width/max-height applies. */ |
102 | | - margin: auto; |
103 | | -
|
104 | | - /* The host is not clickable, only the overlay part is. */ |
105 | | - pointer-events: none; |
106 | | -
|
107 | | - /* Remove tap highlight on touch devices. */ |
108 | | - -webkit-tap-highlight-color: transparent; |
109 | | -
|
110 | | - /* CSS API for host */ |
111 | | - --vaadin-overlay-viewport-bottom: 0; |
112 | | - } |
113 | | -
|
114 | | - :host([hidden]), |
115 | | - :host(:not([opened]):not([closing])) { |
116 | | - display: none !important; |
117 | | - } |
118 | | -
|
119 | | - [part='overlay'] { |
120 | | - -webkit-overflow-scrolling: touch; |
121 | | - overflow: auto; |
122 | | - pointer-events: auto; |
123 | | -
|
124 | | - /* Prevent overflowing the host in MSIE 11 */ |
125 | | - max-width: 100%; |
126 | | - box-sizing: border-box; |
127 | | -
|
128 | | - -webkit-tap-highlight-color: initial; /* reenable tap highlight inside */ |
129 | | - } |
130 | | -
|
131 | | - [part='backdrop'] { |
132 | | - z-index: -1; |
133 | | - content: ''; |
134 | | - background: rgba(0, 0, 0, 0.5); |
135 | | - position: fixed; |
136 | | - top: 0; |
137 | | - left: 0; |
138 | | - bottom: 0; |
139 | | - right: 0; |
140 | | - pointer-events: auto; |
141 | | - } |
142 | | - </style> |
143 | | -
|
144 | 82 | <div id="backdrop" part="backdrop" hidden$="[[!withBackdrop]]"></div> |
145 | 83 | <div part="overlay" id="overlay" tabindex="0"> |
146 | 84 | <div part="content" id="content"> |
|
0 commit comments