Skip to content

Commit

Permalink
Merge pull request #20 from verto-health/screen-mask
Browse files Browse the repository at this point in the history
Screen Mask and Large Cursor Widget
  • Loading branch information
choyiny authored Aug 23, 2023
2 parents 30ca7fd + ecc09ee commit 5348966
Show file tree
Hide file tree
Showing 8 changed files with 736 additions and 7 deletions.
15 changes: 15 additions & 0 deletions cypress/e2e/astral-accessibility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,20 @@ describe('template spec', () => {
cy.wrap(elmt).should('have.css', 'font-size', `${initialSize}px`);
}
});

const screenMaskComponent = cy.document().find('astral-screen-mask');
// cursor size check
cy.document().find('style').should('not.contain', "cursor: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAyCAYAAADSprJaAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIaADAAQAAAABAAAAMgAAAADCOgBRAAAACXBIWXMAAAsTAAALEwEAmpwYAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXR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UoE9OVD4iaF+K/6KAqXluOKOEkhUjQlqdG9PT01h+CHzjkmmVd2Hs5+d3Pv9Dh0qo0VPHxvr6OqAN5MHy8/MNmmML3S88wsLCHnh5eT0kyEAaMaDODHU9PDyMjY0NY2trC2k3ysOUBFB4264SugJDQ0NYbqwEFFFq0PcrzzPdsv486/WqicumQwcYGRnB0PmUXFxcBAM7I+Ll5WW8s0RHRwtSQi2/tygPKjsK+H7xuFAJACiI+/fvw9nMeXl56Mw6MDCAvs+UQLq5uRnSioSEhB8phl3t4+i8EmqTQeOjo6M8StysaVn9TY2zA25vb+P1mRqPHj3ifDrCd6nMO6Agc7dFTjwvgxgbGwPACY5kkplHSHfJfylPzMzM8HeiAsbJmZuby2rQrtgiu3VeDQWBuVU2MTHBAFCAPPkXNRYq2w+I6upqEzYomHLQ4eFhdlCqA8Vgtg3Flrb/jI2NRYfsYGh0fHycAejAEd7e3r/K2iytj49PEo0UPiKePXvGe7KCWVtbQz0z/nry9PS8J+s53AK4XGRkJEOgkdnZWQaAAgTwm2wIkYcMBs37H5QW/f39JkDrTtzZ2clTkpSUNIpKZM5BUEFB2y7+FGEAX19f/H7ATdgeysF4joODg8v8/f151DgPYEqNJ0+esIPSReaIqkbLNjAAhyZof2cA2t8FdTCu1dAbUHPsTkr9Q2XE5OQkf4AoB8X1n05LVoOms0u245SDMkBERASccEIDUApoWbb1TxtTNyCKi4tN+CSEqX1lamqKNzVaVYt6RUfpEzRI4XetoK6Alm1b+zRl0YmJiceo9/TpU16ugJmbm7NWVVVBCSummOLPZWWHvoHC07IwossAVBFukOQeowz40unjx4+t9GcsTwPyCADLFXtLDAXYRara3sjnQ+2XIwAUVaP6WI6WFaF8QQ5poWn9idLvoqA0hwAopwo5A4DyykGRfo6VQkvylPzkZ/qdiExpcEjVtsqzG1+pMLWkPL6JnBn7RoLWOt45OyCu9h8Ye2qUOQGERgAAAABJRU5ErkJggg=='), auto;");
screenMaskComponent.click();
cy.document().find('style').should('contain', "cursor: url('data:image/png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kkplHSHfJfylPzMzM8HeiAsbJmZuby2rQrtgiu3VeDQWBuVU2MTHBAFCAPPkXNRYq2w+I6upqEzYomHLQ4eFhdlCqA8Vgtg3Flrb/jI2NRYfsYGh0fHycAejAEd7e3r/K2iytj49PEo0UPiKePXvGe7KCWVtbQz0z/nry9PS8J+s53AK4XGRkJEOgkdnZWQaAAgTwm2wIkYcMBs37H5QW/f39JkDrTtzZ2clTkpSUNIpKZM5BUEFB2y7+FGEAX19f/H7ATdgeysF4joODg8v8/f151DgPYEqNJ0+esIPSReaIqkbLNjAAhyZof2cA2t8FdTCu1dAbUHPsTkr9Q2XE5OQkf4AoB8X1n05LVoOms0u245SDMkBERASccEIDUApoWbb1TxtTNyCKi4tN+CSEqX1lamqKNzVaVYt6RUfpEzRI4XetoK6Alm1b+zRl0YmJiceo9/TpU16ugJmbm7NWVVVBCSummOLPZWWHvoHC07IwossAVBFukOQeowz40unjx4+t9GcsTwPyCADLFXtLDAXYRara3sjnQ+2XIwAUVaP6WI6WFaF8QQ5poWn9idLvoqA0hwAopwo5A4DyykGRfo6VQkvylPzkZ/qdiExpcEjVtsqzG1+pMLWkPL6JnBn7RoLWOt45OyCu9h8Ye2qUOQGERgAAAABJRU5ErkJggg=='), auto;");

// screen mask check

