@ftdata/ui 0.0.15 → 0.0.17
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/Collapse/styles.js +2 -0
- package/dist/components/IconButton/index.d.ts +15 -0
- package/dist/components/IconButton/index.js +37 -0
- package/dist/components/IconButton/modifiers/color.d.ts +36 -0
- package/dist/components/IconButton/modifiers/color.js +38 -0
- package/dist/components/IconButton/styles.d.ts +10 -0
- package/dist/components/IconButton/styles.js +32 -0
- package/dist/components/Menu/constants/icons.d.ts +2 -16
- package/dist/components/Menu/constants/icons.js +13 -58
- package/dist/components/Menu/helpers/createMenus.js +13 -6
- package/dist/components/Menu/helpers/createSubMenus.d.ts +1 -1
- package/dist/components/Menu/helpers/createSubMenus.js +1 -1
- package/dist/components/Menu/helpers/generateColorScale.js +2 -2
- package/dist/components/Menu/helpers/getLuminance.d.ts +1 -1
- package/dist/components/Menu/helpers/getLuminance.js +2 -2
- package/dist/components/Menu/index.d.ts +1 -1
- package/dist/components/Menu/index.js +18 -31
- package/dist/components/Menu/styles.d.ts +0 -1
- package/dist/components/Menu/styles.js +29 -45
- package/dist/components/Menu/types/IconKeysType.d.ts +1 -1
- package/dist/components/Menu/types/MenuItem.d.ts +3 -2
- package/dist/components/Modal/index.d.ts +25 -0
- package/dist/components/Modal/index.js +69 -0
- package/dist/components/Modal/styles.d.ts +8 -0
- package/dist/components/Modal/styles.js +81 -0
- package/dist/components/MultiSelect/components/Badge/index.d.ts +2 -1
- package/dist/components/MultiSelect/components/Badge/index.js +5 -2
- package/dist/components/MultiSelect/components/Badge/styles.d.ts +5 -1
- package/dist/components/MultiSelect/components/Badge/styles.js +2 -1
- package/dist/components/MultiSelect/components/MultiSelectList/Row/index.d.ts +3 -2
- package/dist/components/MultiSelect/components/MultiSelectList/Row/index.js +21 -10
- package/dist/components/MultiSelect/components/MultiSelectList/Row/style.js +0 -1
- package/dist/components/MultiSelect/components/MultiSelectList/index.d.ts +3 -3
- package/dist/components/MultiSelect/components/MultiSelectList/index.js +8 -11
- package/dist/components/MultiSelect/components/MultiSelectList/style.d.ts +1 -1
- package/dist/components/MultiSelect/components/MultiSelectList/style.js +21 -3
- package/dist/components/MultiSelect/helpers/addOption.d.ts +3 -3
- package/dist/components/MultiSelect/helpers/computeUnselected.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/computeUnselected.js +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.js +9 -9
- package/dist/components/MultiSelect/helpers/filterOptions.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/removeOptions.d.ts +3 -3
- package/dist/components/MultiSelect/index.d.ts +37 -19
- package/dist/components/MultiSelect/index.js +92 -135
- package/dist/components/MultiSelect/styles.js +8 -23
- package/dist/components/Texts/paragraphs.d.ts +12 -0
- package/dist/components/Texts/paragraphs.js +14 -0
- package/dist/components/Texts/text.d.ts +17 -0
- package/dist/components/Texts/text.js +21 -0
- package/dist/components/Texts/titles.d.ts +7 -0
- package/dist/components/Texts/titles.js +37 -0
- package/dist/components/fields/modifiers/selectColorModifier.d.ts +1 -1
- package/dist/components/fields/modifiers/selectColorModifier.js +7 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -2
- package/package.json +3 -3
- package/dist/components/Collapse/Colapse.stories.d.ts +0 -10
- package/dist/components/Collapse/Colapse.stories.js +0 -108
- package/dist/components/Menu/Menu.stories.d.ts +0 -6
- package/dist/components/Menu/Menu.stories.js +0 -116
- package/dist/components/MultiSelect/helpers/arraysEqual.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/arraysEqual.js +0 -5
- package/dist/components/MultiSelect/helpers/computeSelected.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/computeSelected.js +0 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.d.ts +0 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.js +0 -17
- package/dist/components/MultiSelect/hooks/useMultiSelect.d.ts +0 -10
- package/dist/components/MultiSelect/hooks/useMultiSelect.js +0 -44
- package/dist/components/MultiSelect/interfaces/actions.d.ts +0 -4
- package/dist/components/MultiSelect/interfaces/actions.js +0 -0
- package/dist/components/MultiSelect/interfaces/config.d.ts +0 -17
- package/dist/components/MultiSelect/interfaces/config.js +0 -0
- package/dist/components/MultiSelect/interfaces/state.d.ts +0 -10
- package/dist/components/MultiSelect/interfaces/state.js +0 -0
- package/dist/components/MultiSelect/reducers/stateReducer.d.ts +0 -21
- package/dist/components/MultiSelect/reducers/stateReducer.js +0 -44
- package/dist/components/Text/Paragraph/Paragraph.stories.d.ts +0 -29
- package/dist/components/Text/Paragraph/Paragraph.stories.js +0 -124
- package/dist/components/Text/Title/Title.stories.d.ts +0 -41
- package/dist/components/Text/Title/Title.stories.js +0 -106
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IconsNames } from "@ftdata/f-icons";
|
|
3
|
+
export type IconButtonVariants = "default" | "accent" | "danger" | "success" | "warning" | "light";
|
|
4
|
+
export type IconButtonSizes = "small" | "medium" | "big";
|
|
5
|
+
interface IconButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
icon: IconsNames;
|
|
7
|
+
variant?: IconButtonVariants;
|
|
8
|
+
size?: IconButtonSizes | string;
|
|
9
|
+
iconSize?: string;
|
|
10
|
+
color?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
active?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export default function IconButton({ icon, variant, size, iconSize, color, disabled, active, ...rest }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { IconButtonStyled } from "./styles.js";
|
|
4
|
+
import { Icon } from "@ftdata/f-icons";
|
|
5
|
+
const SIZE_VARIANTS = {
|
|
6
|
+
small: {
|
|
7
|
+
buttonSize: "1.5rem",
|
|
8
|
+
iconSize: "1rem"
|
|
9
|
+
},
|
|
10
|
+
medium: {
|
|
11
|
+
buttonSize: "2rem",
|
|
12
|
+
iconSize: "1.5rem"
|
|
13
|
+
},
|
|
14
|
+
big: {
|
|
15
|
+
buttonSize: "2.5rem",
|
|
16
|
+
iconSize: "2rem"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function IconButton({ icon, variant = "default", size = "medium", iconSize, color, disabled = false, active = false, ...rest }) {
|
|
20
|
+
const isPresetSize = size in SIZE_VARIANTS;
|
|
21
|
+
const buttonSize = isPresetSize ? SIZE_VARIANTS[size].buttonSize : size;
|
|
22
|
+
const finalIconSize = iconSize || (isPresetSize ? SIZE_VARIANTS[size].iconSize : "1.5rem");
|
|
23
|
+
return /*#__PURE__*/ jsx(IconButtonStyled, {
|
|
24
|
+
variant: variant,
|
|
25
|
+
size: buttonSize,
|
|
26
|
+
color: color,
|
|
27
|
+
disabled: disabled,
|
|
28
|
+
$active: active,
|
|
29
|
+
...rest,
|
|
30
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
31
|
+
name: icon,
|
|
32
|
+
size: finalIconSize,
|
|
33
|
+
color: "currentColor"
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { IconButton as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const ICON_BUTTON_COLOR_MODIFIERS: {
|
|
2
|
+
default: {
|
|
3
|
+
background: string;
|
|
4
|
+
color: string;
|
|
5
|
+
hover: string;
|
|
6
|
+
};
|
|
7
|
+
accent: {
|
|
8
|
+
background: string;
|
|
9
|
+
color: string;
|
|
10
|
+
hover: string;
|
|
11
|
+
};
|
|
12
|
+
danger: {
|
|
13
|
+
background: string;
|
|
14
|
+
color: string;
|
|
15
|
+
hover: string;
|
|
16
|
+
};
|
|
17
|
+
success: {
|
|
18
|
+
background: string;
|
|
19
|
+
color: string;
|
|
20
|
+
hover: string;
|
|
21
|
+
};
|
|
22
|
+
warning: {
|
|
23
|
+
background: string;
|
|
24
|
+
color: string;
|
|
25
|
+
hover: string;
|
|
26
|
+
};
|
|
27
|
+
light: {
|
|
28
|
+
background: string;
|
|
29
|
+
color: string;
|
|
30
|
+
hover: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export declare const ICON_BUTTON_DISABLED_MODIFIERS: {
|
|
34
|
+
opacity: number;
|
|
35
|
+
cursor: string;
|
|
36
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { COLOR_ACCENT_LIGHTER, COLOR_ACCENT_MEDIUM, COLOR_DANGER_LIGHTER, COLOR_DANGER_MEDIUM, COLOR_NEUTRAL_DARKER, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_LIGHTER, COLOR_SUCCESS_LIGHTER, COLOR_SUCCESS_MEDIUM, COLOR_WARNING_LIGHTER, COLOR_WARNING_MEDIUM } from "@ftdata/f-tokens";
|
|
2
|
+
const ICON_BUTTON_COLOR_MODIFIERS = {
|
|
3
|
+
default: {
|
|
4
|
+
background: COLOR_NEUTRAL_LIGHTER,
|
|
5
|
+
color: COLOR_NEUTRAL_DARKER,
|
|
6
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
7
|
+
},
|
|
8
|
+
accent: {
|
|
9
|
+
background: COLOR_ACCENT_LIGHTER,
|
|
10
|
+
color: COLOR_ACCENT_MEDIUM,
|
|
11
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
12
|
+
},
|
|
13
|
+
danger: {
|
|
14
|
+
background: COLOR_DANGER_LIGHTER,
|
|
15
|
+
color: COLOR_DANGER_MEDIUM,
|
|
16
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
17
|
+
},
|
|
18
|
+
success: {
|
|
19
|
+
background: COLOR_SUCCESS_LIGHTER,
|
|
20
|
+
color: COLOR_SUCCESS_MEDIUM,
|
|
21
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
22
|
+
},
|
|
23
|
+
warning: {
|
|
24
|
+
background: COLOR_WARNING_LIGHTER,
|
|
25
|
+
color: COLOR_WARNING_MEDIUM,
|
|
26
|
+
hover: COLOR_NEUTRAL_LIGHTER
|
|
27
|
+
},
|
|
28
|
+
light: {
|
|
29
|
+
background: "rgba(255, 255, 255, 0.5)",
|
|
30
|
+
color: COLOR_NEUTRAL_DAY,
|
|
31
|
+
hover: "rgba(255, 255, 255, 0.32)"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const ICON_BUTTON_DISABLED_MODIFIERS = {
|
|
35
|
+
opacity: 0.5,
|
|
36
|
+
cursor: "not-allowed"
|
|
37
|
+
};
|
|
38
|
+
export { ICON_BUTTON_COLOR_MODIFIERS, ICON_BUTTON_DISABLED_MODIFIERS };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IconButtonVariants } from ".";
|
|
2
|
+
interface IconButtonStyledProps {
|
|
3
|
+
variant: IconButtonVariants;
|
|
4
|
+
size: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
$active?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const IconButtonStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, IconButtonStyledProps>> & string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
import { ICON_BUTTON_COLOR_MODIFIERS, ICON_BUTTON_DISABLED_MODIFIERS } from "./modifiers/color.js";
|
|
3
|
+
import { COLOR_NEUTRAL_DARKER } from "@ftdata/f-tokens";
|
|
4
|
+
const IconButtonStyled = styled_components.button`
|
|
5
|
+
border-radius: 50%;
|
|
6
|
+
transition: all 0.15s ease-in-out;
|
|
7
|
+
width: ${({ size })=>size};
|
|
8
|
+
height: ${({ size })=>size};
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
color: ${({ color })=>color || COLOR_NEUTRAL_DARKER};
|
|
13
|
+
|
|
14
|
+
&:hover {
|
|
15
|
+
background-color: ${({ variant })=>ICON_BUTTON_COLOR_MODIFIERS[variant].hover};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:active {
|
|
19
|
+
background-color: ${({ variant })=>ICON_BUTTON_COLOR_MODIFIERS[variant].background};
|
|
20
|
+
color: ${({ variant })=>ICON_BUTTON_COLOR_MODIFIERS[variant].color};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
${({ $active, variant })=>$active && `
|
|
24
|
+
color: ${ICON_BUTTON_COLOR_MODIFIERS[variant].color};
|
|
25
|
+
`}
|
|
26
|
+
|
|
27
|
+
${({ disabled })=>disabled && `
|
|
28
|
+
opacity: ${ICON_BUTTON_DISABLED_MODIFIERS.opacity};
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
`}
|
|
31
|
+
`;
|
|
32
|
+
export { IconButtonStyled };
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
registration: import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
logistics: import("react/jsx-runtime").JSX.Element;
|
|
5
|
-
reports: import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
driver_behavior: import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
settings: import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
f_analytics: import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
f_speed: import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
title_module_playback_f_view: import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
message: import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
maps: import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
changelog: import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
dashboard: import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
mosaic: import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
};
|
|
1
|
+
import { IconsNames } from "@ftdata/f-icons";
|
|
2
|
+
export declare const ICONS: Record<string, IconsNames>;
|
|
17
3
|
export type IconsKeys = keyof typeof ICONS;
|
|
@@ -1,61 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Icon } from "@ftdata/f-icons";
|
|
1
|
+
import "react";
|
|
3
2
|
const ICONS = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reports: /*#__PURE__*/ jsx(Icon, {
|
|
17
|
-
name: "bp chart-19",
|
|
18
|
-
color: "currentColor"
|
|
19
|
-
}),
|
|
20
|
-
driver_behavior: /*#__PURE__*/ jsx(Icon, {
|
|
21
|
-
name: "nav direction-arrow-road",
|
|
22
|
-
color: "currentColor"
|
|
23
|
-
}),
|
|
24
|
-
settings: /*#__PURE__*/ jsx(Icon, {
|
|
25
|
-
name: "ui settings",
|
|
26
|
-
color: "currentColor"
|
|
27
|
-
}),
|
|
28
|
-
f_analytics: /*#__PURE__*/ jsx(Icon, {
|
|
29
|
-
name: "sm google-analytics",
|
|
30
|
-
color: "currentColor"
|
|
31
|
-
}),
|
|
32
|
-
f_speed: /*#__PURE__*/ jsx(Icon, {
|
|
33
|
-
name: "cs speedometer",
|
|
34
|
-
color: "currentColor"
|
|
35
|
-
}),
|
|
36
|
-
title_module_playback_f_view: /*#__PURE__*/ jsx(Icon, {
|
|
37
|
-
name: "ui video-camera",
|
|
38
|
-
color: "currentColor"
|
|
39
|
-
}),
|
|
40
|
-
message: /*#__PURE__*/ jsx(Icon, {
|
|
41
|
-
name: "eml emails-letter-mail-2",
|
|
42
|
-
color: "currentColor"
|
|
43
|
-
}),
|
|
44
|
-
maps: /*#__PURE__*/ jsx(Icon, {
|
|
45
|
-
name: "nav earth-home-world",
|
|
46
|
-
color: "currentColor"
|
|
47
|
-
}),
|
|
48
|
-
changelog: /*#__PURE__*/ jsx(Icon, {
|
|
49
|
-
name: "ui info-information",
|
|
50
|
-
color: "currentColor"
|
|
51
|
-
}),
|
|
52
|
-
dashboard: /*#__PURE__*/ jsx(Icon, {
|
|
53
|
-
name: "ui dashboard-minimal",
|
|
54
|
-
color: "currentColor"
|
|
55
|
-
}),
|
|
56
|
-
mosaic: /*#__PURE__*/ jsx(Icon, {
|
|
57
|
-
name: "ui grid-layout-add",
|
|
58
|
-
color: "currentColor"
|
|
59
|
-
})
|
|
3
|
+
"fa-building-o": "ui briefcase",
|
|
4
|
+
"fa-edit": "ui plus-add",
|
|
5
|
+
"fa-connectdevelop": "nav arrow-location-direction-1",
|
|
6
|
+
"fa-list-ol": "bp chart-19",
|
|
7
|
+
"fa-road": "nav direction-arrow-road",
|
|
8
|
+
"fa-cogs": "ui settings",
|
|
9
|
+
"fa-bar-chart": "sm google-analytics",
|
|
10
|
+
"fa-gauge": "cs speedometer",
|
|
11
|
+
"fa-camera": "ui video-camera",
|
|
12
|
+
"fa-globe": "nav earth-home-world",
|
|
13
|
+
"fa-truck": "nmk truck",
|
|
14
|
+
"fa-dashboard": "ui dashboard-minimal"
|
|
60
15
|
};
|
|
61
16
|
export { ICONS };
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Icon } from "@ftdata/f-icons";
|
|
2
4
|
import { createSubMenus } from "./createSubMenus.js";
|
|
5
|
+
import { ICONS } from "../constants/icons.js";
|
|
3
6
|
function createMenuItems(data, translate) {
|
|
4
|
-
return data.sort((a, b)=>a.ordenation - b.ordenation).
|
|
5
|
-
const icon =
|
|
7
|
+
return data.sort((a, b)=>a.ordenation - b.ordenation).map((item)=>{
|
|
8
|
+
const icon = /*#__PURE__*/ jsx(Icon, {
|
|
9
|
+
name: ICONS[item.menu_icon.trim()] || "ui plus-add",
|
|
10
|
+
color: "currentColor"
|
|
11
|
+
});
|
|
6
12
|
const subItems = item.itens.sort((a, b)=>a.ordenation - b.ordenation);
|
|
7
13
|
return {
|
|
8
|
-
|
|
9
|
-
icon,
|
|
14
|
+
id: item.id,
|
|
10
15
|
callback: ()=>{
|
|
11
16
|
if (item.endpoint) {
|
|
12
17
|
const url = new URL(item.endpoint, window.location.origin).toString();
|
|
13
18
|
window.open(url, "_blank");
|
|
14
19
|
}
|
|
15
20
|
},
|
|
16
|
-
submenus: createSubMenus(subItems, translate)
|
|
21
|
+
submenus: createSubMenus(subItems, translate),
|
|
22
|
+
icon,
|
|
23
|
+
label: translate(item.translate_key)
|
|
17
24
|
};
|
|
18
25
|
});
|
|
19
26
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MenuItemData, SubMenuData } from
|
|
1
|
+
import { MenuItemData, SubMenuData } from '../types/MenuItem';
|
|
2
2
|
export declare function createSubMenus(data: MenuItemData[], translate: (key: string) => string): SubMenuData[];
|
|
@@ -23,7 +23,7 @@ function generateColorScale(hex) {
|
|
|
23
23
|
950
|
|
24
24
|
];
|
|
25
25
|
const toRgb = (hex)=>{
|
|
26
|
-
const clean = hex.replace(
|
|
26
|
+
const clean = hex.replace('#', '');
|
|
27
27
|
const bigint = parseInt(clean, 16);
|
|
28
28
|
return {
|
|
29
29
|
r: bigint >> 16 & 255,
|
|
@@ -35,7 +35,7 @@ function generateColorScale(hex) {
|
|
|
35
35
|
r,
|
|
36
36
|
g,
|
|
37
37
|
b
|
|
38
|
-
].map((c)=>Math.round(c).toString(16).padStart(2,
|
|
38
|
+
].map((c)=>Math.round(c).toString(16).padStart(2, '0')).join('')}`;
|
|
39
39
|
const mix = (c1, c2, amount)=>c1 + (c2 - c1) * amount;
|
|
40
40
|
const { r: baseR, g: baseG, b: baseB } = toRgb(hex);
|
|
41
41
|
const lighten = (amount)=>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getLuminance(hex: string):
|
|
1
|
+
export declare function getLuminance(hex: string): 'dark' | 'light';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
function getLuminance(hex) {
|
|
2
|
-
const sanitizedHex = hex.replace(
|
|
2
|
+
const sanitizedHex = hex.replace('#', '');
|
|
3
3
|
const r = parseInt(sanitizedHex.substring(0, 2), 16);
|
|
4
4
|
const g = parseInt(sanitizedHex.substring(2, 4), 16);
|
|
5
5
|
const b = parseInt(sanitizedHex.substring(4, 6), 16);
|
|
6
6
|
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
7
|
-
return luminance < 0.5 ?
|
|
7
|
+
return luminance < 0.5 ? 'dark' : 'light';
|
|
8
8
|
}
|
|
9
9
|
export { getLuminance };
|
|
@@ -9,5 +9,5 @@ interface MenuProps {
|
|
|
9
9
|
translate: (key: string) => string;
|
|
10
10
|
active?: string;
|
|
11
11
|
}
|
|
12
|
-
export default function Menu({ background, fontcolor, subMenusBackground, logo, items, translate, active, }: MenuProps):
|
|
12
|
+
export default function Menu({ background, fontcolor, subMenusBackground, logo, items, translate, active, }: MenuProps): JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -7,22 +7,14 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
7
7
|
const [expand, setExpand] = useState(false);
|
|
8
8
|
const [submenus, setSubmenus] = useState([]);
|
|
9
9
|
const [isClosingSubmenu, setIsClosingSubmenu] = useState(false);
|
|
10
|
-
const [menuAnimating, setMenuAnimating] = useState(false);
|
|
11
10
|
const menuRef = useRef(null);
|
|
12
11
|
const menus = createMenus(items, translate);
|
|
13
12
|
const toggleMenu = ()=>{
|
|
14
|
-
if (expand) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
setExpand(false);
|
|
19
|
-
setMenuAnimating(false);
|
|
20
|
-
}, 120);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
13
|
+
if (expand) return void setTimeout(()=>{
|
|
14
|
+
setSubmenus([]);
|
|
15
|
+
setExpand(false);
|
|
16
|
+
}, 120);
|
|
23
17
|
setExpand(true);
|
|
24
|
-
setMenuAnimating(true);
|
|
25
|
-
setTimeout(()=>setMenuAnimating(false), 120);
|
|
26
18
|
};
|
|
27
19
|
const handleClickItem = (event, submenus, callback)=>{
|
|
28
20
|
event.stopPropagation();
|
|
@@ -34,10 +26,6 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
34
26
|
event.stopPropagation();
|
|
35
27
|
toggleMenu();
|
|
36
28
|
};
|
|
37
|
-
const handleClickAside = (event)=>{
|
|
38
|
-
if (!expand) return void toggleMenu();
|
|
39
|
-
if (event.target === event.currentTarget) toggleMenu();
|
|
40
|
-
};
|
|
41
29
|
const handleClickBack = ()=>{
|
|
42
30
|
setIsClosingSubmenu(true);
|
|
43
31
|
setTimeout(()=>{
|
|
@@ -62,7 +50,7 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
62
50
|
return /*#__PURE__*/ jsxs(MenuAside, {
|
|
63
51
|
ref: menuRef,
|
|
64
52
|
background: background,
|
|
65
|
-
onClick:
|
|
53
|
+
onClick: expand ? ()=>null : toggleMenu,
|
|
66
54
|
$expand: expand,
|
|
67
55
|
children: [
|
|
68
56
|
/*#__PURE__*/ jsxs(MenuHeader, {
|
|
@@ -71,12 +59,12 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
71
59
|
onClick: handleClickHamburger,
|
|
72
60
|
fontcolor: fontcolor,
|
|
73
61
|
$expand: expand,
|
|
74
|
-
$animating: menuAnimating,
|
|
75
62
|
children: [
|
|
76
63
|
/*#__PURE__*/ jsx("div", {
|
|
77
64
|
children: /*#__PURE__*/ jsx(Icon, {
|
|
78
65
|
name: "ui menu-burger-square",
|
|
79
|
-
width: "1.5rem"
|
|
66
|
+
width: "1.5rem",
|
|
67
|
+
color: "currentColor"
|
|
80
68
|
})
|
|
81
69
|
}),
|
|
82
70
|
/*#__PURE__*/ jsx("span", {
|
|
@@ -96,7 +84,6 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
96
84
|
onClick: (event)=>handleClickItem(event, menu.submenus, menu.callback),
|
|
97
85
|
$expand: expand || void 0,
|
|
98
86
|
$active: menu.label === translate(active || ""),
|
|
99
|
-
$animating: menuAnimating,
|
|
100
87
|
children: [
|
|
101
88
|
/*#__PURE__*/ jsx("div", {
|
|
102
89
|
children: menu.icon
|
|
@@ -111,24 +98,24 @@ function Menu({ background, fontcolor, subMenusBackground, logo, items, translat
|
|
|
111
98
|
$isClosing: isClosingSubmenu || void 0,
|
|
112
99
|
background: subMenusBackground,
|
|
113
100
|
children: [
|
|
114
|
-
/*#__PURE__*/
|
|
101
|
+
/*#__PURE__*/ jsx(SubItemsHeader, {
|
|
115
102
|
fontcolor: fontcolor,
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
name: "arw arrow-left"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
children: /*#__PURE__*/ jsxs("button", {
|
|
104
|
+
onClick: handleClickBack,
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
107
|
+
name: "arw arrow-left",
|
|
108
|
+
color: "currentColor"
|
|
109
|
+
}),
|
|
110
|
+
translate("back")
|
|
111
|
+
]
|
|
112
|
+
})
|
|
125
113
|
}),
|
|
126
114
|
/*#__PURE__*/ jsx(SubItemsWrapper, {
|
|
127
115
|
background: subMenusBackground,
|
|
128
116
|
children: submenus.map((submenu, idx)=>/*#__PURE__*/ jsx(SubMenuItem, {
|
|
129
117
|
fontcolor: fontcolor,
|
|
130
118
|
onClick: (event)=>handleClickItem(event, [], submenu.callback),
|
|
131
|
-
$animating: menuAnimating,
|
|
132
119
|
children: submenu.label
|
|
133
120
|
}, `${submenu.label}-${idx}`))
|
|
134
121
|
})
|
|
@@ -4,7 +4,6 @@ interface ICommonProps {
|
|
|
4
4
|
$active?: boolean;
|
|
5
5
|
$expand?: boolean;
|
|
6
6
|
$isClosing?: boolean;
|
|
7
|
-
$animating?: boolean;
|
|
8
7
|
}
|
|
9
8
|
export declare const MenuAside: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, ICommonProps>> & string;
|
|
10
9
|
export declare const MenuHeader: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ICommonProps>> & string;
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import styled_components, { keyframes } from "styled-components";
|
|
2
2
|
import { generateColorScale } from "./helpers/generateColorScale.js";
|
|
3
3
|
import { getLuminance } from "./helpers/getLuminance.js";
|
|
4
|
+
const shrinkToRight = keyframes`
|
|
5
|
+
from {
|
|
6
|
+
transform: scaleX(1);
|
|
7
|
+
opacity: 1;
|
|
8
|
+
}
|
|
9
|
+
to {
|
|
10
|
+
transform: scaleX(0);
|
|
11
|
+
opacity: 0;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
const growFromRight = keyframes`
|
|
15
|
+
from {
|
|
16
|
+
transform: scaleX(0);
|
|
17
|
+
opacity: 0;
|
|
18
|
+
}
|
|
19
|
+
to {
|
|
20
|
+
transform: scaleX(1);
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
4
24
|
const fadeOutAndHide = keyframes`
|
|
5
25
|
0% {
|
|
6
26
|
opacity: 1;
|
|
@@ -33,26 +53,6 @@ const fadeInAndShow = keyframes`
|
|
|
33
53
|
display: flex;
|
|
34
54
|
}
|
|
35
55
|
`;
|
|
36
|
-
const submenuEnter = keyframes`
|
|
37
|
-
from {
|
|
38
|
-
width: 0;
|
|
39
|
-
opacity: 0;
|
|
40
|
-
}
|
|
41
|
-
to {
|
|
42
|
-
width: 15.25rem;
|
|
43
|
-
opacity: 1;
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
46
|
-
const submenuExit = keyframes`
|
|
47
|
-
from {
|
|
48
|
-
width: 15.25rem;
|
|
49
|
-
opacity: 1;
|
|
50
|
-
}
|
|
51
|
-
to {
|
|
52
|
-
width: 0;
|
|
53
|
-
opacity: 0;
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
56
|
const MenuAside = styled_components.aside`
|
|
57
57
|
background-color: ${({ background })=>background || "#000"};
|
|
58
58
|
box-sizing: border-box;
|
|
@@ -78,7 +78,6 @@ const MenuHeader = styled_components.div`
|
|
|
78
78
|
`;
|
|
79
79
|
const ContainerLogo = styled_components.div`
|
|
80
80
|
padding: 0 0.5rem;
|
|
81
|
-
max-height: 8.875rem;
|
|
82
81
|
animation: ${({ $expand })=>$expand ? fadeInAndShow : fadeOutAndHide}
|
|
83
82
|
0.25s forwards;
|
|
84
83
|
|
|
@@ -87,7 +86,7 @@ const ContainerLogo = styled_components.div`
|
|
|
87
86
|
align-items: center;
|
|
88
87
|
display: flex;
|
|
89
88
|
justify-content: center;
|
|
90
|
-
max-height:
|
|
89
|
+
max-height: 8.875rem;
|
|
91
90
|
max-width: 100%;
|
|
92
91
|
}
|
|
93
92
|
`;
|
|
@@ -125,40 +124,33 @@ const ItemMenu = styled_components.div`
|
|
|
125
124
|
transition:
|
|
126
125
|
opacity 0.4s ease,
|
|
127
126
|
transform 0.4s ease;
|
|
128
|
-
white-space: ${({ $expand
|
|
127
|
+
white-space: ${({ $expand })=>$expand ? "wrap" : "nowrap"};
|
|
129
128
|
overflow: hidden;
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
&:hover {
|
|
132
131
|
opacity: 1;
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
`;
|
|
136
135
|
const SubItemsContainer = styled_components.div`
|
|
137
|
-
animation: ${({ $isClosing })=>$isClosing ?
|
|
138
|
-
0.
|
|
136
|
+
animation: ${({ $isClosing })=>$isClosing ? shrinkToRight : growFromRight}
|
|
137
|
+
0.4s ease forwards;
|
|
139
138
|
background-color: ${({ background })=>generateColorScale(background || "#000000")[500]};
|
|
140
139
|
box-sizing: border-box;
|
|
141
140
|
display: flex;
|
|
142
141
|
flex-direction: column;
|
|
143
142
|
gap: 0.5rem;
|
|
144
143
|
height: 100%;
|
|
145
|
-
padding:
|
|
144
|
+
padding: 1rem 0 0 1rem;
|
|
146
145
|
position: absolute;
|
|
147
146
|
right: 0;
|
|
148
147
|
top: 0;
|
|
149
148
|
transform-origin: right;
|
|
150
149
|
width: 15.25rem;
|
|
151
150
|
z-index: 1;
|
|
152
|
-
overflow: hidden;
|
|
153
151
|
`;
|
|
154
152
|
const SubItemsHeader = styled_components.div`
|
|
155
153
|
padding: 0.5rem 0 1.5rem 0;
|
|
156
|
-
display: flex;
|
|
157
|
-
gap: 0.5rem;
|
|
158
|
-
color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
|
|
159
|
-
font-size: 1rem;
|
|
160
|
-
line-height: 1.5rem;
|
|
161
|
-
font-weight: 500;
|
|
162
154
|
|
|
163
155
|
button {
|
|
164
156
|
align-items: center;
|
|
@@ -167,18 +159,13 @@ const SubItemsHeader = styled_components.div`
|
|
|
167
159
|
color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
|
|
168
160
|
cursor: pointer;
|
|
169
161
|
display: flex;
|
|
162
|
+
font-size: 1rem;
|
|
163
|
+
font-weight: 500;
|
|
170
164
|
gap: 0.5rem;
|
|
171
165
|
line-height: 1rem;
|
|
172
166
|
margin: 0;
|
|
173
|
-
border-radius: 50%;
|
|
174
167
|
padding: 0;
|
|
175
|
-
transition:
|
|
176
|
-
|
|
177
|
-
&:hover {
|
|
178
|
-
background-color: ${({ background })=>generateColorScale(background || "#00000")["dark" === getLuminance(background || "#00000") ? 400 : 600]};
|
|
179
|
-
box-shadow: 0 0 0 2px
|
|
180
|
-
${({ background })=>generateColorScale(background || "#00000")["dark" === getLuminance(background || "#00000") ? 400 : 600]};
|
|
181
|
-
}
|
|
168
|
+
transition: opacity 0.2s ease;
|
|
182
169
|
}
|
|
183
170
|
`;
|
|
184
171
|
const SubItemsWrapper = styled_components.div`
|
|
@@ -207,9 +194,6 @@ const SubMenuItem = styled_components.span`
|
|
|
207
194
|
opacity: ${({ $active })=>$active ? "1" : "0.68"};
|
|
208
195
|
padding: 0.5rem 0.75rem;
|
|
209
196
|
transition: background-color 0.2s ease;
|
|
210
|
-
white-space: ${({ $expand, $animating })=>$expand && !$animating ? "normal" : "nowrap"};
|
|
211
|
-
overflow: hidden;
|
|
212
|
-
text-overflow: ellipsis;
|
|
213
197
|
|
|
214
198
|
&:hover {
|
|
215
199
|
opacity: 1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ICONS } from
|
|
1
|
+
import { ICONS } from '../constants/icons';
|
|
2
2
|
export type IconsKeysType = keyof typeof ICONS;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { JSX } from
|
|
2
|
-
import { IconsKeysType } from
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { IconsKeysType } from './IconKeysType';
|
|
3
3
|
export type SubMenuData = {
|
|
4
4
|
callback: () => void;
|
|
5
5
|
label: string;
|
|
@@ -19,6 +19,7 @@ export type MenuItemData = {
|
|
|
19
19
|
ordenation: number;
|
|
20
20
|
};
|
|
21
21
|
export type MenuItem = {
|
|
22
|
+
id: number;
|
|
22
23
|
callback: () => void;
|
|
23
24
|
submenus: SubMenu[];
|
|
24
25
|
icon: JSX.Element;
|