@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.
@@ -0,0 +1,4 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const BasicDropdown: Story<any>;
@@ -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;
@@ -24,3 +24,4 @@ export * from './UserInfo';
24
24
  export * from './CategoryReadOnly';
25
25
  export * from './Notification';
26
26
  export * from './ExportTableData';
27
+ export * from './DropdownButton';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -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
+ };
@@ -14,5 +14,6 @@ Primary.args = {
14
14
  homeLink: false,
15
15
  title: 'Gestão de Aplicações',
16
16
  loginLink: true,
17
- userName: "Diogo Silva Coutinho"
17
+ userName: "Diogo Silva Coutinho",
18
+ options: ['Option 1', 'Option 2', 'Option 3'],
18
19
  };
@@ -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 && <Link href="#" icon={<UserOutlined />} linkSecondary iconAlignRight> {getInitials(userName)} </Link>}
68
- {homeLink && <Link href="#" icon={<HomeOutlined />} linkSecondary iconAlignRight onClick={homeOnClickFunction}> {!isTablet && t('navigation.home')} </Link>}
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>
@@ -23,4 +23,5 @@ export * from './Upload';
23
23
  export * from './UserInfo';
24
24
  export * from './CategoryReadOnly';
25
25
  export * from './Notification';
26
- export * from './ExportTableData'
26
+ export * from './ExportTableData';
27
+ export * from './DropdownButton';