@omniumretail/component-library 1.1.12 → 1.1.13
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/bundle.js +1 -1
- package/dist/types/components/DropdownButton/DropdownButton.stories.d.ts +4 -0
- package/dist/types/components/DropdownButton/index.d.ts +10 -0
- package/dist/types/components/Navigation/index.d.ts +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/DropdownButton/DropdownButton.stories.tsx +15 -0
- package/src/components/DropdownButton/index.tsx +35 -0
- package/src/components/Navigation/Navigation.stories.tsx +2 -1
- package/src/components/Navigation/index.tsx +20 -2
- package/src/components/index.tsx +2 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DropdownProps } from 'antd';
|
|
3
|
+
interface DropdownButtonProps extends DropdownProps {
|
|
4
|
+
options: string[];
|
|
5
|
+
buttonText: string;
|
|
6
|
+
buttonClass?: string;
|
|
7
|
+
customButton?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const DropdownButton: ({ options, buttonText, buttonClass, customButton, ...props }: DropdownButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -7,5 +7,6 @@ export interface NavigationProps {
|
|
|
7
7
|
loginOnClickFunction?: () => void;
|
|
8
8
|
backLinkOnClickFunction?: () => void;
|
|
9
9
|
homeOnClickFunction?: () => void;
|
|
10
|
+
options?: string[];
|
|
10
11
|
}
|
|
11
12
|
export declare const Navigation: (props: NavigationProps) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, Story } from '@storybook/react';
|
|
3
|
+
import { DropdownButton } from './index';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'DropdownButton',
|
|
7
|
+
component: DropdownButton,
|
|
8
|
+
} as Meta;
|
|
9
|
+
|
|
10
|
+
const Template: Story<any> = (args) => <DropdownButton {...args} />;
|
|
11
|
+
|
|
12
|
+
export const BasicDropdown = Template.bind({});
|
|
13
|
+
BasicDropdown.args = {
|
|
14
|
+
options: ['Option 1', 'Option 2', 'Option 3'],
|
|
15
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Menu, Dropdown, DropdownProps } from 'antd';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Button } from '../Button';
|
|
5
|
+
|
|
6
|
+
interface DropdownButtonProps extends DropdownProps {
|
|
7
|
+
options: string[];
|
|
8
|
+
buttonText: string;
|
|
9
|
+
buttonClass?: string;
|
|
10
|
+
customButton?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DropdownButton = ({ options, buttonText, buttonClass, customButton, ...props }: DropdownButtonProps) => {
|
|
14
|
+
const menu = (
|
|
15
|
+
<Menu>
|
|
16
|
+
{options.map((option, index) => (
|
|
17
|
+
<Menu.Item key={index}>{option}</Menu.Item>
|
|
18
|
+
))}
|
|
19
|
+
</Menu>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const linkClasses = classNames({
|
|
23
|
+
[`${buttonClass}`]: buttonClass,
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Dropdown overlay={menu} trigger={['click']}>
|
|
28
|
+
{customButton ? (
|
|
29
|
+
customButton
|
|
30
|
+
) : (
|
|
31
|
+
<Button className={linkClasses}>{buttonText}</Button>
|
|
32
|
+
)}
|
|
33
|
+
</Dropdown>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styles from './styles.module.scss';
|
|
2
2
|
import { Link } from '../Link';
|
|
3
|
+
import { DropdownButton } from '../DropdownButton';
|
|
3
4
|
import { ArrowLeftOutlined, HomeOutlined, LogoutOutlined, UserOutlined } from '@ant-design/icons';
|
|
4
5
|
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import { useEffect, useState } from 'react';
|
|
@@ -13,6 +14,7 @@ export interface NavigationProps {
|
|
|
13
14
|
loginOnClickFunction?: () => void;
|
|
14
15
|
backLinkOnClickFunction?: () => void;
|
|
15
16
|
homeOnClickFunction?: () => void;
|
|
17
|
+
options?: string[];
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const TABLET_MAX_WIDTH = 1000;
|
|
@@ -22,6 +24,7 @@ export const Navigation = (props: NavigationProps) => {
|
|
|
22
24
|
const { t } = useTranslation();
|
|
23
25
|
|
|
24
26
|
const [isTablet, setIsTablet] = useState(false);
|
|
27
|
+
const [showDropdown, setShowDropdown] = useState(false);
|
|
25
28
|
|
|
26
29
|
const checkMediaQuery = () => {
|
|
27
30
|
const isPhoneWidth = window.innerWidth < TABLET_MAX_WIDTH;
|
|
@@ -64,8 +67,23 @@ export const Navigation = (props: NavigationProps) => {
|
|
|
64
67
|
<h1 className={`${styles.title} ${styles.titleMobile}`}>{title}</h1>
|
|
65
68
|
</div>
|
|
66
69
|
<div className={`${userName ? styles.columnRightWithUser : styles.columnRightWithNoUser}`}>
|
|
67
|
-
{userName &&
|
|
68
|
-
|
|
70
|
+
{userName && (
|
|
71
|
+
<DropdownButton
|
|
72
|
+
options={props.options!}
|
|
73
|
+
buttonText={props.userName!}
|
|
74
|
+
customButton={(
|
|
75
|
+
<Link
|
|
76
|
+
icon={<UserOutlined />}
|
|
77
|
+
linkSecondary
|
|
78
|
+
iconAlignRight
|
|
79
|
+
onClick={() => setShowDropdown(!showDropdown)}
|
|
80
|
+
>
|
|
81
|
+
{getInitials(userName)}
|
|
82
|
+
</Link>
|
|
83
|
+
)}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
|
+
{homeLink && <Link icon={<HomeOutlined />} linkSecondary iconAlignRight onClick={homeOnClickFunction}> {!isTablet && t('navigation.home')} </Link>}
|
|
69
87
|
{loginLink && <Link href="#" onClick={loginOnClickFunction} icon={<LogoutOutlined />} linkSecondary iconAlignRight>{!isTablet && t('navigation.logout')}</Link>}
|
|
70
88
|
</div>
|
|
71
89
|
</div>
|
package/src/components/index.tsx
CHANGED