pge-front-common 1.0.2 → 2.0.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.
Files changed (44) hide show
  1. package/.storybook/main.ts +22 -21
  2. package/.storybook/preview.ts +24 -13
  3. package/README.md +22 -6
  4. package/package.json +49 -44
  5. package/src/components/Button/Button.stories.tsx +21 -23
  6. package/src/components/Button/Button.tsx +22 -46
  7. package/src/components/Button/styles.tsx +39 -0
  8. package/src/components/Modal/Modal.stories.tsx +62 -0
  9. package/src/components/Modal/Modal.tsx +42 -0
  10. package/src/components/Modal/ModalConfirm/ModalConfirm.stories.tsx +48 -0
  11. package/src/components/Modal/ModalConfirm/index.tsx +32 -0
  12. package/src/components/Modal/ModalConfirm/styles.tsx +9 -0
  13. package/src/components/Modal/styles.tsx +75 -0
  14. package/src/components/theme.ts +24 -0
  15. package/src/icons/add-cell-icon.tsx +17 -0
  16. package/src/icons/add-icon.tsx +17 -0
  17. package/src/icons/arrow-expland-icon.tsx +17 -0
  18. package/src/icons/arrow-to-recall-icon.tsx +17 -0
  19. package/src/icons/calendar-icon.tsx +17 -0
  20. package/src/icons/check-circle-icon.tsx +17 -0
  21. package/src/icons/circle-expland-icon.tsx +17 -0
  22. package/src/icons/circle-to-recall-icon.tsx +17 -0
  23. package/src/icons/close-icon.tsx +17 -0
  24. package/src/icons/delete-icon.tsx +17 -0
  25. package/src/icons/download-icon.tsx +17 -0
  26. package/src/icons/edit-icon.tsx +17 -0
  27. package/src/icons/event-avaliable-icon.tsx +17 -0
  28. package/src/icons/icons.stories.tsx +92 -0
  29. package/src/icons/index.ts +49 -0
  30. package/src/icons/logout-icon.tsx +17 -0
  31. package/src/icons/new-tab-icon.tsx +17 -0
  32. package/src/icons/pdf-icon.tsx +17 -0
  33. package/src/icons/profile-icon.tsx +17 -0
  34. package/src/icons/remove-icon.tsx +14 -0
  35. package/src/icons/swap-icon.tsx +17 -0
  36. package/src/icons/triangle-expand-icon.tsx +14 -0
  37. package/src/icons/triangle-to-recall-icon.tsx +14 -0
  38. package/src/icons/upload-icon.tsx +17 -0
  39. package/src/icons/visibillity-icon.tsx +17 -0
  40. package/src/icons/warning-icon.tsx +17 -0
  41. package/src/index.ts +54 -1
  42. package/src/styled-components.d.ts +25 -0
  43. package/tsconfig.json +1 -1
  44. package/src/components/Button/button.css +0 -30
