diff --git a/CHANGELOG.md b/CHANGELOG.md index 1965c287e..2b90b6121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ +# [1.27.0](https://github.com/mParticle/aquarium/compare/v1.26.0...v1.27.0) (2024-08-14) + +### Bug Fixes + +- add width auto to be able to manage the wdith from the component ([#368](https://github.com/mParticle/aquarium/issues/368)) ([b47c45f](https://github.com/mParticle/aquarium/commit/b47c45f029f49428eb22576971d2e6299ab9acc7)) +- icon color not changing on button hover ([#363](https://github.com/mParticle/aquarium/issues/363)) ([aa07067](https://github.com/mParticle/aquarium/commit/aa07067eecca986208a9b7ff4737077193c83d41)) +- improve workspace selector performace ([#370](https://github.com/mParticle/aquarium/issues/370)) ([590e231](https://github.com/mParticle/aquarium/commit/590e231fb7b086530fd23eaa70986bfb6eca48b0)) +- update empty component ([#371](https://github.com/mParticle/aquarium/issues/371)) ([655e252](https://github.com/mParticle/aquarium/commit/655e2527b06c55cda2b18af889d143b0ceacad3d)) + +### Features + +- add overview dt icon ([#362](https://github.com/mParticle/aquarium/issues/362)) ([78d7854](https://github.com/mParticle/aquarium/commit/78d7854eec0b7ad0762aa95dd7310d187102e12b)) +- update SuiteLogo in GlobalNav to render nav switcher Tour ([#367](https://github.com/mParticle/aquarium/issues/367)) ([a3920af](https://github.com/mParticle/aquarium/commit/a3920afb53ea5af159ea66d5394f35baf3b7be48)) + +# [1.27.0-global-nav-switcher-tour-component.1](https://github.com/mParticle/aquarium/compare/v1.26.0...v1.27.0-global-nav-switcher-tour-component.1) (2024-08-13) + +### Bug Fixes + +- add width auto to be able to manage the wdith from the component ([#368](https://github.com/mParticle/aquarium/issues/368)) ([b47c45f](https://github.com/mParticle/aquarium/commit/b47c45f029f49428eb22576971d2e6299ab9acc7)) +- icon color not changing on button hover ([#363](https://github.com/mParticle/aquarium/issues/363)) ([aa07067](https://github.com/mParticle/aquarium/commit/aa07067eecca986208a9b7ff4737077193c83d41)) + +### Features + +- add overview dt icon ([#362](https://github.com/mParticle/aquarium/issues/362)) ([78d7854](https://github.com/mParticle/aquarium/commit/78d7854eec0b7ad0762aa95dd7310d187102e12b)) +- update SuiteLogo to render nav switcher tour ([6098374](https://github.com/mParticle/aquarium/commit/609837455f3f8c3014b9cd007b5efab9d096ff63)) + # [1.26.0](https://github.com/mParticle/aquarium/compare/v1.25.1...v1.26.0) (2024-08-07) ### Bug Fixes diff --git a/package-lock.json b/package-lock.json index 214676894..c3d0f4d47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mparticle/aquarium", - "version": "1.26.0", + "version": "1.27.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mparticle/aquarium", - "version": "1.26.0", + "version": "1.27.0", "license": "Apache-2.0", "dependencies": { "lodash.clonedeep": "4.5.0" diff --git a/package.json b/package.json index e4098fe5a..5fcd933df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mparticle/aquarium", - "version": "1.26.0", + "version": "1.27.0", "description": "mParticle Component Library", "license": "Apache-2.0", "keywords": [ diff --git a/src/components/data-display/Empty/Empty.stories.tsx b/src/components/data-display/Empty/Empty.stories.tsx index e72e1c44b..83dc20610 100644 --- a/src/components/data-display/Empty/Empty.stories.tsx +++ b/src/components/data-display/Empty/Empty.stories.tsx @@ -55,7 +55,7 @@ export const NoImage: Story = { export const AltImage: Story = { args: { image: Empty.PRESENTED_IMAGE_SIMPLE, - imageStyle: { width: '100px', height: '62px', margin: 'auto' }, + imageStyle: { width: '100px', height: '62px' }, }, } diff --git a/src/components/data-display/Empty/empty.css b/src/components/data-display/Empty/empty.css index beb7293fd..c919bcf09 100644 --- a/src/components/data-display/Empty/empty.css +++ b/src/components/data-display/Empty/empty.css @@ -1,3 +1,7 @@ -.ant-empty-image > svg{ - width: auto !important; +.ant-empty-image { + margin: auto !important; +} + +.ant-empty-image > svg { + width: auto !important; } \ No newline at end of file diff --git a/src/components/data-display/Tour/Tour.stories.tsx b/src/components/data-display/Tour/Tour.stories.tsx index 57d48b1e1..9d585ee07 100644 --- a/src/components/data-display/Tour/Tour.stories.tsx +++ b/src/components/data-display/Tour/Tour.stories.tsx @@ -1,5 +1,7 @@ import { type Meta, type StoryObj } from '@storybook/react' -import { Tour } from 'src/components/data-display/Tour/Tour' +import React, { useRef, useState } from 'react' +import { type ITourProps, Tour } from 'src/components/data-display/Tour/Tour' +import { Button, Icon, SuiteLogo } from 'src/components' const meta: Meta = { title: 'Aquarium/Data Display/Tour', @@ -12,3 +14,92 @@ export default meta type Story = StoryObj export const Primary: Story = {} + +export const ExamplePlacement: Story = { + render: () => { + const ref = useRef(null) + const [open, setOpen] = useState(false) + + const steps: ITourProps['steps'] = [ + { + title: 'Center', + description: 'Displayed in the center of screen.', + target: null, + }, + { + title: 'Right', + description: 'On the right of target.', + placement: 'right', + target: () => ref.current, + }, + { + title: 'Top', + description: 'On the top of target.', + placement: 'top', + target: () => ref.current, + }, + ] + + return ( + <> +
+ +
+ + { + setOpen(false) + }} + steps={steps} + /> + + ) + }, +} + +export const ExampleNavLogo: Story = { + render: () => { + const ref = useRef(null) + const [open, setOpen] = useState(false) + + const steps: ITourProps['steps'] = [ + { + title: 'Navigate mParticle effortlessly!', + description: 'Switch between product suites anytime using this selector.', + placement: 'right', + target: () => ref.current, + }, + ] + + return ( + <> +
+ } + onSuiteLogoClick={() => { + setOpen(true) + }} + /> +
+ + { + setOpen(false) + }} + steps={steps} + /> + + ) + }, +} diff --git a/src/components/navigation/GlobalNavigation/GlobalNavigation.stories.tsx b/src/components/navigation/GlobalNavigation/GlobalNavigation.stories.tsx index fbf8cca39..0f316a7dd 100644 --- a/src/components/navigation/GlobalNavigation/GlobalNavigation.stories.tsx +++ b/src/components/navigation/GlobalNavigation/GlobalNavigation.stories.tsx @@ -1,6 +1,6 @@ import { type Meta, type StoryObj } from '@storybook/react' import { expect, fn, screen, userEvent } from '@storybook/test' -import React from 'react' +import React, { useState } from 'react' import { Button, Center, Flex, GlobalNavigation, Icon, type INavigationCreateProps, Space } from 'src/components' import { Badge } from 'src/components/data-display/Badge/Badge' import { @@ -1180,3 +1180,49 @@ export const MPWithoutCustomSizeLogo: Story = { showSuiteLogo: true, }, } + +export const MPWithNavSwitcherTour: Story = { + render: () => { + const [open, setOpen] = useState(false) + + const navigationButtonItemOptions = { + label: 'Sign Out of mParticle', + onClick: () => { + alert('Signout!') + }, + } + + const mpLogoWithTour: IGlobalNavigationLogo = { + label: 'Data Platform', + icon: 'catalog', + type: 'background-solid', + onSuiteLogoClick: () => { + setOpen(currentOpen => !currentOpen) + }, + navSwitcherTourOptions: { + open, + onClose: () => { + setOpen(false) + }, + }, + } + + return ( +
+ { + alert('Searching!') + }} + logo={mpLogoWithTour} + tools={mpTools} + management={mpManagement} + orgs={mpOrgs} + onMpHomeClick={() => { + alert('going to overview map') + }} + navigationButtonItemOptions={navigationButtonItemOptions} + /> +
+ ) + }, +} diff --git a/src/components/navigation/GlobalNavigation/GlobalNavigationItems.d.ts b/src/components/navigation/GlobalNavigation/GlobalNavigationItems.d.ts index 00a20cdd0..c03041402 100644 --- a/src/components/navigation/GlobalNavigation/GlobalNavigationItems.d.ts +++ b/src/components/navigation/GlobalNavigation/GlobalNavigationItems.d.ts @@ -1,4 +1,5 @@ import type { ReactNode, type MouseEvent, ReactElement } from 'react' +import { type ITourProps } from 'src/components' import { type HrefOptions } from 'src/utils/utils' import { type Icons } from 'src/constants/Icons' @@ -14,6 +15,7 @@ export interface IGlobalNavigationLogo extends IBaseGlobalNavigationItem { onSuiteLogoClick: () => void type?: 'default' | 'background-solid' | 'custom-size' icon?: ReactElement | keyof typeof Icons + navSwitcherTourOptions?: INavSwitcherTourOptions } export interface IGlobalNavigationMenu extends IBaseGlobalNavigationItem { @@ -46,3 +48,10 @@ export interface IMiniMapOptions { unauthorizedLinks?: MiniMapLinks[] activeLink: MiniMapLinks } + +export interface INavSwitcherTourOptions extends ITourProps { + open: boolean + onClose: () => void + title?: string + description?: string +} diff --git a/src/components/navigation/GlobalNavigation/SuiteLogo.tsx b/src/components/navigation/GlobalNavigation/SuiteLogo.tsx index c29212590..f0e39f858 100644 --- a/src/components/navigation/GlobalNavigation/SuiteLogo.tsx +++ b/src/components/navigation/GlobalNavigation/SuiteLogo.tsx @@ -1,9 +1,12 @@ -import React, { ReactElement, ReactNode } from 'react' -import { Center, Icon } from 'src/components' +import React, { type ReactNode, useRef } from 'react' +import { Center, Icon, type ITourProps, Tour } 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' +import { type Icons } from 'src/constants/Icons' +import { + type IGlobalNavigationLogo, + type INavSwitcherTourOptions, +} from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems' +import { type IconColor } from 'src/components/general/Icon/Icon' // custom-size is the default size to prevent breaking changes. type IconColorOptions = 'default' | 'background-solid' | 'custom-size' @@ -12,30 +15,73 @@ 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', - } +export function SuiteLogo({ + icon, + label, + type = 'custom-size', + onSuiteLogoClick, + navSwitcherTourOptions, +}: IGlobalNavigationLogo) { + const logoRef = useRef(null) - const iconColorMap: { [key in IconColorOptions]: IconColor } = { - default: 'default', - 'background-solid': 'brand', - 'custom-size': 'default', - } + return ( + <> +
+ {renderNavLogo()} + {navSwitcherTourOptions && renderNavTour(navSwitcherTourOptions)} +
+ + ) + + function renderNavLogo() { + const classMap = { + default: '', + 'custom-size': 'globalNavigation__icon--suiteLogo', + 'background-solid': 'globalNavigation__icon--suiteBackground', + } + + const iconColorMap: { [key in IconColorOptions]: IconColor } = { + default: 'default', + 'background-solid': 'brand', + 'custom-size': 'default', + } - const getIcon = () => { - if (isStringIcon(icon)) { - return + const getIcon = () => { + if (isStringIcon(icon)) { + return + } + return icon } - return icon + + return ( +
+ + {label} +
+ ) } - return ( -
- - {label} -
- ) + function renderNavTour(props: INavSwitcherTourOptions) { + const DefaultTitle = 'Navigate mParticle effortlessly!' as const + const DefaultDescription = 'Switch between product suites anytime using this selector.' as const + const DefaultPlacement = 'right' as const + + const navSwitcherStep: ITourProps['steps'] = [ + { + title: props.title ?? DefaultTitle, + description: props.description ?? DefaultDescription, + placement: DefaultPlacement, + target: () => logoRef.current, + nextButtonProps: { + children: 'Close', + }, + }, + ] + + return ( + <> + + + ) + } } diff --git a/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorContentItems.tsx b/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorContentItems.tsx index d3edde178..da561d94f 100644 --- a/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorContentItems.tsx +++ b/src/components/navigation/GlobalNavigation/WorkspaceSelector/WorkspaceSelectorContentItems.tsx @@ -1,16 +1,23 @@ -import { type IWorkspaceSelectorDisplayItem } from 'src/components' +import { type IWorkspaceSelectorDisplayItem, List } from 'src/components' +import VirtualList from 'rc-virtual-list' type WorkspaceSelectorContentItemsProps = { menuItems: IWorkspaceSelectorDisplayItem[] } + +const CONTAINER_HEIGHT = 324 +const ITEM_HEIGHT = 20 + export function WorkspaceSelectorContentItems({ menuItems }: WorkspaceSelectorContentItemsProps) { return ( -
    - {menuItems.map(item => ( -
  • - {item.label} -
  • - ))} -
+ + + {item => ( +
  • + {item.label} +
  • + )} +
    +
    ) }