Skip to content

Commit 0d32901

Browse files
web-padawanjouni
andauthored
experiment: add dashboard base styles and visual tests (#9679)
* chore: copy existing core styles as base styles * experiment: dashboard widget styles and controls icons * experiment: dashboard section border and outline styles * test: add visual tests for base styles * chore: do not publish base styles to npm * dashboard button text color * use em instead of rem for default values * reduce default gap * remove redundant fallback value * add header gap * remove unnecessary margin from title * fix icon fallback size * add properties to customize widget title styles * remove redundant custom property not used anywhere else * simplify widget and section border and outline styles * add custom property to customize widget header padding * allow widget header to overflow * fix drag icon size * fix resizing styles * test: update reference screenshots * disable lint error * fix forced color mode --------- Co-authored-by: Jouni Koivuviita <jouni@vaadin.com>
1 parent 6a24675 commit 0d32901

37 files changed

+851
-6
lines changed

packages/component-base/src/style-props.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dashboard/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"type": "module",
2222
"files": [
2323
"src",
24+
"!src/styles/*-base-styles.d.ts",
25+
"!src/styles/*-base-styles.js",
2426
"theme",
2527
"vaadin-*.d.ts",
2628
"vaadin-*.js",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import type { CSSResult } from 'lit';
12+
13+
export const dashboardStyles: CSSResult;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import { css } from 'lit';
12+
import { dashboardLayoutStyles } from './vaadin-dashboard-layout-core-styles.js';
13+
14+
const dashboard = css`
15+
#grid[item-resizing] {
16+
-webkit-user-select: none;
17+
user-select: none;
18+
}
19+
20+
::slotted(vaadin-dashboard-widget-wrapper) {
21+
display: contents;
22+
}
23+
`;
24+
25+
export const dashboardStyles = [dashboardLayoutStyles, dashboard];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import type { CSSResult } from 'lit';
12+
13+
export const dashboardButtonStyles: CSSResult;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import { css } from 'lit';
12+
import { buttonStyles } from '@vaadin/button/src/styles/vaadin-button-core-styles.js';
13+
14+
const dashboardButton = css`
15+
:host {
16+
min-width: 1em;
17+
}
18+
19+
:host([theme~='tertiary']) {
20+
color: var(--vaadin-dashboard-button-text-color, var(--vaadin-color-subtle));
21+
}
22+
`;
23+
24+
export const dashboardButtonStyles = [buttonStyles, dashboardButton];
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import type { CSSResult } from 'lit';
12+
13+
export const dashboardLayoutStyles: CSSResult;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import { css } from 'lit';
12+
13+
export const dashboardLayoutStyles = css`
14+
:host {
15+
display: block;
16+
overflow: auto;
17+
box-sizing: border-box;
18+
width: 100%;
19+
}
20+
21+
:host([hidden]) {
22+
display: none !important;
23+
}
24+
25+
:host([dense-layout]) #grid {
26+
grid-auto-flow: dense;
27+
}
28+
29+
#grid {
30+
box-sizing: border-box;
31+
32+
/* Padding around dashboard edges */
33+
--_default-padding: 1em;
34+
--_padding: max(0px, var(--vaadin-dashboard-padding, var(--_default-padding)));
35+
padding: var(--_padding);
36+
37+
/* Gap between widgets */
38+
--_default-gap: 0.5em;
39+
--_gap: max(0px, var(--vaadin-dashboard-gap, var(--_default-gap)));
40+
gap: var(--_gap);
41+
42+
/* Default min and max column widths */
43+
--_default-col-min-width: 25em;
44+
--_default-col-max-width: 1fr;
45+
46+
/* Effective min and max column widths */
47+
--_col-min-width: var(--vaadin-dashboard-col-min-width, var(--_default-col-min-width));
48+
--_col-max-width: var(--vaadin-dashboard-col-max-width, var(--_default-col-max-width));
49+
50+
/* Effective max column count */
51+
--_col-max-count: var(--vaadin-dashboard-col-max-count, var(--_col-count));
52+
53+
/* Effective column count */
54+
--_effective-col-count: min(var(--_col-count), var(--_col-max-count));
55+
56+
/* Default row min height */
57+
--_default-row-min-height: 12em;
58+
/* Effective row min height */
59+
--_row-min-height: var(--vaadin-dashboard-row-min-height, var(--_default-row-min-height));
60+
/* Effective row height */
61+
--_row-height: minmax(var(--_row-min-height, auto), auto);
62+
63+
display: grid;
64+
overflow: hidden;
65+
min-width: calc(var(--_col-min-width) + var(--_padding) * 2);
66+
67+
grid-template-columns: repeat(
68+
var(--_effective-col-count, auto-fill),
69+
minmax(var(--_col-min-width), var(--_col-max-width))
70+
);
71+
72+
grid-auto-rows: var(--_row-height);
73+
}
74+
75+
::slotted(*) {
76+
/* The grid-column value applied to children */
77+
--_item-column: span min(var(--vaadin-dashboard-widget-colspan, 1), var(--_effective-col-count, var(--_col-count)));
78+
79+
grid-column: var(--_item-column);
80+
81+
/* The grid-row value applied to children */
82+
--_item-row: span var(--vaadin-dashboard-widget-rowspan, 1);
83+
grid-row: var(--_item-row);
84+
}
85+
`;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import type { CSSResult } from 'lit';
12+
13+
export const dashboardSectionStyles: CSSResult;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* @license
3+
* Copyright (c) 2000 - 2025 Vaadin Ltd.
4+
*
5+
* This program is available under Vaadin Commercial License and Service Terms.
6+
*
7+
*
8+
* See https://vaadin.com/commercial-license-and-service-terms for the full
9+
* license.
10+
*/
11+
import '@vaadin/component-base/src/style-props.js';
12+
import { css } from 'lit';
13+
import { dashboardWidgetAndSectionStyles } from './vaadin-dashboard-widget-section-core-styles.js';
14+
15+
const sectionStyles = css`
16+
/* stylelint-disable length-zero-no-unit */
17+
18+
:host {
19+
display: grid;
20+
position: relative;
21+
grid-template-columns: subgrid;
22+
--_section-column: 1 / calc(var(--_effective-col-count) + 1);
23+
grid-column: var(--_section-column) !important;
24+
gap: var(--_gap);
25+
/* Dashboard section header height */
26+
grid-template-rows: minmax(0, auto) repeat(auto-fill, var(--_row-height));
27+
grid-auto-rows: var(--_row-height);
28+
border: var(--_widget-border-width) solid var(--_widget-border-color);
29+
border-radius: var(--vaadin-dashboard-section-border-radius, var(--vaadin-radius-l));
30+
padding: calc(var(--_gap) - var(--_widget-border-width));
31+
margin-inline: calc(var(--_gap) * -1);
32+
margin-block: var(--_gap);
33+
}
34+
35+
:host([hidden]) {
36+
display: none !important;
37+
}
38+
39+
::slotted(*) {
40+
--_item-column: span min(var(--vaadin-dashboard-widget-colspan, 1), var(--_effective-col-count, var(--_col-count)));
41+
42+
grid-column: var(--_item-column);
43+
--_item-row: span var(--vaadin-dashboard-widget-rowspan, 1);
44+
grid-row: var(--_item-row);
45+
}
46+
47+
header {
48+
grid-column: var(--_section-column);
49+
}
50+
51+
:host::before {
52+
z-index: 2 !important;
53+
}
54+
55+
::slotted(vaadin-dashboard-widget-wrapper) {
56+
display: contents;
57+
}
58+
59+
/* Section states */
60+
61+
:host(:not([editable])) {
62+
--_widget-border-width: 0px;
63+
}
64+
`;
65+
66+
export const dashboardSectionStyles = [sectionStyles, dashboardWidgetAndSectionStyles];

0 commit comments

Comments
 (0)