-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add possibility to add background color to the suite icon logo (#…
…241)
- Loading branch information
Showing
6 changed files
with
151 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
import { Center } from 'src/components' | ||
import React, { ReactElement, ReactNode } from 'react' | ||
import { Center, Icon } from 'src/components' | ||
import { NavigationIcon } from 'src/components/navigation/GlobalNavigation/NavigationIcon' | ||
import { Icons } from 'src/constants/Icons' | ||
import { type IGlobalNavigationLogo } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' | ||
import { IconColor } from 'src/components/general/Icon/Icon' | ||
|
||
// custom-size is the default size to prevent breaking changes. | ||
function isStringIcon(icon: ReactNode | string): icon is keyof typeof Icons { | ||
return typeof icon === 'string' | ||
} | ||
|
||
export function SuiteLogo({ icon, label, type = 'custom-size', onSuiteLogoClick }: IGlobalNavigationLogo) { | ||
const classMap = { | ||
default: '', | ||
'custom-size': 'globalNavigation__icon--suiteLogo', | ||
'background-solid': 'globalNavigation__icon--suiteBackground', | ||
} | ||
|
||
const iconColorMap: { [key in 'default' | 'background-solid' | 'custom-size']: IconColor } = { | ||
default: 'default', | ||
'background-solid': 'brand', | ||
'custom-size': 'default', | ||
} | ||
|
||
const getIcon = () => { | ||
if (isStringIcon(icon)) { | ||
return <Icon name={icon} color={iconColorMap[type]} size="xxl" /> | ||
} | ||
return icon | ||
} | ||
|
||
export function SuiteLogo(props: IGlobalNavigationLogo) { | ||
return ( | ||
<Center vertical className="globalNavigation__suiteLogo" onClick={props.onSuiteLogoClick}> | ||
<NavigationIcon icon={props.icon} label="" hideLabel className="globalNavigation__icon--suiteLogo" /> | ||
{props.label} | ||
<Center vertical className="globalNavigation__suiteLogo" onClick={onSuiteLogoClick}> | ||
<NavigationIcon icon={getIcon()} label="" hideLabel className={classMap[type]} /> | ||
{label} | ||
</Center> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters