Skip to content

Commit

Permalink
fix(table): Allow wrapping text in table-header and table-cell (#7665)
Browse files Browse the repository at this point in the history
## Summary
Adds styles to allow long text in header or table cell to wrap. Adds
story.
  • Loading branch information
macandcheese authored Sep 2, 2023
1 parent 851bedb commit 15cb2bf
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

td {
@apply text-start focus-base align-middle text-color-1;
@apply text-start focus-base align-middle text-color-1 whitespace-normal;
background: var(--calcite-internal-table-cell-background);
border-inline-end: 1px solid var(--calcite-ui-border-3);
font-size: var(--calcite-internal-table-cell-font-size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

th {
@apply text-color-1 focus-base text-start font-medium align-top;
@apply text-color-1 focus-base text-start font-medium align-top whitespace-normal;
font-size: var(--calcite-internal-table-cell-font-size);
border-inline-end: 1px solid var(--calcite-internal-table-header-border-color);
border-block-end: 1px solid var(--calcite-internal-table-header-border-color);
Expand Down
75 changes: 75 additions & 0 deletions packages/calcite-components/src/components/table/table.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,81 @@ export const selectionModeMultipleAndSelectedOnLoadWithMultipleFooterAndHeader_T
</calcite-table-row>
</calcite-table>`;

export const LongWrappingTextContent_TestOnly = (): string => html` <calcite-table
numbered
caption="Long cell wrapping table"
>
<calcite-table-row slot="table-header">
<calcite-table-header
heading="Heading or a longer wrapping text that goes here"
description="Description"
></calcite-table-header>
<calcite-table-header
heading="Heading or a longer wrapping text that goes here"
description="Description"
></calcite-table-header>
<calcite-table-header
heading="Heading or a longer wrapping text that goes here and maybe one is longer"
description="Description"
></calcite-table-header>
<calcite-table-header
heading="Heading or a longer wrapping text that goes here"
description="Description or a longer bit of text that can go here"
></calcite-table-header>
</calcite-table-row>
<calcite-table-row>
<calcite-table-cell>A slot for adding a calcite-action-bar or other components to display.</calcite-table-cell>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not "none" and one or
more calcite-table-row is selected.</calcite-table-cell
>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not "none" and one or
more calcite-table-row is selected.</calcite-table-cell
>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not
"none".</calcite-table-cell
>
</calcite-table-row>
<calcite-table-row>
<calcite-table-cell>A slot for adding a calcite-action-bar or other components to display.</calcite-table-cell>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not "none" and one or
more calcite-table-row is selected.</calcite-table-cell
>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not "none" and one or
more calcite-table-row is selected.</calcite-table-cell
>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not
"none".</calcite-table-cell
>
</calcite-table-row>
<calcite-table-row>
<calcite-table-cell>A slot for adding a calcite-action-bar or other components to display.</calcite-table-cell>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not "none" and one or
more calcite-table-row is selected.</calcite-table-cell
>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not "none" and one or
more calcite-table-row is selected.</calcite-table-cell
>
<calcite-table-cell
>A slot for adding a calcite-action-bar or other components to display when selectionMode is not
"none".</calcite-table-cell
>
</calcite-table-row>
<calcite-table-row slot="table-footer">
<calcite-table-cell>foot</calcite-table-cell>
<calcite-table-cell>foot</calcite-table-cell>
<calcite-table-cell>foot</calcite-table-cell>
<calcite-table-cell>foot</calcite-table-cell>
</calcite-table-row>
</calcite-table>`;

export const localized_TestOnly = (): string => html`<calcite-table
lang="ar"
numbering-system="arab"
Expand Down

0 comments on commit 15cb2bf

Please sign in to comment.