Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Element Mixin #65

Closed
11 of 21 tasks
Tracked by #28
MekalaNagarajan-Centrica opened this issue Nov 19, 2021 · 4 comments · Fixed by #70
Closed
11 of 21 tasks
Tracked by #28

Form Element Mixin #65

MekalaNagarajan-Centrica opened this issue Nov 19, 2021 · 4 comments · Fixed by #70
Assignees
Labels
Area: Mixins Work related to creating or updating a mixin

Comments

@MekalaNagarajan-Centrica
Copy link
Contributor

MekalaNagarajan-Centrica commented Nov 19, 2021

Outcome

Base setup for any form element.

Scope

  • how do we test?
  • Prefix different inputs in the tokens
  • initial text styles first

Properties

  • value
  • name
  • id
  • heading
  • labelID

Attributes

Tokens

  • typography
  • input states
  • focus
  • hover
  • disabled
  • active
  • valid
  • invalid

Slots

  • label

States

  • id

Events

  • change

HTML Templates

  • label
  • input ?
@MekalaNagarajan-Centrica MekalaNagarajan-Centrica added the Area: Mixins Work related to creating or updating a mixin label Nov 19, 2021
@MekalaNagarajan-Centrica
Copy link
Contributor Author

Templates

In mixin individual element templates can be defined and components extending the mixin can define the actual rendering template based on the type.

  • headingTemplate - used in multiple option input (eg. radio, checkbox)
  • labelTemplate - used in select and single option input
  • htmlFormElementTemplate - used to render anonymous slot template.

@MekalaNagarajan-Centrica
Copy link
Contributor Author

Should labelID be added as properties in FormElementMixin? If label slot is scoped within this mixin, aria mapping between label and slotted HTML form element should also happen here.

@MekalaNagarajan-Centrica MekalaNagarajan-Centrica linked a pull request Nov 23, 2021 that will close this issue
1 task
@MekalaNagarajan-Centrica
Copy link
Contributor Author

Added heading property into the mixin scope. As heading property is required for the multi-option form element.

@MekalaNagarajan-Centrica
Copy link
Contributor Author

For testing mixins,

  • create a test component that extends the mixin and do dummy template implementation.
  • use the test component within tests.
const MuonFormElement = class extends FormElementMixin(MuonElement) {
  get standardTemplate() {
    return html `
    <div class="slotted-content">
        ${this._isMultiple ? this._headingTemplate : this._labelTemplate}
      <div class="input-holder">
        ${super.standardTemplate}
      </div>
    </div>
    `;
  }
}

const tagName = defineCE(MuonFormElement);

@jholt1 jholt1 closed this as completed Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Mixins Work related to creating or updating a mixin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants