Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tup-612 isNestedHeader prop in <SectionHeader> #335

Merged
merged 6 commits into from
Nov 14, 2023
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
2 changes: 1 addition & 1 deletion apps/tup-ui/src/pages/Projects/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Layout: React.FC = () => {
<section className={styles['project-section']}>
<PageLayout
top={
<SectionHeader actions={<NewProject />}>
<SectionHeader actions={<NewProject />} isNestedHeader>
Projects & Allocations
</SectionHeader>
}
Expand Down
6 changes: 4 additions & 2 deletions libs/core-components/src/lib/SectionHeader/SectionHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ function SectionHeader({
isForForm,
isForTable,
isForList,
isNestedHeader,
}) {
let styleName = '';
const styleNameList = [styles['root']];
const HeaderTagName = isNestedHeader ? 'div' : 'header';
const HeadingTagName = isForForm || isForTable || isForList ? 'h2' : 'h1';

if (isForForm) styleNameList.push(styles['for-form']);
Expand All @@ -55,14 +57,14 @@ function SectionHeader({
styleName = styleNameList.join(' ');

return (
<header className={`${className} ${styleName}`}>
<HeaderTagName className={`${className} ${styleName}`}>
{children && (
<HeadingTagName className={styles['heading']}>
{children}
</HeadingTagName>
)}
{actions}
</header>
</HeaderTagName>
);
}
SectionHeader.propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const ProjectHeader: React.FC<{ projectId: number }> = ({

return (
<div className={styles['project-header']}>
<SectionHeader>
<SectionHeader isNestedHeader>
{isActive && <Link to={'/projects?show=active'}>Active Projects </Link>}
{!isActive && (
<Link to={'/projects?show=inactive'}>Inactive Projects </Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ export const SystemStatusHeader: React.FC<SystemDetailProps> = ({

if (error)
return (
<SectionHeader>
<SectionHeader isNestedHeader>
<InlineMessage type="warn">
System Status / Unable to retrieve system name
</InlineMessage>
</SectionHeader>
);

return (
<SectionHeader>System Status / {dataBySystem?.display_name}</SectionHeader>
<SectionHeader isNestedHeader>
System Status / {dataBySystem?.display_name}
</SectionHeader>
);
};
Loading