Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e853dc4
WIP - testing stacked table
Magnus93 Sep 15, 2025
6d7079d
placement work
Magnus93 Sep 15, 2025
2a86670
smaller chevron
Magnus93 Sep 15, 2025
e4e777b
add placement top-center
Magnus93 Sep 15, 2025
c1976d0
placement -> card-area
Magnus93 Sep 15, 2025
35cd714
WIP
Magnus93 Sep 15, 2025
c5c2a02
comment where css vars should go
Magnus93 Sep 15, 2025
e731fc0
Change terminology
Magnus93 Sep 15, 2025
a64d98f
comment to move styling
Magnus93 Sep 15, 2025
e6d32e7
Move expandable-row styling to table
Magnus93 Sep 16, 2025
c2a1e88
,
Magnus93 Sep 16, 2025
12119ed
WIP space between selectors
Magnus93 Sep 16, 2025
b8cbcc5
make use of nested styling in table for cards
Magnus93 Sep 16, 2025
1aed5ef
Move not(.cards) to table
Magnus93 Sep 16, 2025
9ab2e5a
Move all not cards to once block
Magnus93 Sep 16, 2025
117f2c5
remove extra lines
Magnus93 Sep 16, 2025
9d1e8bd
remove empty line
Magnus93 Sep 16, 2025
ac0b7c0
nesting
Magnus93 Sep 16, 2025
a50067b
nesting
Magnus93 Sep 16, 2025
f41d17d
fix selector
Magnus93 Sep 16, 2025
75ca5c4
re nest
Magnus93 Sep 16, 2025
f173098
add card-hidden prop on cell
Magnus93 Sep 16, 2025
f0afe50
update naming
Magnus93 Sep 17, 2025
b7095d6
cardVisibility
Magnus93 Sep 18, 2025
e2528b6
less height for expand button
Magnus93 Sep 18, 2025
816755e
Remove .smoothly-row class
Magnus93 Sep 18, 2025
0101f1b
Remove reduntant syling
Magnus93 Sep 18, 2025
d77d954
target .smoothly-table-cell class instead of element
Magnus93 Sep 18, 2025
b429831
scrollable detail if vertical overflow
Magnus93 Sep 18, 2025
b47638f
change class from content to smoothly-table-cell
Magnus93 Sep 18, 2025
d7306dc
fix padding naming detail
Magnus93 Sep 18, 2025
414d094
fix more css variables for card
Magnus93 Sep 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/assets/style/smoothly.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@

