Skip to content

Commit

Permalink
fix(table-of-contents): fix header space (#4298)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

Refs #4262.

### Description

This change ensures the area for the heading content is hidden unless there is its content actually.

### Changelog

**New**

- UI integration test for below change.

**Changed**

- A change to ensure the area for the heading content is hidden unless there is its content actually.
  • Loading branch information
asudoh authored Oct 28, 2020
1 parent a4d6952 commit 10d7de0
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@

@include carbon--breakpoint('lg') {
display: block;

&[hidden] {
display: none;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@
@import 'carbon-components/scss/globals/scss/vendor/@carbon/elements/scss/colors/colors';
@import 'carbon-components/scss/globals/scss/typography';

.dds-ce-demo-devenv--container {
padding-top: 0;
padding-bottom: 0;
}

.dds-ce-demo--table-of-contents {
padding-top: 3rem;
padding-bottom: 3rem;

a[name] {
display: block;
color: $text-01;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @license
*
* Copyright IBM Corp. 2020
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

describe('dds-table-of-contents', () => {
describe('With wide screen', () => {
describe('Without heading content', function() {
beforeEach(async () => {
await page.setViewportSize({ width: 1280, height: 720 });
await page.goto(`http://localhost:${process.env.PORT}/iframe.html?id=components-table-of-contents--default`);
});

it('should hide the heading container unless it has its content', async () => {
await expect(page).toHaveSelector('dds-table-of-contents .bx--tableofcontents__desktop__children', { state: 'hidden' });
});
});

describe('With heading content', () => {
beforeEach(async () => {
await page.setViewportSize({ width: 1280, height: 720 });
await page.goto(`http://localhost:${process.env.PORT}/iframe.html?id=components-table-of-contents--with-heading-content`);
});

it('should show the heading container', async () => {
await expect(page).toHaveSelector('dds-table-of-contents .bx--tableofcontents__desktop__children', { state: 'visible' });
});
});
});

describe('With narrow screen', () => {
describe('Without heading content', function() {
beforeEach(async () => {
await page.setViewportSize({ width: 672, height: 720 });
await page.goto(`http://localhost:${process.env.PORT}/iframe.html?id=components-table-of-contents--default`);
});

it('should hide the heading container unless it has its content', async () => {
await expect(page).toHaveSelector('dds-table-of-contents .bx--tableofcontents__children__mobile', { state: 'hidden' });
});
});

describe('With heading content', () => {
beforeEach(async () => {
await page.setViewportSize({ width: 672, height: 720 });
await page.goto(`http://localhost:${process.env.PORT}/iframe.html?id=components-table-of-contents--with-heading-content`);
});

it('should show the heading container', async () => {
await expect(page).toHaveSelector('dds-table-of-contents .bx--tableofcontents__children__mobile', { state: 'visible' });
});
});
});
});

0 comments on commit 10d7de0

Please sign in to comment.