Skip to content

Commit

Permalink
fix(color-area): remove deprecated "label" attribute/property
Browse files Browse the repository at this point in the history
BREAKING CHANGE: set labels via the label-x/label-y attributes or labelX/labelY properties
  • Loading branch information
Westbrook committed Nov 30, 2021
1 parent 7f38d11 commit f05b27d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 0 additions & 2 deletions packages/color-area/README.md
Expand Up @@ -69,8 +69,6 @@ An `<sp-color-area>`’s height and width can be customized appropriately for it
An `<sp-color-area>` renders accessible labels for each axis: _"saturation"_ and _"luminosity"_.
Specify `label-x` and `label-y` attributes to override these defaults.

The `label` attribute is **deprecated** in favor of separately labeling each axis.

```html
<sp-color-area
label-x="Color intensity"
Expand Down
7 changes: 2 additions & 5 deletions packages/color-area/src/ColorArea.ts
Expand Up @@ -50,9 +50,6 @@ export class ColorArea extends SpectrumElement {
@property({ type: Boolean, reflect: true })
public focused = false;

@property({ type: String })
public label: string | undefined;

@property({ type: String, attribute: 'label-x' })
public labelX = 'saturation';

Expand Down Expand Up @@ -487,7 +484,7 @@ export class ColorArea extends SpectrumElement {
type="range"
class="slider"
name="x"
aria-label=${this.label ?? this.labelX}
aria-label=${this.labelX}
min="0"
max="1"
step=${this.step}
Expand All @@ -502,7 +499,7 @@ export class ColorArea extends SpectrumElement {
type="range"
class="slider"
name="y"
aria-label=${this.label ?? this.labelY}
aria-label=${this.labelY}
min="0"
max="1"
step=${this.step}
Expand Down
13 changes: 9 additions & 4 deletions packages/color-area/test/color-area.test.ts
Expand Up @@ -109,20 +109,25 @@ describe('ColorArea', () => {
expect(inputX?.getAttribute('aria-label')).to.equal('saturation');
expect(inputY?.getAttribute('aria-label')).to.equal('luminosity');
});
it('overrides both X and Y labels with a provided "label" attribute', async () => {
it('overrides both X and Y labels with a provided custom attributes', async () => {
const el = await fixture<ColorArea>(
html`
<sp-color-area
color="hsl(100, 50%, 50%)"
label="something custom"
label-x="something custom, saturation"
label-y="something custom, luminosity"
></sp-color-area>
`
);
const inputX = el.shadowRoot.querySelector('input[name="x"]');
const inputY = el.shadowRoot.querySelector('input[name="y"]');

expect(inputX?.getAttribute('aria-label')).to.equal('something custom');
expect(inputY?.getAttribute('aria-label')).to.equal('something custom');
expect(inputX?.getAttribute('aria-label')).to.equal(
'something custom, saturation'
);
expect(inputY?.getAttribute('aria-label')).to.equal(
'something custom, luminosity'
);
});
it('accepts "color" values as hsl', async () => {
const el = await fixture<ColorArea>(
Expand Down

0 comments on commit f05b27d

Please sign in to comment.