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

[terra-clinical-header] Added wrapContent to make wrapping of content optional #940

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

* Fixed
* Added `wrapContent` prop to make content wrapping optional.

## 3.31.1 - (March 26, 2024)

* Fixed
Expand Down
12 changes: 10 additions & 2 deletions packages/terra-clinical-header/src/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ const propTypes = {
* Sets the header title to be a hyperlink.
*/
onClick: PropTypes.func,

/**
* A Boolean indicating if start and end content should be wrapped.
*/
wrapContent: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -75,6 +80,7 @@ const defaultProps = {
endContent: null,
isSubheader: false,
text: '',
wrapContent: false,
};

const Header = ({
Expand All @@ -87,6 +93,7 @@ const Header = ({
id,
isSubheader,
onClick,
wrapContent,
...customProps
}) => {
const theme = useContext(ThemeContext);
Expand Down Expand Up @@ -134,17 +141,18 @@ const Header = ({
]);

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

return (
<header {...customProps} className={headerClassNames}>
{startContent && <div className={cx('flex-end')}>{startContent}</div>}
{startContent && <div className={contentClassNames}>{startContent}</div>}
{renderTitle && (
<div className={cx('flex-fill')}>
{titleElement}
</div>
)}
{content}
{endContent && <div className={cx('flex-end')}>{endContent}</div>}
{endContent && <div className={contentClassNames}>{endContent}</div>}
</header>
);
};
Expand Down
8 changes: 7 additions & 1 deletion packages/terra-clinical-header/src/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@
width: 100%;
}

.flex-end {
.flex-end-wrap {
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
}

.flex-end{
display:flex;
flex: 0 0 auto;
position: relative;
}

.title-container {
position: relative;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@
padding: 0;
padding-right: 10px;
}

.button {
margin: 5px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import classNames from 'classnames/bind';

import Header from 'terra-clinical-header';
import Button from 'terra-button';
import styles from './ClinicalHeaderCommontest.module.scss';

const cx = classNames.bind(styles);

const endContent = (
<div
id="headerTest--endContent"
>
<Button text="Update" className={cx('button')} />
<Button text="Renew" className={cx('button')} />
<Button text="Cancel" className={cx('button')} />
<Button text="Complete" className={cx('button')} />
</div>
);

export default () => (
<Header
id="Header"
text="Lorem ipsum dolor sit amet "
endContent={endContent}
wrapContent
/>
);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions packages/terra-clinical-header/tests/wdio/header-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,10 @@ Terra.describeViewports('Clinical header', ['tiny', 'small', 'medium', 'large',

Terra.validates.element('has hyperlink title');
});

it('Wraps the end content', () => {
browser.url('/raw/tests/terra-clinical-header/clinical-header/header-wrap-content');

Terra.validates.element('wrapped content');
});
});
saket2403 marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading