-
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: replace minimap with suite selector
- Loading branch information
1 parent
db88c4e
commit 9d20a9a
Showing
9 changed files
with
211 additions
and
610 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/components/navigation/GlobalNavigation/SuiteSelector/SuiteSelector.tsx
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { type ReactNode } from 'react' | ||
import { type IPopoverProps, Popover } from 'src/components' | ||
import type { IMiniMapOptions, MiniMapLink } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' | ||
import { SuiteSelectorContent } from 'src/components/navigation/GlobalNavigation/SuiteSelector/SuiteSelectorContent' | ||
|
||
interface ISuiteSelectorProps extends IPopoverProps { | ||
minimapOptions: IMiniMapOptions | ||
onLinkClick: (link: MiniMapLink) => void | ||
children: ReactNode | ||
} | ||
|
||
export function SuiteSelector(props: ISuiteSelectorProps) { | ||
return ( | ||
<Popover | ||
content={ | ||
<SuiteSelectorContent | ||
overviewHref={props.minimapOptions.overviewHref} | ||
onUnauthorizedClick={props.minimapOptions.onUnauthorizedClick} | ||
links={props.minimapOptions.links} | ||
onLinkClick={props.onLinkClick} | ||
unauthorizedLinks={props.minimapOptions.unauthorizedLinks} | ||
activeLink={props.minimapOptions.activeLink} | ||
/> | ||
} | ||
placement="bottomLeft" | ||
open={props.open} | ||
trigger="click" | ||
onOpenChange={props.onOpenChange} | ||
arrow={false}> | ||
{props.children} | ||
</Popover> | ||
) | ||
} |
56 changes: 56 additions & 0 deletions
56
src/components/navigation/GlobalNavigation/SuiteSelector/SuiteSelectorContent.tsx
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import './suite-selector.css' | ||
import { ConfigProvider } from 'antd' | ||
import React from 'react' | ||
import { Button, Col, Flex, Row } from 'src/components' | ||
import { | ||
type IMiniMapOptions, | ||
type MiniMapLink, | ||
} from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' | ||
import { SuiteSelectorSuiteLink } from 'src/components/navigation/GlobalNavigation/SuiteSelector/SuiteSelectorSuiteLink' | ||
|
||
type ISuiteSelectorContentProps = IMiniMapOptions | ||
|
||
export function SuiteSelectorContent(props: ISuiteSelectorContentProps) { | ||
const handleLinkClick = (link: MiniMapLink): void => { | ||
const isLinkUnauthorized = props.unauthorizedLinks?.includes(link.linkId) | ||
|
||
if (link) { | ||
if (isLinkUnauthorized) props.onUnauthorizedClick?.(link) | ||
else props.onLinkClick(link) | ||
} | ||
} | ||
return ( | ||
<ConfigProvider> | ||
<div className="u-padding-xxs"> | ||
<Row gutter={[0, 4]} className="suiteSelector__content"> | ||
{props.links.map(link => ( | ||
<Col span={8} key={link.linkId}> | ||
<SuiteSelectorSuiteLink | ||
link={link} | ||
unauthorizedLinks={props.unauthorizedLinks} | ||
activeLink={props.activeLink} | ||
onLinkClick={() => { | ||
handleLinkClick(link) | ||
}} | ||
/> | ||
</Col> | ||
))} | ||
</Row> | ||
|
||
{renderOverviewButton()} | ||
</div> | ||
</ConfigProvider> | ||
) | ||
|
||
function renderOverviewButton() { | ||
return ( | ||
<> | ||
<Flex align="center" justify="start"> | ||
<Button type="primary" href={props.overviewHref || '/'}> | ||
Go to Overview | ||
</Button> | ||
</Flex> | ||
</> | ||
) | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/components/navigation/GlobalNavigation/SuiteSelector/SuiteSelectorSuiteLink.tsx
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react' | ||
import { Center, Flex, Icon } from 'src/components' | ||
import { type MiniMapLink, type MiniMapLinks } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' | ||
import { NavigationIcon } from 'src/components/navigation/GlobalNavigation/NavigationIcon' | ||
import type { IconNames } from 'src/types/icons' | ||
|
||
interface ISuiteSelectorSuiteLinkProps { | ||
link: MiniMapLink | ||
onLinkClick: (link: MiniMapLink) => void | ||
unauthorizedLinks?: MiniMapLinks[] | ||
activeLink: MiniMapLinks | ||
} | ||
|
||
const elementNameMap: Record<MiniMapLinks, string> = { | ||
oversight: 'Oversight', | ||
dataPlatform: 'Data Platform', | ||
customer360: 'Customer 360', | ||
predictions: 'Predictions', | ||
analytics: 'Analytics', | ||
segmentation: 'Segmentation', | ||
} as const | ||
|
||
const elementIconMap: Record<MiniMapLinks, IconNames> = { | ||
oversight: 'oversight', | ||
dataPlatform: 'dataPlatform', | ||
customer360: 'C360', | ||
predictions: 'predictions', | ||
analytics: 'analytics', | ||
segmentation: 'segmentation', | ||
} as const | ||
|
||
export function SuiteSelectorSuiteLink(props: ISuiteSelectorSuiteLinkProps) { | ||
const getLinkClass = (link: MiniMapLink): string => { | ||
const isActiveClass = props.activeLink === link.linkId ? ' suiteSelector__link--active' : '' | ||
const isUnauthorizedClass = props.unauthorizedLinks?.includes(link.linkId) ? ' suiteSelector__link--disabled' : '' | ||
const linkStateClass = isActiveClass || isUnauthorizedClass | ||
|
||
return `suiteSelector__link ${linkStateClass} ` | ||
} | ||
|
||
const handleContainerClick = (e: React.MouseEvent) => { | ||
e.preventDefault() | ||
props.onLinkClick(props.link) | ||
} | ||
|
||
return ( | ||
<> | ||
<div onClick={handleContainerClick} className={getLinkClass(props.link)}> | ||
<Flex vertical align="center" gap="small"> | ||
<NavigationIcon icon={renderLogo(elementIconMap[props.link.linkId])} label="" hideLabel /> | ||
{elementNameMap[props.link.linkId]} | ||
</Flex> | ||
</div> | ||
</> | ||
) | ||
|
||
function renderLogo(name: IconNames) { | ||
return ( | ||
<Center vertical className="suiteSelector__suiteLogo"> | ||
<Icon name={name} size="md" color="brand" variant="duo-tone" /> | ||
</Center> | ||
) | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/components/navigation/GlobalNavigation/SuiteSelector/suite-selector.css
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
:root { | ||
--suite-selector-content-max-width: 272px; | ||
} | ||
|
||
.suiteSelector__content { | ||
max-width: var(--suite-selector-content-max-width); | ||
margin-bottom: var(--margin-xs); | ||
} | ||
|
||
.suiteSelector__link { | ||
padding: var(--padding-sm) 0; | ||
border-radius: var(--border-radius-lg); | ||
color: var(--color-text-base); | ||
font-size: var(--font-size-sm); | ||
border: 1px solid transparent; | ||
cursor: pointer; | ||
} | ||
|
||
.suiteSelector__link:not(.suiteSelector__link--active, .suiteSelector__link--disabled):hover { | ||
background-color: var(--color-primary-bg-hover); | ||
border-color: var(--color-primary-bg-hover); | ||
} | ||
|
||
.suiteSelector__link:not(.suiteSelector__link--active, .suiteSelector__link--disabled):hover .suiteSelector__suiteLogo { | ||
background-color: var(--control-item-bg-hover); | ||
} | ||
|
||
.suiteSelector__link.suiteSelector__link--active { | ||
border-color: var(--color-border); | ||
} | ||
|
||
.suiteSelector__link.suiteSelector__link--disabled { | ||
cursor: default; | ||
color: var(--color-text-disabled); | ||
} | ||
|
||
.suiteSelector__link.suiteSelector__link--disabled .suiteSelector__suiteLogo { | ||
background-color: var(--mp-brand-secondary-3); | ||
} | ||
|
||
.suiteSelector__link.suiteSelector__link--disabled .suiteSelector__suiteLogo svg { | ||
color: var(--color-text-disabled); | ||
} | ||
|
||
.suiteSelector__suiteLogo { | ||
background-color: var(--control-item-bg-active); | ||
width: var(--control-height-lg); | ||
height: var(--control-height-lg); | ||
border-radius: 100%; | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.