Skip to content

Commit

Permalink
Merge pull request #5 from selsa-inube/cmarin/1587/extend-component-t…
Browse files Browse the repository at this point in the history
…o-control-elements-to-show

Extend `<Header />` to control if `<User />` should be included or not
  • Loading branch information
cmarin001 committed May 16, 2024
2 parents 289d819 + da9eee0 commit 2e46d02
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ interface IHeader {
userName: string;
client: string;
links?: IHeaderLink[];
showLinks?: boolean;
showUser?: boolean;
}

const Header = (props: IHeader) => {
const { portalId, navigation, logoURL, userName, client, links } = props;
const {
portalId,
navigation,
logoURL,
userName,
client,
links,
showLinks = false,
showUser = true,
} = props;
const theme = useContext(ThemeContext);
const linkAppearance =
(theme?.header?.content?.appearance as ITextAppearance) ||
Expand All @@ -31,7 +42,12 @@ const Header = (props: IHeader) => {
return (
<StyledHeader>
<Stack alignItems="center" justifyContent="space-between">
<Stack justifyContent="space-between" gap="23px">
<Stack
justifyContent="space-between"
gap="23px"
height={showUser ? "auto" : "53px"}
alignItems="center"
>
{tablet && (
<FullscreenNav
portalId={portalId}
Expand All @@ -43,7 +59,7 @@ const Header = (props: IHeader) => {
{logoURL}
</Stack>
<Stack justifyContent="space-between" gap="23px">
{tablet &&
{showLinks &&
links &&
links.map((link, index) => (
<StyledLink key={index} to={link.path}>
Expand All @@ -52,11 +68,13 @@ const Header = (props: IHeader) => {
</Text>
</StyledLink>
))}
<User
username={userName}
client={client}
size={mobile ? "small" : "large"}
/>
{showUser && (
<User
username={userName}
client={client}
size={mobile ? "small" : "large"}
/>
)}
</Stack>
</Stack>
</StyledHeader>
Expand Down
14 changes: 14 additions & 0 deletions src/Header/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ const props = {
portalId: {
description: "id of the portal element",
},
showLinks: {
description:
"Boolean flag to control the visibility of the links in the header",
table: {
defaultValue: { summary: false },
},
},
showUser: {
description:
"Boolean flag to control the visibility of the user component in the header",
table: {
defaultValue: { summary: true },
},
},
};

export { props, parameters };
Expand Down
2 changes: 2 additions & 0 deletions src/Header/stories/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Default.args = {
icon: <MdAndroid />,
},
],
showLinks: false,
showUser: true,
};

export default story;
Expand Down
3 changes: 3 additions & 0 deletions src/Header/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const StyledHeader = styled.header`
& > div > div:first-child {
padding-left: 12px;
}
& > div > div > img {
height: 33.57px;
}
& > div > div > div:last-child {
padding: 8px 16px;
border-left: 1px solid
Expand Down

0 comments on commit 2e46d02

Please sign in to comment.