From 10c7ff730033b09c85112107c42daec232a5d854 Mon Sep 17 00:00:00 2001 From: WillianLomeu Date: Thu, 5 Sep 2024 20:23:41 -0300 Subject: [PATCH] feat(table): added justify content prop in table col --- src/components.d.ts | 6 ++++++ src/components/table/table-cell/readme.md | 9 +++++---- .../table/table-cell/table-cell.scss | 18 +++++++++++++++--- src/components/table/table-cell/table-cell.tsx | 11 +++++++---- .../table/table-header-cell/readme.md | 9 +++++---- .../table-header-cell/table-header-cell.scss | 12 ++++++++++++ .../table-header-cell/table-header-cell.tsx | 9 ++++++--- src/components/table/table/table.stories.jsx | 14 +++++++++----- 8 files changed, 65 insertions(+), 23 deletions(-) diff --git a/src/components.d.ts b/src/components.d.ts index 4b029510..fd2ce8fe 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -60,6 +60,8 @@ import { sidebarBackground, sidebarPosition, sidebarType } from "./components/si import { Shape as Shape1 } from "./components/skeleton/skeleton"; import { StepOption, typeRange } from "./components/slider/slider-interface"; import { SwitchSize } from "./components/switch/switch"; +import { JustifyContent } from "./components/table/table-cell/table-cell"; +import { JustifyContent as JustifyContent1 } from "./components/table/table-header-cell/table-header-cell"; import { Overflow } from "./components/tabs/tab (depreciated)/tabs-interface"; import { Themes } from "./components/theme-provider/theme-provider"; import { ActionType, ButtonActionType, CreateToastType, PositionType, VariantType } from "./components/toast/toast-interface"; @@ -2484,6 +2486,7 @@ export namespace Components { interface BdsTableBody { } interface BdsTableCell { + "justifyContent": JustifyContent; "sortable": boolean; "type"?: string; } @@ -2503,6 +2506,7 @@ export namespace Components { } interface BdsTableTh { "arrow": string; + "justifyContent": JustifyContent; "sortable": boolean; } interface BdsTabs { @@ -6251,6 +6255,7 @@ declare namespace LocalJSX { interface BdsTableBody { } interface BdsTableCell { + "justifyContent"?: JustifyContent; "sortable"?: boolean; "type"?: string; } @@ -6270,6 +6275,7 @@ declare namespace LocalJSX { } interface BdsTableTh { "arrow"?: string; + "justifyContent"?: JustifyContent; "sortable"?: boolean; } interface BdsTabs { diff --git a/src/components/table/table-cell/readme.md b/src/components/table/table-cell/readme.md index 02da1159..e8d42344 100644 --- a/src/components/table/table-cell/readme.md +++ b/src/components/table/table-cell/readme.md @@ -7,10 +7,11 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| ---------- | ---------- | ----------- | --------- | -------- | -| `sortable` | `sortable` | | `boolean` | `false` | -| `type` | `type` | | `string` | `'text'` | +| Property | Attribute | Description | Type | Default | +| ---------------- | ----------------- | ----------- | ------------------------------- | -------- | +| `justifyContent` | `justify-content` | | `"center" \| "left" \| "right"` | `'left'` | +| `sortable` | `sortable` | | `boolean` | `false` | +| `type` | `type` | | `string` | `'text'` | ## Dependencies diff --git a/src/components/table/table-cell/table-cell.scss b/src/components/table/table-cell/table-cell.scss index 2b343be9..b5458cd9 100644 --- a/src/components/table/table-cell/table-cell.scss +++ b/src/components/table/table-cell/table-cell.scss @@ -16,19 +16,31 @@ flex-wrap: wrap; } -.dense-cell { +.dense_cell { margin: 0; } -.cell-custom { +.cell_custom { gap: 8px; } -.cell-action { +.cell_action { flex-direction: row; gap: 8px; } +.justify { + &--left { + justify-content: flex-start; + } + &--center { + justify-content: center; + } + &--right { + justify-content: flex-end; + } +} + :host:first-child { padding-left: 16px; } diff --git a/src/components/table/table-cell/table-cell.tsx b/src/components/table/table-cell/table-cell.tsx index b1c5d019..204a22d3 100644 --- a/src/components/table/table-cell/table-cell.tsx +++ b/src/components/table/table-cell/table-cell.tsx @@ -2,6 +2,8 @@ import { Component, h, Host, Prop, Element, State } from '@stencil/core'; export type IconType = 'text' | 'custom' | 'emoji' | 'collapse'; +export type JustifyContent = 'left' | 'center' | 'right'; + @Component({ tag: 'bds-table-cell', styleUrl: 'table-cell.scss', @@ -12,24 +14,25 @@ export class TableCell { @State() isDense = false; @Prop() type?: string = 'text'; @Prop() sortable = false; + @Prop() justifyContent: JustifyContent = 'left'; renderContent(): HTMLElement { return this.type === 'custom' ? ( -
+
) : this.type === 'text' ? ( -
+
) : this.type === 'action' ? ( -
+
) : this.type === 'collapse' ? ( - + ) : ( diff --git a/src/components/table/table-header-cell/readme.md b/src/components/table/table-header-cell/readme.md index c356261b..8c3ca2a5 100644 --- a/src/components/table/table-header-cell/readme.md +++ b/src/components/table/table-header-cell/readme.md @@ -7,10 +7,11 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| ---------- | ---------- | ----------- | --------- | ------- | -| `arrow` | `arrow` | | `string` | `''` | -| `sortable` | `sortable` | | `boolean` | `false` | +| Property | Attribute | Description | Type | Default | +| ---------------- | ----------------- | ----------- | ------------------------------- | -------- | +| `arrow` | `arrow` | | `string` | `''` | +| `justifyContent` | `justify-content` | | `"center" \| "left" \| "right"` | `'left'` | +| `sortable` | `sortable` | | `boolean` | `false` | ## Dependencies diff --git a/src/components/table/table-header-cell/table-header-cell.scss b/src/components/table/table-header-cell/table-header-cell.scss index daef080a..dc146d6d 100644 --- a/src/components/table/table-header-cell/table-header-cell.scss +++ b/src/components/table/table-header-cell/table-header-cell.scss @@ -15,6 +15,18 @@ } } +.justify { + &--left { + justify-content: flex-start; + } + &--center { + justify-content: center; + } + &--right { + justify-content: flex-end; + } +} + .dense-th { min-height: 48px; height: auto; diff --git a/src/components/table/table-header-cell/table-header-cell.tsx b/src/components/table/table-header-cell/table-header-cell.tsx index 749bc287..12c49a2e 100644 --- a/src/components/table/table-header-cell/table-header-cell.tsx +++ b/src/components/table/table-header-cell/table-header-cell.tsx @@ -1,5 +1,6 @@ import { Component, h, Host, Prop, Element, State } from '@stencil/core'; +export type JustifyContent = 'left' | 'center' | 'right'; @Component({ tag: 'bds-table-th', styleUrl: 'table-header-cell.scss', @@ -10,6 +11,7 @@ export class TableHeaderCell { @State() isDense = false; @Prop() sortable = false; @Prop() arrow = ''; + @Prop() justifyContent: JustifyContent = 'left'; componentWillLoad() { const bdsTable = this.element.closest('bds-table'); @@ -25,6 +27,7 @@ export class TableHeaderCell { th_cell: true, [`th_cell--sortable-${this.sortable}`]: true, 'dense-th': this.isDense, + [`justify--${this.justifyContent}`]:true }} > @@ -35,9 +38,9 @@ export class TableHeaderCell { size="small" name={this.arrow === 'asc' ? 'arrow-down' : this.arrow === 'dsc' ? 'arrow-up' : ''} > - ) : ( -
- )} + ) : '' + //
+ }
); diff --git a/src/components/table/table/table.stories.jsx b/src/components/table/table/table.stories.jsx index d4e15096..41e01f57 100644 --- a/src/components/table/table/table.stories.jsx +++ b/src/components/table/table/table.stories.jsx @@ -63,16 +63,20 @@ export const Properties = (args) => { - {heading.map((item, index) => { - return {item}; - })} + Identificador + Produtos + Valor + Disponibilidade + Marca + Estoque + Categoria {DATA.map((row, index) => { return ( - + {row.id} @@ -91,7 +95,7 @@ export const Properties = (args) => { {row.marca} - + {row.estoque}