Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/dashboard styling #8236

Merged
merged 12 commits into from
Nov 29, 2024
11 changes: 8 additions & 3 deletions packages/dashboard/src/vaadin-dashboard-layout-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const DashboardLayoutMixin = (superClass) =>
:host {
display: block;
overflow: hidden;
width: 100%;
}

:host([hidden]) {
Expand All @@ -36,13 +37,20 @@ export const DashboardLayoutMixin = (superClass) =>

#grid {
box-sizing: border-box;

/* Padding around dashboard edges */
--_vaadin-dashboard-default-padding: 1rem;
--_vaadin-dashboard-padding: max(
0px,
var(--vaadin-dashboard-padding, var(--_vaadin-dashboard-default-padding))
);
padding: var(--_vaadin-dashboard-padding);

/* Gap between widgets */
--_vaadin-dashboard-default-gap: 1rem;
--_vaadin-dashboard-gap: max(0px, var(--vaadin-dashboard-gap, var(--_vaadin-dashboard-default-gap)));
gap: var(--_vaadin-dashboard-gap);

/* Default min and max column widths */
--_vaadin-dashboard-default-col-min-width: 25rem;
--_vaadin-dashboard-default-col-max-width: 1fr;
Expand Down Expand Up @@ -86,9 +94,6 @@ export const DashboardLayoutMixin = (superClass) =>
);

grid-auto-rows: var(--_vaadin-dashboard-row-height);
--_vaadin-dashboard-default-gap: 1rem;
--_vaadin-dashboard-gap: max(0px, var(--vaadin-dashboard-gap, var(--_vaadin-dashboard-default-gap)));
gap: var(--_vaadin-dashboard-gap);
}

::slotted(*) {
Expand Down
4 changes: 2 additions & 2 deletions packages/dashboard/src/vaadin-dashboard-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ class DashboardWidget extends DashboardItemMixin(ElementMixin(ThemableMixin(Poly
content: '';
z-index: 2;
position: absolute;
inset-inline-start: 0;
top: 0;
top: -1px;
width: var(--_vaadin-dashboard-widget-resizer-width, 0);
height: var(--_vaadin-dashboard-widget-resizer-height, 0);
background: rgba(0, 0, 0, 0.1);
border-radius: inherit;
}
`,
super.styles,
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/test/dashboard-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const [defaultSpacing, defaultMinimumColumnWidth] = (() => {
document.body.appendChild(div);
div.style.width = '1rem';
const minColWidth = div.offsetWidth * 25;
div.style.width = 'var(--lumo-space-l)';
div.style.width = 'var(--lumo-space-m)';
const spacing = div.offsetWidth;
div.remove();
return [spacing, minColWidth];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab

export const dashboardLayoutStyles = css`
#grid {
--_vaadin-dashboard-default-gap: var(--lumo-space-l);
--_vaadin-dashboard-default-padding: var(--lumo-space-l);
--_vaadin-dashboard-default-gap: var(--lumo-space-m);
--_vaadin-dashboard-default-padding: var(--lumo-space-m);
}
`;

Expand Down
66 changes: 65 additions & 1 deletion packages/dashboard/theme/lumo/vaadin-dashboard-section-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,78 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
import { dashboardWidgetAndSection } from './vaadin-dashboard-widget-styles.js';

const section = css`
/* stylelint-disable rule-empty-line-before */

:host {
--_focus-ring-spacing-max-offset: calc(min(var(--_vaadin-dashboard-gap), var(--_vaadin-dashboard-padding)) / 2);
--_section-outline-offset: calc(min(var(--_vaadin-dashboard-gap), var(--_vaadin-dashboard-padding)) / 3);
--_focus-ring-offset: calc((var(--_section-outline-offset) - var(--_focus-ring-width)));
border-radius: var(--lumo-border-radius-l);
}

header {
margin-bottom: calc(-1 * var(--_section-outline-offset));
line-height: var(--lumo-line-height-s);
padding-inline: var(--lumo-space-s);
min-height: var(--lumo-size-l);
}

[part='title'] {
font-size: var(--lumo-font-size-xl);
font-weight: 600;
}

/* Section states */

:host([editable]) {
outline: 1px solid var(--lumo-contrast-10pct);
outline-offset: calc(var(--_section-outline-offset) - 1px);
background: var(--lumo-contrast-5pct);
box-shadow: 0 0 0 var(--_section-outline-offset) var(--lumo-contrast-5pct);
}
:host([editable]) header {
padding-inline: var(--lumo-space-xs);
}

:host([focused])::after {
content: '';
display: block;
position: absolute;
inset: 0;
border-radius: var(--lumo-border-radius-l);
z-index: 9;
outline: var(--_focus-ring-width) solid var(--_focus-ring-color);
outline-offset: var(--_focus-ring-offset);
}

:host([selected]) {
background: var(--lumo-primary-color-10pct);
box-shadow: 0 0 0 var(--_section-outline-offset) var(--lumo-primary-color-10pct);
}
:host([selected]:not([focused])) {
outline-color: var(--lumo-primary-color-50pct);
}

:host([move-mode]) ::slotted(*) {
--_vaadin-dashboard-widget-opacity: 0.3;
--_vaadin-dashboard-widget-filter: blur(10px);
}

:host([dragging]) {
background: var(--vaadin-dashboard-drop-target-background-color);
outline: var(--vaadin-dashboard-drop-target-border);
box-shadow: 0 0 0 var(--_section-outline-offset) var(--vaadin-dashboard-drop-target-background-color);
}

/* Accessible move mode controls */

[part~='move-backward-button'] {
inset-inline-start: calc(-1 * var(--_section-outline-offset));
}

[part~='move-forward-button'] {
inset-inline-end: calc(-1 * var(--_section-outline-offset));
transform: translateY(-50%);
}
`;

registerStyles('vaadin-dashboard-section', [dashboardWidgetAndSection, section], {
Expand Down
Loading