@vaadin/card 25.0.0-alpha3 → 25.0.0-alpha5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/card",
3
- "version": "25.0.0-alpha3",
3
+ "version": "25.0.0-alpha5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,14 +34,14 @@
34
34
  "web-component"
35
35
  ],
36
36
  "dependencies": {
37
- "@vaadin/component-base": "25.0.0-alpha3",
38
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha3",
39
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha3",
37
+ "@vaadin/component-base": "25.0.0-alpha5",
38
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha5",
39
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha5",
40
40
  "lit": "^3.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@vaadin/chai-plugins": "25.0.0-alpha3",
44
- "@vaadin/test-runner-commands": "25.0.0-alpha3",
43
+ "@vaadin/chai-plugins": "25.0.0-alpha5",
44
+ "@vaadin/test-runner-commands": "25.0.0-alpha5",
45
45
  "@vaadin/testing-helpers": "^2.0.0",
46
46
  "sinon": "^18.0.0"
47
47
  },
@@ -49,5 +49,5 @@
49
49
  "web-types.json",
50
50
  "web-types.lit.json"
51
51
  ],
52
- "gitHead": "8367dd20a47f53ca5589ad349a8e286ec2673055"
52
+ "gitHead": "7dc87bb2a3cae81ed53259fa10b58f990d50c6fd"
53
53
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2024 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const cardStyles: CSSResult;
@@ -0,0 +1,228 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2024 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from 'lit';
7
+
8
+ export const cardStyles = css`
9
+ :host {
10
+ display: flex;
11
+ flex-direction: column;
12
+ box-sizing: border-box;
13
+ padding: var(--_padding);
14
+ gap: var(--_gap);
15
+ --_padding: var(--vaadin-card-padding, 1em);
16
+ --_gap: var(--vaadin-card-gap, 1em);
17
+ --_media: 0;
18
+ --_title: 0;
19
+ --_subtitle: 0;
20
+ --_header: max(var(--_header-prefix), var(--_title), var(--_subtitle), var(--_header-suffix));
21
+ --_header-prefix: 0;
22
+ --_header-suffix: 0;
23
+ --_content: 0;
24
+ --_footer: 0;
25
+ }
26
+
27
+ :host([hidden]) {
28
+ display: none !important;
29
+ }
30
+
31
+ :host(:not([theme~='horizontal'])) {
32
+ justify-content: space-between;
33
+ }
34
+
35
+ :host([_m]) {
36
+ --_media: 1;
37
+ }
38
+
39
+ :host([_t]) {
40
+ --_title: 1;
41
+ }
42
+
43
+ :host([_st]) {
44
+ --_subtitle: 1;
45
+ }
46
+
47
+ :host([_h]) {
48
+ --_header: 1;
49
+ --_title: 0;
50
+ --_subtitle: 0;
51
+ }
52
+
53
+ :host([_hp]) {
54
+ --_header-prefix: 1;
55
+ }
56
+
57
+ :host([_hs]) {
58
+ --_header-suffix: 1;
59
+ }
60
+
61
+ :host([_c]) {
62
+ --_content: 1;
63
+ }
64
+
65
+ :host([_f]) {
66
+ --_footer: 1;
67
+ }
68
+
69
+ [part='media'],
70
+ [part='header'],
71
+ [part='content'],
72
+ [part='footer'] {
73
+ display: none;
74
+ }
75
+
76
+ :host([_m]) [part='media'],
77
+ :host([_c]) [part='content'] {
78
+ display: block;
79
+ }
80
+
81
+ :host([_f]) [part='footer'] {
82
+ display: flex;
83
+ gap: var(--_gap);
84
+ }
85
+
86
+ :host(:is([_h], [_t], [_st], [_hp], [_hs])) [part='header'] {
87
+ display: grid;
88
+ align-items: center;
89
+ gap: var(--_gap);
90
+ row-gap: 0;
91
+ }
92
+
93
+ :host([_hs]) [part='header'] {
94
+ grid-template-columns: 1fr auto;
95
+ }
96
+
97
+ :host([_hp]) [part='header'] {
98
+ grid-template-columns: repeat(var(--_header-prefix), auto) 1fr;
99
+ }
100
+
101
+ slot {
102
+ border-radius: inherit;
103
+ }
104
+
105
+ ::slotted([slot='header-prefix']) {
106
+ grid-column: 1;
107
+ grid-row: 1 / span calc(var(--_title) + var(--_subtitle));
108
+ }
109
+
110
+ ::slotted([slot='header']),
111
+ ::slotted([slot='title']) {
112
+ grid-column: calc(1 + var(--_header-prefix));
113
+ grid-row: 1;
114
+ }
115
+
116
+ ::slotted([slot='subtitle']) {
117
+ grid-column: calc(1 + var(--_header-prefix));
118
+ grid-row: calc(1 + var(--_title));
119
+ }
120
+
121
+ ::slotted([slot='header-suffix']) {
122
+ grid-column: calc(2 + var(--_header-prefix));
123
+ grid-row: 1 / span calc(var(--_title) + var(--_subtitle));
124
+ }
125
+
126
+ /* Horizontal */
127
+ :host([theme~='horizontal']) {
128
+ display: grid;
129
+ grid-template-columns: repeat(var(--_media), minmax(auto, max-content)) 1fr;
130
+ align-items: start;
131
+ }
132
+
133
+ :host([theme~='horizontal'][_f]) {
134
+ grid-template-rows: 1fr auto;
135
+ }
136
+
137
+ :host([theme~='horizontal'][_c]) {
138
+ grid-template-rows: repeat(var(--_header), auto) 1fr;
139
+ }
140
+
141
+ [part='media'] {
142
+ grid-column: 1;
143
+ grid-row: 1 / span calc(var(--_header) + var(--_content) + var(--_footer));
144
+ align-self: stretch;
145
+ border-radius: inherit;
146
+ }
147
+
148
+ [part='header'] {
149
+ margin-bottom: auto;
150
+ grid-column: calc(1 + var(--_media));
151
+ grid-row: 1;
152
+ }
153
+
154
+ [part='content'] {
155
+ grid-column: calc(1 + var(--_media));
156
+ grid-row: calc(1 + var(--_header));
157
+ flex: auto;
158
+ min-height: 0;
159
+ }
160
+
161
+ [part='footer'] {
162
+ grid-column: calc(1 + var(--_media));
163
+ grid-row: calc(1 + var(--_header) + var(--_content));
164
+ border-radius: inherit;
165
+ }
166
+
167
+ :host([theme~='horizontal']) [part='footer'] {
168
+ align-self: end;
169
+ }
170
+
171
+ :host(:not([theme~='horizontal'])) ::slotted([slot='media']:is(img, video, svg)) {
172
+ max-width: 100%;
173
+ }
174
+
175
+ ::slotted([slot='media']) {
176
+ vertical-align: middle;
177
+ }
178
+
179
+ :host(:is([theme~='cover-media'], [theme~='stretch-media']))
180
+ ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
181
+ width: 100%;
182
+ height: auto;
183
+ aspect-ratio: var(--vaadin-card-media-aspect-ratio, 16/9);
184
+ object-fit: cover;
185
+ /* Fixes an issue where an icon overflows the card boundaries on Firefox: https://github.com/vaadin/web-components/issues/8641 */
186
+ overflow: hidden;
187
+ }
188
+
189
+ :host([theme~='horizontal']:is([theme~='cover-media'], [theme~='stretch-media'])) {
190
+ grid-template-columns: repeat(var(--_media), minmax(auto, 0.5fr)) 1fr;
191
+ }
192
+
193
+ :host([theme~='horizontal']:is([theme~='cover-media'], [theme~='stretch-media']))
194
+ ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
195
+ height: 100%;
196
+ aspect-ratio: auto;
197
+ }
198
+
199
+ :host([theme~='cover-media']) ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
200
+ margin-top: calc(var(--_padding) * -1);
201
+ margin-inline: calc(var(--_padding) * -1);
202
+ width: calc(100% + var(--_padding) * 2);
203
+ max-width: none;
204
+ border-radius: inherit;
205
+ border-end-end-radius: 0;
206
+ border-end-start-radius: 0;
207
+ }
208
+
209
+ :host([theme~='horizontal'][theme~='cover-media']) ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
210
+ margin-inline-end: 0;
211
+ width: calc(100% + var(--_padding));
212
+ height: calc(100% + var(--_padding) * 2);
213
+ border-radius: inherit;
214
+ border-start-end-radius: 0;
215
+ border-end-end-radius: 0;
216
+ }
217
+
218
+ /* Scroller in content */
219
+ [part='content'] ::slotted(vaadin-scroller) {
220
+ margin-inline: calc(var(--_padding) * -1);
221
+ padding-inline: var(--_padding);
222
+ }
223
+
224
+ [part='content'] ::slotted(vaadin-scroller)::before,
225
+ [part='content'] ::slotted(vaadin-scroller)::after {
226
+ margin-inline: calc(var(--_padding) * -1);
227
+ }
228
+ `;
@@ -3,12 +3,14 @@
3
3
  * Copyright (c) 2024 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { css, html, LitElement } from 'lit';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
