u2ui 1.7.5 → 1.8.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.
@@ -11,20 +11,13 @@
11
11
  min-width: 1.6em;
12
12
  min-height: 1.6em;
13
13
  padding-inline: .6em;
14
- padding-block: .2em .25em;
14
+ padding-block: .25em;
15
15
  justify-content: center;
16
16
  align-items: center;
17
17
  text-align: center;
18
18
 
19
19
  box-sizing: border-box;
20
20
 
21
- /*
22
- box-decoration-break:clone; /* not needed for inline-flex * /
23
- vertical-align:middle;
24
- margin-bottom:-.1em;
25
- margin-top:-.1em;
26
- transform: scale(0.99999999);
27
- */
28
21
  }
29
22
 
30
23
  .u2-badge:empty {
@@ -13,7 +13,6 @@
13
13
  <link rel="stylesheet" href="../../variables.css">
14
14
  <link rel="stylesheet" href="../../classless.css">
15
15
  <link rel="stylesheet" href="../../more.css">
16
- <link rel="stylesheet" href="../../simple.css">
17
16
 
18
17
  <body>
19
18
 
@@ -3,7 +3,7 @@ Prominent hints, alerts and facts. `<u2-alert open variant=info>...</u2-alert>`
3
3
 
4
4
  ## Features
5
5
 
6
- - Various variants for Success, Warn, Error, and Info alerts.
6
+ - Various variants for Success, Warning, Error, and Info alerts.
7
7
  - Dismissable alerts allow user to close them.
8
8
  - Support for icons within alerts.
9
9
  - Customizable actions through buttons in the alert.
@@ -34,7 +34,7 @@ u2-alert::part(icon) {
34
34
  ### Attributes
35
35
 
36
36
  - `variant`
37
- Determines the alert type (`success`, `warn`, `error`, `info`); sets default icon and ARIA role.
37
+ Determines the alert type (`success`, `warning`, `error`, `info`); sets default icon and ARIA role. `warn` still works, but is deprecated.
38
38
 
39
39
  - `dismissable`
40
40
  Shows a close button. Without this attribute the close button is hidden.
@@ -17,7 +17,7 @@ u2-alert:not([open]) {
17
17
  }
18
18
 
19
19
  u2-alert[variant=success] { --color: var(--color-green); }
20
- u2-alert[variant=warn] { --color: var(--color-yellow); }
20
+ u2-alert:is([variant=warning], [variant=warn]) { --color: var(--color-yellow); } /* warn: deprecated */
21
21
  u2-alert[variant=error] { --color: var(--color-red); }
22
22
  u2-alert[variant=info] { --color: var(--color-blue); }
23
23
 
package/el/alert/alert.js CHANGED
@@ -106,11 +106,11 @@ export default class U2Alert extends U2Element {
106
106
  attributeChangedCallback(name, oldValue, newValue) {
107
107
  if (oldValue === newValue) return;
108
108
  if (name==='variant') {
109
- const variant = this.getAttribute('variant');
109
+ const variant = variantOf(this);
110
110
  this.shadowRoot.getElementById('container').role = variantData[variant]?.role || 'status'; // better to set role to host?
111
111
  }
112
112
  if (name==='variant' || name==='icon') {
113
- const variant = this.getAttribute('variant');
113
+ const variant = variantOf(this);
114
114
  const icon = this.getAttribute('icon') || variantData[variant]?.icon || 'info';
115
115
  this.shadowRoot.querySelector('[name=icon]').innerHTML = `<u2-ico icon=${icon}></u2-ico>`;
116
116
  }
@@ -150,7 +150,7 @@ const variantData = {
150
150
  icon: 'check',
151
151
  role: 'status',
152
152
  },
153
- warn: {
153
+ warning: {
154
154
  icon: 'warning',
155
155
  role: 'alert',
156
156
  },
@@ -160,6 +160,16 @@ const variantData = {
160
160
  }
161
161
  };
162
162
 
163
+ /** The variant; "warn" is read as "warning" (deprecated, warned about once). */
164
+ let warned = false;
165
+ function variantOf(el) {
166
+ const variant = el.getAttribute('variant');
167
+ if (variant !== 'warn') return variant;
168
+ if (!warned) console.warn('u2-alert: variant "warn" is deprecated, use "warning"', el);
169
+ warned = true;
170
+ return 'warning';
171
+ }
172
+
163
173
  customElements.get('u2-alert') || customElements.define('u2-alert', U2Alert);
164
174
 
165
175
  function alert(message, variant, options={}) {
@@ -173,7 +183,7 @@ function alert(message, variant, options={}) {
173
183
  }
174
184
  export const info = (message, options) => alert(message, 'info', options);
175
185
  export const success = (message, options) => alert(message, 'success', options);
176
- export const warn = (message, options) => alert(message, 'warn', options);
186
+ export const warn = (message, options) => alert(message, 'warning', options);
177
187
  export const error = (message, options) => alert(message, 'error', options);
178
188
 
179
189
 
package/el/ico/ico.css CHANGED
@@ -68,7 +68,7 @@ u2-ico[inline] {
68
68
  /* SVG */
69
69
  u2-ico > svg {
70
70
  vertical-align:bottom;
71
- height:1em;
71
+ height:1em; /* todo: 1cap? */
72
72
  width:auto;
73
73
  min-width:1em;
74
74
  overflow:visible;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u2ui",
3
- "version": "1.7.5",
3
+ "version": "1.8.1",
4
4
  "description": "HTML Advanced: More Capabilities, Same Feel, Same Simplicity",
5
5
  "keywords": ["web-components","pattern-library","component-library","ui-toolkit","design-system"],
6
6
  "author": "Tobias Buschor",