diff --git a/.storybook/helpers/common.ts b/.storybook/helpers/common.ts index 74eb15f466..498e1013c8 100644 --- a/.storybook/helpers/common.ts +++ b/.storybook/helpers/common.ts @@ -12,7 +12,7 @@ import { StoryContext } from '@storybook/angular'; export const CommonModules = [CommonModule, BrowserAnimationsModule, FormsModule, ReactiveFormsModule]; -export function removeFocusOutline({ canvasElement }: StoryContext) { +export function removeFocusOutline({ canvasElement }: Pick) { // remove keyboard focus outline from focused element (e.g. modal title) canvasElement.querySelector(':focus')?.blur(); } diff --git a/.storybook/stories/datagrid/datagrid-detail.stories.ts b/.storybook/stories/datagrid/datagrid-detail.stories.ts index aa5dbf78ea..a69eaccfb6 100644 --- a/.storybook/stories/datagrid/datagrid-detail.stories.ts +++ b/.storybook/stories/datagrid/datagrid-detail.stories.ts @@ -6,27 +6,66 @@ */ import { ClrConditionalModule, ClrDatagridDetail, ClrDatagridModule } from '@clr/angular'; -import { Parameters } from '@storybook/addons'; -import { Story } from '@storybook/angular'; +import { moduleMetadata, StoryContext, StoryFn, StoryObj } from '@storybook/angular'; +import { removeFocusOutline } from '../../helpers/common'; import { Element, elements } from '../../helpers/elements.data'; -import { setupStorybook } from '../../helpers/setup-storybook.helpers'; +export default { + title: 'Datagrid/Detail', + component: ClrDatagridDetail, + decorators: [ + moduleMetadata({ + imports: [ClrDatagridModule, ClrConditionalModule], + }), + ], + argTypes: { + // methods + close: { control: { disable: true } }, + // story helpers + elements: { control: { disable: true }, table: { disable: true } }, + detailContentType: { control: 'inline-radio', options: ['json', 'datagrid'] }, + clrDetailAriaLabel: { + description: 'Title of the modal', + }, + clrDetailAriaLabelledBy: { + description: "Id or multiple space separated Id's referencing existing text on the page", + }, + }, + args: { + //inputs + clrDetailAriaLabel: '', + clrDetailAriaLabelledBy: '', + // story helpers + elements, + detailContentType: 'json', + showLongContent: false, + highlight: true, + singleSelectable: false, + multiSelectable: false, + expandable: false, + compact: false, + hidableColumns: false, + height: 0, + }, +}; const longContentElement: Element = { name: 'A really really really really really really really really really long content in the cell', symbol: 'Ac', number: 89, electronegativity: 1.1, }; - -const defaultStory: Story = args => { +const DetailTemplate: StoryFn = args => { args.elements = args.showLongContent ? [longContentElement, ...args.elements] : args.elements; - return { template: ` { Electronegativity - - {{element.name}} - {{element.symbol}} - {{element.number}} + {{ element.name }} + {{ element.symbol }} + {{ element.number }} -
- {{element.electronegativity}} +
+ {{ element.electronegativity }}
- {{element|json}} + {{ element | json }} - - - {{element.name}} + + {{ element.name }} - - {{element | json}} - - + {{ element | json }} Key Value - Name - {{element.name}} + {{ element.name }} - Symbol - {{element.symbol}} + {{ element.symbol }} - Number - {{element.number}} + {{ element.number }} - Electronegativity - {{element.electronegativity}} + {{ element.electronegativity }} - - Elements per page - {{pagination.firstItem + 1}} - {{pagination.lastItem + 1}} of {{pagination.totalItems}} elements + Elements per page + {{ pagination.firstItem + 1 }} - {{ pagination.lastItem + 1 }} of {{ pagination.totalItems }} elements @@ -106,32 +140,20 @@ const defaultStory: Story = args => { props: { ...args }, }; }; +export const Detail: StoryObj = { + render: DetailTemplate, +}; -const defaultParameters: Parameters = { - title: 'Datagrid/Detail', - component: ClrDatagridDetail, - argTypes: { - // methods - close: { control: { disable: true } }, - // story helpers - elements: { control: { disable: true }, table: { disable: true } }, - detailContentType: { control: { type: 'inline-radio', options: ['json', 'datagrid'] } }, +export const OpenDetail: StoryObj = { + render: DetailTemplate, + play({ canvasElement }: StoryContext) { + canvasElement.querySelector('button.datagrid-detail-caret-button').click(); + + removeFocusOutline({ canvasElement }); }, args: { - // story helpers - elements, - detailContentType: 'json', - showLongContent: false, - highlight: true, - singleSelectable: false, - multiSelectable: false, - expandable: false, - compact: false, - hidableColumns: false, - height: 0, + detailContentType: 'datagrid', + // The height is set larger than the height of the rows to regression test the detail pane border. (CDE-2188) + height: 500, }, }; - -const variants: Parameters[] = []; - -setupStorybook([ClrDatagridModule, ClrConditionalModule], defaultStory, defaultParameters, variants); diff --git a/projects/angular/src/data/datagrid/_datagrid.clarity.scss b/projects/angular/src/data/datagrid/_datagrid.clarity.scss index b53cd2ece0..8b3429d552 100644 --- a/projects/angular/src/data/datagrid/_datagrid.clarity.scss +++ b/projects/angular/src/data/datagrid/_datagrid.clarity.scss @@ -553,6 +553,12 @@ flex: 1 1 auto; align-content: flex-start; + .datagrid-rows { + display: flex; + flex-direction: column; + flex: 1 1 auto; + } + .datagrid-body { width: auto; } diff --git a/tests/snapshots/chromium/datagrid/detail--variants-core-dark.png b/tests/snapshots/chromium/datagrid/detail--detail-core-dark.png similarity index 100% rename from tests/snapshots/chromium/datagrid/detail--variants-core-dark.png rename to tests/snapshots/chromium/datagrid/detail--detail-core-dark.png diff --git a/tests/snapshots/chromium/datagrid/detail--variants-core-light.png b/tests/snapshots/chromium/datagrid/detail--detail-core-light.png similarity index 100% rename from tests/snapshots/chromium/datagrid/detail--variants-core-light.png rename to tests/snapshots/chromium/datagrid/detail--detail-core-light.png diff --git a/tests/snapshots/chromium/datagrid/detail--variants-ng-dark.png b/tests/snapshots/chromium/datagrid/detail--detail-ng-dark.png similarity index 100% rename from tests/snapshots/chromium/datagrid/detail--variants-ng-dark.png rename to tests/snapshots/chromium/datagrid/detail--detail-ng-dark.png diff --git a/tests/snapshots/chromium/datagrid/detail--variants-ng-light.png b/tests/snapshots/chromium/datagrid/detail--detail-ng-light.png similarity index 100% rename from tests/snapshots/chromium/datagrid/detail--variants-ng-light.png rename to tests/snapshots/chromium/datagrid/detail--detail-ng-light.png diff --git a/tests/snapshots/chromium/datagrid/detail--open-detail-core-dark.png b/tests/snapshots/chromium/datagrid/detail--open-detail-core-dark.png new file mode 100644 index 0000000000..93e0fd4fc4 Binary files /dev/null and b/tests/snapshots/chromium/datagrid/detail--open-detail-core-dark.png differ diff --git a/tests/snapshots/chromium/datagrid/detail--open-detail-core-light.png b/tests/snapshots/chromium/datagrid/detail--open-detail-core-light.png new file mode 100644 index 0000000000..64b5c8ea85 Binary files /dev/null and b/tests/snapshots/chromium/datagrid/detail--open-detail-core-light.png differ diff --git a/tests/snapshots/chromium/datagrid/detail--open-detail-ng-dark.png b/tests/snapshots/chromium/datagrid/detail--open-detail-ng-dark.png new file mode 100644 index 0000000000..0d6e0ebc81 Binary files /dev/null and b/tests/snapshots/chromium/datagrid/detail--open-detail-ng-dark.png differ diff --git a/tests/snapshots/chromium/datagrid/detail--open-detail-ng-light.png b/tests/snapshots/chromium/datagrid/detail--open-detail-ng-light.png new file mode 100644 index 0000000000..2611a0a004 Binary files /dev/null and b/tests/snapshots/chromium/datagrid/detail--open-detail-ng-light.png differ diff --git a/tests/snapshots/firefox/datagrid/detail--variants-core-dark.png b/tests/snapshots/firefox/datagrid/detail--detail-core-dark.png similarity index 100% rename from tests/snapshots/firefox/datagrid/detail--variants-core-dark.png rename to tests/snapshots/firefox/datagrid/detail--detail-core-dark.png diff --git a/tests/snapshots/firefox/datagrid/detail--variants-core-light.png b/tests/snapshots/firefox/datagrid/detail--detail-core-light.png similarity index 100% rename from tests/snapshots/firefox/datagrid/detail--variants-core-light.png rename to tests/snapshots/firefox/datagrid/detail--detail-core-light.png diff --git a/tests/snapshots/firefox/datagrid/detail--variants-ng-dark.png b/tests/snapshots/firefox/datagrid/detail--detail-ng-dark.png similarity index 100% rename from tests/snapshots/firefox/datagrid/detail--variants-ng-dark.png rename to tests/snapshots/firefox/datagrid/detail--detail-ng-dark.png diff --git a/tests/snapshots/firefox/datagrid/detail--variants-ng-light.png b/tests/snapshots/firefox/datagrid/detail--detail-ng-light.png similarity index 100% rename from tests/snapshots/firefox/datagrid/detail--variants-ng-light.png rename to tests/snapshots/firefox/datagrid/detail--detail-ng-light.png diff --git a/tests/snapshots/firefox/datagrid/detail--open-detail-core-dark.png b/tests/snapshots/firefox/datagrid/detail--open-detail-core-dark.png new file mode 100644 index 0000000000..fb07252194 Binary files /dev/null and b/tests/snapshots/firefox/datagrid/detail--open-detail-core-dark.png differ diff --git a/tests/snapshots/firefox/datagrid/detail--open-detail-core-light.png b/tests/snapshots/firefox/datagrid/detail--open-detail-core-light.png new file mode 100644 index 0000000000..6d13ff952e Binary files /dev/null and b/tests/snapshots/firefox/datagrid/detail--open-detail-core-light.png differ diff --git a/tests/snapshots/firefox/datagrid/detail--open-detail-ng-dark.png b/tests/snapshots/firefox/datagrid/detail--open-detail-ng-dark.png new file mode 100644 index 0000000000..ff1ea343cb Binary files /dev/null and b/tests/snapshots/firefox/datagrid/detail--open-detail-ng-dark.png differ diff --git a/tests/snapshots/firefox/datagrid/detail--open-detail-ng-light.png b/tests/snapshots/firefox/datagrid/detail--open-detail-ng-light.png new file mode 100644 index 0000000000..e972904b42 Binary files /dev/null and b/tests/snapshots/firefox/datagrid/detail--open-detail-ng-light.png differ