@dile/ui 2.25.3 → 2.25.6

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.
@@ -57,7 +57,7 @@ export class DileAppDrawer extends DileCloseOnEscPressed(LitElement) {
57
57
  position: fixed;
58
58
  box-sizing: border-box;
59
59
  z-index: var(--dile-app-drawer-z-index, 99);
60
- background-color: var(--dile-primary-light-color, #ddd);
60
+ background-color: var(--dile-app-drawer-background-color, var(--dile-primary-light-color, #ddd));
61
61
  transition: transform 0.3s ease;
62
62
  overflow: auto;
63
63
  }
@@ -15,6 +15,7 @@ export class DileButton extends LitElement {
15
15
  constructor() {
16
16
  super();
17
17
  this.disabled = false;
18
+ this.type = "button";
18
19
  this._internals = this.attachInternals();
19
20
  }
20
21
 
@@ -51,8 +52,9 @@ export class DileButton extends LitElement {
51
52
  color: var(--dile-button-hover-text-color, var(--dile-on-primary-light-color, #303030));
52
53
  border-color: var(--dile-button-hover-border-color, var(--dile-primary-color, #666666));
53
54
  }
54
- button:focus {
55
- outline: none;
55
+ button:focus-visible {
56
+ outline: 2px solid var(--dile-button-ring-color, #12c9e9);
57
+ outline-offset: 2px;
56
58
  box-shadow: 0 0 0 calc(0px + var(--dile-button-ring-offset-width, 3px)) var(--dile-button-ring-color, #12c9e9);
57
59
  border-color: var(--dile-button-ring-color, #12c9e9);
58
60
  }
@@ -84,7 +86,7 @@ export class DileButton extends LitElement {
84
86
  <button
85
87
  @click=${this._onClick}
86
88
  ?disabled=${this.disabled}
87
- type=${this.type}
89
+ type=${this.type || "button"}
88
90
  ><slot></slot></button>
89
91
  `;
90
92
  }
@@ -20,11 +20,11 @@ export class DileCard extends LitElement {
20
20
  background-color: var(--dile-card-grey-background-color, #f4f4f4);
21
21
  color: var(--dile-card-grey-text-color, #303030);
22
22
  }
23
- h1, main, footer {
23
+ .card-title, main, footer {
24
24
  padding-right: var(--dile-card-padding-x, 1rem);
25
25
  padding-left: var(--dile-card-padding-x, 1rem);
26
26
  }
27
- h1 {
27
+ .card-title {
28
28
  padding-top: var(--dile-card-padding-y, 1rem);
29
29
  font-size: var(--dile-card-title-font-size, 1.5rem);
30
30
  font-weight: var(--dile-card-title-font-weight, 300);
@@ -69,10 +69,16 @@ export class DileCard extends LitElement {
69
69
 
70
70
  static get properties() {
71
71
  return {
72
- title: { type: String }
72
+ title: { type: String },
73
+ titleLevel: { type: Number }
73
74
  };
74
75
  }
75
76
 
77
+ constructor() {
78
+ super();
79
+ this.titleLevel = 2; // sensible default to avoid forcing h1 in page context
80
+ }
81
+
76
82
  render() {
77
83
  return html`
78
84
  ${this.titleTemplate}
@@ -84,9 +90,14 @@ export class DileCard extends LitElement {
84
90
  }
85
91
 
86
92
  get titleTemplate() {
87
- return this.title
88
- ? html`<h1>${this.title}</h1>`
89
- : ''
93
+ // Allow consumers to provide a custom title slot (e.g. an h2/h3) to control heading semantics
94
+ if (this.hasSlot('title')) {
95
+ return html`<div class="card-title"><slot name="title"></slot></div>`;
96
+ }
97
+
98
+ return this.title
99
+ ? html`<div class="card-title" role="heading" aria-level="${this.titleLevel}">${this.title}</div>`
100
+ : '';
90
101
  }
91
102
 
92
103
 
@@ -16,13 +16,25 @@ export class DileCardSlide extends DileSlideDown(DileCard) {
16
16
  return [
17
17
  ...super.styles,
18
18
  css`
19
- h1 {
19
+ .card-title {
20
20
  display: flex;
21
21
  align-items: center;
22
22
  justify-content: space-between;
23
- cursor: pointer;
24
23
  padding-bottom: var(--dile-card-slide-title-padding-bottom, var(--dile-card-padding-y, 1rem));
25
24
  }
25
+ .card-title button {
26
+ all: unset;
27
+ cursor: pointer;
28
+ display: flex;
29
+ align-items: center;
30
+ justify-content: space-between;
31
+ width: 100%;
32
+ text-align: left;
33
+ }
34
+ .card-title button:focus-visible {
35
+ outline: 2px solid Highlight;
36
+ outline-offset: 2px;
37
+ }
26
38
  #content {
27
39
  height: 0;
28
40
  overflow: hidden;
@@ -35,7 +47,7 @@ export class DileCardSlide extends DileSlideDown(DileCard) {
35
47
  transition: transform 0.5s ease;
36
48
  --dile-icon-color: var(--dile-card-slide-icon-color, var(--dile-primary-color, #303030));
37
49
  }
38
- h1.opened dile-icon {
50
+ .opened dile-icon {
39
51
  transform: rotate(0deg);
40
52
  }
41
53
  main {
@@ -49,36 +61,48 @@ export class DileCardSlide extends DileSlideDown(DileCard) {
49
61
  super();
50
62
  this.opened = false;
51
63
  this.icon = arrowDropDownIcon;
64
+ // unique id for aria-controls
65
+ this._contentId = `dile-card-content-${Math.random().toString(36).slice(2,9)}`;
52
66
  }
53
67
 
54
68
  firstUpdated() {
55
- this.content = this.shadowRoot.getElementById('content');
69
+ // content element by generated id
70
+ this.content = this.shadowRoot.getElementById(this._contentId);
71
+ // ensure initial aria-hidden state
72
+ if (this.content) {
73
+ this.content.setAttribute('aria-hidden', String(!this.opened));
74
+ }
56
75
  }
57
76
 
58
77
  updated(changedProperties) {
59
78
  if (changedProperties.has('opened') && this.opened != undefined) {
60
79
  if (this.opened) {
61
80
  this.slideShow(this.content);
81
+ if (this.content) this.content.setAttribute('aria-hidden', 'false');
62
82
  } else {
63
83
  this.slideHide(this.content);
84
+ if (this.content) this.content.setAttribute('aria-hidden', 'true');
64
85
  }
65
86
  }
66
87
  }
67
88
 
68
89
  get titleTemplate() {
90
+ // Render a heading wrapper with a button inside so keyboard and semantics are correct.
69
91
  return this.title
70
92
  ? html`
71
- <h1 @click="${this.toggle}" class="${this.opened ? 'opened' : ''}">
72
- ${this.title}
73
- <dile-icon .icon=${this.icon}></dile-icon>
74
- </h1>`
93
+ <div class="card-title" role="heading" aria-level="${this.titleLevel}">
94
+ <button @click="${this.toggle}" class="${this.opened ? 'opened' : ''}" aria-expanded="${this.opened ? 'true' : 'false'}" aria-controls="${this._contentId}">
95
+ <span>${this.title}</span>
96
+ <dile-icon .icon=${this.icon}></dile-icon>
97
+ </button>
98
+ </div>`
75
99
  : ''
76
100
  }
77
101
 
78
102
  render() {
79
103
  return html`
80
104
  ${this.titleTemplate}
81
- <div id="content">
105
+ <div id="${this._contentId}">
82
106
  <main>
83
107
  <slot></slot>
84
108
  </main>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/ui",
3
- "version": "2.25.3",
3
+ "version": "2.25.6",
4
4
  "description": "UI Core components from dile-components.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "210e3b9f6c0633ace3f52e41990e511cdc61851d"
29
+ "gitHead": "23545d34486a852eb091d262227ab9378599beca"
30
30
  }