cy.document().find('.mask-top').should('not.exist')
screenMaskComponent.click();
cy.document().find('.mask-top').should('exist')
cy.reload()
cy.document().find('.mask-top').should('not.exist')

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<div class="action">
<astral-text-spacing></astral-text-spacing>
</div>
<div class="action d-none d-sm-block">
<astral-screen-mask></astral-screen-mask>
</div>
<div class="action">
<astral-line-height></astral-line-height>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@
word-spacing: 0.48em;
letter-spacing: 0.36em;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { SaturateComponent } from './controls/saturate.component';
import { TextSizeComponent } from './controls/text-size.component';
import { TextSpacingComponent } from './controls/text-spacing.component';
import { ScreenReaderComponent } from './controls/screen-reader.component';
import { ScreenMaskComponent } from './controls/screen-mask.component';
import { LineHeightComponent } from './controls/line-height.component';

@Component({
selector: 'astral-accessibility',
Expand All @@ -20,6 +22,8 @@ import { ScreenReaderComponent } from './controls/screen-reader.component';
TextSizeComponent,
TextSpacingComponent,
ScreenReaderComponent,
ScreenMaskComponent,
LineHeightComponent
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { DOCUMENT, NgIf, NgClass } from '@angular/common';
import { Component, Renderer2, inject } from '@angular/core';
import { AstralCheckmarkSvgComponent } from '../util/astral-checksvg.component';

@Component({
selector: 'astral-line-height',
standalone: true,
template: `
<button
(click)="nextState()"
[ngClass]="{ 'in-use': states[currentState] != base }"
>
<div class="title">
<div class="icon-state-wrap">
<div
class="icon action-icon"
[ngClass]="{
inactive: states[currentState] == base,
active: states[currentState] != base
}"
>
<svg width="25px" height="25px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13 6L21 6.00048M13 12L21 12.0005M13 18L21 18.0005M6 4V20M6 4L3 7M6 4L9 7M6 20L3 17M6 20L9 17" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div class="state-dots-wrap">
<span>{{ states[currentState] }}</span>
<div
class="dots"
[ngClass]="{ inactive: states[currentState] === base }"
>
<div
class="dot"
[ngClass]="{ active: states[currentState] === 'Light Height' }"
></div>
<div
class="dot"
[ngClass]="{
active: states[currentState] === 'Moderate Height'
}"
></div>
<div
class="dot"
[ngClass]="{ active: states[currentState] === 'Heavy Height' }"
></div>
</div>
</div>
</div>
</div>
<astral-widget-checkmark
[isActive]="states[currentState] !== base"
></astral-widget-checkmark>
</button>
`,
imports: [NgIf, NgClass, AstralCheckmarkSvgComponent],
})
export class LineHeightComponent {
constructor(private renderer: Renderer2) {}
document = inject(DOCUMENT);

currentState = 0;
base = 'Line Height';
states = [this.base, 'Light Height', 'Moderate Height', 'Heavy Height'];

lowHeight = `
*{
line-height: 1.5 !important;
}`;

moderateHeight = `
*{
line-height: 3 !important;
}`;

heavyHeight = `
*{
line-height: 4 !important;
}`;

private lowHeightStyleTag: HTMLStyleElement | null = null;
private moderateHeightStyleTag: HTMLStyleElement | null = null;
private heavyHeightStyleTag: HTMLStyleElement | null = null;

_style: HTMLStyleElement;

nextState() {
this.currentState += 1;
this.currentState = this.currentState % 4;

this._runStateLogic();
}

private _runStateLogic() {
this._style?.remove?.();
this._style = this.document.createElement('style');

if (this.states[this.currentState] === 'Light Height') {
if (!this.lowHeightStyleTag) {
this.lowHeightStyleTag = this.renderer.createElement('style');
this.renderer.appendChild(this.lowHeightStyleTag, this.renderer.createText(this.lowHeight));
this.renderer.appendChild(this.document.head, this.lowHeightStyleTag);
}
} else {
if (this.lowHeightStyleTag) {
this.renderer.removeChild(this.document.head, this.lowHeightStyleTag);
this.lowHeightStyleTag = null;
}
}

if (this.states[this.currentState] === 'Moderate Height') {
if (!this.moderateHeightStyleTag) {
this.moderateHeightStyleTag = this.renderer.createElement('style');
this.renderer.appendChild(this.moderateHeightStyleTag, this.renderer.createText(this.moderateHeight));
this.renderer.appendChild(this.document.head, this.moderateHeightStyleTag);
}
} else {
if (this.moderateHeightStyleTag) {
this.renderer.removeChild(this.document.head, this.moderateHeightStyleTag);
this.moderateHeightStyleTag = null;
}
}

if (this.states[this.currentState] === 'Heavy Height') {
if (!this.heavyHeightStyleTag) {
this.heavyHeightStyleTag = this.renderer.createElement('style');
this.renderer.appendChild(this.heavyHeightStyleTag, this.renderer.createText(this.heavyHeight));
this.renderer.appendChild(this.document.head, this.heavyHeightStyleTag);
}
} else {
if (this.heavyHeightStyleTag) {
this.renderer.removeChild(this.document.head, this.heavyHeightStyleTag);
this.heavyHeightStyleTag = null;
}
}

this.document.body.appendChild(this._style);
}
}
Loading

0 comments on commit 5348966

Please sign in to comment.