Skip to content

Commit

Permalink
fix: accessibility issues see details (#178)
Browse files Browse the repository at this point in the history
* fix: input placeholder and icon contrast

* fix; remove unused settings menu entry

* feat: scanner-mask component

* fix: tab button alert

* fix: tab button height
  • Loading branch information
phoebus-84 authored Oct 16, 2024
1 parent aabb7f6 commit 759214c
Show file tree
Hide file tree
Showing 16 changed files with 224 additions and 28 deletions.
19 changes: 17 additions & 2 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export namespace Components {
interface DScanButton {
"href": string;
}
interface DScannerMask {
"description": string;
"heading": string;
}
interface DSessionCard {
"date": string;
"failureMessage": string;
Expand All @@ -172,7 +176,6 @@ export namespace Components {
"logOut": string;
"notificationsSettings": string;
"privacyPolicy": string;
"securityAndAuthentication": string;
"support": string;
"version": string;
}
Expand Down Expand Up @@ -476,6 +479,12 @@ declare global {
prototype: HTMLDScanButtonElement;
new (): HTMLDScanButtonElement;
};
interface HTMLDScannerMaskElement extends Components.DScannerMask, HTMLStencilElement {
}
var HTMLDScannerMaskElement: {
prototype: HTMLDScannerMaskElement;
new (): HTMLDScannerMaskElement;
};
interface HTMLDSessionCardElement extends Components.DSessionCard, HTMLStencilElement {
}
var HTMLDSessionCardElement: {
Expand Down Expand Up @@ -573,6 +582,7 @@ declare global {
"d-page-description": HTMLDPageDescriptionElement;
"d-qr-code": HTMLDQrCodeElement;
"d-scan-button": HTMLDScanButtonElement;
"d-scanner-mask": HTMLDScannerMaskElement;
"d-session-card": HTMLDSessionCardElement;
"d-settings-menu": HTMLDSettingsMenuElement;
"d-swipable-page": HTMLDSwipablePageElement;
Expand Down Expand Up @@ -738,6 +748,10 @@ declare namespace LocalJSX {
interface DScanButton {
"href"?: string;
}
interface DScannerMask {
"description"?: string;
"heading"?: string;
}
interface DSessionCard {
"date"?: string;
"failureMessage"?: string;
Expand All @@ -759,7 +773,6 @@ declare namespace LocalJSX {
"onLanguageSettingsClick"?: (event: DSettingsMenuCustomEvent<void>) => void;
"onLogoutClick"?: (event: DSettingsMenuCustomEvent<void>) => void;
"privacyPolicy"?: string;
"securityAndAuthentication"?: string;
"support"?: string;
"version"?: string;
}
Expand Down Expand Up @@ -826,6 +839,7 @@ declare namespace LocalJSX {
"d-page-description": DPageDescription;
"d-qr-code": DQrCode;
"d-scan-button": DScanButton;
"d-scanner-mask": DScannerMask;
"d-session-card": DSessionCard;
"d-settings-menu": DSettingsMenu;
"d-swipable-page": DSwipablePage;
Expand Down Expand Up @@ -869,6 +883,7 @@ declare module "@stencil/core" {
"d-page-description": LocalJSX.DPageDescription & JSXBase.HTMLAttributes<HTMLDPageDescriptionElement>;
"d-qr-code": LocalJSX.DQrCode & JSXBase.HTMLAttributes<HTMLDQrCodeElement>;
"d-scan-button": LocalJSX.DScanButton & JSXBase.HTMLAttributes<HTMLDScanButtonElement>;
"d-scanner-mask": LocalJSX.DScannerMask & JSXBase.HTMLAttributes<HTMLDScannerMaskElement>;
"d-session-card": LocalJSX.DSessionCard & JSXBase.HTMLAttributes<HTMLDSessionCardElement>;
"d-settings-menu": LocalJSX.DSettingsMenu & JSXBase.HTMLAttributes<HTMLDSettingsMenuElement>;
"d-swipable-page": LocalJSX.DSwipablePage & JSXBase.HTMLAttributes<HTMLDSwipablePageElement>;
Expand Down
12 changes: 12 additions & 0 deletions src/components/d-scanner-mask/d-scanner-mask.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:host {
display: block;
}

.viewfinder {
--s: 50px;
--t: 8px;

padding: calc(var(--t));
outline-offset: calc(-1 * var(--t));
mask: conic-gradient(at var(--s) var(--s), #0000 75%, #000 0) 0 0 / calc(100% - var(--s)) calc(100% - var(--s)), linear-gradient(#000 0 0) content-box;
}
77 changes: 77 additions & 0 deletions src/components/d-scanner-mask/d-scanner-mask.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Component, Host, h, State, Prop } from '@stencil/core';

@Component({
tag: 'd-scanner-mask',
styleUrl: 'd-scanner-mask.css',
shadow: true,
})
export class DScannerMask {
@Prop() heading: string;
@Prop() description: string;
@State() translateY: number = -138;
animationDuration = 2000;

componentDidLoad() {
this.toggleAnimation();
}

toggleAnimation() {
const easingFunction = this.quartInOut;
let start = performance.now();

const animate = (time: number) => {
const progress = Math.min((time - start) / this.animationDuration, 1); // cap at 1
const easedProgress = easingFunction(progress);

// Calculate the translateY value
this.translateY = -138 + easedProgress * (135 - -138);

if (progress < 1) {
requestAnimationFrame(animate);
} else {
// Reverse the animation once complete
setTimeout(() => {
this.translateY === -138 ? this.animateTo(135) : this.animateTo(-138);
}, 0);
}
};

requestAnimationFrame(animate);
}

animateTo(value: number) {
this.translateY = value;
this.toggleAnimation();
}

quartInOut(t: number) {
return t < 0.5 ? 8 * t * t * t * t : 1 - Math.pow(-2 * t + 2, 4) / 2;
}

render() {
const style = {
transform: `translateY(${this.translateY}px)`,
};
return (
<Host>
<div class="visible fixed left-0 top-0 z-40 flex h-screen w-full flex-col items-center justify-center">
<div class="bg-surface bg-opacity-70 min-h-24 w-full flex-grow" />
<div class="flex h-72 w-full">
<div class="max-w-1/4 bg-surface bg-opacity-70 h-full flex-grow" />
<div class="viewfinder relative z-50 h-72 w-72 overflow-hidden rounded-md bg-transparent">
<div class="absolute left-0 top-0 h-full w-full border-8 border-accent"></div>
<div class="absolute left-0 top-1/2 h-1 w-full -translate-y-1/2 transform bg-accent" style={style}></div>
</div>
<div class="bg-surface bg-opacity-70 h-full flex-grow" />
</div>

<div class="bg-surface bg-opacity-70 w-full flex-grow">
<div class="text-center justify-center">
<d-page-description title={this.heading} description={this.description} />
</div>
</div>
</div>
</Host>
);
}
}
33 changes: 33 additions & 0 deletions src/components/d-scanner-mask/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# d-scanner-mask



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------- | ------------- | ----------- | -------- | ----------- |
| `description` | `description` | | `string` | `undefined` |
| `heading` | `heading` | | `string` | `undefined` |


## Dependencies

### Depends on

- [d-page-description](../page-description)

### Graph
```mermaid
graph TD;
d-scanner-mask --> d-page-description
d-page-description --> d-heading
d-page-description --> d-text
style d-scanner-mask fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
20 changes: 20 additions & 0 deletions src/components/d-scanner-mask/scanner-mask.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Meta, StoryObj } from '@storybook/html';
import type { Components } from '../../components.js';

const meta = {
title: 'Design System/MEDIA & ICONS/ScannerMask',
render: args => `<d-scanner-mask
${args.heading ? `heading="${args.heading}"` : ''}
${args.description ? `description="${args.description}"` : ''}
></d-scanner-mask>`,
} satisfies Meta<Components.DScannerMask>;

export default meta;
type Story = StoryObj<Components.DScannerMask>;

export const Default: Story = {
args: {
heading: 'Heading',
description: 'Description',
}
};
11 changes: 11 additions & 0 deletions src/components/d-scanner-mask/test/d-scanner-mask.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { newE2EPage } from '@stencil/core/testing';

describe('d-scanner-mask', () => {
it('renders', async () => {
const page = await newE2EPage();
await page.setContent('<d-scanner-mask></d-scanner-mask>');

const element = await page.find('d-scanner-mask');
expect(element).toHaveClass('hydrated');
});
});
33 changes: 33 additions & 0 deletions src/components/d-scanner-mask/test/d-scanner-mask.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { newSpecPage } from '@stencil/core/testing';
import { DScannerMask } from '../d-scanner-mask';

describe('d-scanner-mask', () => {
it('renders', async () => {
const page = await newSpecPage({
components: [DScannerMask],
html: `<d-scanner-mask></d-scanner-mask>`,
});
expect(page.root).toEqualHtml(`
<d-scanner-mask>
<mock:shadow-root>
<div class="fixed flex flex-col h-screen items-center justify-center left-0 top-0 visible w-full z-40">
<div class="bg-opacity-70 bg-surface flex-grow min-h-24 w-full"></div>
<div class="flex h-72 w-full">
<div class="bg-opacity-70 bg-surface flex-grow h-full max-w-1/4"></div>
<div class="bg-transparent h-72 overflow-hidden relative rounded-md viewfinder w-72 z-50">
<div class="absolute border-8 border-accent h-full left-0 top-0 w-full"></div>
<div class="-translate-y-1/2 absolute bg-accent h-1 left-0 top-1/2 transform w-full" style="transform: translateY(-138px);"></div>
</div>
<div class="bg-opacity-70 bg-surface flex-grow h-full"></div>
</div>
<div class="bg-opacity-70 bg-surface flex-grow w-full">
<div class="justify-center text-center">
<d-page-description></d-page-description>
</div>
</div>
</div>
</mock:shadow-root>
</d-scanner-mask>
`);
});
});
1 change: 1 addition & 0 deletions src/components/input/d-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
--border-color: var(--stroke);
--color: var(--on);
--placeholder-color: var(--on-alt);
--placeholder-opacity: 1;
--highlight-color-focused: var(--accent);
--highlight-color-invalid: var(--error);
--highlight-color-valid: var(--success);
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/d-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class DInput {
)}
{this.hidable && (
<d-button class="h-full" slot="end" clear onClick={this.changePasswordVisibility} aria-checked={this.type !== 'password' ? 'true' : 'false'} aria-label="show password" role="switch">
{this.type === 'password' ? <d-icon icon="visibility" outline /> : <d-icon icon="visibility-off" outline />}
{this.type === 'password' ? <d-icon icon="visibility" outline class="text-on" /> : <d-icon icon="visibility-off" outline class="text-on"/>}
</d-button>
)}
</ion-input>
Expand Down
5 changes: 5 additions & 0 deletions src/components/page-description/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

## Dependencies

### Used by

- [d-scanner-mask](../d-scanner-mask)

### Depends on

- [d-heading](../heading)
Expand All @@ -25,6 +29,7 @@
graph TD;
d-page-description --> d-heading
d-page-description --> d-text
d-scanner-mask --> d-page-description
style d-page-description fill:#f9f,stroke:#333,stroke-width:4px
```

Expand Down
5 changes: 0 additions & 5 deletions src/components/settings-menu/d-settings-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Component, Host, Prop, h, Event, EventEmitter } from '@stencil/core';
})
export class DSettingsMenu {
@Prop({ attribute: 'account-settings' }) accountSettings: string;
@Prop({ attribute: 'security-and-authentication' }) securityAndAuthentication: string;
@Prop({ attribute: 'notifications-settings' }) notificationsSettings: string;
@Prop() languages: string;
@Prop() support: string;
Expand All @@ -30,10 +29,6 @@ export class DSettingsMenu {
{this.accountSettings}
<d-icon icon="profile" slot="start" outline />
</d-button>
<d-button href="/" size="large" disabled>
{this.securityAndAuthentication}
<d-icon icon="lock" slot="start" outline />
</d-button>
<d-button onClick={()=>this.appSettingsClick.emit()} aria-hidden size="large">
{this.notificationsSettings}
<d-icon icon="notification" slot="start" outline />
Expand Down
21 changes: 10 additions & 11 deletions src/components/settings-menu/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@

## Properties

| Property | Attribute | Description | Type | Default |
| --------------------------- | ----------------------------- | ----------- | -------- | ----------- |
| `accountSettings` | `account-settings` | | `string` | `undefined` |
| `developedBy` | `developed-by` | | `string` | `undefined` |
| `languages` | `languages` | | `string` | `undefined` |
| `logOut` | `log-out` | | `string` | `undefined` |
| `notificationsSettings` | `notifications-settings` | | `string` | `undefined` |
| `privacyPolicy` | `privacy-policy` | | `string` | `undefined` |
| `securityAndAuthentication` | `security-and-authentication` | | `string` | `undefined` |
| `support` | `support` | | `string` | `undefined` |
| `version` | `version` | | `string` | `undefined` |
| Property | Attribute | Description | Type | Default |
| ----------------------- | ------------------------ | ----------- | -------- | ----------- |
| `accountSettings` | `account-settings` | | `string` | `undefined` |
| `developedBy` | `developed-by` | | `string` | `undefined` |
| `languages` | `languages` | | `string` | `undefined` |
| `logOut` | `log-out` | | `string` | `undefined` |
| `notificationsSettings` | `notifications-settings` | | `string` | `undefined` |
| `privacyPolicy` | `privacy-policy` | | `string` | `undefined` |
| `support` | `support` | | `string` | `undefined` |
| `version` | `version` | | `string` | `undefined` |


## Events
Expand Down
2 changes: 0 additions & 2 deletions src/components/settings-menu/settings-menu.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const meta = {
title: 'Design System/NAVIGATION/SettingsMenu',
render: args => `<d-settings-menu
account-settings="${args.accountSettings}"
security-and-authentication="${args.securityAndAuthentication}"
notifications-settings="${args.notificationsSettings}"
languages="${args.languages}"
support="${args.support}"
Expand All @@ -22,7 +21,6 @@ type Story = StoryObj<Components.DSettingsMenu>;
export const Default: Story = {
args: {
accountSettings: 'Account settings',
securityAndAuthentication: 'Security and authentication',
notificationsSettings: 'Notifications settings',
languages: 'Languages',
support: 'Support',
Expand Down
3 changes: 0 additions & 3 deletions src/components/settings-menu/test/d-settings-menu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ describe('d-settings-menu', () => {
<d-button aria-hidden="" size="large">
<d-icon icon="profile" outline="" slot="start"></d-icon>
</d-button>
<d-button disabled="" href="/" size="large">
<d-icon icon="lock" outline="" slot="start"></d-icon>
</d-button>
<d-button aria-hidden="" size="large">
<d-icon icon="notification" outline="" slot="start"></d-icon>
</d-button>
Expand Down
6 changes: 3 additions & 3 deletions src/components/tab-button/d-tab-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export class DTabButton {
tab={this.tab}
href={`/${this.tab}`}
class={{
'min-h-12 min-w-12 block': true,
'h-12 min-w-12 block': true,
'text-on-alt': !this.active,
'text-on': this.active,
}}
>
<div class="relative w-fit">
{this.hasAlert && (
<div class="absolute right-1 top-1">
<d-info-led type="warning" class={{ 'border rounded-full': true }}></d-info-led>
<div class="absolute right-1 top-1 border-surface">
<d-info-led type="warning" class={{ 'border rounded-full border-surface': true }}></d-info-led>
</div>
)}
{svg()}
Expand Down
Loading

0 comments on commit 759214c

Please sign in to comment.