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

Commit 7fb6530

Browse files
committed
Added wrapContent
1 parent 4dcf6bb commit 7fb6530

File tree

24 files changed

+58
-3
lines changed

24 files changed

+58
-3
lines changed

packages/terra-clinical-header/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
* Fixed
6+
* Added `wrapContent` prop to make content wrapping optional.
7+
58
## 3.31.1 - (March 26, 2024)
69

710
* Fixed

packages/terra-clinical-header/src/Header.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ const propTypes = {
6767
* Sets the header title to be a hyperlink.
6868
*/
6969
onClick: PropTypes.func,
70+
71+
/**
72+
* A Boolean indicating if start and end content should be wrapped.
73+
*/
74+
wrapContent: PropTypes.bool,
7075
};
7176

7277
const defaultProps = {
@@ -75,6 +80,7 @@ const defaultProps = {
7580
endContent: null,
7681
isSubheader: false,
7782
text: '',
83+
wrapContent: false,
7884
};
7985

8086
const Header = ({
@@ -87,6 +93,7 @@ const Header = ({
8793
id,
8894
isSubheader,
8995
onClick,
96+
wrapContent,
9097
...customProps
9198
}) => {
9299
const theme = useContext(ThemeContext);
@@ -134,17 +141,18 @@ const Header = ({
134141
]);
135142

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

138146
return (
139147
<header {...customProps} className={headerClassNames}>
140-
{startContent && <div className={cx('flex-end')}>{startContent}</div>}
148+
{startContent && <div className={contentClassNames}>{startContent}</div>}
141149
{renderTitle && (
142150
<div className={cx('flex-fill')}>
143151
{titleElement}
144152
</div>
145153
)}
146154
{content}
147-
{endContent && <div className={cx('flex-end')}>{endContent}</div>}
155+
{endContent && <div className={contentClassNames}>{endContent}</div>}
148156
</header>
149157
);
150158
};

packages/terra-clinical-header/src/Header.module.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,20 @@
3737
width: 100%;
3838
}
3939

40-
.flex-end {
40+
.flex-end-wrap {
4141
display: flex;
4242
flex-flow: row wrap;
4343
justify-content: flex-start;
4444
align-items: flex-start;
4545
align-content: flex-start;
4646
}
4747

48+
.flex-end{
49+
display:flex;
50+
flex: 0 0 auto;
51+
position: relative;
52+
}
53+
4854
.title-container {
4955
position: relative;
5056
width: 100%;

packages/terra-clinical-header/src/terra-dev-site/test/clinical-header/ClinicalHeaderCommontest.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@
2323
padding: 0;
2424
padding-right: 10px;
2525
}
26+
27+
.button {
28+
margin: 5px;
29+
}
2630
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import classNames from 'classnames/bind';
3+
4+
import Header from 'terra-clinical-header';
5+
import Button from 'terra-button';
6+
import styles from './ClinicalHeaderCommontest.module.scss';
7+
8+
const cx = classNames.bind(styles);
9+
10+
const endContent = (
11+
<div
12+
id="headerTest--endContent"
13+
>
14+
<Button text="Update" className={cx('button')} />
15+
<Button text="Renew" className={cx('button')} />
16+
<Button text="Cancel" className={cx('button')} />
17+
<Button text="Complete" className={cx('button')} />
18+
</div>
19+
);
20+
21+
export default () => (
22+
<Header
23+
id="Header"
24+
text="Lorem ipsum dolor sit amet "
25+
endContent={endContent}
26+
wrapContent
27+
/>
28+
);

packages/terra-clinical-header/tests/wdio/header-spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,10 @@ Terra.describeViewports('Clinical header', ['tiny', 'small', 'medium', 'large',
7676

7777
Terra.validates.element('has hyperlink title');
7878
});
79+
80+
it('Wraps the end content', () => {
81+
browser.url('/raw/tests/terra-clinical-header/clinical-header/header-wrap-content');
82+
83+
Terra.validates.element('wrapped content');
84+
});
7985
});

0 commit comments

Comments
 (0)