@neovici/cosmoz-button 1.1.0 → 1.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.
@@ -8,6 +8,10 @@ export interface CosmozButtonElement extends HTMLElement {
8
8
  'full-width': boolean;
9
9
  type: ButtonType;
10
10
  value: string | null;
11
+ href: string | null;
12
+ target: string | null;
13
+ rel: string | null;
14
+ download: string | null;
11
15
  }
12
16
  /**
13
17
  * A customizable button component using Untitled UI design tokens.
@@ -20,12 +24,16 @@ export interface CosmozButtonElement extends HTMLElement {
20
24
  * @attr {boolean} full-width - Makes the button 100% width
21
25
  * @attr {string} type - Button type: button (default), submit, reset
22
26
  * @attr {string} value - Value associated with the button (optional)
27
+ * @attr {string} href - When present, renders as an anchor link instead of a button
28
+ * @attr {string} target - Target attribute for the anchor (only with href)
29
+ * @attr {string} rel - Rel attribute for the anchor (only with href)
30
+ * @attr {string} download - Download attribute for the anchor (only with href)
23
31
  *
24
32
  * @slot - Default slot for button text content
25
33
  * @slot prefix - Slot for prefix icon (before text)
26
34
  * @slot suffix - Slot for suffix icon (after text)
27
35
  *
28
- * @csspart button - The native button element
36
+ * @csspart button - The native button or anchor element
29
37
  */
30
38
  declare const CosmozButton: (host: CosmozButtonElement) => import("lit-html").TemplateResult<1>;
31
39
  export { CosmozButton };
@@ -1,5 +1,7 @@
1
1
  import { normalize } from '@neovici/cosmoz-tokens/normalize';
2
2
  import { component, html, useEffect } from '@pionjs/pion';
3
+ import { nothing } from 'lit-html';
4
+ import { ifDefined } from 'lit-html/directives/if-defined.js';
3
5
  import { styles } from './styles';
4
6
  const observedAttributes = [
5
7
  'variant',
@@ -8,6 +10,10 @@ const observedAttributes = [
8
10
  'full-width',
9
11
  'type',
10
12
  'value',
13
+ 'href',
14
+ 'target',
15
+ 'rel',
16
+ 'download',
11
17
  ];
12
18
  /**
13
19
  * A customizable button component using Untitled UI design tokens.
@@ -20,16 +26,21 @@ const observedAttributes = [
20
26
  * @attr {boolean} full-width - Makes the button 100% width
21
27
  * @attr {string} type - Button type: button (default), submit, reset
22
28
  * @attr {string} value - Value associated with the button (optional)
29
+ * @attr {string} href - When present, renders as an anchor link instead of a button
30
+ * @attr {string} target - Target attribute for the anchor (only with href)
31
+ * @attr {string} rel - Rel attribute for the anchor (only with href)
32
+ * @attr {string} download - Download attribute for the anchor (only with href)
23
33
  *
24
34
  * @slot - Default slot for button text content
25
35
  * @slot prefix - Slot for prefix icon (before text)
26
36
  * @slot suffix - Slot for suffix icon (after text)
27
37
  *
28
- * @csspart button - The native button element
38
+ * @csspart button - The native button or anchor element
29
39
  */
30
40
  const CosmozButton = (host) => {
31
41
  const disabled = host.hasAttribute('disabled');
32
42
  const type = host.getAttribute('type') || 'button';
43
+ const href = host.getAttribute('href');
33
44
  useEffect(() => {
34
45
  const handler = (e) => {
35
46
  if (host.hasAttribute('disabled'))
@@ -38,11 +49,31 @@ const CosmozButton = (host) => {
38
49
  host.addEventListener('click', handler, { capture: true });
39
50
  return () => host.removeEventListener('click', handler, { capture: true });
40
51
  }, []);
52
+ const content = html `
53
+ <slot name="prefix"></slot>
54
+ <slot></slot>
55
+ <slot name="suffix"></slot>
56
+ `;
57
+ if (href != null) {
58
+ const target = host.getAttribute('target');
59
+ const rel = host.getAttribute('rel');
60
+ const download = host.getAttribute('download');
61
+ return html `
62
+ <a
63
+ href=${href}
64
+ class="button"
65
+ part="button"
66
+ aria-disabled=${disabled ? 'true' : nothing}
67
+ target=${ifDefined(target)}
68
+ rel=${ifDefined(rel)}
69
+ download=${ifDefined(download)}
70
+ >${content}</a
71
+ >
72
+ `;
73
+ }
41
74
  return html `
42
75
  <button type=${type} class="button" ?disabled=${disabled} part="button">
43
- <slot name="prefix"></slot>
44
- <slot></slot>
45
- <slot name="suffix"></slot>
76
+ ${content}
46
77
  </button>
47
78
  `;
48
79
  };
package/dist/styles.js CHANGED
@@ -69,6 +69,9 @@ export const styles = css `
69
69
  box-shadow 0.15s ease;
70
70
  width: 100%;
71
71
  white-space: nowrap;
72
+ border: none;
73
+ background: none;
74
+ text-align: center;
72
75
 
73
76
  /* Medium (md) - default size */
74
77
  height: 40px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-button",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A customizable button web component built with Untitled UI design tokens",
5
5
  "keywords": [
6
6
  "web-components",
@@ -35,19 +35,8 @@
35
35
  "storybook:build": "storybook build",
36
36
  "storybook:deploy": "storybook-to-ghpages",
37
37
  "storybook:preview": "npm run storybook:build && http-server ./storybook-static/ --silent",
38
- "prepare": "husky"
39
- },
40
- "release": {
41
- "plugins": [
42
- "@semantic-release/commit-analyzer",
43
- "@semantic-release/release-notes-generator",
44
- "@semantic-release/changelog",
45
- "@semantic-release/github",
46
- "@semantic-release/npm",
47
- "@semantic-release/git"
48
- ],
49
- "branch": "main",
50
- "preset": "conventionalcommits"
38
+ "prepare": "husky",
39
+ "changeset": "changeset"
51
40
  },
52
41
  "publishConfig": {
53
42
  "access": "public"
@@ -63,17 +52,16 @@
63
52
  "dependencies": {
64
53
  "@neovici/cosmoz-tokens": "^3.2.0",
65
54
  "@pionjs/pion": "^2.5.2",
66
- "@playwright/test": "^1.60.0",
67
55
  "lit-html": "^3.3.1"
68
56
  },
69
57
  "devDependencies": {
58
+ "@changesets/cli": "^2.27.0",
70
59
  "@commitlint/cli": "^20.0.0",
71
60
  "@commitlint/config-conventional": "^20.4.1",
72
61
  "@neovici/cfg": "^2.13.0",
73
62
  "@neovici/testing": "^2.0.0",
74
63
  "@open-wc/testing": "^4.0.0",
75
- "@semantic-release/changelog": "^6.0.0",
76
- "@semantic-release/git": "^10.0.0",
64
+ "@playwright/test": "1.60.0",
77
65
  "@storybook/addon-docs": "^10.2.3",
78
66
  "@storybook/web-components-vite": "^10.0.0",
79
67
  "@types/mocha": "^10.0.6",
@@ -83,7 +71,6 @@
83
71
  "http-server": "^14.1.1",
84
72
  "husky": "^9.0.0",
85
73
  "lint-staged": "^16.2.7",
86
- "semantic-release": "^25.0.3",
87
74
  "sinon": "^21.0.1",
88
75
  "storybook": "^10.2.4",
89
76
  "typescript": "^5.4.3"