@ac-components/ac-icon-button-basic 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Renzo Cordova
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 CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # `@ac-components/ac-icon-button-basic`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Botón solo-ícono, accesible, pensado para toolbars y acciones compactas (cerrar, buscar, abrir un menú, avanzar/retroceder) — a diferencia de `ac-button-basic`, nunca muestra texto visible, solo un ícono.
4
+
5
+ Envuelve internamente un `<ac-icon-basic>` real: **`@ac-components/ac-icon-basic` es una dependencia de runtime, no opcional** (`workspace:^` en `dependencies`, no en `devDependencies`) — este componente no reimplementa ningún SVG propio, delega todo el set de íconos y su whitelist/fallback a `ac-icon-basic`.
6
+
7
+ ## Instalación
8
+
9
+ ```bash
10
+ pnpm add @ac-components/ac-icon-button-basic
11
+ ```
12
+
13
+ ```js
14
+ import '@ac-components/ac-icon-button-basic';
15
+ ```
16
+
17
+ ```html
18
+ <ac-icon-button-basic name="close" a11y-label="Cerrar"></ac-icon-button-basic>
19
+ ```
20
+
21
+ ## Propiedades
22
+
23
+ | Propiedad | Atributo | Tipo | Default | Descripción |
24
+ | ----------- | ------------ | ------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | `name` | `name` | String | `''` | Nombre del ícono — se pasa directo a `<ac-icon-basic>` interno. Mismo whitelist/fallback que ese componente (ver su README para la lista completa). |
26
+ | `a11yLabel` | `a11y-label` | String | `''` | Etiqueta accesible del botón. Si no se define, el `aria-label` cae al propio `name` (ver "Accesibilidad" abajo) — pero **siempre debería pasarse explícito**. |
27
+ | `ambient` | `ambient` | String | `'primary'` | `primary` \| `secondary` \| `danger`, con whitelist y fallback a `'primary'` si no matchea. |
28
+ | `size` | `size` | String | `'md'` | `sm` \| `md` \| `lg`, con whitelist y fallback a `'md'`. Se propaga también al `<ac-icon-basic>` interno, para que el ícono escale junto con el botón. |
29
+ | `disabled` | `disabled` | Boolean | `false` | Deshabilita el `<button>` nativo interno. |
30
+
31
+ Sin `slot`, sin eventos custom: es un `<button type="button">` nativo — su `click` nativo ya burbujea (`composed: true` por defecto en los eventos nativos), igual criterio que `ac-button-basic` (que tampoco emite un evento propio).
32
+
33
+ ## Accesibilidad
34
+
35
+ Un botón solo-ícono sin texto visible **no tiene ningún nombre accesible propio** salvo el que le dé `aria-label` — a diferencia de un botón con texto (`ac-button-basic`), acá no hay slot ni `text` de los que WCAG 4.1.2 pueda derivar un nombre. Por eso `a11y-label` es **casi obligatorio en la práctica**, aunque tenga un fallback: si no se define, el `aria-label` usa el propio `name` (ej. `"close"`), lo que evita que el botón quede completamente roto para un lector de pantalla, pero sigue siendo un nombre técnico en inglés, no una descripción de la acción para el usuario final (ej. `"Cerrar"` dice más que `"close"`). El README deja esto explícito porque el fallback existe **para que el componente nunca quede sin nombre accesible**, no como forma recomendada de usarlo.
36
+
37
+ ## Theming
38
+
39
+ Colores por `ambient`: `primary` y `secondary` usan los mismos tokens que `ac-button-basic` (`--color-primary-700`/`--color-primary-50`, `--color-accent-500`/`--color-accent-900`); `danger` usa `--color-danger` con texto negro (mismo criterio ya validado en `ac-badge-basic`). El radio de borde escala junto con `size` (`--radius-sm` en `sm`, `--radius-md` en `md`, `--radius-lg` en `lg`) — nunca `--radius-full`, reservado en el catálogo para controles de estado binario/toggle (ver "Emerald Pro" en `docs/CONVENTIONS.md`).
40
+
41
+ ```js
42
+ import '@ac-base/ac-core/tokens/modern-warm-palette.css';
43
+ ```
44
+
45
+ ## i18n
46
+
47
+ El componente no tiene ningún texto propio fijo (ni siquiera en estado deshabilitado) — `locales.json` no declara ninguna clave.
48
+
49
+ ## Desarrollo
50
+
51
+ ```bash
52
+ pnpm --filter @ac-components/ac-icon-button-basic component:lint
53
+ pnpm --filter @ac-components/ac-icon-button-basic component:serve # demo en http://localhost:5173
54
+ pnpm --filter @ac-components/ac-icon-button-basic component:test
55
+ pnpm --filter @ac-components/ac-icon-button-basic component:build
56
+ pnpm --filter @ac-components/ac-icon-button-basic component:test:e2e # funcional (WebdriverIO + Cucumber)
57
+ pnpm --filter @ac-components/ac-icon-button-basic component:test:e2e:a11y # accesibilidad (axe-core)
58
+ ```
59
+
60
+ > `src/icon-button-basic.styles.js` se genera a partir de `src/icon-button-basic.styles.scss` (`component:build:styles`, corre automáticamente antes de `component:serve`/`component:build`/`component:test`) y no se versiona en git. Durante `component:serve` queda además en modo watch: cada guardado de `.scss` lo recompila y Vite recarga el navegador solo, sin reiniciar nada.
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import locales from './locales.json' with { type: 'json' };
2
+ import { registerTranslations } from '@ac-base/ac-intl-mixin';
3
+ import { IconButtonBasic } from './src/icon-button-basic.js';
4
+
5
+ export { IconButtonBasic } from './src/icon-button-basic.js';
6
+
7
+ registerTranslations(IconButtonBasic.is, locales);
8
+
9
+ // Auto-registro del componente
10
+ customElements.define(IconButtonBasic.is, IconButtonBasic);
package/locales.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "es-PE": {},
3
+ "en-EN": {},
4
+ "pt-BR": {}
5
+ }
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@ac-components/ac-icon-button-basic",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/RenzoCordovaDev/ac-lit.git",
7
+ "directory": "packages/components/ac-icon-button-basic"
8
+ },
9
+ "description": "ac-lit icon-button-basic Web Component",
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "main": "index.js",
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./locales.json": "./locales.json"
16
+ },
17
+ "files": [
18
+ "/src/",
19
+ "index.js",
20
+ "locales.json"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "dependencies": {
26
+ "@ac-base/ac-component-mixin": "^0.1.0",
27
+ "@ac-base/ac-intl-mixin": "^0.1.0",
28
+ "@ac-components/ac-icon-basic": "^0.2.0"
29
+ },
30
+ "peerDependencies": {
31
+ "lit": "^3.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@open-wc/testing": "^4.0.0",
35
+ "@web/test-runner": "^0.18.0",
36
+ "concurrently": "^9.1.0",
37
+ "lit": "^3.0.0",
38
+ "sass": "^1.79.4",
39
+ "vite": "^5.4.8",
40
+ "@ac-base/ac-demo-content": "^0.4.0",
41
+ "@ac-base/ac-core": "^0.1.0",
42
+ "@ac-base/ac-e2e-testing": "^0.1.0",
43
+ "@ac-base/cli": "^0.5.2"
44
+ },
45
+ "scripts": {
46
+ "component:lint": "eslint .",
47
+ "component:build:styles": "node ./node_modules/@ac-base/cli/scripts/compile-scss-to-lit.cjs src/icon-button-basic.styles.scss src/icon-button-basic.styles.js IconButtonBasicStyles",
48
+ "component:build:styles:watch": "node ./node_modules/@ac-base/cli/scripts/compile-scss-to-lit.cjs src/icon-button-basic.styles.scss src/icon-button-basic.styles.js IconButtonBasicStyles --watch",
49
+ "component:serve": "pnpm run component:build:styles && concurrently -k -n styles,vite -c blue,green \"pnpm run component:build:styles:watch\" \"vite demo\"",
50
+ "component:build": "pnpm run component:build:styles && vite build",
51
+ "component:preview": "vite preview",
52
+ "component:test": "pnpm run component:build:styles && web-test-runner \"test/**/*.test.js\"",
53
+ "component:test:e2e": "pnpm run component:build && start-server-and-test component:preview http://localhost:4173 component:test:e2e:run",
54
+ "component:test:e2e:run": "wdio run test_e2e/wdio.conf.js",
55
+ "component:test:e2e:a11y": "pnpm run component:build && start-server-and-test component:preview http://localhost:4173 component:test:e2e:a11y:run",
56
+ "component:test:e2e:a11y:run": "wdio run test_e2e/wdio.a11y.conf.js"
57
+ }
6
58
  }
