Skip to content

Commit

Permalink
feat(a11y): added support in the CloudImageEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Didenko committed Jun 14, 2024
1 parent c18ed11 commit 9b2de04
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 118 deletions.
15 changes: 8 additions & 7 deletions blocks/CloudImageEditor/src/EditorButtonControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export class EditorButtonControl extends Block {
this._titleEl = this.ref['title-el'];
this._iconEl = this.ref['icon-el'];

this.setAttribute('role', 'button');
if (this.tabIndex === -1) {
this.tabIndex = 0;
}
// this.setAttribute('role', 'button');
// if (this.tabIndex === -1) {
// this.tabIndex = 0;
// }

this.sub('title', (title) => {
let titleEl = this._titleEl;
Expand All @@ -42,7 +42,8 @@ export class EditorButtonControl extends Block {
}

EditorButtonControl.template = /* HTML */ `
<div class="before"></div>
<lr-icon set="@name: icon;"></lr-icon>
<div class="title" ref="title-el">{{title}}</div>
<button tabindex="0">
<lr-icon set="@name: icon;"></lr-icon>
<div class="title" ref="title-el">{{title}}</div>
</button>
`;
7 changes: 4 additions & 3 deletions blocks/CloudImageEditor/src/EditorFilterControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class EditorFilterControl extends EditorButtonControl {
}

EditorFilterControl.template = /* HTML */ `
<div class="before"></div>
<div class="preview" ref="preview-el"></div>
<lr-icon ref="icon-el" set="@name: icon; @size: iconSize;"></lr-icon>
<button>
<div class="preview" ref="preview-el"></div>
<lr-icon ref="icon-el" set="@name: icon; @size: iconSize;"></lr-icon>
</button>
`;
15 changes: 5 additions & 10 deletions blocks/CloudImageEditor/src/EditorToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,7 @@ import { viewerImageSrc } from './util.js';
function renderTabToggle(id) {
return /* HTML */ `
<lr-presence-toggle class="tab-toggle" set="visible: presence.tabToggle.${id}; styles: presence.tabToggleStyles;">
<lr-btn-ui
theme="boring"
ref="tab-toggle-${id}"
data-id="${id}"
icon="${id}"
tabindex="0"
set="onclick: on.clickTab;"
>
<lr-btn-ui theme="boring" ref="tab-toggle-${id}" data-id="${id}" icon="${id}" set="onclick: on.clickTab;">
</lr-btn-ui>
</lr-presence-toggle>
`;
Expand Down Expand Up @@ -111,6 +104,8 @@ export class EditorToolbar extends Block {
/** @param {MouseEvent} e */
'on.clickTab': (e) => {
const id = /** @type {HTMLElement} */ (e.currentTarget).getAttribute('data-id');

console.log({ id });
if (id) {
this._activateTab(id, { fromViewer: false });
}
Expand Down Expand Up @@ -395,12 +390,12 @@ EditorToolbar.template = /* HTML */ `
<lr-presence-toggle class="sub-toolbar" set="visible: presence.mainToolbar; styles: presence.subTopToolbarStyles">
<div class="tab-content-row">${ALL_TABS.map(renderTabContent).join('')}</div>
<div class="controls-row">
<lr-btn-ui theme="boring" icon="closeMax" set="onclick: on.cancel"> </lr-btn-ui>
<lr-btn-ui theme="boring" icon="closeMax" set="onclick: on.cancel"></lr-btn-ui>
<lr-presence-toggle class="tab-toggles" set="visible: presence.tabToggles; styles: presence.tabTogglesStyles">
<div ref="tabs-indicator" class="tab-toggles_indicator"></div>
${ALL_TABS.map(renderTabToggle).join('')}
</lr-presence-toggle>
<lr-btn-ui theme="primary" icon="done" set="onclick: on.apply"> </lr-btn-ui>
<lr-btn-ui theme="primary" icon="done" set="onclick: on.apply"></lr-btn-ui>
</div>
</lr-presence-toggle>
<lr-presence-toggle class="sub-toolbar" set="visible: presence.subToolbar; styles: presence.subBottomToolbarStyles">
Expand Down
104 changes: 104 additions & 0 deletions blocks/CloudImageEditor/src/css/buttons.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
:where(.lr-cloud-image-editor, lr-cloud-image-editor) button {
all: unset;
border: none;
display: flex;
align-items: center;
height: 100%;
}

:where(.lr-cloud-image-editor, lr-cloud-image-editor) button svg {
width: 100%;
height: 100%;
}

:where(lr-editor-button-control, lr-editor-crop-button-control, lr-editor-filter-control, lr-editor-operation-control)
> button
> lr-icon
> svg {
width: 20px;
height: 20px;
}

lr-editor-button-control.active > button,
lr-editor-operation-control.active > button,
lr-editor-crop-button-control.active > button,
lr-editor-filter-control.active > button {
--idle-color-rgb: var(--rgb-primary-accent);
}

lr-editor-button-control.not_active > button,
lr-editor-operation-control.not_active > button,
lr-editor-crop-button-control.not_active > button,
lr-editor-filter-control.not_active > button {
--idle-color-rgb: var(--rgb-text-base);
}

lr-editor-button-control > button::before,
lr-editor-operation-control > button::before,
lr-editor-crop-button-control > button::before,
lr-editor-filter-control > button::before {
position: absolute;
content: '';
right: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
background-color: rgba(var(--color-effect), var(--opacity-effect));
border-radius: var(--border-radius-editor);
transition: var(--transition-duration-3);
}

lr-editor-button-control > button .title,
lr-editor-operation-control > button .title,
lr-editor-crop-button-control > button .title,
lr-editor-filter-control > button .title {
padding-right: var(--cldtr-gap-mid-1);
font-size: 0.7em;
letter-spacing: 1.004px;
text-transform: uppercase;
}

lr-editor-filter-control > lr-icon.original-icon > svg {
width: 100%;
height: 100%;
}

lr-editor-filter-control.not_active .preview[loaded] {
opacity: 1;
}

lr-editor-filter-control.active .preview {
opacity: 0;
}

lr-editor-filter-control > button .preview {
position: absolute;
right: 0;
left: 0;
z-index: 1;
width: 100%;
height: var(--l-base-height);
background-repeat: no-repeat;
background-size: contain;
border-radius: var(--border-radius-editor);
opacity: 0;
filter: brightness(var(--filter-effect));
transition: var(--transition-duration-3);
}

lr-editor-filter-control > button .original-icon {
color: var(--color-text-base);
opacity: 0.3;
}

/* @TODO perhaps need to change */
lr-btn-ui[icon='closeMax'],
lr-btn-ui[icon='done'] {
width: 40px;
}

[role='button']:focus-visible,
button:focus-visible {
outline: 1px auto -webkit-focus-ring-color;
}
109 changes: 20 additions & 89 deletions blocks/CloudImageEditor/src/css/common.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* TODO: we shuoud use basic theme there */

@import url('buttons.css');

:host(.lr-cloud-image-editor),
.lr-cloud-image-editor {
/* Theme settings >>> */
Expand Down Expand Up @@ -398,6 +400,12 @@ lr-editor-operation-control {
--down-filter: 0.6;

position: relative;
}

lr-editor-button-control button,
lr-editor-crop-button-control button,
lr-editor-filter-control button,
lr-editor-operation-control button {
display: grid;
grid-template-columns: var(--l-base-min-width) auto;
grid-template-rows: 100%;
Expand All @@ -409,85 +417,6 @@ lr-editor-operation-control {
transition: var(--l-width-transition);
}

:where(lr-editor-button-control, lr-editor-crop-button-control, lr-editor-filter-control, lr-editor-operation-control)
> lr-icon
> svg {
width: 20px;
height: 20px;
}

lr-editor-filter-control > lr-icon.original-icon > svg {
width: 100%;
height: 100%;
}

lr-editor-button-control.active,
lr-editor-operation-control.active,
lr-editor-crop-button-control.active,
lr-editor-filter-control.active {
--idle-color-rgb: var(--rgb-primary-accent);
}

lr-editor-filter-control.not_active .preview[loaded] {
opacity: 1;
}

lr-editor-filter-control.active .preview {
opacity: 0;
}

lr-editor-button-control.not_active,
lr-editor-operation-control.not_active,
lr-editor-crop-button-control.not_active,
lr-editor-filter-control.not_active {
--idle-color-rgb: var(--rgb-text-base);
}

lr-editor-button-control > .before,
lr-editor-operation-control > .before,
lr-editor-crop-button-control > .before,
lr-editor-filter-control > .before {
position: absolute;
right: 0px;
left: 0px;
z-index: -1;
width: 100%;
height: 100%;
background-color: rgba(var(--color-effect), var(--opacity-effect));
border-radius: var(--border-radius-editor);
transition: var(--transition-duration-3);
}

lr-editor-button-control > .title,
lr-editor-operation-control > .title,
lr-editor-crop-button-control > .title,
lr-editor-filter-control > .title {
padding-right: var(--cldtr-gap-mid-1);
font-size: 0.7em;
letter-spacing: 1.004px;
text-transform: uppercase;
}

lr-editor-filter-control > .preview {
position: absolute;
right: 0px;
left: 0px;
z-index: 1;
width: 100%;
height: var(--l-base-height);
background-repeat: no-repeat;
background-size: contain;
border-radius: var(--border-radius-editor);
opacity: 0;
filter: brightness(var(--filter-effect));
transition: var(--transition-duration-3);
}

lr-editor-filter-control > .original-icon {
color: var(--color-text-base);
opacity: 0.3;
}

lr-editor-image-cropper {
position: absolute;
top: 0px;
Expand Down Expand Up @@ -751,6 +680,7 @@ lr-editor-toolbar
> .tab-toggles
> .tab-toggle
> lr-btn-ui
> button
> lr-icon
> svg {
width: 100%;
Expand Down Expand Up @@ -832,7 +762,7 @@ lr-editor-toolbar .slider {
padding-left: var(--l-slider-padding);
}

lr-btn-ui {
lr-btn-ui > button {
--filter-effect: var(--idle-brightness);
--opacity-effect: var(--idle-opacity);
--color-effect: var(--idle-color-rgb);
Expand All @@ -852,11 +782,11 @@ lr-btn-ui {
user-select: none;
}

lr-btn-ui .text {
lr-btn-ui > button .text {
white-space: nowrap;
}

lr-btn-ui .icon {
lr-btn-ui > button .icon {
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -865,27 +795,28 @@ lr-btn-ui .icon {
transition: var(--l-transition-effect);
}

lr-btn-ui .icon_left {
lr-btn-ui > button .icon_left {
margin-right: var(--cldtr-gap-mid-1);
margin-left: 0px;
}

lr-btn-ui .icon_right {
lr-btn-ui > button .icon_right {
margin-right: 0px;
margin-left: var(--cldtr-gap-mid-1);
}

lr-btn-ui .icon_single {
lr-btn-ui > button .icon_single {
margin-right: 0px;
margin-left: 0px;
}

lr-btn-ui .icon_hidden {
lr-btn-ui > button .icon_hidden,
lr-btn-ui > button [hidden] {
display: none;
margin: 0;
}

lr-btn-ui.primary {
lr-btn-ui.primary > button {
--idle-color-rgb: var(--rgb-primary-accent);
--idle-brightness: 1;
--idle-opacity: 0.6;
Expand All @@ -900,7 +831,7 @@ lr-btn-ui.primary {
--active-opacity: 1;
}

lr-btn-ui.boring {
lr-btn-ui.boring > button {
--idle-color-rgb: var(--rgb-text-base);
--idle-brightness: 1;
--idle-opacity: 0.6;
Expand All @@ -915,7 +846,7 @@ lr-btn-ui.boring {
--active-opacity: 1;
}

lr-btn-ui.default {
lr-btn-ui.default > button {
--idle-color-rgb: var(--rgb-text-base);
--idle-brightness: 1;
--idle-opacity: 0.6;
Expand Down
Loading

0 comments on commit 9b2de04

Please sign in to comment.