@@ -1,21 +1,22 @@
1
- import type { StorybookConfig } from "@storybook/react-vite";
2
-
3
- const config: StorybookConfig = {
4
- stories: [
5
- // "../stories/**/*.mdx",
6
- // "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
7
- "../src/**/*.stories.tsx",
8
- ],
9
- addons: [
10
- "@storybook/addon-onboarding",
11
- "@storybook/addon-links",
12
- "@storybook/addon-essentials",
13
- "@chromatic-com/storybook",
14
- "@storybook/addon-interactions",
15
- ],
16
- framework: {
17
- name: "@storybook/react-vite",
18
- options: {},
19
- },
20
- };
21
- export default config;
1
+ import type { StorybookConfig } from "@storybook/react-vite";
2
+
3
+ const config: StorybookConfig = {
4
+ stories: [
5
+ // "../stories/**/*.mdx",
6
+ // "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
7
+ "../src/**/*.stories.tsx",
8
+ ],
9
+ addons: [
10
+ "@storybook/addon-onboarding",
11
+ "@storybook/addon-links",
12
+ "@storybook/addon-essentials",
13
+ "@chromatic-com/storybook",
14
+ "@storybook/addon-interactions",
15
+ "@storybook/addon-themes",
16
+ ],
17
+ framework: {
18
+ name: "@storybook/react-vite",
19
+ options: {},
20
+ },
21
+ };
22
+ export default config;
@@ -1,14 +1,25 @@
1
- import type { Preview } from "@storybook/react";
2
-
3
- const preview: Preview = {
4
- parameters: {
5
- controls: {
6
- matchers: {
7
- color: /(background|color)$/i,
8
- date: /Date$/i,
9
- },
10
- },
11
- },
12
- };
1
+ // .storybook/preview.jsx
2
+ import { createGlobalStyle, ThemeProvider } from "styled-components";
3
+ import { withThemeFromJSXProvider } from "@storybook/addon-themes";
4
+
5
+ import theme from "../src/components/theme";
6
+
7
+ const GlobalStyle = createGlobalStyle`
8
+ @import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
9
+ body {
10
+ font-family: 'Open Sans', sans-serif !;
11
+ }
12
+ `;
13
13
 
