Skip to content

Commit

Permalink
feat(addon/components/paper-radio-group-label): converts to a glimmer…
Browse files Browse the repository at this point in the history
… component.
  • Loading branch information
matthewhartstonge committed Nov 15, 2024
1 parent 94e3db0 commit e566dc8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
14 changes: 7 additions & 7 deletions addon/components/paper-radio-group-label.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{! template-lint-disable no-curly-component-invocation }}
{{#if (has-block)}}
{{yield}}
{{else}}
{{@text}}
{{/if}}

<md-label id={{this.labelId}} {{did-insert this.didInsertNode}} ...attributes>
{{#if (has-block)}}
{{yield}}
{{else}}
{{@text}}
{{/if}}
</md-label>
34 changes: 24 additions & 10 deletions addon/components/paper-radio-group-label.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
/* eslint-disable ember/no-classic-components, ember/no-component-lifecycle-hooks, ember/require-tagless-components */
import Component from '@ember/component';
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { guidFor } from '@ember/object/internals';

export default Component.extend({
tagName: 'md-label',
export default class PaperRadioGroupLabel extends Component {
/**
* provides a globally unique component id for tracking bindings between aria
* tags and labels.
* @type {string}
*/
labelId;

didInsertElement() {
this._super(...arguments);
constructor(owner, args) {
super(owner, args);

if (this.setAriaLabelledby) {
this.setAriaLabelledby(this.elementId);
this.labelId = this.args.labelId || `${guidFor(this)}-label`;
}

/**
* Performs any required DOM setup.
* @param element
*/
@action didInsertNode() {
if (this.args.setAriaLabelledby) {
this.args.setAriaLabelledby(this.labelId);
}
},
});
}
}

0 comments on commit e566dc8

Please sign in to comment.