Skip to content

Commit

Permalink
Merge pull request #4 from matthewgallo/tearsheet-updates
Browse files Browse the repository at this point in the history
Customize columns (web component):Tearsheet updates
  • Loading branch information
matthewgallo authored Sep 20, 2024
2 parents 6d55449 + e83bcf1 commit ed920dc
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions web-components/customize-columns/src/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import '@carbon/web-components/es/components/button/index.js';
import '@carbon/web-components/es/components/tearsheet/index.js';
import Column from '@carbon/web-components/es/icons/column/16';
import { CDSTableToolbarSearch } from '@carbon/web-components/es';
// import { DragDropManager } from '@dnd-kit/dom';
// import { Sortable } from '@dnd-kit/dom/sortable';

import { makeData } from './makeData';

Expand Down Expand Up @@ -72,7 +70,6 @@ export class MyBasicTable extends LitElement {
this._tearsheetOpen = !this._tearsheetOpen;
}


render() {
const table = this.tableController.table({
columns,
Expand Down Expand Up @@ -158,7 +155,33 @@ export class MyBasicTable extends LitElement {
@cds-tearsheet-closed=${() => this._tearsheetOpen = false}
>
<span slot='title'>Customize column order</span>
content
${repeat(
table.getHeaderGroups(),
headerGroup => headerGroup.id,
headerGroup =>
html`<div class="drag-wrapper">
${repeat(
headerGroup.headers,
header => header.id,
header =>
html` <div class="item">
${header.isPlaceholder
? null
: flexRender(
header.column.columnDef.header,
header.getContext()
)}
</div>`
)}</div>`
)}
<cds-button
@click=${() => this._tearsheetOpen = false}
slot="actions"
kind=${'secondary'}>Cancel</cds-button>
<cds-button
@click=${() => this._tearsheetOpen = false}
slot="actions"
kind=${'primary'}>Save</cds-button>
</cds-tearsheet>
`
}
Expand All @@ -175,6 +198,34 @@ export class MyBasicTable extends LitElement {
.customize-col-icon {
fill: var(--cds-icon-primary)
}
.drag-wrapper {
gap: 2px;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.item {
display: flex;
align-items: center;
padding: 0 1rem;
border: none;
min-height: 3rem;
width: 100%;
transition: transform 0.3s ease, box-shadow 0.3s ease;
cursor: hand;
border-bottom: 1px solid var(--cds-border-subtle);
}
.dragging-item {
border: 2px solid blue;
opacity: 1;
}
.ghost-item {
opacity: 0;
}
`
}

Expand Down

0 comments on commit ed920dc

Please sign in to comment.