react-simple-initials 1.0.0 → 1.0.2

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 Winston Almeida Jr.
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,64 @@
1
+ # React Simple Initials
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/react-simple-initials.svg)](https://www.npmjs.com/package/react-simple-initials)
4
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/react-simple-initials)](https://bundlephobia.com/package/react-simple-initials)
5
+
6
+ Um componente React minimalista, elegante e ultraleve para gerar avatares coloridos baseados nas iniciais do usuário. Perfeito para painéis, listas de contatos e comentários onde o usuário ainda não enviou uma foto de perfil.
7
+
8
+ ---
9
+
10
+ ## Funcionalidades
11
+
12
+ - **Zero Dependências:** Sem bibliotecas de imagens pesadas; usa apenas CSS e HTML puro.
13
+ - **Cores Determinísticas:** O fundo do avatar é calculado com base no tamanho do nome. O mesmo nome sempre terá a mesma cor.
14
+ - **Altamente Customizável:** Adapta-se automaticamente à fonte do seu projeto, ou permite customização total de tamanho e cor.
15
+ - **Suporte a TypeScript & SSR:** Funciona perfeitamente com Next.js, Vite, Remix e Create React App.
16
+
17
+ ## Instalação
18
+
19
+ Você pode instalar usando o seu gerenciador de pacotes favorito:
20
+
21
+ npm install react-simple-initials
22
+
23
+ ## Como usar
24
+
25
+ A configuração é instantânea. Basta importar o componente e passar o nome desejado:
26
+
27
+ import React from 'react';
28
+ import InitialsAvatar from 'react-simple-initials';
29
+
30
+ export default function App() {
31
+ return (
32
+
33
+ <div style={{ display: 'flex', gap: '16px' }}>
34
+ <InitialsAvatar nome="Visitante" />
35
+ <InitialsAvatar nome="Maria Silva" tamanho={60} />
36
+ <InitialsAvatar nome="João" tamanho={80} corTexto="#FFF" fonte="Arial, sans-serif" />
37
+ </div>
38
+ );
39
+ }
40
+
41
+ ## Propriedades (API)
42
+
43
+ O componente aceita as seguintes propriedades (props) para você customizar como preferir:
44
+
45
+ | Propriedade | Tipo | Padrão | Descrição |
46
+ | :---------- | :----- | :-------- | :------------------------------------------------------------------------------------------------- |
47
+ | nome | string | "?" | O nome do usuário. A primeira letra será extraída e capitalizada automaticamente. |
48
+ | tamanho | number | 40 | O diâmetro do avatar (largura e altura) em pixels. O tamanho da fonte se ajusta proporcionalmente. |
49
+ | fonte | string | "inherit" | A família da fonte. Por padrão, herda a fonte do elemento pai. |
50
+ | corTexto | string | "#FFFFFF" | A cor da letra exibida no centro do avatar. |
51
+
52
+ ## Contribuindo
53
+
54
+ Contribuições são super bem-vindas! Se você encontrou um bug ou tem uma ideia para uma nova funcionalidade:
55
+
56
+ 1. Faça um Fork do projeto
57
+ 2. Crie sua branch de funcionalidade (git checkout -b feature/MinhaNovaFeature)
58
+ 3. Faça o commit das suas alterações (git commit -m 'feat: Adiciona nova paleta de cores')
59
+ 4. Faça o push para a branch (git push origin feature/MinhaNovaFeature)
60
+ 5. Abra um Pull Request
61
+
62
+ ## Licença
63
+
64
+ Este projeto está licenciado sob a Licença MIT.
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "react-simple-initials",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Um componente React minimalista para avatares com iniciais do nome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
7
8
  "scripts": {
8
- "build": "tsup src/index.jsx --format cjs,esm"
9
+ "build": "tsup src/index.tsx --format cjs,esm --dts"
9
10
  },
10
11
  "keywords": [
11
12
  "react",
@@ -19,6 +20,7 @@
19
20
  "react": ">=16.8.0"
20
21
  },
21
22
  "devDependencies": {
23
+ "@types/react": "^19.2.14",
22
24
  "tsup": "^8.5.1",
23
25
  "typescript": "^5.9.3"
24
26
  }
@@ -1,4 +1,9 @@
1
- import React from "react";
1
+ interface InitialsAvatarProps {
2
+ nome?: string;
3
+ tamanho?: number;
4
+ fonte?: string;
5
+ corTexto?: string;
6
+ }
2
7
 
3
8
  const FUNDOS = [
4
9
  "#EF4444",
@@ -16,7 +21,7 @@ export default function InitialsAvatar({
16
21
  tamanho = 40,
17
22
  fonte = "inherit",
18
23
  corTexto = "#FFFFFF",
19
- }) {
24
+ }: InitialsAvatarProps) {
20
25
  const tamanhoNome = nome.length;
21
26
  const FundoEscolhido = FUNDOS[tamanhoNome % FUNDOS.length];
22
27
  const inicial = nome.trim().charAt(0).toUpperCase();
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "jsx": "react-jsx",
5
+ "moduleResolution": "node",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true
9
+ },
10
+ "include": ["src"]
11
+ }
package/dist/index.js DELETED
@@ -1,75 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/index.jsx
30
- var index_exports = {};
31
- __export(index_exports, {
32
- default: () => InitialsAvatar
33
- });
34
- module.exports = __toCommonJS(index_exports);
35
- var import_react = __toESM(require("react"));
36
- var FUNDOS = [
37
- "#EF4444",
38
- "#F97316",
39
- "#EAB308",
40
- "#22C55E",
41
- "#3B82F6",
42
- "#A855F7",
43
- "#EC4899",
44
- "#64748B"
45
- ];
46
- function InitialsAvatar({
47
- nome = "?",
48
- tamanho = 40,
49
- fonte = "inherit",
50
- corTexto = "#FFFFFF"
51
- }) {
52
- const tamanhoNome = nome.length;
53
- const FundoEscolhido = FUNDOS[tamanhoNome % FUNDOS.length];
54
- const inicial = nome.trim().charAt(0).toUpperCase();
55
- return /* @__PURE__ */ import_react.default.createElement(
56
- "div",
57
- {
58
- style: {
59
- width: tamanho,
60
- height: tamanho,
61
- backgroundColor: FundoEscolhido,
62
- color: corTexto,
63
- fontFamily: fonte,
64
- display: "flex",
65
- alignItems: "center",
66
- justifyContent: "center",
67
- borderRadius: "50%",
68
- fontSize: tamanho / 2.2,
69
- fontWeight: "bold",
70
- userSelect: "none"
71
- }
72
- },
73
- inicial
74
- );
75
- }
package/dist/index.mjs DELETED
@@ -1,45 +0,0 @@
1
- // src/index.jsx
2
- import React from "react";
3
- var FUNDOS = [
4
- "#EF4444",
5
- "#F97316",
6
- "#EAB308",
7
- "#22C55E",
8
- "#3B82F6",
9
- "#A855F7",
10
- "#EC4899",
11
- "#64748B"
12
- ];
13
- function InitialsAvatar({
14
- nome = "?",
15
- tamanho = 40,
16
- fonte = "inherit",
17
- corTexto = "#FFFFFF"
18
- }) {
19
- const tamanhoNome = nome.length;
20
- const FundoEscolhido = FUNDOS[tamanhoNome % FUNDOS.length];
21
- const inicial = nome.trim().charAt(0).toUpperCase();
22
- return /* @__PURE__ */ React.createElement(
23
- "div",
24
- {
25
- style: {
26
- width: tamanho,
27
- height: tamanho,
28
- backgroundColor: FundoEscolhido,
29
- color: corTexto,
30
- fontFamily: fonte,
31
- display: "flex",
32
- alignItems: "center",
33
- justifyContent: "center",
34
- borderRadius: "50%",
35
- fontSize: tamanho / 2.2,
36
- fontWeight: "bold",
37
- userSelect: "none"
38
- }
39
- },
40
- inicial
41
- );
42
- }
43
- export {
44
- InitialsAvatar as default
45
- };