diff --git a/web-components/customize-columns/src/basic.ts b/web-components/customize-columns/src/basic.ts index 1c00c63..7e3b833 100644 --- a/web-components/customize-columns/src/basic.ts +++ b/web-components/customize-columns/src/basic.ts @@ -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'; @@ -72,7 +70,6 @@ export class MyBasicTable extends LitElement { this._tearsheetOpen = !this._tearsheetOpen; } - render() { const table = this.tableController.table({ columns, @@ -158,7 +155,33 @@ export class MyBasicTable extends LitElement { @cds-tearsheet-closed=${() => this._tearsheetOpen = false} > Customize column order - content + ${repeat( + table.getHeaderGroups(), + headerGroup => headerGroup.id, + headerGroup => + html`
+ ${repeat( + headerGroup.headers, + header => header.id, + header => + html`
+ ${header.isPlaceholder + ? null + : flexRender( + header.column.columnDef.header, + header.getContext() + )} +
` + )}
` + )} + this._tearsheetOpen = false} + slot="actions" + kind=${'secondary'}>Cancel + this._tearsheetOpen = false} + slot="actions" + kind=${'primary'}>Save ` } @@ -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; + } ` }