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

quick pr to allow for easier manual rtl testing #726

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-ads-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@microsoft/atlas-site': minor
---

Add button for easier manual right to left testing.
3 changes: 1 addition & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Task: task-[work-item-number]

Link: [preview](http://localhost:1111/)

[Explain the context of this pull request here]
Expand All @@ -20,3 +18,4 @@ Link: [preview](http://localhost:1111/)
- [ ] Did you submit a changeset? Changesets are required for all code changes.
- [ ] Does your pull request implement complex UI logic (js/ts)? Consider adding an integration test to test your user flow.
- [ ] Does your pull request add a new page to the documentation site? Add your new page for automated accessibility testing in /integration/tests/accessibility.
- [ ] Does your pull request change any transforms? Did you test they work on right to left?
1 change: 1 addition & 0 deletions site/src/scaffold/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import './styles/code-block.scss';
@import './styles/burger.scss';
@import './styles/layout-buttons.scss';
@import './styles/direction-change.scss';

// hack to mark markdown logo on '/' look a tad different, excludes header logo
main img[src^='/atlas-light.'] {
Expand Down
2 changes: 2 additions & 0 deletions site/src/scaffold/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { handleFocusableIfScrollable } from './scripts/focusable-if-scrollable';
import { initFullScreenToggle } from './scripts/full-screen-toggle';
import { initLayoutPageControls } from './scripts/layout-page';
import { handleFullScreenNavButton } from './scripts/mobile-navigation';
import { initReadingDirectionButtons } from './scripts/direction-buttons';

initTheme();
initDismiss();
Expand All @@ -25,3 +26,4 @@ handleFocusableIfScrollable();
handleFullScreenNavButton();
initLayoutPageControls();
initLayout();
initReadingDirectionButtons();
17 changes: 17 additions & 0 deletions site/src/scaffold/scripts/direction-buttons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function initReadingDirectionButtons() {
window.addEventListener('click', (e: MouseEvent) => {
const target =
e.target instanceof Element &&
(e.target.closest('[data-direction-change]') as HTMLButtonElement);
if (!target) {
return;
}

const direction = target.dataset.directionChange;
if (direction !== 'ltr' && direction !== 'rtl') {
throw new Error('Misconfigured direction button');
}

document.documentElement.dir = direction;
});
}
21 changes: 19 additions & 2 deletions site/src/scaffold/standard.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" class="layout layout-holy-grail theme-light default-focus">
<html lang="en" class="layout layout-holy-grail theme-light default-focus" dir="ltr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down Expand Up @@ -104,7 +104,7 @@ <h1 class="font-size-h1 font-weight-semibold">Missing h1</h1>
<main id="main" class="layout-body-main">
{{{breadcrumbs}}}

<div id="actions-holder" class="layout-padding">
<div id="actions-holder" class="layout-padding padding-right-none">
<button
aria-label="Change theme"
class="button button-clear"
Expand All @@ -115,6 +115,22 @@ <h1 class="font-size-h1 font-weight-semibold">Missing h1</h1>
</svg>
</span>
</button>
<button
aria-label="Apply right to left reading direction"
class="button button-clear display-none display-block-tablet display-none-rtl"
data-direction-change="rtl">
<span class="icon" aria-hidden="true">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path class="fill-current-color" d="M16.25 3a1 1 0 0 0-.923.615l-3.75 9a1 1 0 1 0 1.846.77L14.416 11h3.667l.994 2.385a1 1 0 0 0 1.846-.77l-3.75-9A1 1 0 0 0 16.25 3Zm0 3.6 1 2.4h-2l1-2.4ZM6.707 5.293a1 1 0 0 0-1.414 0L3.366 7.227a.998.998 0 0 0-.366.77v.006c0 .31.143.588.366.77l1.927 1.934a1 1 0 0 0 1.414-1.414L6.414 9H11a1 1 0 0 0 0-2H6.414l.293-.293a1 1 0 0 0 0-1.414Zm-1.414 9a1 1 0 0 1 1.414 1.414L6.414 16H20a1 1 0 0 1 0 2H6.414l.293.293a1 1 0 1 1-1.414 1.414l-2-2a1 1 0 0 1 0-1.414l2-2Z" /></svg>
</span>
</button>
<button
aria-label="Apply left to left reading direction"
class="button button-clear display-none display-block-tablet display-none-ltr"
data-direction-change="ltr">
<span class="icon display-none-ltr" aria-hidden="true">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path class="fill-current-color" d="M7.75 3a1 1 0 0 1 .923.615l3.75 9a1 1 0 1 1-1.846.77L9.584 11H5.917l-.994 2.385a1 1 0 0 1-1.846-.77l3.75-9A1 1 0 0 1 7.75 3Zm0 3.6-1 2.4h2l-1-2.4Zm9.543-1.307a1 1 0 0 1 1.414 0l1.927 1.934c.223.182.365.46.366.77v.006c0 .31-.143.588-.366.77l-1.927 1.934a1 1 0 0 1-1.414-1.414L17.586 9H13a1 1 0 0 1 0-2h4.586l-.293-.293a1 1 0 0 1 0-1.414Zm1.414 9a1 1 0 0 0-1.414 1.414l.293.293H4a1 1 0 1 0 0 2h13.586l-.293.293a1 1 0 0 0 1.414 1.414l2-2a1 1 0 0 0 0-1.414l-2-2Z" /></svg>
</span>
</button>
<a
aria-label="Edit this page on GitHub"
class="button button-clear"
Expand All @@ -132,6 +148,7 @@ <h1 class="font-size-h1 font-weight-semibold">Missing h1</h1>
<svg class="fill-current-color" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2048 2048"><path d="M1664 1664v-384h128v512h-512v-128h384zM1280 256h512v512h-128V384h-384V256zM256 768V256h512v128H384v384H256zm128 512v384h384v128H256v-512h128z"/></svg>
</span>
</button>

</div>

<div id="article">
Expand Down
7 changes: 7 additions & 0 deletions site/src/scaffold/styles/direction-change.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.display-none-rtl:dir(rtl) {
display: none !important;
}

.display-none-ltr:dir(ltr) {
display: none !important;
}
18 changes: 17 additions & 1 deletion site/src/scaffold/token.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h1 class="font-size-h1 font-weight-semibold">Missing h1</h1>
<main id="main" class="layout-body-main">
{{{breadcrumbs}}}

<div id="actions-holder" class="layout-padding">
<div id="actions-holder" class="layout-padding padding-right-none">
<button
aria-label="Change theme"
class="button button-clear"
Expand All @@ -114,6 +114,22 @@ <h1 class="font-size-h1 font-weight-semibold">Missing h1</h1>
</svg>
</span>
</button>
<button
aria-label="Apply right to left reading direction"
class="button button-clear display-none display-block-tablet display-none-rtl"
data-direction-change="rtl">
<span class="icon" aria-hidden="true">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path class="fill-current-color" d="M16.25 3a1 1 0 0 0-.923.615l-3.75 9a1 1 0 1 0 1.846.77L14.416 11h3.667l.994 2.385a1 1 0 0 0 1.846-.77l-3.75-9A1 1 0 0 0 16.25 3Zm0 3.6 1 2.4h-2l1-2.4ZM6.707 5.293a1 1 0 0 0-1.414 0L3.366 7.227a.998.998 0 0 0-.366.77v.006c0 .31.143.588.366.77l1.927 1.934a1 1 0 0 0 1.414-1.414L6.414 9H11a1 1 0 0 0 0-2H6.414l.293-.293a1 1 0 0 0 0-1.414Zm-1.414 9a1 1 0 0 1 1.414 1.414L6.414 16H20a1 1 0 0 1 0 2H6.414l.293.293a1 1 0 1 1-1.414 1.414l-2-2a1 1 0 0 1 0-1.414l2-2Z" /></svg>
</span>
</button>
<button
aria-label="Apply left to left reading direction"
class="button button-clear display-none display-block-tablet display-none-ltr"
data-direction-change="ltr">
<span class="icon display-none-ltr" aria-hidden="true">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path class="fill-current-color" d="M7.75 3a1 1 0 0 1 .923.615l3.75 9a1 1 0 1 1-1.846.77L9.584 11H5.917l-.994 2.385a1 1 0 0 1-1.846-.77l3.75-9A1 1 0 0 1 7.75 3Zm0 3.6-1 2.4h2l-1-2.4Zm9.543-1.307a1 1 0 0 1 1.414 0l1.927 1.934c.223.182.365.46.366.77v.006c0 .31-.143.588-.366.77l-1.927 1.934a1 1 0 0 1-1.414-1.414L17.586 9H13a1 1 0 0 1 0-2h4.586l-.293-.293a1 1 0 0 1 0-1.414Zm1.414 9a1 1 0 0 0-1.414 1.414l.293.293H4a1 1 0 1 0 0 2h13.586l-.293.293a1 1 0 0 0 1.414 1.414l2-2a1 1 0 0 0 0-1.414l-2-2Z" /></svg>
</span>
</button>
<a
aria-label="Edit this page on GitHub"
class="button button-clear"
Expand Down
Loading