@@ -0,0 +1,74 @@
1
+ import { LitElement, html } from 'lit';
2
+ import { ComponentMixin, componentBaseStyles } from '@ac-base/ac-component-mixin';
3
+ import '@ac-components/ac-icon-basic';
4
+ // Authored in icon-button-basic.styles.scss, compiled to icon-button-basic.styles.js by
5
+ // `pnpm run component:build:styles` (@ac-base/cli/scripts/compile-scss-to-lit.cjs). The compiled file
6
+ // is gitignored — run `pnpm install` then `pnpm component:build` or `pnpm component:serve` to generate it.
7
+ import { IconButtonBasicStyles } from './icon-button-basic.styles.js';
8
+
9
+ const AMBIENTS = new Set(['primary', 'secondary', 'danger']);
10
+ const DEFAULT_AMBIENT = 'primary';
11
+
12
+ const SIZES = new Set(['sm', 'md', 'lg']);
13
+ const DEFAULT_SIZE = 'md';
14
+
15
+ export class IconButtonBasic extends ComponentMixin(LitElement) {
16
+ static get is() {
17
+ return 'ac-icon-button-basic';
18
+ }
19
+
20
+ // componentBaseStyles primero: fija `font-family` y el skeleton de
21
+ // `loading` compartidos, convención del catálogo (ver docs/CONVENTIONS.md).
22
+ static get styles() {
23
+ return [componentBaseStyles, IconButtonBasicStyles];
24
+ }
25
+
26
+ static get properties() {
27
+ return {
28
+ name: { type: String },
29
+ a11yLabel: { type: String, attribute: 'a11y-label' },
30
+ ambient: { type: String, reflect: true },
31
+ size: { type: String, reflect: true },
32
+ disabled: { type: Boolean, reflect: true },
33
+ };
34
+ }
35
+
36
+ constructor() {
37
+ super();
38
+ this.name = '';
39
+ this.a11yLabel = '';
40
+ this.ambient = DEFAULT_AMBIENT;
41
+ this.size = DEFAULT_SIZE;
42
+ this.disabled = false;
43
+ }
44
+
45
+ get _ambient() {
46
+ return AMBIENTS.has(this.ambient) ? this.ambient : DEFAULT_AMBIENT;
47
+ }
48
+
49
+ get _size() {
50
+ return SIZES.has(this.size) ? this.size : DEFAULT_SIZE;
51
+ }
52
+
53
+ render() {
54
+ // Un botón solo-ícono sin texto visible es inútil para un lector de
55
+ // pantalla si `aria-label` queda vacío: si el consumidor no define
56
+ // `a11yLabel`, usamos el propio `name` como fallback — nunca queda
57
+ // completamente roto, aunque lo ideal (documentado en el README) sea
58
+ // siempre pasar `a11y-label` explícito.
59
+ const label = this.a11yLabel || this.name;
60
+ const classes = `ac-icon-button-basic ac-icon-button--${this._ambient} ac-icon-button--${this._size}`;
61
+
62
+ return html`
63
+ <button
64
+ part="root"
65
+ class=${classes}
66
+ type="button"
67
+ aria-label=${label}
68
+ ?disabled=${this.disabled}
69
+ >
70
+ <ac-icon-basic part="icon" name=${this.name} size=${this._size}></ac-icon-basic>
71
+ </button>
72
+ `;
73
+ }
74
+ }
@@ -0,0 +1,73 @@
1
+ import { css } from 'lit';
2
+
3
+ export const IconButtonBasicStyles = css`
4
+ :host {
5
+ display: inline-block;
6
+ }
7
+
8
+ :host([hidden]) {
9
+ display: none;
10
+ }
11
+
12
+ .ac-icon-button-basic {
13
+ display: inline-flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ border: none;
17
+ cursor: pointer;
18
+ transition: background 150ms ease, color 150ms ease, transform 120ms ease;
19
+ }
20
+
21
+ .ac-icon-button--sm {
22
+ padding: var(--space-2, 0.5rem);
23
+ border-radius: var(--radius-sm, 0.5rem);
24
+ corner-shape: squircle;
25
+ }
26
+
27
+ .ac-icon-button--md {
28
+ padding: var(--space-3, 0.75rem);
29
+ border-radius: var(--radius-md, 1rem);
30
+ corner-shape: squircle;
31
+ }
32
+
33
+ .ac-icon-button--lg {
34
+ padding: var(--space-4, 1rem);
35
+ border-radius: var(--radius-lg, 1.5rem);
36
+ corner-shape: squircle;
37
+ }
38
+
39
+ .ac-icon-button--primary {
40
+ background: var(--color-primary-700, #047857);
41
+ color: var(--color-primary-50, #ecfdf5);
42
+ }
43
+
44
+ .ac-icon-button--secondary {
45
+ background: var(--color-accent-500, #f59e0b);
46
+ color: var(--color-accent-900, #451a03);
47
+ }
48
+
49
+ .ac-icon-button--danger {
50
+ background: var(--color-danger, #e05555);
51
+ color: #000;
52
+ }
53
+
54
+ .ac-icon-button-basic:hover:not(:disabled) {
55
+ transform: translateY(-1px);
56
+ opacity: 0.95;
57
+ }
58
+
59
+ .ac-icon-button-basic:active:not(:disabled) {
60
+ transform: translateY(1px);
61
+ }
62
+
63
+ .ac-icon-button-basic:focus {
64
+ outline: 3px solid rgba(0, 0, 0, 0.08);
65
+ outline-offset: 3px;
66
+ }
67
+
68
+ .ac-icon-button-basic[disabled] {
69
+ opacity: 0.45;
70
+ cursor: not-allowed;
71
+ transform: none;
72
+ }
73
+ `;
@@ -0,0 +1,85 @@
1
+ :host {
2
+ display: inline-block;
3
+ }
4
+
5
+ :host([hidden]) {
6
+ display: none;
7
+ }
8
+
9
+ .ac-icon-button-basic {
10
+ display: inline-flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ border: none;
14
+ cursor: pointer;
15
+ transition:
16
+ background 150ms ease,
17
+ color 150ms ease,
18
+ transform 120ms ease;
19
+ }
20
+
21
+ // Tamaños — mismo criterio de escala que el radio de borde (más grande =
22
+ // más padding, nunca --radius-full: ver "Emerald Pro" en docs/CONVENTIONS.md).
23
+ // El tamaño total crece junto con el ícono interno (16/20/24px de
24
+ // ac-icon-basic), nunca al revés.
25
+ .ac-icon-button--sm {
26
+ padding: var(--space-2, 0.5rem);
27
+ border-radius: var(--radius-sm, 0.5rem);
28
+ corner-shape: squircle;
29
+ }
30
+
31
+ .ac-icon-button--md {
32
+ padding: var(--space-3, 0.75rem);
33
+ border-radius: var(--radius-md, 1rem);
34
+ corner-shape: squircle;
35
+ }
36
+
37
+ .ac-icon-button--lg {
38
+ padding: var(--space-4, 1rem);
39
+ border-radius: var(--radius-lg, 1.5rem);
40
+ corner-shape: squircle;
41
+ }
42
+
43
+ // Ambients — mismos tokens que ac-button-basic para primary/secondary
44
+ // (ver button-basic.styles.scss), + danger con --color-danger (mismo
45
+ // fondo + texto negro ya validado en ac-badge-basic para ese token).
46
+ .ac-icon-button--primary {
47
+ background: var(--color-primary-700, #047857);
48
+ color: var(--color-primary-50, #ecfdf5);
49
+ }
50
+
51
+ .ac-icon-button--secondary {
52
+ background: var(--color-accent-500, #f59e0b);
53
+ // Texto oscuro: tonos más claros sobre #f59e0b no cumplen contraste WCAG AA
54
+ color: var(--color-accent-900, #451a03);
55
+ }
56
+
57
+ .ac-icon-button--danger {
58
+ background: var(--color-danger, #e05555);
59
+ color: #000;
60
+ }
61
+
62
+ // Hover / active
63
+ .ac-icon-button-basic:hover:not(:disabled) {
64
+ transform: translateY(-1px);
65
+ opacity: 0.95;
66
+ }
67
+
68
+ .ac-icon-button-basic:active:not(:disabled) {
69
+ transform: translateY(1px);
70
+ }
71
+
72
+ .ac-icon-button-basic:focus {
73
+ outline: 3px solid rgba(0, 0, 0, 0.08);
74
+ outline-offset: 3px;
75
+ }
76
+
77
+ // Disabled — nunca `opacity` sobre texto (rompe contraste WCAG de forma
78
+ // impredecible, ver docs/CONVENTIONS.md); acá no hay texto, solo un ícono
79
+ // vectorial de color fijo, así que atenuar con opacity el control entero
80
+ // (no una porción de texto) es aceptable, mismo criterio que ac-button-basic.
81
+ .ac-icon-button-basic[disabled] {
82
+ opacity: 0.45;
83
+ cursor: not-allowed;
84
+ transform: none;
85
+ }