@ftdata/ui 0.0.4 → 0.0.5

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,2 @@
1
+ import Inter_Regular_namespaceObject from "../../static/font/Inter-Regular.ttf";
2
+ export { Inter_Regular_namespaceObject as default };
@@ -19,10 +19,6 @@ export declare const Sizes: Story;
19
19
  * Variante do Avatar com nome de usuário.
20
20
  */
21
21
  export declare const Alt: Story;
22
- /**
23
- * Variação do Avatar quando o usuário está online.
24
- */
25
- export declare const Active: Story;
26
22
  /**
27
23
  * Variação do Avatar com imagem de usuário personalizada.
28
24
  */
@@ -21,14 +21,6 @@ const meta = {
21
21
  }
22
22
  }
23
23
  },
24
- active: {
25
- description: "Define se o usu\xe1rio est\xe1 online ou offline (Pontinho verde no canto inferior direito).",
26
- table: {
27
- defaultValue: {
28
- summary: "false"
29
- }
30
- }
31
- },
32
24
  alt: {
33
25
  description: "Define a propriedade alt da imagem. Representa tamb\xe9m o nome de usu\xe1rio.",
34
26
  table: {
@@ -86,21 +78,12 @@ const Sizes = {
86
78
  },
87
79
  alt: {
88
80
  control: false
89
- },
90
- active: {
91
- control: false
92
81
  }
93
82
  }
94
83
  };
95
84
  const Alt = {
96
85
  args: {
97
- alt: "Alt Name",
98
- size: "large"
99
- }
100
- };
101
- const Active = {
102
- args: {
103
- active: true,
86
+ alt: "USER",
104
87
  size: "large"
105
88
  }
106
89
  };
@@ -168,10 +151,7 @@ const Index = {
168
151
  },
169
152
  alt: {
170
153
  control: false
171
- },
172
- active: {
173
- control: false
174
154
  }
175
155
  }
176
156
  };
177
- export { Active, Alt, CustomImage, Default, Index, Sizes, Avatar_stories as default };
157
+ export { Alt, CustomImage, Default, Index, Sizes, Avatar_stories as default };
@@ -1,6 +1,6 @@
1
1
  interface AvatarColors {
2
2
  background: string;
3
- fontColor: string;
3
+ color: string;
4
4
  }
5
5
  export declare const getAvatarColors: (index?: number) => AvatarColors;
6
6
  export {};
