You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add string based title and default role (#8822)
* feat: add string based title and default role
* refactor: set role on ready
* refactor: use separate observers
* refactor: make title property notify
* Update packages/card/src/vaadin-card.js
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
* refactor: remove validation for title heading level
* refactor: reflect title heading level to attribute
* refactor: rename title to card title
* fix: add attribute annotations
* chore: remove unnecessary type annotations
* fix: change attribute type
---------
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
* The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.
47
+
* @attr {string} card-title
48
+
*/
49
+
cardTitle: string;
50
+
51
+
/**
52
+
* Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.
@@ -279,10 +280,47 @@ class Card extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
279
280
`;
280
281
}
281
282
283
+
staticgetproperties(){
284
+
return{
285
+
/**
286
+
* The title of the card. When set, any custom slotted title is removed and this string-based title is used instead. If this title is used, an `aria-labelledby` attribute that points to the generated title element is set.
287
+
*
288
+
* @attr {string} card-title
289
+
*/
290
+
cardTitle: {
291
+
type: String,
292
+
notify: true,
293
+
observer: '__cardTitleChanged',
294
+
},
295
+
296
+
/**
297
+
* Sets the heading level (`aria-level`) for the string-based title. If not set, the level defaults to 2. Setting values outside the range [1, 6] can cause accessibility issues.
298
+
*
299
+
* @attr {number} title-heading-level
300
+
*/
301
+
titleHeadingLevel: {
302
+
type: Number,
303
+
reflectToAttribute: true,
304
+
observer: '__titleHeadingLevelChanged',
305
+
},
306
+
};
307
+
}
308
+
282
309
staticgetexperimental(){
283
310
returntrue;
284
311
}
285
312
313
+
/** @protected */
314
+
ready(){
315
+
super.ready();
316
+
317
+
// By default, if the user hasn't provided a custom role,
318
+
// the role attribute is set to "region".
319
+
if(!this.hasAttribute('role')){
320
+
this.setAttribute('role','region');
321
+
}
322
+
}
323
+
286
324
/** @protected */
287
325
render(){
288
326
returnhtml`
@@ -322,6 +360,79 @@ class Card extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
0 commit comments