14
- export default preview;
14
+ /* snipped for brevity */
15
+
16
+ export const decorators = [
17
+ withThemeFromJSXProvider({
18
+ themes: {
19
+ default: theme,
20
+ },
21
+ defaultTheme: "default",
22
+ Provider: ThemeProvider,
23
+ GlobalStyles: GlobalStyle,
24
+ }),
25
+ ];
package/README.md CHANGED
@@ -10,16 +10,14 @@ My Component Library é uma biblioteca de componentes React criada com TypeScrip
10
10
  - [Instalação](#instalação)
11
11
  - [Uso](#uso)
12
12
  - [Desenvolvimento](#desenvolvimento)
13
- - [Componentes](#componentes)
14
- - [Contribuição](#contribuição)
15
- - [Licença](#licença)
13
+ - [Template Pull Request](#template)
16
14
 
17
15
  ## Instalação
18
16
 
19
17
  Instale a biblioteca usando npm:
20
18
 
21
19
  ```bash
22
- npm install pge-design-system
20
+ npm i pge-front-common
23
21
  ```
24
22
 
25
23
  ## Uso
@@ -28,7 +26,7 @@ Instale a biblioteca usando npm:
28
26
 
29
27
  ```typescript
30
28
  import React from 'react';
31
- import { Button } from 'my-component-library';
29
+ import { Button } from 'pge-front-common';
32
30
 
33
31
  const App: React.FC = () => {
34
32
  const handleClick = () => {
@@ -38,7 +36,7 @@ const App: React.FC = () => {
38
36
  return (
39
37
  <div>
40
38
  <h1>Hello, World!</h1>
41
- <Button label="Click Me" onClick={handleClick} />
39
+ <Button variant="secondary" text="Text" />
42
40
  </div>
43
41
  );
44
42
  };
@@ -62,3 +60,21 @@ npm run storybook
62
60
  ```
63
61
 
64
62
  O Storybook estará disponível em http://localhost:6006.
63
+
64
+ ## Template Pull Request
65
+
66
+ # Qual é a Feature ou Bug?
67
+
68
+ # Como foi implementada a solução?
69
+
70
+
71
+ # Isso pode impactar outra parte do projeto?
72
+
73
+
74
+ # O que é esperado após esta implementação
75
+
76
+
77
+ # Existem alterações na UI/UX? (screenshots, gravações de tela)
78
+
79
+
80
+ # Como reproduzir esta feature/correção?
package/package.json CHANGED
@@ -1,44 +1,49 @@
1
- {
2
- "devDependencies": {
3
- "@chromatic-com/storybook": "^1.6.0",
4
- "@rollup/plugin-commonjs": "^26.0.1",
5
- "@rollup/plugin-node-resolve": "^15.2.3",
6
- "@rollup/plugin-typescript": "^11.1.6",
7
- "@storybook/addon-essentials": "^8.1.11",
8
- "@storybook/addon-interactions": "^8.1.11",
9
- "@storybook/addon-links": "^8.1.11",
10
- "@storybook/addon-onboarding": "^8.1.11",
11
- "@storybook/blocks": "^8.1.11",
12
- "@storybook/react": "^8.1.11",
13
- "@storybook/react-vite": "^8.1.11",
14
- "@storybook/test": "^8.1.11",
15
- "@types/react": "^18.3.3",
16
- "postcss": "^8.4.39",
17
- "react": "^18.3.1",
18
- "react-dom": "^18.3.1",
19
- "rollup": "^4.18.0",
20
- "rollup-plugin-dts": "^6.1.1",
21
- "rollup-plugin-peer-deps-external": "^2.2.4",
22
- "rollup-plugin-postcss": "^4.0.2",
23
- "storybook": "^8.1.11",
24
- "typescript": "^5.5.2"
25
- },
26
- "peerDependencies": {
27
- "react": "^18.2.0",
28
- "react-dom": "^18.2.0"
29
- },
30
- "scripts": {
31
- "storybook": "storybook dev -p 6006",
32
- "build-storybook": "storybook build",
33
- "build": "rollup -c"
34
- },
35
- "main": "lib/index.js",
36
- "module": "lib/index.esm.js",
37
- "types": "lib/index.d.ts",
38
- "name": "pge-front-common",
39
- "version": "1.0.2",
40
- "description": "",
41
- "keywords": [],
42
- "author": "sturmer cesar",
43
- "license": "ISC"
44
- }
1
+ {
2
+ "devDependencies": {
3
+ "@chromatic-com/storybook": "^1.6.0",
4
+ "@radix-ui/react-alert-dialog": "^1.1.1",
5
+ "@rollup/plugin-commonjs": "^26.0.1",
6
+ "@rollup/plugin-node-resolve": "^15.2.3",
7
+ "@rollup/plugin-typescript": "^11.1.6",
8
+ "@storybook/addon-essentials": "^8.1.11",
9
+ "@storybook/addon-interactions": "^8.1.11",
10
+ "@storybook/addon-links": "^8.1.11",
11
+ "@storybook/addon-onboarding": "^8.1.11",
12
+ "@storybook/addon-themes": "^8.1.11",
13
+ "@storybook/blocks": "^8.1.11",
14
+ "@storybook/react": "^8.1.11",
15
+ "@storybook/react-vite": "^8.1.11",
16
+ "@storybook/test": "^8.1.11",
17
+ "@types/react": "^18.3.3",
18
+ "postcss": "^8.4.39",
19
+ "react": "^18.3.1",
20
+ "react-dom": "^18.3.1",
21
+ "rollup": "^4.18.0",
22
+ "rollup-plugin-dts": "^6.1.1",
23
+ "rollup-plugin-peer-deps-external": "^2.2.4",
24
+ "rollup-plugin-postcss": "^4.0.2",
25
+ "storybook": "^8.1.11",
26
+ "typescript": "^5.5.2"
27
+ },
28
+ "peerDependencies": {
29
+ "react": "^18.2.0",
30
+ "react-dom": "^18.2.0"
31
+ },
32
+ "scripts": {
33
+ "storybook": "storybook dev -p 6006",
34
+ "build-storybook": "storybook build",
35
+ "build": "rollup -c"
36
+ },
37
+ "main": "lib/index.js",
38
+ "module": "lib/index.esm.js",
39
+ "types": "lib/index.d.ts",
40
+ "name": "pge-front-common",
41
+ "version": "2.0.0",
42
+ "description": "",
43
+ "keywords": [],
44
+ "author": "sturmer cesar",
45
+ "license": "ISC",
46
+ "dependencies": {
47
+ "styled-components": "^6.1.11"
48
+ }
49
+ }
@@ -2,51 +2,49 @@ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { fn } from "@storybook/test";
3
3
  import { Button } from "./Button";
4
4
 
5
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
6
- const meta = {
5
+ const meta: Meta<typeof Button> = {
7
6
  title: "Example/Button",
8
7
  component: Button,
9
8
  parameters: {
10
- // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
11
9
  layout: "centered",
12
10
  },
13
- // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
14
11
  tags: ["autodocs"],
15
- // More on argTypes: https://storybook.js.org/docs/api/argtypes
16
12
  argTypes: {
17
- backgroundColor: { control: "color" },
13
+ variant: {
14
+ control: { type: "select" },
15
+ options: ["primary", "secondary"],
16
+ },
17
+ text: { control: "text" },
18
+ leftIcon: { control: "text" },
19
+ onClick: { action: "clicked" },
18
20
  },
19
- // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
20
- args: { onClick: fn() },
21
- } satisfies Meta<typeof Button>;
21
+ args: {
22
+ onClick: fn(),
23
+ },
24
+ };
22
25
 
23
26
  export default meta;
27
+
24
28
  type Story = StoryObj<typeof meta>;
25
29
 
26
- // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
27
30
  export const Primary: Story = {
28
31
  args: {
29
- primary: true,
30
- label: "Button",
32
+ variant: "primary",
33
+ text: "Primary Button",
31
34
  },
32
35
  };
33
36
 
34
37
  export const Secondary: Story = {
35
38
  args: {
36
- label: "Button",
37
- },
38
- };
39
-
40
- export const Large: Story = {
41
- args: {
42
- size: "large",
43
- label: "Button",
39
+ variant: "secondary",
40
+ text: "Secondary Button",
44
41
  },
45
42
  };
46
43
 
47
- export const Small: Story = {
44
+ export const WithIcon: Story = {
48
45
  args: {
49
- size: "small",
50
- label: "Button",
46
+ variant: "primary",
47
+ text: "Button with Icon",
48
+ leftIcon: "⭐", // You can use any ReactNode, here we use a simple star emoji for demonstration
51
49
  },
52
50
  };
@@ -1,52 +1,28 @@
1
- import React from "react";
2
- import "./button.css";
1
+ import React, { ButtonHTMLAttributes } from "react";
2
+ import styled from "styled-components";
3
+ import * as s from "./styles";
3
4
 
4
- export interface ButtonProps {
5
- /**
6
- * Is this the principal call to action on the page?
7
- */
8
- primary?: boolean;
9
- /**
10
- * What background color to use
11
- */
12
- backgroundColor?: string;
13
- /**
14
- * How large should the button be?
15
- */
16
- size?: "small" | "medium" | "large";
17
- /**
18
- * Button contents
19
- */
20
- label: string;
21
- /**
22
- * Optional click handler
23
- */
24
- onClick?: () => void;
5
+ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
6
+ variant: "primary" | "secondary";
7
+ text: string;
8
+ leftIcon?: React.ReactNode;
25
9
  }
26
10
 
27
- /**
28
- * Primary UI component for user interaction
29
- */
30
- export const Button = ({
31
- primary = false,
32
- size = "medium",
33
- backgroundColor,
34
- label,
11
+ const StyledButton = styled(s.BaseButton)<{ variant: "primary" | "secondary" }>`
12
+ ${({ variant }) =>
13
+ variant === "primary" ? s.PrimaryButton : s.SecondaryButton}
14
+ `;
15
+
16
+ export function Button({
17
+ variant,
18
+ text = "",
19
+ leftIcon,
35
20
  ...props
36
- }: ButtonProps) => {
37
- const mode = primary
38
- ? "storybook-button--primary"
39
- : "storybook-button--secondary";
21
+ }: ButtonProps) {
40
22
  return (
41
- <button
42
- type="button"
43
- className={["storybook-button", `storybook-button--${size}`, mode].join(
44
- " "
45
- )}
46
- style={{ backgroundColor }}
47
- {...props}
48
- >
49
- {label}
50
- </button>
23
+ <StyledButton variant={variant} {...props}>
24
+ {leftIcon}
25
+ {text}
26
+ </StyledButton>
51
27
  );
52
- };
28
+ }
@@ -0,0 +1,39 @@
1
+ import styled, { css } from "styled-components";
2
+
3
+ // Estilos base compartilhados
4
+ export const BaseButton = styled.button`
5
+ all: unset;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ gap: 4px;
10
+ cursor: pointer;
11
+
12
+ &:disabled {
13
+ cursor: not-allowed;
14
+ }
15
+ `;
16
+
17
+ // Estilos do botão primário
18
+ export const PrimaryButton = css`
19
+ width: fit-content;
20
+ height: fit-content;
21
+ padding: 12px 16px;
22
+ border-radius: 8px;
23
+ border: 1px solid ${({ theme }) => theme.colors.primary};
24
+ color: #fff;
25
+ font-weight: 700;
26
+ background: ${({ theme }) => theme.colors.primary};
27
+ `;
28
+
29
+ // Estilos do botão secundário
30
+ export const SecondaryButton = css`
31
+ width: fit-content;
32
+ height: fit-content;
33
+ padding: 12px 8px;
34
+ border-radius: 8px;
35
+ border: 1px solid ${({ theme }) => theme.colors.primary};
36
+ font-weight: 700;
37
+ color: ${({ theme }) => theme.colors.primary};
38
+ background: transparent;
39
+ `;
@@ -0,0 +1,62 @@
1
+ import React, { useState } from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { Modal } from "./Modal";
4
+ import { fn } from "@storybook/test";
5
+
6
+ const meta = {
7
+ title: "Example/Modal",
8
+ component: Modal,
9
+ parameters: {
10
+ layout: "centered",
11
+ },
12
+ tags: ["autodocs"],
13
+ argTypes: {
14
+ isModalOpen: { control: "boolean" },
15
+ onOpenChange: { action: "onOpenChange" },
16
+ children: { control: "text" },
17
+ },
18
+ args: {
19
+ isModalOpen: false,
20
+ onOpenChange: fn(),
21
+ children: "This is the modal content.",
22
+ title: "Title",
23
+ },
24
+ } satisfies Meta<typeof Modal>;
25
+
26
+ export default meta;
27
+ type Story = StoryObj<typeof meta>;
28
+
29
+ const Template: Story = {
30
+ render: (args) => {
31
+ const [isModalOpen, setIsModalOpen] = useState(args.isModalOpen);
32
+
33
+ return (
34
+ <Modal
35
+ {...args}
36
+ isModalOpen={isModalOpen}
37
+ onOpenChange={(open) => {
38
+ setIsModalOpen(open);
39
+ args.onOpenChange(open);
40
+ }}
41
+ >
42
+ {args.children}
43
+ </Modal>
44
+ );
45
+ },
46
+ };
47
+
48
+ export const Default: Story = {
49
+ ...Template,
50
+ args: {
51
+ isModalOpen: true,
52
+ children: "This is the modal content.",
53
+ },
54
+ };
55
+
56
+ export const Closed: Story = {
57
+ ...Template,
58
+ args: {
59
+ isModalOpen: false,
60
+ children: "This is the modal content.",
61
+ },
62
+ };
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import * as Alert from "@radix-ui/react-alert-dialog";
3
+ import {
4
+ AlertOverlay,
5
+ ContentContainer,
6
+ ModalHeaderContainer,
7
+ ModalHeaderText,
8
+ CloseBtn,
9
+ ContentChildren,
10
+ } from "./styles";
11
+ import { IconCLose } from "../../icons/close-icon";
12
+ export interface ModalProps {
13
+ isModalOpen: boolean;
14
+ onOpenChange: React.Dispatch<React.SetStateAction<boolean>>;
15
+ children: React.ReactNode;
16
+ title: string;
17
+ }
18
+
19
+ export const Modal = ({
20
+ isModalOpen,
21
+ onOpenChange,
22
+ children,
23
+ title,
24
+ }: ModalProps) => {
25
+ return (
26
+ <Alert.Root open={isModalOpen} onOpenChange={onOpenChange}>
27
+ <Alert.Portal>
28
+ <AlertOverlay />
29
+ <ContentContainer>
30
+ <ModalHeaderContainer>
31
+ <ModalHeaderText>{title}</ModalHeaderText>
32
+ <CloseBtn onClick={() => onOpenChange(!isModalOpen)}>
33
+ <IconCLose />
34
+ </CloseBtn>
35
+ </ModalHeaderContainer>
36
+
37
+ <ContentChildren>{children}</ContentChildren>
38
+ </ContentContainer>
39
+ </Alert.Portal>
40
+ </Alert.Root>
41
+ );
42
+ };
@@ -0,0 +1,48 @@
1
+ import React, { useState } from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import ModalConfirm from "./index";
4
+ import { fn } from "@storybook/test";
5
+
6
+ const meta = {
7
+ title: "Example/ModalConfirm",
8
+ component: ModalConfirm,
9
+ parameters: {
10
+ layout: "centered",
11
+ },
12
+
13
+ args: {
14
+ isModalOpen: false,
15
+ onOpenChange: fn(),
16
+ children: "conteúdo",
17
+ },
18
+ } satisfies Meta<typeof ModalConfirm>;
19
+
20
+ export default meta;
21
+ type Story = StoryObj<typeof meta>;
22
+
23
+ const Template: Story = {
24
+ render: (args) => {
25
+ const [isModalOpen, setIsModalOpen] = useState(args.isModalOpen);
26
+
27
+ return (
28
+ <ModalConfirm
29
+ {...args}
30
+ isModalOpen={isModalOpen}
31
+ onOpenChange={(open) => {
32
+ setIsModalOpen(open);
33
+ args.onOpenChange(open);
34
+ }}
35
+ >
36
+ {args.children}
37
+ </ModalConfirm>
38
+ );
39
+ },
40
+ };
41
+
42
+ export const Default: Story = {
43
+ ...Template,
44
+ args: {
45
+ isModalOpen: true,
46
+ children: "conteúdo",
47
+ },
48
+ };
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import { Modal } from "../Modal";
3
+ import { Button } from "../../Button/Button";
4
+ import * as S from "./styles";
5
+
6
+ export interface ModalProps {
7
+ isModalOpen: boolean;
8
+ onOpenChange: React.Dispatch<React.SetStateAction<boolean>>;
9
+ children: React.ReactNode;
10
+ }
11
+
12
+ const ModalConfirm: React.FC<ModalProps> = ({
13
+ isModalOpen,
14
+ onOpenChange,
15
+ children,
16
+ }) => {
17
+ return (
18
+ <Modal
19
+ isModalOpen={isModalOpen}
20
+ onOpenChange={onOpenChange}
21
+ title="Título (Resumo do conteúdo)"
22
+ >
23
+ {children}
24
+ <S.ContainerModalConfirm>
25
+ <Button variant="secondary" text="Cancelar" />
26
+ <Button variant="primary" text="Ação" />
27
+ </S.ContainerModalConfirm>
28
+ </Modal>
29
+ );
30
+ };
31
+
32
+ export default ModalConfirm;
@@ -0,0 +1,9 @@
1
+ import styled from "styled-components";
2
+
3
+ export const ContainerModalConfirm = styled.div`
4
+ display: flex;
5
+ justify-content: flex-end;
6
+ gap: 5px;
7
+
8
+ margin-top: 10%;
9
+ `;