catastyle 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Phillip
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # Catastyle
2
+
3
+ Design System reutilizável baseado em **React** e **styled-components**, com temas claro/escuro, componentes acessíveis e suporte a customização via arquivos de configuração no projeto consumidor.
4
+
5
+ ## Instalação
6
+
7
+ ```bash
8
+ npm install catastyle react react-dom styled-components react-router-dom
9
+ ```
10
+
11
+ **Peer dependencies:** `react` (^18 ou ^19), `react-dom`, `styled-components`, `react-router-dom` (^6 ou ^7). O projeto consumidor deve instalá-las; o Catastyle não as inclui em `dependencies` para evitar duplicação.
12
+
13
+ ### Projetos com Vite
14
+
15
+ Em projetos que usam **Vite**, configure `resolve.dedupe` para garantir uma única instância de React e styled-components (evita erros de contexto e duplicação de tema):
16
+
17
+ ```ts
18
+ // vite.config.ts
19
+ import { defineConfig } from 'vite'
20
+ import react from '@vitejs/plugin-react'
21
+
22
+ export default defineConfig({
23
+ plugins: [react()],
24
+ resolve: {
25
+ dedupe: ['react', 'react-dom', 'styled-components'],
26
+ },
27
+ })
28
+ ```
29
+
30
+ ## Uso básico
31
+
32
+ Envolva sua aplicação com `ThemeProvider` e `GlobalStyle`:
33
+
34
+ ```tsx
35
+ import {
36
+ ThemeProvider,
37
+ DarkTheme,
38
+ LightTheme,
39
+ GlobalStyle,
40
+ MainContainer,
41
+ Button,
42
+ Title,
43
+ Text,
44
+ } from 'catastyle'
45
+
46
+ function App() {
47
+ const [theme, setTheme] = useState(DarkTheme)
48
+
49
+ return (
50
+ <ThemeProvider theme={theme}>
51
+ <GlobalStyle />
52
+ <MainContainer>
53
+ <Title>Olá, Catastyle</Title>
54
+ <Text>Design system pronto para uso.</Text>
55
+ <Button>Clique aqui</Button>
56
+ </MainContainer>
57
+ </ThemeProvider>
58
+ )
59
+ }
60
+ ```
61
+
62
+ ## Componentes
63
+
64
+ | Componente | Descrição |
65
+ |----------------|----------------------------------------------------------------------------|
66
+ | `Button` | Botão com variantes de estilo |
67
+ | `Checkbox` | Caixa de seleção |
68
+ | `Footer` | Rodapé de página; aceita `children` para conteúdo customizável |
69
+ | `Input` | Campo de texto (inclui toggle de visibilidade para tipo password) |
70
+ | `Label` | Rótulo para formulários |
71
+ | `Link` | Link externo ou interno (integra com react-router-dom via `$isInternal`) |
72
+ | `Logo` | Logo com suporte a tema claro/escuro |
73
+ | `Main` | Container principal com ThemeProvider, GlobalStyle e ThemeButton |
74
+ | `Text` | Parágrafo ou texto inline (`as="p"` ou `as="span"`) |
75
+ | `ThemeButton` | Botão para alternar tema claro/escuro |
76
+ | `Title` | Título |
77
+
78
+ ### Exemplo: Footer customizável
79
+
80
+ O `Footer` recebe `children`; o conteúdo fica a cargo do projeto consumidor:
81
+
82
+ ```tsx
83
+ import { Footer, Text } from 'catastyle'
84
+
85
+ <Footer>
86
+ <Text as="p">© {new Date().getFullYear()} Minha Empresa - Todos os direitos reservados</Text>
87
+ </Footer>
88
+ ```
89
+
90
+ ## Temas
91
+
92
+ - **`DarkTheme`** e **`LightTheme`** — temas padrão do design system.
93
+ - Use `ThemeProvider` do `styled-components` (re-exportado) para aplicar o tema.
94
+ - Troca de tema: altere o objeto passado para `theme` no `ThemeProvider` (ex.: entre `DarkTheme` e `LightTheme`).
95
+
96
+ ## Customização (projeto consumidor)
97
+
98
+ Após instalar o pacote, o script **postinstall** cria em seu projeto a pasta de configuração:
99
+
100
+ ```
101
+ src/catastyle/config/
102
+ ├── theme.config.ts
103
+ └── logo.config.ts
104
+ ```
105
+
106
+ ### Temas customizados
107
+
108
+ Edite `src/catastyle/config/theme.config.ts` e defina `darkTheme` e/ou `lightTheme`. Se forem `null`, os temas padrão do Catastyle são usados.
109
+
110
+ Exemplo de tema customizado:
111
+
112
+ ```ts
113
+ import type { DefaultTheme } from 'styled-components'
114
+
115
+ export const darkTheme: DefaultTheme | null = {
116
+ primaryColor: '#EBFFEB',
117
+ secondaryColor: '#538A53',
118
+ tertiaryColor: '#669966',
119
+ bgColor: '#011F1F',
120
+ linkColor: '#33CC66',
121
+ }
122
+
123
+ export const lightTheme: DefaultTheme | null = {
124
+ primaryColor: '#011F1F',
125
+ secondaryColor: '#33CC66',
126
+ tertiaryColor: '#538A53',
127
+ bgColor: '#EBFFEB',
128
+ linkColor: '#006633',
129
+ }
130
+ ```
131
+
132
+ ### Logos customizados
133
+
134
+ Os **logos padrão** do Catastyle vêm embutidos no pacote (data URL) e funcionam em qualquer bundler (Vite, Webpack, etc.) sem configuração extra.
135
+
136
+ Para usar seus próprios SVGs, edite `src/catastyle/config/logo.config.ts` e defina os caminhos. Use `'default'` para manter os logos do Catastyle. Os caminhos devem ser os que o seu projeto consegue resolver (ex.: caminho público ou URL).
137
+
138
+ ```ts
139
+ export const logoLight: string = '/src/assets/logo-light.svg'
140
+ export const logoDark: string = '/src/assets/logo-dark.svg'
141
+ ```
142
+
143
+ ## Exports adicionais
144
+
145
+ - **Estilos globais:** `GlobalStyle`, `MainContainer`
146
+ - **Tipos:** `WidthType`, `FontSizeType`, `FontSize`, `BreakpointType`
147
+ - **Utilitários:** `fontSizeToRem`, `mdScreen`, `smScreen`
148
+
149
+ ## Testes
150
+
151
+ O projeto usa **Vitest** e **React Testing Library** para testes unitários dos componentes e utilitários.
152
+
153
+ ```bash
154
+ # Rodar todos os testes (modo watch)
155
+ npm test
156
+
157
+ # Rodar testes unitários uma vez
158
+ npm run test:unit
159
+
160
+ # Rodar com cobertura
161
+ npm run test:coverage
162
+ ```
163
+
164
+ ## Desenvolvimento
165
+
166
+ ```bash
167
+ # Instalar dependências
168
+ npm install
169
+
170
+ # Build da biblioteca
171
+ npm run build
172
+
173
+ # Modo watch (rebuild ao editar)
174
+ npm run dev
175
+
176
+ # Lint (verificar / corrigir)
177
+ npm run lint:check
178
+ npm run lint
179
+
180
+ # Testes
181
+ npm run test:unit
182
+
183
+ # Storybook (documentação e exemplos dos componentes)
184
+ npm run storybook
185
+ ```
186
+
187
+ ## CI/CD
188
+
189
+ O repositório usa **GitHub Actions** para garantir qualidade em todo push e pull request:
190
+
191
+ - **Lint** — `npm run lint:check`
192
+ - **Testes unitários** — `npm run test:unit`
193
+ - **Build** — `npm run build`
194
+
195
+ O workflow está em `.github/workflows/ci.yml` e roda em qualquer branch.
196
+
197
+ ## Estrutura do pacote
198
+
199
+ - **`main`:** `./dist/index.js` (CommonJS)
200
+ - **`module`:** `./dist/index.mjs` (ESM)
201
+ - **`types`:** `./dist/index.d.ts`
202
+
203
+ ## Sobre o projeto
204
+
205
+ Projeto **autoral**, desenvolvido com intuito de **estudo** e de criar uma biblioteca reutilizável que possa ser **integrada a outros projetos**. O Catastyle é mantido de forma independente e está disponível para uso e contribuição.
206
+
207
+ - Repositório: [github.com/Phillipml/catastyle](https://github.com/Phillipml/catastyle)
208
+
209
+ ## Licença
210
+
211
+ ISC
@@ -0,0 +1,120 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import react__default, { HTMLAttributes } from 'react';
4
+ import { DefaultTheme } from 'styled-components/';
5
+ import * as styled_components from 'styled-components';
6
+ export { ThemeProvider } from 'styled-components';
7
+ import * as styled_components_dist_types from 'styled-components/dist/types';
8
+
9
+ type WidthType = {
10
+ $lgWidth?: number | undefined;
11
+ $mdWidth?: number | undefined;
12
+ $smWidth?: number | undefined;
13
+ };
14
+
15
+ type FontSize = 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40;
16
+ type FontSizeType = {
17
+ $lgFontSize?: FontSize;
18
+ $mdFontSize?: FontSize;
19
+ $smFontSize?: FontSize;
20
+ };
21
+ declare const fontSizeToRem: (size: FontSize) => string;
22
+
23
+ declare const mdScreen: string;
24
+ declare const smScreen: string;
25
+ type BreakpointType = {
26
+ mdScreen?: boolean;
27
+ smScreen?: boolean;
28
+ };
29
+
30
+ type ButtonType = {
31
+ children: React.ReactNode;
32
+ id?: string;
33
+ onClick?: () => void;
34
+ disabled?: boolean;
35
+ as?: React.ElementType;
36
+ type?: 'button' | 'submit' | 'reset';
37
+ } & WidthType & FontSizeType;
38
+ declare const Button: ({ children, onClick, disabled, $lgWidth, $mdWidth, $smWidth, $lgFontSize, $mdFontSize, $smFontSize, as, type, id }: ButtonType) => react_jsx_runtime.JSX.Element;
39
+
40
+ type CheckboxType = {
41
+ id: string;
42
+ name: string;
43
+ checked?: boolean;
44
+ $disabled?: boolean;
45
+ children: string;
46
+ display?: string;
47
+ onClick?: () => void;
48
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
49
+ } & WidthType & FontSizeType;
50
+ declare const Checkbox: ({ id, name, checked, $disabled, children, display, $lgWidth, $mdWidth, $smWidth, $lgFontSize, $mdFontSize, $smFontSize, onClick, onChange }: CheckboxType) => react_jsx_runtime.JSX.Element;
51
+
52
+ declare const Footer: ({ children }: {
53
+ children: React.ReactNode;
54
+ }) => react_jsx_runtime.JSX.Element;
55
+
56
+ type InputType = {
57
+ type: string;
58
+ id: string;
59
+ name: string;
60
+ placeholder?: string;
61
+ value?: string;
62
+ display?: string;
63
+ $disabled?: boolean;
64
+ $required?: boolean;
65
+ onClick?: () => void;
66
+ onChange?: (event: react__default.ChangeEvent<HTMLInputElement>) => void;
67
+ } & WidthType & FontSizeType;
68
+ declare const Input: ({ type, id, name, placeholder, display, $lgWidth, $mdWidth, $smWidth, $lgFontSize, $mdFontSize, $smFontSize, $disabled, $required, onClick, onChange }: InputType) => react_jsx_runtime.JSX.Element;
69
+
70
+ type LabelType = {
71
+ htmlFor: string;
72
+ children: react__default.ReactNode;
73
+ color?: 'primary' | 'secondary';
74
+ } & FontSizeType;
75
+ declare const Label: ({ htmlFor, children, $lgFontSize, $mdFontSize, $smFontSize }: LabelType) => react_jsx_runtime.JSX.Element;
76
+
77
+ type LinkType = {
78
+ href?: string;
79
+ to?: string;
80
+ children: React.ReactNode;
81
+ $target?: '_blank' | '_self';
82
+ $isInternal?: boolean;
83
+ } & FontSizeType;
84
+ declare const Link: ({ href, to, children, $target, $isInternal, $lgFontSize, $mdFontSize, $smFontSize }: LinkType) => react_jsx_runtime.JSX.Element;
85
+
86
+ type LogoProps = WidthType & HTMLAttributes<HTMLDivElement>;
87
+ declare const Logo: (props: LogoProps) => react_jsx_runtime.JSX.Element;
88
+
89
+ type MainType = {
90
+ children: React.ReactNode;
91
+ };
92
+ declare const Main: ({ children }: MainType) => react_jsx_runtime.JSX.Element;
93
+
94
+ type TextType = {
95
+ as: 'p' | 'span';
96
+ children: React.ReactNode;
97
+ color?: 'primary' | 'secondary';
98
+ } & FontSizeType;
99
+ declare const Text: ({ as, children, color, $lgFontSize, $mdFontSize, $smFontSize }: TextType) => react_jsx_runtime.JSX.Element;
100
+
101
+ type ThemeButtonType = {
102
+ onClick?: () => void;
103
+ };
104
+ declare const ThemeButton: ({ onClick }: ThemeButtonType) => react_jsx_runtime.JSX.Element;
105
+
106
+ type TitleType = {
107
+ children: string;
108
+ color: 'primary' | 'secondary';
109
+ } & FontSizeType;
110
+ declare const Title: ({ children, color, $lgFontSize, $mdFontSize, $smFontSize }: TitleType) => react_jsx_runtime.JSX.Element;
111
+
112
+ declare const DarkTheme: DefaultTheme;
113
+
114
+ declare const LightTheme: DefaultTheme;
115
+
116
+ declare const GlobalStyle: react.NamedExoticComponent<styled_components.ExecutionProps & object>;
117
+
118
+ declare const MainContainer: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
119
+
120
+ export { type BreakpointType, Button, Checkbox, DarkTheme, type FontSize, type FontSizeType, Footer, GlobalStyle, Input, Label, LightTheme, Link, Logo, Main, MainContainer, Text, ThemeButton, Title, type WidthType, fontSizeToRem, mdScreen, smScreen };
@@ -0,0 +1,120 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import react__default, { HTMLAttributes } from 'react';
4
+ import { DefaultTheme } from 'styled-components/';
5
+ import * as styled_components from 'styled-components';
6
+ export { ThemeProvider } from 'styled-components';
7
+ import * as styled_components_dist_types from 'styled-components/dist/types';
8
+
9
+ type WidthType = {
10
+ $lgWidth?: number | undefined;
11
+ $mdWidth?: number | undefined;
12
+ $smWidth?: number | undefined;
13
+ };
14
+
15
+ type FontSize = 4 | 8 | 12 | 16 | 20 | 24 | 32 | 40;
16
+ type FontSizeType = {
17
+ $lgFontSize?: FontSize;
18
+ $mdFontSize?: FontSize;
19
+ $smFontSize?: FontSize;
20
+ };
21
+ declare const fontSizeToRem: (size: FontSize) => string;
22
+
23
+ declare const mdScreen: string;
24
+ declare const smScreen: string;
25
+ type BreakpointType = {
26
+ mdScreen?: boolean;
27
+ smScreen?: boolean;
28
+ };
29
+
30
+ type ButtonType = {
31
+ children: React.ReactNode;
32
+ id?: string;
33
+ onClick?: () => void;
34
+ disabled?: boolean;
35
+ as?: React.ElementType;
36
+ type?: 'button' | 'submit' | 'reset';
37
+ } & WidthType & FontSizeType;
38
+ declare const Button: ({ children, onClick, disabled, $lgWidth, $mdWidth, $smWidth, $lgFontSize, $mdFontSize, $smFontSize, as, type, id }: ButtonType) => react_jsx_runtime.JSX.Element;
39
+
40
+ type CheckboxType = {
41
+ id: string;
42
+ name: string;
43
+ checked?: boolean;
44
+ $disabled?: boolean;
45
+ children: string;
46
+ display?: string;
47
+ onClick?: () => void;
48
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
49
+ } & WidthType & FontSizeType;
50
+ declare const Checkbox: ({ id, name, checked, $disabled, children, display, $lgWidth, $mdWidth, $smWidth, $lgFontSize, $mdFontSize, $smFontSize, onClick, onChange }: CheckboxType) => react_jsx_runtime.JSX.Element;
51
+
52
+ declare const Footer: ({ children }: {
53
+ children: React.ReactNode;
54
+ }) => react_jsx_runtime.JSX.Element;
55
+
56
+ type InputType = {
57
+ type: string;
58
+ id: string;
59
+ name: string;
60
+ placeholder?: string;
61
+ value?: string;
62
+ display?: string;
63
+ $disabled?: boolean;
64
+ $required?: boolean;
65
+ onClick?: () => void;
66
+ onChange?: (event: react__default.ChangeEvent<HTMLInputElement>) => void;
67
+ } & WidthType & FontSizeType;
68
+ declare const Input: ({ type, id, name, placeholder, display, $lgWidth, $mdWidth, $smWidth, $lgFontSize, $mdFontSize, $smFontSize, $disabled, $required, onClick, onChange }: InputType) => react_jsx_runtime.JSX.Element;
69
+
70
+ type LabelType = {
71
+ htmlFor: string;
72
+ children: react__default.ReactNode;
73
+ color?: 'primary' | 'secondary';
74
+ } & FontSizeType;
75
+ declare const Label: ({ htmlFor, children, $lgFontSize, $mdFontSize, $smFontSize }: LabelType) => react_jsx_runtime.JSX.Element;
76
+
77
+ type LinkType = {
78
+ href?: string;
79
+ to?: string;
80
+ children: React.ReactNode;
81
+ $target?: '_blank' | '_self';
82
+ $isInternal?: boolean;
83
+ } & FontSizeType;
84
+ declare const Link: ({ href, to, children, $target, $isInternal, $lgFontSize, $mdFontSize, $smFontSize }: LinkType) => react_jsx_runtime.JSX.Element;
85
+
86
+ type LogoProps = WidthType & HTMLAttributes<HTMLDivElement>;
87
+ declare const Logo: (props: LogoProps) => react_jsx_runtime.JSX.Element;
88
+
89
+ type MainType = {
90
+ children: React.ReactNode;
91
+ };
92
+ declare const Main: ({ children }: MainType) => react_jsx_runtime.JSX.Element;
93
+
94
+ type TextType = {
95
+ as: 'p' | 'span';
96
+ children: React.ReactNode;
97
+ color?: 'primary' | 'secondary';
98
+ } & FontSizeType;
99
+ declare const Text: ({ as, children, color, $lgFontSize, $mdFontSize, $smFontSize }: TextType) => react_jsx_runtime.JSX.Element;
100
+
101
+ type ThemeButtonType = {
102
+ onClick?: () => void;
103
+ };
104
+ declare const ThemeButton: ({ onClick }: ThemeButtonType) => react_jsx_runtime.JSX.Element;
105
+
106
+ type TitleType = {
107
+ children: string;
108
+ color: 'primary' | 'secondary';
109
+ } & FontSizeType;
110
+ declare const Title: ({ children, color, $lgFontSize, $mdFontSize, $smFontSize }: TitleType) => react_jsx_runtime.JSX.Element;
111
+
112
+ declare const DarkTheme: DefaultTheme;
113
+
114
+ declare const LightTheme: DefaultTheme;
115
+
116
+ declare const GlobalStyle: react.NamedExoticComponent<styled_components.ExecutionProps & object>;
117
+
118
+ declare const MainContainer: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>, never>> & string;
119
+
120
+ export { type BreakpointType, Button, Checkbox, DarkTheme, type FontSize, type FontSizeType, Footer, GlobalStyle, Input, Label, LightTheme, Link, Logo, Main, MainContainer, Text, ThemeButton, Title, type WidthType, fontSizeToRem, mdScreen, smScreen };