feat(layout): introduce dees-tile component for unified tile layout

This commit is contained in:
2026-04-03 11:49:58 +00:00
parent 472132e8cf
commit 6e5def5708
10 changed files with 296 additions and 109 deletions

View File

@@ -0,0 +1,67 @@
import { html, css, cssManager } from '@design.estate/dees-element';
import './dees-tile.js';
export const demoFunc = () => {
return html`
<dees-demowrapper>
<style>
${css`
.demoBox {
background: ${cssManager.bdTheme('hsl(0 0% 95%)', 'hsl(0 0% 9%)')};
padding: 40px;
display: flex;
flex-direction: column;
gap: 24px;
}
.tile-demo-content {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
color: ${cssManager.bdTheme('hsl(0 0% 45%)', 'hsl(0 0% 55%)')};
font-size: 13px;
}
.footer-stats {
display: flex;
align-items: center;
gap: 24px;
font-size: 11px;
width: 100%;
}
.footer-stats .stat {
display: flex;
align-items: center;
gap: 6px;
}
.footer-stats .stat strong {
color: ${cssManager.bdTheme('hsl(0 0% 15%)', 'hsl(0 0% 90%)')};
}
`}
</style>
<div class="demoBox">
<dees-tile heading="Simple Tile" style="height: 200px;">
<div class="tile-demo-content">Content area with rounded corners</div>
</dees-tile>
<dees-tile heading="Tile with Footer" style="height: 200px;">
<div class="tile-demo-content">Content goes here</div>
<div slot="footer" class="footer-stats">
<span class="stat">latest <strong>42</strong></span>
<span class="stat">min <strong>12</strong></span>
<span class="stat">max <strong>87</strong></span>
<span class="stat">avg <strong>45.3</strong></span>
</div>
</dees-tile>
<dees-tile style="height: 200px;">
<div slot="header" style="display:flex;align-items:center;gap:12px;width:100%;">
<span style="font-weight:500;">Custom Header</span>
<input type="text" placeholder="Search..." style="flex:1;max-width:200px;padding:2px 8px;border:1px solid;border-radius:4px;font-size:12px;background:transparent;color:inherit;border-color:inherit;">
</div>
<div class="tile-demo-content">Custom header slot with search input</div>
</dees-tile>
</div>
</dees-demowrapper>
`;
};

View File

@@ -0,0 +1,139 @@
import {
customElement,
DeesElement,
html,
css,
cssManager,
property,
state,
type TemplateResult,
} from '@design.estate/dees-element';
import { demoFunc } from './dees-tile.demo.js';
import { cssGeistFontFamily } from '../../00fonts.js';
import { themeDefaultStyles } from '../../00theme.js';
declare global {
interface HTMLElementTagNameMap {
'dees-tile': DeesTile;
}
}
/**
* dees-tile — the unified "rounded on rounded" tile frame.
*
* RESPONSIBILITIES (what this component owns):
* 1. Outer card — border, border-radius, background, overflow clipping
* 2. Flex column layout — stacking header / content / footer vertically
* 3. Content inset — the rounded inner area with border-top and border-bottom
* 4. Default heading — styled 32px heading text when no slot="header" is provided
* 5. Footer visibility — auto-hides footer area when slot="footer" is empty
*
* NOT RESPONSIBILITIES (what consumer components own):
* - Header/footer height, padding, font-size, colors when using custom slots
* - Content layout (absolute, flex, grid — consumer decides)
* - Any semantic meaning of header/footer content
*
* The header and footer slots are BARE containers (just flex-shrink: 0).
* The slotted content fully controls its own appearance.
* Only the default heading fallback (.tile-heading) carries tile-level styling.
*/
@customElement('dees-tile')
export class DeesTile extends DeesElement {
public static demo = demoFunc;
public static demoGroups = ['Layout'];
@property({ type: String })
accessor heading: string = '';
@state()
accessor hasFooter: boolean = false;
public static styles = [
themeDefaultStyles,
cssManager.defaultStyles,
css`
:host {
display: flex;
flex-direction: column;
font-family: ${cssGeistFontFamily};
color: ${cssManager.bdTheme('hsl(0 0% 3.9%)', 'hsl(0 0% 98%)')};
}
/* --- The frame --- */
.tile-outer {
position: relative;
flex: 1;
min-height: 0;
background: ${cssManager.bdTheme('hsl(0 0% 100%)', 'hsl(0 0% 3.9%)')};
border: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
border-radius: 8px;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* --- Header: bare container, only the default heading gets styled --- */
.tile-header {
flex-shrink: 0;
}
.tile-heading {
height: 32px;
line-height: 32px;
padding: 0 16px;
font-size: 14px;
font-weight: 500;
letter-spacing: -0.01em;
color: ${cssManager.bdTheme('hsl(0 0% 20%)', 'hsl(0 0% 63.9%)')};
}
/* --- Content: the rounded inset --- */
.tile-content {
flex: 1;
position: relative;
border-radius: 8px;
border-top: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
border-bottom: 1px solid ${cssManager.bdTheme('hsl(0 0% 89.8%)', 'hsl(0 0% 14.9%)')};
overflow: hidden;
}
.tile-content.no-footer {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
/* --- Footer: bare container, consumer styles the slotted content --- */
.tile-footer {
flex-shrink: 0;
}
.tile-footer.hidden {
display: none;
}
`,
];
public render(): TemplateResult {
return html`
<div class="tile-outer">
<div class="tile-header">
<slot name="header">
<div class="tile-heading">${this.heading}</div>
</slot>
</div>
<div class="tile-content ${!this.hasFooter ? 'no-footer' : ''}">
<slot></slot>
</div>
<div class="tile-footer ${!this.hasFooter ? 'hidden' : ''}">
<slot name="footer" @slotchange=${this.onFooterSlotChange}></slot>
</div>
</div>
`;
}
private onFooterSlotChange(e: Event) {
const slot = e.target as HTMLSlotElement;
this.hasFooter = slot.assignedNodes({ flatten: true }).length > 0;
}
}

View File

@@ -0,0 +1 @@
export * from './dees-tile.js';