From db3ba0677f7b4999e220fdb34635959f5f086ad3 Mon Sep 17 00:00:00 2001 From: Brad Paugh Date: Fri, 13 Oct 2023 10:39:58 -0700 Subject: [PATCH] fix(root-layout): convert to pure CSS grid method (#1253) * fix(root-layout): convert to pure CSS grid method * separate classes * fix storybook booleans * fix test * map fixed prop correctly * remove sidebar sticky --- components/root_layout/root_layout.stories.js | 24 ++- components/root_layout/root_layout.test.js | 8 +- components/root_layout/root_layout.vue | 158 +++++++++++++----- .../root_layout/root_layout_default.story.vue | 1 - .../root_layout/root_layout_sticky.story.vue | 13 +- 5 files changed, 140 insertions(+), 64 deletions(-) diff --git a/components/root_layout/root_layout.stories.js b/components/root_layout/root_layout.stories.js index 8b0fbfb3a3..09a444afa5 100644 --- a/components/root_layout/root_layout.stories.js +++ b/components/root_layout/root_layout.stories.js @@ -8,14 +8,15 @@ import { import DtRootLayout from './root_layout.vue'; import DtRootLayoutDefaultTemplate from './root_layout_default.story.vue'; +import DtRootLayoutStickyTemplate from './root_layout_sticky.story.vue'; // Default Prop Values export const argsData = { sidebarPosition: 'left', - header: '
Header
', - footer: '
Footer
', + header: '
Header
', + footer: '
Footer
', sidebar: - '
Sidebar item 1
Sidebar item 2
Sidebar item 3
', + '
Sidebar item 1
Sidebar item 2
Sidebar item 3
', default: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam dignissim eleifend condimentum. Vestibulum euismod leo at finibus mattis. Integer ut dui id ligula tincidunt pellentesque. Vestibulum a ullamcorper risus. Ut tristique sapien eget magna lacinia, non interdum lacus malesuada. Proin augue lacus, finibus eget aliquam @@ -95,11 +96,19 @@ export const argTypesData = { responsiveBreakpoint: { defaultValue: null, + options: ROOT_LAYOUT_RESPONSIVE_BREAKPOINTS, control: { type: 'select', - options: ROOT_LAYOUT_RESPONSIVE_BREAKPOINTS, }, }, + + headerSticky: { + control: 'boolean', + }, + + fixed: { + control: 'boolean', + }, }; // Story Collection @@ -109,11 +118,16 @@ export default { args: argsData, argTypes: argTypesData, excludeStories: /.*Data$/, + parameters: { + layout: 'fullscreen', + }, }; // Templates const DefaultTemplate = (args, { argTypes }) => createTemplateFromVueFile(args, argTypes, DtRootLayoutDefaultTemplate); +const StickyTemplate = (args, { argTypes }) => + createTemplateFromVueFile(args, argTypes, DtRootLayoutStickyTemplate); export const Default = { render: DefaultTemplate, @@ -124,7 +138,7 @@ export const Default = { }; export const StickyHeader = { - render: DefaultTemplate, + render: StickyTemplate, args: { headerSticky: true, diff --git a/components/root_layout/root_layout.test.js b/components/root_layout/root_layout.test.js index dd22ae1bc5..a0d15fdefe 100644 --- a/components/root_layout/root_layout.test.js +++ b/components/root_layout/root_layout.test.js @@ -20,7 +20,6 @@ describe('DtRootLayout Tests', () => { let wrapper; let header; let footer; - let body; let sidebar; let content; @@ -33,7 +32,6 @@ describe('DtRootLayout Tests', () => { header = wrapper.find('[data-qa="dt-root-layout-header"]'); footer = wrapper.find('[data-qa="dt-root-layout-footer"]'); - body = wrapper.find('[data-qa="dt-root-layout-body"]'); sidebar = wrapper.find('[data-qa="dt-root-layout-sidebar"]'); content = wrapper.find('[data-qa="dt-root-layout-content"]'); }; @@ -110,14 +108,14 @@ describe('DtRootLayout Tests', () => { it('Has correct class', async () => { await wrapper.setProps({ sidebarPosition: ROOT_LAYOUT_SIDEBAR_POSITIONS.LEFT }); - expect(body.classes('d-root-layout__body--invert')).toBe(false); + expect(wrapper.classes('d-root-layout--inverted')).toBe(false); }); }); describe('When sidebarPosition is set to right', () => { it('Has correct class', async () => { - await wrapper.setProps({ sidebarPosition: ROOT_LAYOUT_SIDEBAR_POSITIONS.LEFT }); + await wrapper.setProps({ sidebarPosition: ROOT_LAYOUT_SIDEBAR_POSITIONS.RIGHT }); - expect(body.classes('d-root-layout__body--invert')).toBe(false); + expect(wrapper.classes('d-root-layout--inverted')).toBe(true); }); }); }); diff --git a/components/root_layout/root_layout.vue b/components/root_layout/root_layout.vue index bb56669f80..54ef914e90 100644 --- a/components/root_layout/root_layout.vue +++ b/components/root_layout/root_layout.vue @@ -1,6 +1,14 @@