Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Removed title div
Browse files Browse the repository at this point in the history
  • Loading branch information
saket2403 committed Apr 15, 2024
1 parent d8666fb commit 41f70b1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
3 changes: 3 additions & 0 deletions packages/terra-clinical-header/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Changed
* Removed title div when value is not provided for text prop.

## 3.31.2 - (April 2, 2024)

* Fixed
Expand Down
6 changes: 3 additions & 3 deletions packages/terra-clinical-header/src/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ const Header = ({
customProps.className,
]);

const renderTitle = !(!titleContent && startContent && endContent);
const contentClassNames = wrapContent ? cx('flex-end-wrap') : cx('flex-end');
const endClassNames = cx({ 'end-content': !title });

return (
<header {...customProps} className={headerClassNames}>
{startContent && <div className={contentClassNames}>{startContent}</div>}
{renderTitle && (
{titleContent && (
<div className={cx('flex-fill')}>
{titleElement}
</div>
)}
{content}
{endContent && <div className={contentClassNames}>{endContent}</div>}
{endContent && <div className={`${contentClassNames} ${endClassNames}`}>{endContent}</div>}
</header>
);
};
Expand Down
4 changes: 4 additions & 0 deletions packages/terra-clinical-header/src/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
position: relative;
}

.end-content {
margin-left: auto;
}

.title-container {
position: relative;
width: 100%;
Expand Down
12 changes: 5 additions & 7 deletions packages/terra-clinical-header/tests/jest/Header.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,21 @@ it('should render a header with heading level', () => {

it('should render a header with content on the left', () => {
const startContent = <div id="start-id">start content</div>;
const flexFill = <div className="flex-fill" />;
const flexEnd = <div className="flex-end">{startContent}</div>;
const header = shallow(<Header startContent={startContent} />);

// ensure flex-fill title container is after start content
expect(header.find('.flex-header').props().children[0]).toEqual(flexEnd);
expect(header.find('.flex-header').props().children[1]).toEqual(flexFill);
expect(header).toMatchSnapshot();
});

it('should render a header with content on the right', () => {
const endContent = <div id="end-id">end content</div>;
const flexFill = <div className="flex-fill" />;
const flexEnd = <div className="flex-end">{endContent}</div>;
const flexFill = '';
const flexEnd = <div className="flex-end end-content">{endContent}</div>;
const header = shallow(<Header endContent={endContent} />);

// ensure flex-fill title container is before end content
// ensure flex-fill title container is not rendered if no title is provided
expect(header.find('.flex-header').props().children[1]).toEqual(flexFill);
expect(header.find('.flex-header').props().children[3]).toEqual(flexEnd);
expect(header).toMatchSnapshot();
Expand All @@ -74,7 +72,7 @@ it('should render a header with all content', () => {
</div>
);
const flexEndStart = <div className="flex-end">{startContent}</div>;
const flexEndEnd = <div className="flex-end">{endContent}</div>;
const flexEndEnd = <div className="flex-end end-content">{endContent}</div>;
const header = shallow((
<Header
startContent={startContent}
Expand All @@ -95,7 +93,7 @@ it('should render a header with start and end content and no title', () => {
const startContent = <div id="start-id">start content</div>;
const endContent = <div id="end-id">end content</div>;
const flexEndStart = <div className="flex-end">{startContent}</div>;
const flexEndEnd = <div className="flex-end">{endContent}</div>;
const flexEndEnd = <div className="flex-end end-content">{endContent}</div>;
const header = shallow((
<Header
startContent={startContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
exports[`should render a default component 1`] = `
<header
className="flex-header"
>
<div
className="flex-fill"
/>
</header>
/>
`;

exports[`should render a header with all content 1`] = `
Expand Down Expand Up @@ -37,7 +33,7 @@ exports[`should render a header with all content 1`] = `
</div>
</div>
<div
className="flex-end"
className="flex-end end-content"
>
<div
id="end-id"
Expand All @@ -61,9 +57,6 @@ exports[`should render a header with content on the left 1`] = `
start content
</div>
</div>
<div
className="flex-fill"
/>
</header>
`;

Expand All @@ -72,10 +65,7 @@ exports[`should render a header with content on the right 1`] = `
className="flex-header"
>
<div
className="flex-fill"
/>
<div
className="flex-end"
className="flex-end end-content"
>
<div
id="end-id"
Expand Down Expand Up @@ -211,7 +201,7 @@ exports[`should render a header with start and end content and no title 1`] = `
</div>
</div>
<div
className="flex-end"
className="flex-end end-content"
>
<div
id="end-id"
Expand Down Expand Up @@ -267,7 +257,7 @@ exports[`should render a subheader with all content 1`] = `
</div>
</div>
<div
className="flex-end"
className="flex-end end-content"
>
<div>
end content
Expand Down

0 comments on commit 41f70b1

Please sign in to comment.