9
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
10
  import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
11
+ import { CSSInjectionMixin } from '@vaadin/vaadin-themable-mixin/css-injection-mixin.js';
11
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
+ import { cardStyles } from './styles/vaadin-card-core-styles.js';
12
14
 
13
15
  /**
14
16
  * `<vaadin-card>` is a versatile container for grouping related content and actions.
@@ -50,236 +52,13 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
50
52
  * @mixes ElementMixin
51
53
  * @mixes ThemableMixin
52
54
  */
53
- class Card extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
55
+ class Card extends ElementMixin(ThemableMixin(CSSInjectionMixin(PolylitMixin(LitElement)))) {
54
56
  static get is() {
55
57
  return 'vaadin-card';
56
58
  }
57
59
 
58
60
  static get styles() {
59
- return css`
60
- :host {
61
- display: flex;
62
- flex-direction: column;
63
- box-sizing: border-box;
64
- padding: var(--_padding);
65
- gap: var(--_gap);
66
- --_padding: var(--vaadin-card-padding, 1em);
67
- --_gap: var(--vaadin-card-gap, 1em);
68
- --_media: 0;
69
- --_title: 0;
70
- --_subtitle: 0;
71
- --_header: max(var(--_header-prefix), var(--_title), var(--_subtitle), var(--_header-suffix));
72
- --_header-prefix: 0;
73
- --_header-suffix: 0;
74
- --_content: 0;
75
- --_footer: 0;
76
- }
77
-
78
- :host([hidden]) {
79
- display: none !important;
80
- }
81
-
82
- :host(:not([theme~='horizontal'])) {
83
- justify-content: space-between;
84
- }
85
-
86
- :host([_m]) {
87
- --_media: 1;
88
- }
89
-
90
- :host([_t]) {
91
- --_title: 1;
92
- }
93
-
94
- :host([_st]) {
95
- --_subtitle: 1;
96
- }
97
-
98
- :host([_h]) {
99
- --_header: 1;
100
- --_title: 0;
101
- --_subtitle: 0;
102
- }
103
-
104
- :host([_hp]) {
105
- --_header-prefix: 1;
106
- }
107
-
108
- :host([_hs]) {
109
- --_header-suffix: 1;
110
- }
111
-
112
- :host([_c]) {
113
- --_content: 1;
114
- }
115
-
116
- :host([_f]) {
117
- --_footer: 1;
118
- }
119
-
120
- [part='media'],
121
- [part='header'],
122
- [part='content'],
123
- [part='footer'] {
124
- display: none;
125
- }
126
-
127
- :host([_m]) [part='media'],
128
- :host([_c]) [part='content'] {
129
- display: block;
130
- }
131
-
132
- :host([_f]) [part='footer'] {
133
- display: flex;
134
- gap: var(--_gap);
135
- }
136
-
137
- :host(:is([_h], [_t], [_st], [_hp], [_hs])) [part='header'] {
138
- display: grid;
139
- align-items: center;
140
- gap: var(--_gap);
141
- row-gap: 0;
142
- }
143
-
144
- [part='header'] {
145
- margin-bottom: auto;
146
- }
147
-
148
- :host([_hs]) [part='header'] {
149
- grid-template-columns: 1fr auto;
150
- }
151
-
152
- :host([_hp]) [part='header'] {
153
- grid-template-columns: repeat(var(--_header-prefix), auto) 1fr;
154
- }
155
-
156
- slot {
157
- border-radius: inherit;
158
- }
159
-
160
- ::slotted([slot='header-prefix']) {
161
- grid-column: 1;
162
- grid-row: 1 / span calc(var(--_title) + var(--_subtitle));
163
- }
164
-
165
- ::slotted([slot='header']),
166
- ::slotted([slot='title']) {
167
- grid-column: calc(1 + var(--_header-prefix));
168
- grid-row: 1;
169
- }
170
-
171
- ::slotted([slot='subtitle']) {
172
- grid-column: calc(1 + var(--_header-prefix));
173
- grid-row: calc(1 + var(--_title));
174
- }
175
-
176
- ::slotted([slot='header-suffix']) {
177
- grid-column: calc(2 + var(--_header-prefix));
178
- grid-row: 1 / span calc(var(--_title) + var(--_subtitle));
179
- }
180
-
181
- /* Horizontal */
182
- :host([theme~='horizontal']) {
183
- display: grid;
184
- grid-template-columns: repeat(var(--_media), minmax(auto, max-content)) 1fr;
185
- align-items: start;
186
- }
187
-
188
- :host([theme~='horizontal'][_f]) {
189
- grid-template-rows: 1fr auto;
190
- }
191
-
192
- :host([theme~='horizontal'][_c]) {
193
- grid-template-rows: repeat(var(--_header), auto) 1fr;
194
- }
195
-
196
- [part='media'] {
197
- grid-column: 1;
198
- grid-row: 1 / span calc(var(--_header) + var(--_content) + var(--_footer));
199
- align-self: stretch;
200
- border-radius: inherit;
201
- }
202
-
203
- [part='header'] {
204
- grid-column: calc(1 + var(--_media));
205
- grid-row: 1;
206
- }
207
-
208
- [part='content'] {
209
- grid-column: calc(1 + var(--_media));
210
- grid-row: calc(1 + var(--_header));
211
- flex: auto;
212
- min-height: 0;
213
- }
214
-
215
- [part='footer'] {
216
- grid-column: calc(1 + var(--_media));
217
- grid-row: calc(1 + var(--_header) + var(--_content));
218
- border-radius: inherit;
219
- }
220
-
221
- :host([theme~='horizontal']) [part='footer'] {
222
- align-self: end;
223
- }
224
-
225
- :host(:not([theme~='horizontal'])) ::slotted([slot='media']:is(img, video, svg)) {
226
- max-width: 100%;
227
- }
228
-
229
- ::slotted([slot='media']) {
230
- vertical-align: middle;
231
- }
232
-
233
- :host(:is([theme~='cover-media'], [theme~='stretch-media']))
234
- ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
235
- width: 100%;
236
- height: auto;
237
- aspect-ratio: var(--vaadin-card-media-aspect-ratio, 16/9);
238
- object-fit: cover;
239
- /* Fixes an issue where an icon overflows the card boundaries on Firefox: https://github.com/vaadin/web-components/issues/8641 */
240
- overflow: hidden;
241
- }
242
-
243
- :host([theme~='horizontal']:is([theme~='cover-media'], [theme~='stretch-media'])) {
244
- grid-template-columns: repeat(var(--_media), minmax(auto, 0.5fr)) 1fr;
245
- }
246
-
247
- :host([theme~='horizontal']:is([theme~='cover-media'], [theme~='stretch-media']))
248
- ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
249
- height: 100%;
250
- aspect-ratio: auto;
251
- }
252
-
253
- :host([theme~='cover-media']) ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
254
- margin-top: calc(var(--_padding) * -1);
255
- margin-inline: calc(var(--_padding) * -1);
256
- width: calc(100% + var(--_padding) * 2);
257
- max-width: none;
258
- border-radius: inherit;
259
- border-end-end-radius: 0;
260
- border-end-start-radius: 0;
261
- }
262
-
263
- :host([theme~='horizontal'][theme~='cover-media']) ::slotted([slot='media']:is(img, video, svg, vaadin-icon)) {
264
- margin-inline-end: 0;
265
- width: calc(100% + var(--_padding));
266
- height: calc(100% + var(--_padding) * 2);
267
- border-radius: inherit;
268
- border-start-end-radius: 0;
269
- border-end-end-radius: 0;
270
- }
271
-
272
- /* Scroller in content */
273
- [part='content'] ::slotted(vaadin-scroller) {
274
- margin-inline: calc(var(--_padding) * -1);
275
- padding-inline: var(--_padding);
276
- }
277
-
278
- [part='content'] ::slotted(vaadin-scroller)::before,
279
- [part='content'] ::slotted(vaadin-scroller)::after {
280
- margin-inline: calc(var(--_padding) * -1);
281
- }
282
- `;
61
+ return cardStyles;
283
62
  }
284
63
 
285
64
  static get properties() {
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/card",
4
- "version": "25.0.0-alpha3",
4
+ "version": "25.0.0-alpha5",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/card",
4
- "version": "25.0.0-alpha3",
4
+ "version": "25.0.0-alpha5",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {