@servicetitan/navigation 3.3.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/header-navigation/header-navigation-content.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-content.js +3 -3
- package/dist/components/header-navigation/header-navigation-content.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts +3 -3
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.js +8 -22
- package/dist/components/header-navigation/header-navigation-extra.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.d.ts +3 -30
- package/dist/components/header-navigation/header-navigation-links.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.js +8 -5
- package/dist/components/header-navigation/header-navigation-links.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts +1 -0
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +8 -26
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.d.ts +1 -28
- package/dist/components/header-navigation/header-navigation.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.js +5 -8
- package/dist/components/header-navigation/header-navigation.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.module.less +13 -70
- package/dist/components/header-navigation/header-navigation.stories.d.ts +1 -0
- package/dist/components/header-navigation/header-navigation.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +9 -27
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/header-navigation/index.d.ts +0 -1
- package/dist/components/header-navigation/index.d.ts.map +1 -1
- package/dist/components/header-navigation/index.js +0 -1
- package/dist/components/header-navigation/index.js.map +1 -1
- package/dist/components/layout.stories.d.ts +1 -0
- package/dist/components/layout.stories.d.ts.map +1 -1
- package/dist/components/layout.stories.js +4 -2
- package/dist/components/layout.stories.js.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts +16 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.js +43 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.js.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.d.ts +23 -0
- package/dist/components/left-navigation/header-navigation-tiny.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.js +7 -0
- package/dist/components/left-navigation/header-navigation-tiny.js.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.module.less +109 -0
- package/dist/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.d.ts +2 -2
- package/dist/components/left-navigation/header-navigation-tiny.stories.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.stories.js +30 -0
- package/dist/components/left-navigation/header-navigation-tiny.stories.js.map +1 -0
- package/dist/components/left-navigation/index.d.ts +3 -0
- package/dist/components/left-navigation/index.d.ts.map +1 -0
- package/dist/components/left-navigation/index.js +3 -0
- package/dist/components/left-navigation/index.js.map +1 -0
- package/dist/components/{side-navigation → left-navigation}/side-navigation.d.ts +1 -12
- package/dist/components/left-navigation/side-navigation.d.ts.map +1 -0
- package/dist/components/left-navigation/side-navigation.js +23 -0
- package/dist/components/left-navigation/side-navigation.js.map +1 -0
- package/dist/components/{side-navigation → left-navigation}/side-navigation.module.less +28 -22
- package/dist/components/left-navigation/side-navigation.stories.d.ts +10 -0
- package/dist/components/left-navigation/side-navigation.stories.d.ts.map +1 -0
- package/dist/components/left-navigation/side-navigation.stories.js +31 -0
- package/dist/components/left-navigation/side-navigation.stories.js.map +1 -0
- package/dist/components/links.d.ts +5 -0
- package/dist/components/links.d.ts.map +1 -0
- package/dist/components/links.js +14 -0
- package/dist/components/links.js.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts +2 -8
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js +5 -43
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts +9 -0
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js +13 -0
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +2 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +16 -7
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +7 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts +9 -8
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.js +39 -39
- package/dist/components/profile-dropdown/profile-dropdown.stories.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/test/data-stories.module.less +8 -0
- package/dist/test/data.stories.d.ts +26 -0
- package/dist/test/data.stories.d.ts.map +1 -0
- package/dist/test/data.stories.js +151 -0
- package/dist/test/data.stories.js.map +1 -0
- package/dist/utils/navigation-context.d.ts +2 -2
- package/dist/utils/navigation-context.d.ts.map +1 -1
- package/dist/utils/navigation-context.js +18 -5
- package/dist/utils/navigation-context.js.map +1 -1
- package/dist/utils/navigation.d.ts +47 -0
- package/dist/utils/navigation.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/components/header-navigation/header-navigation-content.tsx +3 -3
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +29 -38
- package/src/components/header-navigation/header-navigation-links.tsx +19 -41
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +18 -70
- package/src/components/header-navigation/header-navigation.module.less +13 -70
- package/src/components/header-navigation/header-navigation.module.less.d.ts +0 -1
- package/src/components/header-navigation/header-navigation.stories.tsx +20 -71
- package/src/components/header-navigation/header-navigation.tsx +6 -82
- package/src/components/header-navigation/index.ts +0 -1
- package/src/components/layout.stories.tsx +4 -2
- package/src/components/left-navigation/header-navigation-tiny-links.tsx +110 -0
- package/src/components/left-navigation/header-navigation-tiny.module.less +109 -0
- package/src/components/left-navigation/header-navigation-tiny.module.less.d.ts +14 -0
- package/src/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.tsx +39 -46
- package/src/components/left-navigation/header-navigation-tiny.tsx +65 -0
- package/src/components/left-navigation/index.ts +2 -0
- package/src/components/{side-navigation → left-navigation}/side-navigation.module.less +28 -22
- package/src/components/{side-navigation → left-navigation}/side-navigation.module.less.d.ts +3 -3
- package/src/components/left-navigation/side-navigation.stories.tsx +46 -0
- package/src/components/left-navigation/side-navigation.tsx +171 -0
- package/src/components/links.tsx +31 -0
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +5 -170
- package/src/components/profile-dropdown/profile-dropdown-tiny.stories.tsx +15 -0
- package/src/components/profile-dropdown/profile-dropdown.module.less +7 -1
- package/src/components/profile-dropdown/profile-dropdown.module.less.d.ts +1 -0
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +106 -129
- package/src/components/profile-dropdown/profile-dropdown.tsx +35 -8
- package/src/index.ts +2 -1
- package/src/test/data-stories.module.less +8 -0
- package/src/test/data-stories.module.less.d.ts +3 -0
- package/src/test/data.stories.tsx +223 -0
- package/src/utils/navigation-context.tsx +10 -10
- package/src/utils/navigation.ts +54 -0
- package/dist/components/header-navigation/header-navigation-tiny.stories.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-tiny.stories.js +0 -25
- package/dist/components/header-navigation/header-navigation-tiny.stories.js.map +0 -1
- package/dist/components/side-navigation/icons.d.ts +0 -7
- package/dist/components/side-navigation/icons.d.ts.map +0 -1
- package/dist/components/side-navigation/icons.js +0 -5
- package/dist/components/side-navigation/icons.js.map +0 -1
- package/dist/components/side-navigation/index.d.ts +0 -2
- package/dist/components/side-navigation/index.d.ts.map +0 -1
- package/dist/components/side-navigation/index.js +0 -2
- package/dist/components/side-navigation/index.js.map +0 -1
- package/dist/components/side-navigation/side-navigation.d.ts.map +0 -1
- package/dist/components/side-navigation/side-navigation.js +0 -37
- package/dist/components/side-navigation/side-navigation.js.map +0 -1
- package/dist/components/side-navigation/side-navigation.stories.d.ts +0 -10
- package/dist/components/side-navigation/side-navigation.stories.d.ts.map +0 -1
- package/dist/components/side-navigation/side-navigation.stories.js +0 -52
- package/dist/components/side-navigation/side-navigation.stories.js.map +0 -1
- package/src/components/side-navigation/icons.tsx +0 -74
- package/src/components/side-navigation/index.ts +0 -1
- package/src/components/side-navigation/side-navigation.stories.tsx +0 -95
- package/src/components/side-navigation/side-navigation.tsx +0 -224
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Icon } from '@servicetitan/anvil2';
|
|
2
|
+
import SvgCollapse from '@servicetitan/anvil2/assets/icons/st/gnav_menu_collapse.svg';
|
|
3
|
+
import SvgExpand from '@servicetitan/anvil2/assets/icons/st/gnav_menu_expand.svg';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { FC, Fragment } from 'react';
|
|
6
|
+
import { HeaderNavigationItemData, NavLinkComponentProps } from '../../utils/navigation';
|
|
7
|
+
import { DefaultNavLinkComponent } from '../../utils/navigation-context';
|
|
8
|
+
import { withTooltip } from '../../utils/with-tooltip';
|
|
9
|
+
import { CounterTag } from '../counter-tag';
|
|
10
|
+
import * as Styles from './side-navigation.module.less';
|
|
11
|
+
|
|
12
|
+
export interface SideNavigationProps {
|
|
13
|
+
/** container class name */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** container id */
|
|
16
|
+
id?: string;
|
|
17
|
+
/** main navigation items */
|
|
18
|
+
items?: HeaderNavigationItemData[];
|
|
19
|
+
/** top navigation items */
|
|
20
|
+
itemsTop?: HeaderNavigationItemData[];
|
|
21
|
+
/** is menu expanded */
|
|
22
|
+
expanded?: boolean;
|
|
23
|
+
/** navigation component used for routing */
|
|
24
|
+
navigationComponent?: FC<NavLinkComponentProps>;
|
|
25
|
+
/** expand change handler */
|
|
26
|
+
onExpandedChange(expanded: boolean): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const SideNavigation: FC<SideNavigationProps> = ({
|
|
30
|
+
className,
|
|
31
|
+
expanded,
|
|
32
|
+
id,
|
|
33
|
+
items,
|
|
34
|
+
itemsTop,
|
|
35
|
+
navigationComponent = DefaultNavLinkComponent,
|
|
36
|
+
onExpandedChange,
|
|
37
|
+
}) => {
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={classNames(
|
|
41
|
+
Styles.sideNav,
|
|
42
|
+
expanded ? Styles.sideNavExpanded : Styles.sideNavSlim,
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
id={id}
|
|
46
|
+
data-cy="side-navigation"
|
|
47
|
+
>
|
|
48
|
+
{!!itemsTop?.length && (
|
|
49
|
+
<Fragment>
|
|
50
|
+
<div className={Styles.sideNavTop} data-cy="navigation-items-top">
|
|
51
|
+
{itemsTop.map(item => (
|
|
52
|
+
<SideNavigationItem
|
|
53
|
+
key={item.id}
|
|
54
|
+
expanded={expanded}
|
|
55
|
+
navigationComponent={navigationComponent}
|
|
56
|
+
{...item}
|
|
57
|
+
/>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
<div className={Styles.divider} />
|
|
61
|
+
</Fragment>
|
|
62
|
+
)}
|
|
63
|
+
<div className={Styles.sideNavContent} data-cy="navigation-items">
|
|
64
|
+
{items?.map(item => (
|
|
65
|
+
<SideNavigationItem
|
|
66
|
+
key={item.id}
|
|
67
|
+
expanded={expanded}
|
|
68
|
+
navigationComponent={navigationComponent}
|
|
69
|
+
{...item}
|
|
70
|
+
/>
|
|
71
|
+
))}
|
|
72
|
+
</div>
|
|
73
|
+
<div className={Styles.sideNavBottom}>
|
|
74
|
+
<SideNavigationOptionsToggle
|
|
75
|
+
expanded={expanded}
|
|
76
|
+
onExpandedChange={onExpandedChange}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
interface SideNavigationItemProps extends HeaderNavigationItemData {
|
|
84
|
+
navigationComponent: FC<NavLinkComponentProps>;
|
|
85
|
+
expanded?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Side Navigation menu item */
|
|
89
|
+
const SideNavigationItem: FC<SideNavigationItemProps> = ({
|
|
90
|
+
id,
|
|
91
|
+
to,
|
|
92
|
+
title,
|
|
93
|
+
hint,
|
|
94
|
+
counter,
|
|
95
|
+
className,
|
|
96
|
+
iconClassName,
|
|
97
|
+
iconComponent: IconComponent,
|
|
98
|
+
icon,
|
|
99
|
+
iconActive,
|
|
100
|
+
isActive,
|
|
101
|
+
navigationComponent: NavigationComponent,
|
|
102
|
+
expanded,
|
|
103
|
+
}) => {
|
|
104
|
+
return withTooltip(
|
|
105
|
+
<NavigationComponent
|
|
106
|
+
data-cy={`navigation-item-${id}`}
|
|
107
|
+
data-pendo={`navigation-item-${id}`}
|
|
108
|
+
key={id}
|
|
109
|
+
to={to}
|
|
110
|
+
title={hint}
|
|
111
|
+
className={classNames(Styles.navigationItem, className, {
|
|
112
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
113
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
114
|
+
})}
|
|
115
|
+
isActive={typeof isActive === 'function' ? isActive : undefined}
|
|
116
|
+
activeClassName={Styles.navigationItemActive}
|
|
117
|
+
>
|
|
118
|
+
{IconComponent ? (
|
|
119
|
+
<i className={classNames(Styles.navigationIcon, iconClassName)}>
|
|
120
|
+
<IconComponent />
|
|
121
|
+
</i>
|
|
122
|
+
) : (
|
|
123
|
+
<Fragment>
|
|
124
|
+
{icon && (
|
|
125
|
+
<Icon
|
|
126
|
+
svg={icon}
|
|
127
|
+
className={classNames(Styles.navigationIcon, iconClassName)}
|
|
128
|
+
/>
|
|
129
|
+
)}
|
|
130
|
+
{iconActive && (
|
|
131
|
+
<Icon
|
|
132
|
+
svg={iconActive}
|
|
133
|
+
className={classNames(
|
|
134
|
+
Styles.navigationIcon,
|
|
135
|
+
Styles.navigationIconActive,
|
|
136
|
+
iconClassName
|
|
137
|
+
)}
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
</Fragment>
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
{!!expanded && <span className={Styles.navigationItemText}>{title}</span>}
|
|
144
|
+
{!!counter && <CounterTag data={counter} className={Styles.navigationItemCounter} />}
|
|
145
|
+
</NavigationComponent>,
|
|
146
|
+
expanded ? undefined : title,
|
|
147
|
+
'right'
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** Side Navigation options toggle */
|
|
152
|
+
export const SideNavigationOptionsToggle: FC<{
|
|
153
|
+
expanded?: boolean;
|
|
154
|
+
onExpandedChange(expanded: boolean): void;
|
|
155
|
+
}> = ({ expanded, onExpandedChange }) =>
|
|
156
|
+
withTooltip(
|
|
157
|
+
<div
|
|
158
|
+
data-cy="navigation-left-options"
|
|
159
|
+
data-pendo="navigation-left-options"
|
|
160
|
+
className={classNames(Styles.optionsItem)}
|
|
161
|
+
onClick={() => onExpandedChange(!expanded)}
|
|
162
|
+
>
|
|
163
|
+
<div className={Styles.optionsIconWrapper}>
|
|
164
|
+
<Icon className={Styles.optionsIcon} svg={expanded ? SvgCollapse : SvgExpand} />
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
{!!expanded && <span className={Styles.optionsItemText}>Collapse Menu</span>}
|
|
168
|
+
</div>,
|
|
169
|
+
expanded ? undefined : 'Expand Menu',
|
|
170
|
+
'right'
|
|
171
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FC, useContext } from 'react';
|
|
2
|
+
import { HeaderNavigationLinkProps, HeaderNavigationTriggerProps } from '../utils/navigation';
|
|
3
|
+
import { NavigationLegacyContext } from '../utils/navigation-context';
|
|
4
|
+
import {
|
|
5
|
+
HeaderNavigationLink as HeaderNavigationLinkLegacy,
|
|
6
|
+
HeaderNavigationTrigger as HeaderNavigationTriggerLegacy,
|
|
7
|
+
} from './header-navigation/header-navigation-links';
|
|
8
|
+
import {
|
|
9
|
+
HeaderNavigationLink as HeaderNavigationLinkModern,
|
|
10
|
+
HeaderNavigationTrigger as HeaderNavigationTriggerModern,
|
|
11
|
+
} from './left-navigation/header-navigation-tiny-links';
|
|
12
|
+
|
|
13
|
+
export const HeaderNavigationLink: FC<HeaderNavigationLinkProps> = props => {
|
|
14
|
+
const isLegacy = useContext(NavigationLegacyContext);
|
|
15
|
+
|
|
16
|
+
return isLegacy ? (
|
|
17
|
+
<HeaderNavigationLinkLegacy {...props} />
|
|
18
|
+
) : (
|
|
19
|
+
<HeaderNavigationLinkModern {...props} />
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const HeaderNavigationTrigger: FC<HeaderNavigationTriggerProps> = props => {
|
|
24
|
+
const isLegacy = useContext(NavigationLegacyContext);
|
|
25
|
+
|
|
26
|
+
return isLegacy ? (
|
|
27
|
+
<HeaderNavigationTriggerLegacy {...props} />
|
|
28
|
+
) : (
|
|
29
|
+
<HeaderNavigationTriggerModern {...props} />
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -1,178 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
import { NavLinkComponentProps } from '../../utils/navigation';
|
|
1
|
+
import { withAnvil, withMemoryRouter } from '../../test/data.stories';
|
|
4
2
|
import { HeaderNavigationStacked } from '../header-navigation';
|
|
3
|
+
export * from './profile-dropdown.stories';
|
|
5
4
|
import { ProfileDropdown } from './profile-dropdown';
|
|
6
5
|
|
|
6
|
+
const withHeaderNavigationStacked = (Story: any) => <HeaderNavigationStacked right={<Story />} />;
|
|
7
|
+
|
|
7
8
|
export default {
|
|
8
9
|
title: 'Navigation/ProfileDropdownStacked',
|
|
9
10
|
component: ProfileDropdown,
|
|
10
11
|
parameters: {},
|
|
12
|
+
decorators: [withMemoryRouter, withAnvil, withHeaderNavigationStacked],
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
const NavLinkMock: FC<NavLinkComponentProps> = props => (
|
|
14
|
-
<a
|
|
15
|
-
href={props.to}
|
|
16
|
-
target={props.target}
|
|
17
|
-
onClick={e => {
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
}}
|
|
20
|
-
className={props.className}
|
|
21
|
-
>
|
|
22
|
-
{props.children}
|
|
23
|
-
</a>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const profileDropdownDefault = () => (
|
|
27
|
-
<HeaderNavigationStacked
|
|
28
|
-
navigationComponent={NavLinkMock}
|
|
29
|
-
right={
|
|
30
|
-
<ProfileDropdown>
|
|
31
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
32
|
-
first link
|
|
33
|
-
</ProfileDropdown.Link>
|
|
34
|
-
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
35
|
-
second link
|
|
36
|
-
</ProfileDropdown.Link>
|
|
37
|
-
<ProfileDropdown.Divider />
|
|
38
|
-
<ProfileDropdown.Section id="content">some content</ProfileDropdown.Section>
|
|
39
|
-
<ProfileDropdown.Divider />
|
|
40
|
-
<ProfileDropdown.Divider />
|
|
41
|
-
<ProfileDropdown.Divider />
|
|
42
|
-
<ProfileDropdown.Link id="third" to="https://google.com">
|
|
43
|
-
third link
|
|
44
|
-
</ProfileDropdown.Link>
|
|
45
|
-
<ProfileDropdown.Divider />
|
|
46
|
-
</ProfileDropdown>
|
|
47
|
-
}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
export const profileDropdownWithLogo = () => (
|
|
52
|
-
<HeaderNavigationStacked
|
|
53
|
-
navigationComponent={NavLinkMock}
|
|
54
|
-
right={
|
|
55
|
-
<ProfileDropdown
|
|
56
|
-
trigger={{
|
|
57
|
-
imageSrc:
|
|
58
|
-
'https://upload.wikimedia.org/wikipedia/en/1/11/Milhouse_Van_Houten.png',
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
62
|
-
first link
|
|
63
|
-
</ProfileDropdown.Link>
|
|
64
|
-
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
65
|
-
second link
|
|
66
|
-
</ProfileDropdown.Link>
|
|
67
|
-
</ProfileDropdown>
|
|
68
|
-
}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
export const profileDropdownWithErrorLogo = () => (
|
|
73
|
-
<HeaderNavigationStacked
|
|
74
|
-
right={
|
|
75
|
-
<ProfileDropdown
|
|
76
|
-
trigger={{
|
|
77
|
-
imageSrc: 'https://some.incorrect.url/logo.png',
|
|
78
|
-
}}
|
|
79
|
-
/>
|
|
80
|
-
}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
export const profileDropdownWithInfo = () => (
|
|
85
|
-
<HeaderNavigationStacked
|
|
86
|
-
right={
|
|
87
|
-
<ProfileDropdown
|
|
88
|
-
trigger={{
|
|
89
|
-
info: { text: 'first', title: 'tenant user' },
|
|
90
|
-
avatarBadge: true,
|
|
91
|
-
}}
|
|
92
|
-
/>
|
|
93
|
-
}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
export const profileDropdownWithCounter = () => (
|
|
98
|
-
<HeaderNavigationStacked
|
|
99
|
-
right={
|
|
100
|
-
<ProfileDropdown
|
|
101
|
-
trigger={{
|
|
102
|
-
info: { text: 'first', title: 'tenant user' },
|
|
103
|
-
avatarBadge: true,
|
|
104
|
-
badge: { content: 3, className: 'bg-red-500' },
|
|
105
|
-
}}
|
|
106
|
-
/>
|
|
107
|
-
}
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
export const profileDropdownWithBothBadges = () => (
|
|
112
|
-
<HeaderNavigationStacked
|
|
113
|
-
right={
|
|
114
|
-
<ProfileDropdown
|
|
115
|
-
trigger={{
|
|
116
|
-
avatarBadge: 'yellow-500',
|
|
117
|
-
badge: { className: 'bg-red-400' },
|
|
118
|
-
}}
|
|
119
|
-
/>
|
|
120
|
-
}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// eslint-disable-next-line no-console
|
|
125
|
-
const log = (text: string) => console.log(text);
|
|
126
|
-
|
|
127
|
-
export const profileDropdownWithHintPopup = () => (
|
|
128
|
-
<HeaderNavigationStacked
|
|
129
|
-
navigationComponent={NavLinkMock}
|
|
130
|
-
right={
|
|
131
|
-
<ProfileDropdown
|
|
132
|
-
trigger={{
|
|
133
|
-
avatarBadge: 'yellow-500',
|
|
134
|
-
badge: { className: 'bg-red-400' },
|
|
135
|
-
}}
|
|
136
|
-
hintPopup={{
|
|
137
|
-
className: 'bg-blue-500-i c-white',
|
|
138
|
-
content: ({ openProfile }) => (
|
|
139
|
-
<div>
|
|
140
|
-
hello{' '}
|
|
141
|
-
<Button onClick={openProfile} size="xsmall">
|
|
142
|
-
show me
|
|
143
|
-
</Button>
|
|
144
|
-
</div>
|
|
145
|
-
),
|
|
146
|
-
width: 's',
|
|
147
|
-
onClose: () => log('close profile dropdown hint'),
|
|
148
|
-
}}
|
|
149
|
-
onOpen={() => log('open profile dropdown')}
|
|
150
|
-
onClose={() => log('close profile dropdown')}
|
|
151
|
-
>
|
|
152
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
153
|
-
first item
|
|
154
|
-
</ProfileDropdown.Link>
|
|
155
|
-
<ProfileDropdown.Divider />
|
|
156
|
-
<ProfileDropdown.Section id="second">second item</ProfileDropdown.Section>
|
|
157
|
-
</ProfileDropdown>
|
|
158
|
-
}
|
|
159
|
-
/>
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
export const profileDropdownWithHintAndInfoPopup = () => (
|
|
163
|
-
<HeaderNavigationStacked
|
|
164
|
-
navigationComponent={NavLinkMock}
|
|
165
|
-
right={
|
|
166
|
-
<ProfileDropdown
|
|
167
|
-
trigger={{
|
|
168
|
-
avatarBadge: 'yellow-500',
|
|
169
|
-
badge: { className: 'bg-red-400' },
|
|
170
|
-
info: { title: 'some text', text: 'qq' },
|
|
171
|
-
}}
|
|
172
|
-
hintPopup={{
|
|
173
|
-
content: () => <div>hello</div>,
|
|
174
|
-
}}
|
|
175
|
-
/>
|
|
176
|
-
}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { withAnvil, withMemoryRouter } from '../../test/data.stories';
|
|
2
|
+
import { HeaderNavigationTiny } from '../left-navigation';
|
|
3
|
+
export * from './profile-dropdown.stories';
|
|
4
|
+
import { ProfileDropdown } from './profile-dropdown';
|
|
5
|
+
|
|
6
|
+
const withHeaderNavigationTiny = (Story: any) => (
|
|
7
|
+
<HeaderNavigationTiny className="border" right={<Story />} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Navigation/ProfileDropdownTiny',
|
|
12
|
+
component: ProfileDropdown,
|
|
13
|
+
parameters: {},
|
|
14
|
+
decorators: [withMemoryRouter, withAnvil, withHeaderNavigationTiny],
|
|
15
|
+
};
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
.avatar-badge {
|
|
18
18
|
position: absolute;
|
|
19
19
|
top: 8px;
|
|
20
|
-
left:
|
|
20
|
+
left: 4px;
|
|
21
21
|
height: 12px;
|
|
22
22
|
width: 12px;
|
|
23
23
|
border-radius: @border-radius-circular;
|
|
@@ -50,6 +50,12 @@
|
|
|
50
50
|
border-radius: 8px;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
&.trigger-container-legacy {
|
|
54
|
+
.avatar-badge {
|
|
55
|
+
left: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
&.trigger-container-hint-arrow:first-child:before {
|
|
54
60
|
display: none;
|
|
55
61
|
content: '';
|