From d1e3ecb04a94c11bfa987b491001128098713d72 Mon Sep 17 00:00:00 2001 From: mollykreis <20542556+mollykreis@users.noreply.github.com> Date: Thu, 25 Jul 2024 12:13:05 -0500 Subject: [PATCH 01/24] Add attribute to make the table height fit to the number of rows --- packages/nimble-components/src/table/index.ts | 3 +++ packages/nimble-components/src/table/styles.ts | 9 ++++++++- packages/nimble-components/src/table/template.ts | 10 +++++----- packages/storybook/src/nimble/table/table.stories.ts | 3 +++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/nimble-components/src/table/index.ts b/packages/nimble-components/src/table/index.ts index 2e480f3fdb..30e8533bb2 100644 --- a/packages/nimble-components/src/table/index.ts +++ b/packages/nimble-components/src/table/index.ts @@ -87,6 +87,9 @@ export class Table< @attr({ attribute: 'selection-mode' }) public selectionMode: TableRowSelectionMode = TableRowSelectionMode.none; + @attr({ attribute: 'fit-height-to-rows', mode: 'boolean' }) + public fitHeightToRows = false; + /** * @internal */ diff --git a/packages/nimble-components/src/table/styles.ts b/packages/nimble-components/src/table/styles.ts index 4fc0dec644..88d5ae6e65 100644 --- a/packages/nimble-components/src/table/styles.ts +++ b/packages/nimble-components/src/table/styles.ts @@ -10,7 +10,8 @@ import { mediumPadding, standardPadding, tableRowBorderColor, - borderHoverColor + borderHoverColor, + controlHeight } from '../theme-provider/design-tokens'; import { Theme } from '../theme-provider/types'; import { hexToRgbaCssColor } from '../utilities/style/colors'; @@ -27,6 +28,12 @@ export const styles = css` height: 480px; --ni-private-column-divider-width: 2px; --ni-private-column-divider-padding: 3px; + + background: lightblue; + } + + :host([fit-height-to-rows]) { + height: min(calc(var(--ni-private-table-scroll-height) + ${controlHeight}), calc(100 * ${controlHeight})); } :host(${focusVisible}) { diff --git a/packages/nimble-components/src/table/template.ts b/packages/nimble-components/src/table/template.ts index 32ae5addd7..a8170798da 100644 --- a/packages/nimble-components/src/table/template.ts +++ b/packages/nimble-components/src/table/template.ts @@ -39,10 +39,8 @@ export const template = html