@@ -2,35 +2,35 @@ import { COLOR_VISUAL_BLUE, COLOR_VISUAL_CYAN, COLOR_VISUAL_GREEN, COLOR_VISUAL_
2
2
  const AVATAR_COLORS = [
3
3
  {
4
4
  background: `${COLOR_VISUAL_BLUE}2d`,
5
- fontColor: COLOR_VISUAL_BLUE
5
+ color: COLOR_VISUAL_BLUE
6
6
  },
7
7
  {
8
8
  background: `${COLOR_VISUAL_CYAN}2d`,
9
- fontColor: COLOR_VISUAL_CYAN
9
+ color: COLOR_VISUAL_CYAN
10
10
  },
11
11
  {
12
12
  background: `${COLOR_VISUAL_GREEN}2d`,
13
- fontColor: COLOR_VISUAL_GREEN
13
+ color: COLOR_VISUAL_GREEN
14
14
  },
15
15
  {
16
16
  background: `${COLOR_VISUAL_YELLOW}2d`,
17
- fontColor: COLOR_VISUAL_YELLOW
17
+ color: COLOR_VISUAL_YELLOW
18
18
  },
19
19
  {
20
20
  background: `${COLOR_VISUAL_ORANGE}2d`,
21
- fontColor: COLOR_VISUAL_ORANGE
21
+ color: COLOR_VISUAL_ORANGE
22
22
  },
23
23
  {
24
24
  background: `${COLOR_VISUAL_RED}2d`,
25
- fontColor: COLOR_VISUAL_RED
25
+ color: COLOR_VISUAL_RED
26
26
  },
27
27
  {
28
28
  background: `${COLOR_VISUAL_VIOLET}2d`,
29
- fontColor: COLOR_VISUAL_VIOLET
29
+ color: COLOR_VISUAL_VIOLET
30
30
  },
31
31
  {
32
32
  background: `${COLOR_VISUAL_PURPLE}2d`,
33
- fontColor: COLOR_VISUAL_PURPLE
33
+ color: COLOR_VISUAL_PURPLE
34
34
  }
35
35
  ];
36
36
  const getAvatarColors = (index)=>{
@@ -0,0 +1 @@
1
+ export declare function getInitials(name?: string): string;
@@ -0,0 +1,14 @@
1
+ function getInitials(name) {
2
+ if (!name) return "JD";
3
+ const words = name.trim().split(" ").filter(Boolean);
4
+ if (0 === words.length) return "JD";
5
+ if (1 === words.length) {
6
+ const word = words[0];
7
+ if (1 === word.length) return word[0].toUpperCase();
8
+ return (word[0] + word[word.length - 1]).toUpperCase();
9
+ }
10
+ const first = words[0][0];
11
+ const last = words[words.length - 1][0];
12
+ return (first + last).toUpperCase();
13
+ }
14
+ export { getInitials };
@@ -1,7 +1,6 @@
1
1
  export interface AvatarProps extends React.ImgHTMLAttributes<HTMLImageElement> {
2
2
  alt?: string;
3
- active?: boolean;
4
3
  size?: "large" | "medium" | "small" | "mini";
5
4
  index?: number;
6
5
  }
7
- export default function Avatar({ alt, src, active, size, index, ...rest }: AvatarProps): import("react/jsx-runtime").JSX.Element;
6
+ export default function Avatar({ alt, src, size, index, ...rest }: AvatarProps): import("react/jsx-runtime").JSX.Element;
@@ -1,28 +1,26 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Image, StatusDot, Wrapper } from "./styles.js";
3
- import { getAvatarColors } from "./utils/getAvatarColors.js";
4
- function Avatar({ alt, src, active, size = "medium", index, ...rest }) {
5
- const imageSource = ()=>{
6
- if (src) return src;
7
- const { background, fontColor } = getAvatarColors(index);
8
- const name = alt?.length ? alt.split(" ").join("+") : "John Doe";
9
- return `https://ui-avatars.com/api/
10
- ?name=${name}
11
- &length=2
12
- &size=40
13
- &bold=true
14
- &background=${background.replace("#", "")}
15
- &color=${fontColor.replace("#", "")}`;
16
- };
17
- return /*#__PURE__*/ jsxs(Wrapper, {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Image, Initials, Wrapper } from "./styles.js";
3
+ import { getAvatarColors } from "./helpers/getAvatarColors.js";
4
+ import { getInitials } from "./helpers/getInitials.js";
5
+ import { useRef } from "react";
6
+ function Avatar({ alt, src, size = "medium", index, ...rest }) {
7
+ const initials = getInitials(alt);
8
+ const styleRef = useRef(getAvatarColors(index));
9
+ const { background, color } = styleRef.current;
10
+ return /*#__PURE__*/ jsx(Wrapper, {
18
11
  size: size,
19
12
  ...rest,
20
- children: [
21
- /*#__PURE__*/ jsx(Image, {
22
- src: imageSource()
23
- }),
24
- active && "mini" !== size && /*#__PURE__*/ jsx(StatusDot, {})
25
- ]
13
+ children: src ? /*#__PURE__*/ jsx(Image, {
14
+ src: src,
15
+ alt: alt
16
+ }) : /*#__PURE__*/ jsx(Initials, {
17
+ background: background,
18
+ color: color,
19
+ size: size,
20
+ children: /*#__PURE__*/ jsx("span", {
21
+ children: initials
22
+ })
23
+ })
26
24
  });
27
25
  }
28
26
  export { Avatar as default };
@@ -1,4 +1,10 @@
1
1
  import type { AvatarProps } from ".";
2
2
  export declare const Wrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, AvatarProps>> & string;
3
+ interface InitialsProps {
4
+ background: string;
5
+ color: string;
6
+ size?: AvatarProps["size"];
7
+ }
8
+ export declare const Initials: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, InitialsProps>> & string;
3
9
  export declare const Image: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, never>> & string;
4
- export declare const StatusDot: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
10
+ export {};
@@ -1,19 +1,44 @@
1
1
  import styled_components from "styled-components";
2
- import { COLOR_NEUTRAL_DAY, COLOR_SUCCESS_MEDIUM } from "@ftdata/f-tokens";
2
+ import { COLOR_NEUTRAL_DAY } from "@ftdata/f-tokens";
3
3
  const AVATAR_SIZES = {
4
4
  large: "height: 2.5rem; width: 2.5rem;",
5
5
  medium: "height: 2rem; width: 2rem;",
6
6
  small: "height: 1.5rem; width: 1.5rem;",
7
7
  mini: "height: 1rem; width: 1rem;"
8
8
  };
9
+ const FONT_SIZES = {
10
+ large: "2.5rem",
11
+ medium: "2rem",
12
+ small: "1.5rem",
13
+ mini: "1rem"
14
+ };
9
15
  const Wrapper = styled_components.div`
10
16
  border-radius: 50%;
11
17
  background-color: ${COLOR_NEUTRAL_DAY};
12
18
  height: 100%;
13
19
  position: relative;
14
20
  width: 100%;
21
+ font-size: ${({ size })=>FONT_SIZES[size ?? "medium"]};
22
+
23
+ ${({ size })=>AVATAR_SIZES[size ?? "medium"]};
24
+ `;
25
+ const Initials = styled_components.div`
26
+ background-color: ${({ background })=>background};
27
+ width: 100%;
28
+ height: 100%;
29
+ border-radius: 50%;
30
+ color: ${({ color })=>color};
31
+ display: flex;
32
+ align-items: center;
33
+ justify-content: center;
34
+ line-height: 1em;
15
35
 
16
- ${({ size })=>AVATAR_SIZES[size ? size : "medium"]};
36
+ span {
37
+ font-weight: 700;
38
+ text-transform: uppercase;
39
+ font-size: 0.45em;
40
+ font-family: "Inter", sans-serif;
41
+ }
17
42
  `;
18
43
  const Image = styled_components.img`
19
44
  border-radius: 50%;
@@ -21,17 +46,4 @@ const Image = styled_components.img`
21
46
  object-fit: cover;
22
47
  width: 100%;
23
48
  `;
24
- const StatusDot = styled_components.span`
25
- background-color: ${COLOR_SUCCESS_MEDIUM};
26
- border-color: ${COLOR_NEUTRAL_DAY};
27
- border-style: solid;
28
- border-width: 0.125rem;
29
- border-radius: 50%;
30
- bottom: -0.125rem;
31
- display: block;
32
- height: 0.5rem;
33
- position: absolute;
34
- right: -0.125rem;
35
- width: 0.5rem;
36
- `;
37
- export { Image, StatusDot, Wrapper };
49
+ export { Image, Initials, Wrapper };
@@ -2,11 +2,11 @@ import { JSX } from "react";
2
2
  import { MenuItemData } from "./types/MenuItem";
3
3
  interface MenuProps {
4
4
  background: string;
5
- fontColor: string;
5
+ fontcolor: string;
6
6
  subMenusBackground: string;
7
7
  logo: JSX.Element;
8
8
  items: MenuItemData[];
9
9
  translate: (key: string) => string;
10
10
  }
11
- export default function Menu({ background, fontColor, subMenusBackground, logo, items, translate, }: MenuProps): import("react/jsx-runtime").JSX.Element;
11
+ export default function Menu({ background, fontcolor, subMenusBackground, logo, items, translate, }: MenuProps): import("react/jsx-runtime").JSX.Element;
12
12
  export {};
@@ -3,7 +3,7 @@ import { useState } from "react";
3
3
  import { ContainerLogo, ItemMenu, ItemsContainer, MenuAside, MenuHeader, SubItemsContainer, SubItemsHeader, SubItemsWrapper, SubMenuItem } from "./styles.js";
4
4
  import createMenus from "./helpers/createMenus.js";
5
5
  import { Icon } from "@ftdata/f-icons";
6
- function Menu({ background, fontColor, subMenusBackground, logo, items, translate }) {
6
+ function Menu({ background, fontcolor, subMenusBackground, logo, items, translate }) {
7
7
  const [expand, setExpand] = useState(false);
8
8
  const [submenus, setSubmenus] = useState([]);
9
9
  const [isClosingSubmenu, setIsClosingSubmenu] = useState(false);
@@ -35,14 +35,14 @@ function Menu({ background, fontColor, subMenusBackground, logo, items, translat
35
35
  return /*#__PURE__*/ jsxs(MenuAside, {
36
36
  background: background,
37
37
  onClick: expand ? ()=>null : toggleMenu,
38
- expand: expand,
38
+ $expand: expand,
39
39
  children: [
40
40
  /*#__PURE__*/ jsxs(MenuHeader, {
41
41
  children: [
42
42
  /*#__PURE__*/ jsxs(ItemMenu, {
43
43
  onClick: handleClickHamburger,
44
- fontColor: fontColor,
45
- expand: expand,
44
+ fontcolor: fontcolor,
45
+ $expand: expand,
46
46
  children: [
47
47
  /*#__PURE__*/ jsx("div", {
48
48
  children: /*#__PURE__*/ jsx(Icon, {
@@ -56,16 +56,16 @@ function Menu({ background, fontColor, subMenusBackground, logo, items, translat
56
56
  ]
57
57
  }),
58
58
  /*#__PURE__*/ jsx(ContainerLogo, {
59
- expand: expand,
59
+ $expand: expand || void 0,
60
60
  children: logo
61
61
  })
62
62
  ]
63
63
  }),
64
64
  /*#__PURE__*/ jsx(ItemsContainer, {
65
65
  children: menus.map((menu, idx)=>/*#__PURE__*/ jsxs(ItemMenu, {
66
- fontColor: fontColor,
66
+ fontcolor: fontcolor,
67
67
  onClick: (event)=>handleClickItem(event, menu.submenus, menu.callback),
68
- expand: expand,
68
+ $expand: expand || void 0,
69
69
  children: [
70
70
  /*#__PURE__*/ jsx("div", {
71
71
  children: menu.icon
@@ -77,11 +77,11 @@ function Menu({ background, fontColor, subMenusBackground, logo, items, translat
77
77
  }, `${menu.label}-${idx}`))
78
78
  }),
79
79
  submenus.length > 0 && /*#__PURE__*/ jsxs(SubItemsContainer, {
80
- isClosing: isClosingSubmenu,
80
+ $isClosing: isClosingSubmenu || void 0,
81
81
  background: subMenusBackground,
82
82
  children: [
83
83
  /*#__PURE__*/ jsx(SubItemsHeader, {
84
- fontColor: fontColor,
84
+ fontcolor: fontcolor,
85
85
  children: /*#__PURE__*/ jsxs("button", {
86
86
  onClick: handleClickBack,
87
87
  children: [
@@ -95,7 +95,7 @@ function Menu({ background, fontColor, subMenusBackground, logo, items, translat
95
95
  /*#__PURE__*/ jsx(SubItemsWrapper, {
96
96
  background: subMenusBackground,
97
97
  children: submenus.map((submenu, idx)=>/*#__PURE__*/ jsx(SubMenuItem, {
98
- fontColor: fontColor,
98
+ fontcolor: fontcolor,
99
99
  onClick: (event)=>handleClickItem(event, [], submenu.callback),
100
100
  children: submenu.label
101
101
  }, `${submenu.label}-${idx}`))
@@ -1,9 +1,9 @@
1
1
  interface ICommonProps {
2
2
  background?: string;
3
- fontColor?: string;
4
- active?: boolean;
5
- expand?: boolean;
6
- isClosing?: boolean;
3
+ fontcolor?: string;
4
+ $active?: boolean;
5
+ $expand?: boolean;
6
+ $isClosing?: boolean;
7
7
  }
8
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;
9
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;
@@ -64,7 +64,7 @@ const MenuAside = styled_components.aside`
64
64
  padding: 1rem 0.5rem;
65
65
  position: relative;
66
66
  transition: width 0.3s ease-in-out;
67
- width: ${({ expand })=>expand ? "18.75rem" : "3.5rem"};
67
+ width: ${({ $expand })=>$expand ? "18.75rem" : "3.5rem"};
68
68
 
69
69
  * {
70
70
  font-family: "Inter", sans-serif;
@@ -78,8 +78,8 @@ const MenuHeader = styled_components.div`
78
78
  `;
79
79
  const ContainerLogo = styled_components.div`
80
80
  padding: 0 0.5rem;
81
- animation: ${({ expand })=>expand ? fadeInAndShow : fadeOutAndHide} 0.25s
82
- forwards;
81
+ animation: ${({ $expand })=>$expand ? fadeInAndShow : fadeOutAndHide}
82
+ 0.25s forwards;
83
83
 
84
84
  svg,
85
85
  img {
@@ -101,7 +101,7 @@ const ItemMenu = styled_components.div`
101
101
  cursor: pointer;
102
102
  display: flex;
103
103
  gap: 0.75rem;
104
- opacity: ${({ active })=>active ? "1" : "0.68"};
104
+ opacity: ${({ $active })=>$active ? "1" : "0.68"};
105
105
  transition: all 0.18s ease-in-out;
106
106
  width: 100%;
107
107
 
@@ -114,17 +114,17 @@ const ItemMenu = styled_components.div`
114
114
  display: flex;
115
115
  justify-content: center;
116
116
  padding: 0.5rem;
117
- color: ${({ fontColor })=>fontColor || "#FFFFFF"};
117
+ color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
118
118
  }
119
119
 
120
120
  span {
121
- color: ${({ fontColor })=>fontColor || "#FFFFFF"};
122
- opacity: ${({ expand })=>expand ? 1 : 0};
123
- transform: translateX(${({ expand })=>expand ? "0" : "-8px"});
121
+ color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
122
+ opacity: ${({ $expand })=>$expand ? 1 : 0};
123
+ transform: translateX(${({ $expand })=>$expand ? "0" : "-8px"});
124
124
  transition:
125
125
  opacity 0.4s ease,
126
126
  transform 0.4s ease;
127
- white-space: ${({ expand })=>expand ? "wrap" : "nowrap"};
127
+ white-space: ${({ $expand })=>$expand ? "wrap" : "nowrap"};
128
128
  overflow: hidden;
129
129
 
130
130
  &:hover {
@@ -133,7 +133,7 @@ const ItemMenu = styled_components.div`
133
133
  }
134
134
  `;
135
135
  const SubItemsContainer = styled_components.div`
136
- animation: ${({ isClosing })=>isClosing ? shrinkToRight : growFromRight}
136
+ animation: ${({ $isClosing })=>$isClosing ? shrinkToRight : growFromRight}
137
137
  0.4s ease forwards;
138
138
  background-color: ${({ background })=>generateColorScale(background || "#000000")[500]};
139
139
  box-sizing: border-box;
@@ -156,7 +156,7 @@ const SubItemsHeader = styled_components.div`
156
156
  align-items: center;
157
157
  background: transparent;
158
158
  border: none;
159
- color: ${({ fontColor })=>fontColor || "#FFFFFF"};
159
+ color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
160
160
  cursor: pointer;
161
161
  display: flex;
162
162
  font-size: 1rem;
@@ -186,12 +186,12 @@ const SubItemsWrapper = styled_components.div`
186
186
  `;
187
187
  const SubMenuItem = styled_components.span`
188
188
  border-radius: 6px;
189
- color: ${({ fontColor })=>fontColor || "#FFFFFF"};
189
+ color: ${({ fontcolor })=>fontcolor || "#FFFFFF"};
190
190
  cursor: pointer;
191
191
  font-size: 0.875rem;
192
192
  font-weight: 500;
193
193
  line-height: 1.5rem;
194
- opacity: ${({ active })=>active ? "1" : "0.68"};
194
+ opacity: ${({ $active })=>$active ? "1" : "0.68"};
195
195
  padding: 0.5rem 0.75rem;
196
196
  transition: background-color 0.2s ease;
197
197
 
@@ -201,5 +201,25 @@ img, video {
201
201
 
202
202
  body {
203
203
  font-family: Inter, sans-serif;
204
+
205
+ & ::-webkit-scrollbar-track {
206
+ background-color: #f4f4f4;
207
+ }
208
+
209
+ & ::-webkit-scrollbar {
210
+ background: #f4f4f4;
211
+ width: 10px;
212
+ }
213
+
214
+ & ::-webkit-scrollbar-thumb {
215
+ background: #d5d8da;
216
+ border-radius: 10px;
217
+ }
218
+ }
219
+
220
+ @font-face {
221
+ font-family: Inter;
222
+ font-style: normal;
223
+ src: url(../static/font/Inter-Regular.ttf) format("truetype");
204
224
  }
205
225
 
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@ftdata/ui",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
8
8
  "import": "./dist/index.js"
9
+ },
10
+ "./base.css": {
11
+ "default": "./dist/style/base.css"
9
12
  }
10
13
  },
11
14
  "types": "./dist/index.d.ts",