--smoothly-shadow: 0 0 4px 2px rgba(var(--smoothly-color-contrast), 0.25);
--smoothly-shadow-strong: 0 0 4px 4px rgba(var(--smoothly-light-color), 0.25);
--table-width: 100%;
}
8 changes: 8 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,15 @@ export namespace Components {
"tooltip": string;
}
interface SmoothlyTable {
"cardAt"?: string;
"columns": number;
}
interface SmoothlyTableBody {
}
interface SmoothlyTableCell {
"cardArea"?: "checkbox" | "primary" | "status" | "actions";
"cardLabel"?: string;
"cardVisibility": "always" | "opened" | "hidden";
"span"?: number;
}
interface SmoothlyTableDemo {
Expand Down Expand Up @@ -2881,11 +2885,15 @@ declare namespace LocalJSX {
"tooltip"?: string;
}
interface SmoothlyTable {
"cardAt"?: string;
"columns"?: number;
}
interface SmoothlyTableBody {
}
interface SmoothlyTableCell {
"cardArea"?: "checkbox" | "primary" | "status" | "actions";
"cardLabel"?: string;
"cardVisibility"?: "always" | "opened" | "hidden";
"span"?: number;
}
interface SmoothlyTableDemo {
Expand Down
6 changes: 5 additions & 1 deletion src/components/table/cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { Component, h, Host, Prop, VNode } from "@stencil/core"
})
export class SmoothlyTableCell {
@Prop({ reflect: true }) span?: number = 1
@Prop({ reflect: true }) cardLabel?: string
@Prop({ reflect: true }) cardArea?: "checkbox" | "primary" | "status" | "actions"
@Prop({ reflect: true }) cardVisibility: "always" | "opened" | "hidden" = "always"

render(): VNode | VNode[] {
return (
<Host style={{ "--smoothly-table-cell-span": this.span?.toString(10) }}>
<Host class="smoothly-table-cell" style={{ "--smoothly-table-cell-span": this.span?.toString(10) }}>
{typeof this.cardLabel == "string" && <span class="smoothly-card-field-label">{this.cardLabel}</span>}
<slot />
</Host>
)
Expand Down
9 changes: 3 additions & 6 deletions src/components/table/cell/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
:host {
grid-column: span var(--smoothly-table-cell-span, 1);
display: flex;
align-items: center;
padding: 0.5rem 1.1rem;
white-space: nowrap;
:host>.smoothly-card-field-label {
min-width: var(--smoothly-card-field-label-min-width, 12ch);
color: rgb(var(--smoothly-card-label-color, var(--smoothly-medium-color)));
}
6 changes: 3 additions & 3 deletions src/components/table/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export class SmoothlyTableDemo {
return (
<Host>
<smoothly-table-demo-filler-row />
<smoothly-table-demo-group />
<smoothly-table-demo-colspan />
<smoothly-table-demo-simple />
{/* <smoothly-table-demo-group /> */}
{/* <smoothly-table-demo-colspan /> */}
{/* <smoothly-table-demo-simple /> */}
<smoothly-table-demo-nested-no-cell />
<smoothly-table-demo-filtered />
</Host>
Expand Down
33 changes: 24 additions & 9 deletions src/components/table/demo/nested-no-cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class SmoothlyTableDemoNestedNoCell {
return (
<Host>
<smoothly-display type="text" value="Nested" />
<smoothly-table color="primary" columns={8}>
<smoothly-table color="primary" columns={9} card-at="48rem">
<smoothly-table-head>
<smoothly-table-row>
<div>Id</div>
Expand All @@ -22,20 +22,35 @@ export class SmoothlyTableDemoNestedNoCell {
<div>EyeColor</div>
<div>Gender</div>
<div>Company</div>
<div></div>
</smoothly-table-row>
</smoothly-table-head>
<smoothly-table-body>
{data.map(entry => (
<smoothly-table-expandable-row>
<smoothly-table-demo-nested-no-cell-inner color="secondary" data={entry.friends} slot={"detail"} />
<div>{entry.id}</div>
<div>{entry.registered}</div>
<div>{entry.name}</div>
<div>{entry.age}</div>
<div>{entry.balance}</div>
<div>{entry.eyeColor}</div>
<div>{entry.gender}</div>
<div>{entry.company}</div>
<smoothly-table-cell card-label="Id">{entry.id}</smoothly-table-cell>
<smoothly-table-cell card-label="Registered">{entry.registered}</smoothly-table-cell>
<smoothly-table-cell card-area="primary" card-label="Name">
{entry.name}
</smoothly-table-cell>
<smoothly-table-cell card-label="Age">{entry.age}</smoothly-table-cell>
<smoothly-table-cell card-label="Balance" card-visibility="opened">
{entry.balance}
</smoothly-table-cell>
<smoothly-table-cell card-area="status" card-label="EyeColor">
{entry.eyeColor}
</smoothly-table-cell>
<smoothly-table-cell card-visibility="hidden">{entry.gender}</smoothly-table-cell>
<smoothly-table-cell card-label="Company">{entry.company}</smoothly-table-cell>
<smoothly-table-cell card-area="actions">
<smoothly-icon
name="trash-bin-outline"
color="danger"
fill="outline"
onClick={() => console.log("Delete", entry.name)}
/>
</smoothly-table-cell>
</smoothly-table-expandable-row>
))}
</smoothly-table-body>
Expand Down
8 changes: 4 additions & 4 deletions src/components/table/demo/nested-no-cell/inner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export class SmoothlyTableDemoNestedNoCellInner {
<smoothly-table-body>
{this.data?.map(entry => (
<smoothly-table-expandable-row>
<div>{entry.id}</div>
<div>{entry.name}</div>
<div>{entry.age}</div>
<div>{entry.balance}</div>
<div class="smoothly-table-cell">{entry.id}</div>
<div class="smoothly-table-cell">{entry.name}</div>
<div class="smoothly-table-cell">{entry.age}</div>
<div class="smoothly-table-cell">{entry.balance}</div>
</smoothly-table-expandable-row>
))}
</smoothly-table-body>
Expand Down
2 changes: 1 addition & 1 deletion src/components/table/demo/nested-no-cell/inner/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:host {
display: block;
margin: 1em auto;
width: 60%;
max-width: min(30rem, 100%);
}
17 changes: 0 additions & 17 deletions src/components/table/demo/simple/simple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,6 @@ export class SmoothlyTableDemoSimple {
</smoothly-table-expandable-cell>
</smoothly-table-row>
))}
<smoothly-table-expandable-row>
<a class="smoothly-row" href="#" onClick={e => !e.button && e.preventDefault()} target="_blank">
<smoothly-table-cell>Cell1 in expandable row</smoothly-table-cell>
<smoothly-table-cell>Cell2 in expandable row</smoothly-table-cell>
</a>
<div slot={"detail"}>
Content
<br />
of
<br />
the
<br />
expandable
<br />
row
</div>
</smoothly-table-expandable-row>
<smoothly-table-row>
<smoothly-table-cell>Cell5</smoothly-table-cell>
<smoothly-table-expandable-cell>
Expand Down
3 changes: 2 additions & 1 deletion src/components/table/demo/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
max-width: 80rem;
width: 100%;
margin: auto;
padding: 2rem;
padding-block: 2rem;
padding-inline: 0.5rem;
}
2 changes: 1 addition & 1 deletion src/components/table/expandable/arrow.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

:host::slotted(smoothly-table-cell:first-child:hover)::before,
:host::slotted(smoothly-table-cell:first-child:has(~ smoothly-table-cell:hover))::before,
:host>div.content:hover:first-child::before {
:host>div.smoothly-table-cell:hover:first-child::before {
opacity: 1;
border-bottom: 1px solid rgb(var(--smoothly-color-contrast));
border-right: 1px solid rgb(var(--smoothly-color-contrast));
Expand Down
2 changes: 1 addition & 1 deletion src/components/table/expandable/cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SmoothlyTableExpandableCell {
<Host
style={{ "--smoothly-table-cell-span": this.span?.toString(10) }}
onClick={(e: MouseEvent) => this.clickHandler(e)}>
<div class={"content"}>
<div class={"smoothly-table-cell"}>
<slot />
</div>
<div class={"detail"} ref={(el: HTMLDivElement) => (this.detailElement = el)}>
Expand Down
23 changes: 12 additions & 11 deletions src/components/table/expandable/cell/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
display: contents;
}

:host>div {
padding: 0.5rem 1.1rem;
:host > .smoothly-table-cell {
padding-inline: var(--smoothly-table-cell-padding-inline, 1.1rem);
min-height: var(--smoothly-table-cell-min-height, 2.75rem);
}

:host>div.content {
:host > div.smoothly-table-cell {
grid-column: span var(--smoothly-table-cell-span, 1);
display: flex;
box-sizing: border-box;
Expand All @@ -25,37 +26,37 @@
}
}

:host[open]>div.content {
:host[open] > div.smoothly-table-cell {
@include arrow-open;
}

:host>div:first-child {
:host > div:first-child {
cursor: pointer;
}

:host>div.detail {
:host > div.detail {
grid-column: 1 / -1;
grid-row: 2;
position: relative;
}

:host[open]>div.content {
:host[open] > div.smoothly-table-cell {
box-shadow: 1px 1px 1px -1px rgb(var(--smoothly-table-border)) inset,
-3px -1px 1px -3px rgb(var(--smoothly-table-border)) inset;
}

:host[open]>div {
:host[open] > div {
background-color: rgb(var(--smoothly-table-expanded-background));
color: rgb(var(--smoothly-table-expanded-foreground));
stroke: rgb(var(--smoothly-table-expanded-foreground));
fill: rgb(var(--smoothly-table-expanded-foreground));
}

:host:not([open])>div.detail {
:host:not([open]) > div.detail {
display: none;
}

:host>div.detail::before {
:host > div.detail::before {
content: "";
position: absolute;
display: flex;
Expand All @@ -70,7 +71,7 @@
0px 0px 1px 0px rgb(var(--smoothly-table-border));
}

:host>div.detail::after {
:host > div.detail::after {
content: "";
position: absolute;
display: flex;
Expand Down
31 changes: 25 additions & 6 deletions src/components/table/expandable/row/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,34 @@ import { Component, Event, EventEmitter, h, Host, Prop, VNode, Watch } from "@st
scoped: true,
})
export class SmoothlyTableExpandableRow {
private div?: HTMLDivElement
private detailElement?: HTMLDivElement
private expandButton?: HTMLDivElement
@Prop({ mutable: true, reflect: true }) open = false
@Event() smoothlyTableExpandableRowChange: EventEmitter<boolean>

isStacked(eventPath: EventTarget[]): boolean {
for (const el of eventPath) {
if (el instanceof HTMLElement && el.tagName.toLowerCase() == "smoothly-table") {
return el.classList.contains("cards")
}
}
return false
}

clickHandler(event: MouseEvent): void {
const clickedOnDetail = this.div && event.composedPath().includes(this.div)
if (!clickedOnDetail) {
const selection = window.getSelection()?.toString().trim()
if ((selection?.length ?? 0) == 0)
const isStacked = this.isStacked(event.composedPath())
if (isStacked) {
const clickedOnExpandButton = this.expandButton && event.composedPath().includes(this.expandButton)
if (clickedOnExpandButton) {
this.open = !this.open
}
} else {
const clickedOnDetail = this.detailElement && event.composedPath().includes(this.detailElement)
if (!clickedOnDetail) {
const selection = window.getSelection()?.toString().trim()
if ((selection?.length ?? 0) == 0)
this.open = !this.open
}
}
}
@Watch("open")
Expand All @@ -27,9 +45,10 @@ export class SmoothlyTableExpandableRow {
return (
<Host onClick={(e: MouseEvent) => this.clickHandler(e)}>
<slot />
<div class={"detail"} ref={e => (this.div = e)}>
<div class={"detail"} ref={e => (this.detailElement = e)}>
<slot name="detail" />
</div>
<div ref={e => (this.expandButton = e)} class="smoothly-expand-button"></div>
</Host>
)
}
Expand Down
Loading