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

fix(Accessibility): Color alone is used to convey information #336

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

mariang-ens
Copy link
Contributor

https://jira.corp.adobe.com/browse/SITES-10934

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

@StoianLucian StoianLucian changed the title SITES-10934: Color alone is used to convey information fix(SITES-10934) Color alone is used to convey information Mar 18, 2024
@mariang-ens mariang-ens changed the title fix(SITES-10934) Color alone is used to convey information fix(Accessibility): Color alone is used to convey information Apr 23, 2024
@Pareesh
Copy link
Collaborator

Pareesh commented Jul 25, 2024

LGTM.
Please make sure to test the color input component across porduct to ensure it is not breaking any changes.
cc : @mariang-ens

Copy link
Collaborator

@majornista majornista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So as to not break the component layout. We should use coral-tooltip to show the value. To provide the suggested changes, I implemented this locally. Should I commit those changes to this PR?

@@ -0,0 +1 @@
<label handle="colorLabel" type="label"></label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply including the color value as a block element breaks the layouts of both the ColorInput and ColorInputSwatches. It may be better to use a CoralTooltip to display the value on hover or focus.

Suggested change
<label handle="colorLabel" type="label"></label>
<coral-tooltip handle="colorLabel" placement="top" class="_coral-ColorInput-swatch-tooltip"></coral-tooltip>

Comment on lines 23 to 24
<button handle="colorPreview" is="coral-button" variant="_custom" class="_coral-FieldButton _coral-ColorInput-button _coral-ColorInput-preview" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="{{uid}}"></button>
<label handle="colorPreviewLabel" type="label"></label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply including the color value as a block element breaks the layouts of both the ColorInput and ColorInputSwatches. It may be better to use a CoralTooltip to display the value on hover or focus.

Suggested change
<button handle="colorPreview" is="coral-button" variant="_custom" class="_coral-FieldButton _coral-ColorInput-button _coral-ColorInput-preview" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="{{uid}}"></button>
<label handle="colorPreviewLabel" type="label"></label>
<button handle="colorPreview" is="coral-button" variant="_custom" class="_coral-FieldButton _coral-ColorInput-button _coral-ColorInput-preview" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="{{uid}}" id="{{uid}}-colorPreview" aria-describedby="{{uid}}-tooltip"></button>
<coral-tooltip handle="colorPreviewLabel" class="_coral-ColorInput-preview-tooltip" id="{{uid}}-tooltip" target="#{{uid}}-colorPreview" placement="top"></coral-tooltip>

Comment on lines 42 to 43
colorButton.call(this._elements);
colorLabel.call(this._elements);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass commons through to the colorButton template so that we can call generate a uid within the template.

Suggested change
colorButton.call(this._elements);
colorLabel.call(this._elements);
colorButton.call(this._elements, {commons});
colorLabel.call(this._elements);

@@ -107,10 +109,12 @@ const ColorInputSwatch = Decorator(class extends BaseColorInputAbstractSubview(B
if (cssColorValue) {
this._elements.colorButton.style.backgroundColor = cssColorValue;
this._elements.colorButton.label.textContent = hexColorValue;
this._elements.colorLabel.textContent = hexColorValue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using coral-tooltip we set the textContent of the content element.

Suggested change
this._elements.colorLabel.textContent = hexColorValue;
this._elements.colorLabel.content.textContent = hexColorValue;

this.setAttribute('data-value', hexColorValue);
} else {
this._elements.colorButton.classList.add('_coral-ColorInput-swatch-novalue');
this._elements.colorButton.label.textContent = i18n.get('unset');
this._elements.colorLabel.textContent = i18n.get('unset');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using coral-tooltip we set the textContent of the content element.

Suggested change
this._elements.colorLabel.textContent = i18n.get('unset');
this._elements.colorLabel.content.textContent = i18n.get('unset');

this.appendChild(this._elements.colorButton);
this.appendChild(this._elements.colorLabel);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coral-tooltip should target the colorButton element.

Suggested change
this.appendChild(this._elements.colorLabel);
this.appendChild(this._elements.colorLabel);
this._elements.colorLabel.target = '#' + this._elements.colorButton.id;

Comment on lines 192 to 195

label {
display block;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix text wrapping:

Suggested change
label {
display block;
}
._coral-ColorInput-swatch-tooltip {
min-width: max-content;
}

}

._coral-ColorInput-buttonWrapper {
position: absolute;
right: $colorinput-button-wrapper-offset;
top: $colorinput-button-wrapper-offset;
text-align: center;

// set opacity < 1 to create new stacking context (for checker image to work)
opacity: .999;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix text wrapping within tooltip:

Suggested change
opacity: .999;
opacity: .999;
._coral-ColorInput-preview-tooltip {
min-width: max-content;
}

@mariang-ens
Copy link
Contributor Author

Hello @majornista @Pareesh . I see that all the comments have been resolved and I updated the branch with the latest master branch. Can you please approve & merge this PR when you have some time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants