react-simple-initials 1.0.0 → 1.0.1
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/.github/workflows/publish.yml +32 -0
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/package.json +1 -1
- package/src/index.jsx +0 -2
- package/dist/index.js +0 -75
- package/dist/index.mjs +0 -45
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publicar no NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
publish:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Baixar o código
|
|
15
|
+
uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Configurar o Node.js
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: "20"
|
|
21
|
+
registry-url: "https://registry.npmjs.org"
|
|
22
|
+
|
|
23
|
+
- name: Instalar dependências
|
|
24
|
+
run: npm install
|
|
25
|
+
|
|
26
|
+
- name: Construir o projeto
|
|
27
|
+
run: npm run build
|
|
28
|
+
|
|
29
|
+
- name: Publicar no NPM
|
|
30
|
+
run: npm publish --provenance --access public
|
|
31
|
+
env:
|
|
32
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
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
|
+
[](https://www.npmjs.com/package/react-simple-initials)
|
|
4
|
+
[](https://bundlephobia.com/package/react-simple-initials)
|
|
5
|
+
|
|
6
|
+
Um componente React minimalista, elegante e ultraleve (menos de 5kB) 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
package/src/index.jsx
CHANGED
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
|
-
};
|