Skip to content

Commit

Permalink
fix: review deque accessibility testing of docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Jun 19, 2020
1 parent e861a5d commit 31f43aa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions documentation/src/components/code-example.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ governing permissions and limitations under the License.
}

.demo-example {
max-width: 100%;
overflow: auto;
flex: 1;
padding: var(--spectrum-global-dimension-size-400)
var(--spectrum-global-dimension-size-500);
Expand Down
44 changes: 44 additions & 0 deletions documentation/src/components/code-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CSSResultArray,
property,
css,
query,
} from 'lit-element';
import * as Prism from 'prismjs';
import { toHtmlTemplateString } from '../utils/templates.js';
Expand Down Expand Up @@ -65,13 +66,22 @@ export class LightCode extends Code {
.token.punctuation {
color: #737373;
}
.language-css .token.function {
color: inherit;
}
`,
];
}
}

@customElement('code-example')
export class CodeExample extends LitElement {
@query('#markup')
private markup?: HTMLDivElement;

@query('.demo-example')
private demo?: HTMLDivElement;

@property()
protected codeTheme: 'dark' | 'light' = 'light';

Expand Down Expand Up @@ -141,4 +151,38 @@ export class CodeExample extends LitElement {
</div>
`;
}

private shouldManageTabOrderForScrolling = (): void => {
[this.markup, this.demo].map((el) => {
if (!el) return;
const { offsetWidth, scrollWidth } = el;
if (offsetWidth < scrollWidth) {
el.tabIndex = 0;
} else {
el.removeAttribute('tabindex');
}
});
};

protected updated(): void {
requestAnimationFrame(() => {
this.shouldManageTabOrderForScrolling();
});
}

public connectedCallback(): void {
super.connectedCallback();
window.addEventListener(
'resize',
this.shouldManageTabOrderForScrolling
);
}

public disconnectedCallback(): void {
window.removeEventListener(
'resize',
this.shouldManageTabOrderForScrolling
);
super.disconnectedCallback();
}
}
2 changes: 1 addition & 1 deletion packages/link/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ When a link needs to be placed on top of a colored background or a visual, use t

```html
<div
style="background-color: rgb(255, 160, 175); padding: 15px 20px; display: inline-block;"
style="background-color: #0f797d; padding: 15px 20px; display: inline-block;"
>
<p style="color: rgb(240, 240, 240);">
This
Expand Down

0 comments on commit 31f43aa

Please sign in to comment.