diff --git a/docs/userGuide/syntax/panels.md b/docs/userGuide/syntax/panels.md index b85afb67e5..f629ae3a1f 100644 --- a/docs/userGuide/syntax/panels.md +++ b/docs/userGuide/syntax/panels.md @@ -104,6 +104,14 @@ plain text ... + + + :bulb: Seamless panels inherit the background colour and text colour of any parents! +
+ + This is its content. + +
**Show/Hide buttons using `no-switch`, `no-close`, or `no-minimized-switch`.** diff --git a/packages/vue-components/src/__tests__/Panels.spec.js b/packages/vue-components/src/__tests__/Panels.spec.js index 93b7a82376..2d9e175446 100644 --- a/packages/vue-components/src/__tests__/Panels.spec.js +++ b/packages/vue-components/src/__tests__/Panels.spec.js @@ -1,6 +1,17 @@ import { mount } from '@vue/test-utils'; import NestedPanel from '../panels/NestedPanel.vue'; +const DEFAULT_STUBS = { 'nested-panel': NestedPanel }; + +const BOX_CONTAINER = ` +
+ + +

Test Content

+
+
+`; + describe('NestedPanels', () => { test('should show header when collapsed with expandHeaderless as false', async () => { const wrapper = mount(NestedPanel, { @@ -72,4 +83,37 @@ describe('NestedPanels', () => { expect(wrapper.element).toMatchSnapshot(); }); + + test('renders a seamless panel with a transparent background', async () => { + const wrapper = mount(NestedPanel, { + propsData: { + type: 'seamless', + }, + slots: { + header: 'test header', + }, + }); + + expect(wrapper.find('.card').classes()).toContain('card-seamless'); + expect(wrapper.find('.card-header').classes()).toContain('bg-transparent'); + expect(wrapper.element).toMatchSnapshot(); + }); + + test('seamless panel should inherit parent background color', () => { + const ParentComponent = { + template: BOX_CONTAINER, + }; + + const wrapper = mount(ParentComponent, { + stubs: DEFAULT_STUBS, + }); + + const parentElement = wrapper.find('div'); + const seamlessPanel = wrapper.findComponent(NestedPanel); + + expect(seamlessPanel.props('type')).toBe('seamless'); + expect(window.getComputedStyle(seamlessPanel.element).backgroundColor).toBe( + window.getComputedStyle(parentElement.element).backgroundColor, + ); + }); }); diff --git a/packages/vue-components/src/__tests__/__snapshots__/Panels.spec.js.snap b/packages/vue-components/src/__tests__/__snapshots__/Panels.spec.js.snap index 4798266ef2..1752f79327 100644 --- a/packages/vue-components/src/__tests__/__snapshots__/Panels.spec.js.snap +++ b/packages/vue-components/src/__tests__/__snapshots__/Panels.spec.js.snap @@ -1,5 +1,84 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`NestedPanels renders a seamless panel with a transparent background 1`] = ` +
+
+
+
+ +
+ +
+ test header +
+ +
+ + + + + +
+
+ +
+ + +
+
+ + + + +
+
+`; + exports[`NestedPanels should have span.anchor when id is present 1`] = `
-