Skip to content

Commit 2b1905a

Browse files
committed
docs(ar): changing layout from ltr to rtl
1 parent 917c693 commit 2b1905a

11 files changed

Lines changed: 187 additions & 43 deletions

File tree

src/components/Markdown/Markdown.css

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
}
6868

6969
a[aria-hidden="true"] {
70-
@apply ml-2 text-[0.8em] h-[1em] opacity-0 invisible;
70+
@apply text-[0.8em] h-[1em] opacity-0 invisible;
71+
margin-inline-start: 0.5rem;
7172
transition: all 250ms;
7273
}
7374

@@ -105,7 +106,7 @@
105106

106107
ul,
107108
ol {
108-
@apply pl-[30px];
109+
padding-inline-start: 30px;
109110
list-style: revert;
110111

111112
&:first-child {
@@ -141,7 +142,8 @@
141142
}
142143

143144
aside {
144-
@apply border-l-4 border-solid border-l-aside-border py-[0.75em] px-[1em] text-gray-500;
145+
@apply border-solid py-[0.75em] px-[1em] text-gray-500;
146+
border-inline-start: 4px solid var(--color-aside-border);
145147
> :first-child {
146148
margin-top: 0;
147149
}
@@ -152,7 +154,7 @@
152154
&.warning,
153155
&.preview,
154156
&.todo {
155-
@apply border-l-[3px];
157+
border-inline-start-width: 3px;
156158

157159
.tip-content {
158160
@apply italic;
@@ -171,19 +173,23 @@
171173
}
172174

173175
&.tip {
174-
@apply bg-aside-tip-bg text-aside-tip-text border-l-aside-tip-border;
176+
@apply bg-aside-tip-bg text-aside-tip-text;
177+
border-inline-start-color: var(--color-aside-tip-border);
175178
}
176179

177180
&.warning {
178-
@apply bg-aside-warning-bg text-aside-warning-text border-l-aside-warning-border;
181+
@apply bg-aside-warning-bg text-aside-warning-text;
182+
border-inline-start-color: var(--color-aside-warning-border);
179183
}
180184

181185
&.preview {
182-
@apply bg-gray-100 text-aside-warning-text border-l-brand-blue;
186+
@apply bg-gray-100 text-aside-warning-text;
187+
border-inline-start-color: var(--color-brand-blue);
183188
}
184189

185190
&.todo {
186-
@apply bg-aside-todo-bg text-aside-todo-text border-l-aside-todo-border;
191+
@apply bg-aside-todo-bg text-aside-todo-text;
192+
border-inline-start-color: var(--color-aside-todo-border);
187193

188194
.tip-content::before {
189195
content: "[TODO]: ";
@@ -193,7 +199,8 @@
193199
}
194200

195201
blockquote {
196-
@apply border-l-4 border-solid border-l-aside-border py-[0.75em] px-[1em] text-gray-500 italic;
202+
@apply border-solid py-[0.75em] px-[1em] text-gray-500 italic;
203+
border-inline-start: 4px solid var(--color-aside-border);
197204

198205
> :first-child {
199206
margin-top: 0;
@@ -227,10 +234,12 @@
227234
}
228235

229236
th {
230-
@apply font-bold text-left py-1.5 px-3 bg-table-header-bg border-r border-solid border-r-table-border;
237+
@apply font-bold py-1.5 px-3 bg-table-header-bg border-solid;
238+
border-inline-end: 1px solid var(--color-table-border);
239+
text-align: start;
231240

232241
&:last-child {
233-
@apply border-r-0;
242+
border-inline-end: 0;
234243
}
235244
}
236245

@@ -252,7 +261,9 @@
252261
}
253262

254263
td {
255-
@apply py-1 px-3 border-r-0 grid grid-cols-2 text-left border-b border-solid border-b-gray-100;
264+
@apply py-1 px-3 grid grid-cols-2 border-b border-solid border-b-gray-100;
265+
border-inline-end: 0;
266+
text-align: start;
256267
&::before {
257268
content: attr(data-th);
258269
@apply font-bold;
@@ -267,9 +278,10 @@
267278
&::before {
268279
content: none;
269280
}
270-
@apply border-r border-r-table-border border-b-0;
281+
@apply border-b-0;
282+
border-inline-end: 1px solid var(--color-table-border);
271283
&:last-child {
272-
@apply border-r-0;
284+
border-inline-end: 0;
273285
}
274286
}
275287
}
@@ -391,7 +403,8 @@
391403
}
392404

393405
.dark .markdown blockquote {
394-
@apply border-l-dark-section-border text-dark-muted;
406+
@apply text-dark-muted;
407+
border-inline-start-color: var(--color-dark-section-border);
395408
}
396409

397410
.dark .markdown blockquote.tip {

src/components/Navigation/Navigation.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function Navigation({ links, pathname, hash = "", toggleSidebar }) {
141141
className="fill-current text-white"
142142
/>
143143
</button>
144-
<Link to="/" className="md:mr-auto">
144+
<Link to="/" className="navigation__brand md:mr-auto">
145145
<Logo />
146146
</Link>
147147
<nav
@@ -205,7 +205,7 @@ function Navigation({ links, pathname, hash = "", toggleSidebar }) {
205205
]}
206206
/>
207207
</nav>
208-
<div className="inline-flex items-center gap-x-[18px] ml-[18px]">
208+
<div className="navigation__controls inline-flex items-center gap-x-[18px] ml-[18px]">
209209
<HelloDarkness />
210210
{mounted && (
211211
<DocSearch

src/components/SidebarMobile/SidebarMobile.jsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import CloseIcon from "../../styles/icons/cross.svg";
55
import Link from "../Link/Link.jsx";
66

77
// TODO: Check to make sure all pages are shown and properly sorted
8+
function isRTL() {
9+
return document.documentElement.dir === "rtl";
10+
}
11+
812
export default function SidebarMobile({ isOpen, toggle, sections }) {
913
const containerRef = useRef(null);
1014
const openerRef = useRef(null);
@@ -52,22 +56,19 @@ export default function SidebarMobile({ isOpen, toggle, sections }) {
5256

5357
const handleTouchEnd = useCallback((event) => {
5458
const threshold = 20;
59+
const deltaX = lastTouchPosition.current.x - initialTouchPosition.current.x;
60+
const shouldClose = isRTL() ? deltaX > threshold : deltaX < -threshold;
61+
const shouldOpen = isRTL() ? deltaX < -threshold : deltaX > threshold;
5562

5663
// Free up all the inline styling
5764
containerRef.current.classList.remove("!duration-0");
5865
containerRef.current.style.transform = "";
5966

6067
// are we open?
61-
if (
62-
isOpenRef.current &&
63-
initialTouchPosition.current.x - lastTouchPosition.current.x > threshold
64-
) {
68+
if (isOpenRef.current && shouldClose) {
6569
// this is in top level nav callback
6670
toggleRef.current(false);
67-
} else if (
68-
!isOpenRef.current &&
69-
lastTouchPosition.current.x - initialTouchPosition.current.x > threshold
70-
) {
71+
} else if (!isOpenRef.current && shouldOpen) {
7172
toggleRef.current(true);
7273
event.preventDefault();
7374
event.stopPropagation();
@@ -80,28 +81,34 @@ export default function SidebarMobile({ isOpen, toggle, sections }) {
8081
const opener = openerRef.current;
8182

8283
const handleTouchMove = (event) => {
83-
const xDiff = initialTouchPosition.current.x - event.touches[0].pageX;
84+
const deltaX = event.touches[0].pageX - initialTouchPosition.current.x;
8485
const yDiff = initialTouchPosition.current.y - event.touches[0].pageY;
85-
const factor = Math.abs(yDiff / xDiff);
86+
const xDistance = Math.abs(deltaX);
87+
const closeDistance = isRTL() ? deltaX : -deltaX;
88+
const factor = xDistance === 0 ? Infinity : Math.abs(yDiff / xDistance);
8689

8790
// Factor makes sure horizontal and vertical scroll dont take place together
88-
if (xDiff > 0 && factor < 0.8) {
91+
if (closeDistance > 0 && factor < 0.8) {
8992
event.preventDefault();
90-
container.style.transform = `translateX(-${xDiff}px)`;
93+
container.style.transform = `translateX(${isRTL() ? closeDistance : -closeDistance}px)`;
9194
lastTouchPosition.current.x = event.touches[0].pageX;
9295
lastTouchPosition.current.y = event.touches[0].pageY;
9396
}
9497
};
9598

9699
const handleOpenerTouchMove = (event) => {
97-
const xDiff = event.touches[0].pageX - initialTouchPosition.current.x;
100+
const deltaX = event.touches[0].pageX - initialTouchPosition.current.x;
98101
const yDiff = initialTouchPosition.current.y - event.touches[0].pageY;
99-
const factor = Math.abs(yDiff / xDiff);
102+
const xDistance = Math.abs(deltaX);
103+
const openDistance = isRTL() ? -deltaX : deltaX;
104+
const factor = xDistance === 0 ? Infinity : Math.abs(yDiff / xDistance);
100105

101106
// Factor makes sure horizontal and vertical scroll dont take place together
102-
if (xDiff > 0 && xDiff < 295 && factor < 0.8) {
107+
if (openDistance > 0 && openDistance < 295 && factor < 0.8) {
103108
event.preventDefault();
104-
container.style.transform = `translateX(calc(-100% + ${xDiff}px))`;
109+
container.style.transform = isRTL()
110+
? `translateX(calc(100% - ${openDistance}px))`
111+
: `translateX(calc(-100% + ${openDistance}px))`;
105112
lastTouchPosition.current.x = event.touches[0].pageX;
106113
lastTouchPosition.current.y = event.touches[0].pageY;
107114
}

src/components/Site/Site.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import Content from "../../_content.json";
1616
import OgImage from "../../assets/icon-pwa-512x512.png";
1717
import Logo from "../../assets/logo-on-white-bg.svg";
18+
import { SITE_DIRECTION, SITE_LANGUAGE } from "../../config/site.js";
1819
import Favicon from "../../favicon.ico";
1920
import {
2021
extractPages,
@@ -216,9 +217,12 @@ function Site(props) {
216217
}, [location, navigate]);
217218

218219
return (
219-
<div className="flex flex-col min-h-screen bg-white dark:bg-gray-900">
220+
<div
221+
dir={SITE_DIRECTION}
222+
className="flex flex-col min-h-screen bg-white dark:bg-gray-900"
223+
>
220224
<Helmet>
221-
<html lang="en" />
225+
<html lang={SITE_LANGUAGE} dir={SITE_DIRECTION} />
222226
<meta charset="utf-8" />
223227
<meta name="theme-color" content="#2B3A42" />
224228
<meta name="viewport" content="width=device-width, initial-scale=1" />

src/components/SplashViz/SplashViz.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import HomeSVG from "./SplashVizSVG.mjs";
55

66
export default function SplashViz() {
77
return (
8-
<section className="relative h-[clamp(35rem,calc(100vh-80px),45rem)] bg-blue-800 grid grid-rows-[auto_1fr] overflow-hidden p-4 max-lg:h-[clamp(30rem,calc(100vh-80px),35rem)] max-[425px]:min-h-[clamp(40rem,calc(100vh-80px),50rem)] dark:bg-gray-900!">
8+
<section
9+
dir="ltr"
10+
className="relative h-[clamp(35rem,calc(100vh-80px),45rem)] bg-blue-800 grid grid-rows-[auto_1fr] overflow-hidden p-4 max-lg:h-[clamp(30rem,calc(100vh-80px),35rem)] max-[425px]:min-h-[clamp(40rem,calc(100vh-80px),50rem)] dark:bg-gray-900!"
11+
>
912
<h1 className="flex flex-wrap items-center justify-center text-white text-[33.178px] md:text-[39.813px] text-center font-[200] mt-[80px] md:mt-[90px] row-start-1 row-end-2">
1013
<span> bundle your</span>
1114
<TextRotator delay={5000} repeatDelay={5000} maxWidth={110}>
@@ -16,7 +19,7 @@ export default function SplashViz() {
1619
</TextRotator>
1720
</h1>
1821
<div
19-
className="absolute top-1/2 left-1/2 w-[60vw] min-w-[550px] max-w-[768px] mx-auto -translate-x-1/2 -translate-y-1/2 hidden md:block row-start-2 row-end-3 [&_img]:pt-4 [&_img]:w-full [&_img]:h-full"
22+
className="splash-viz__art absolute top-1/2 left-1/2 w-[60vw] min-w-[550px] max-w-[768px] mx-auto -translate-x-1/2 -translate-y-1/2 hidden md:block row-start-2 row-end-3 [&_img]:pt-4 [&_img]:w-full [&_img]:h-full"
2023
dangerouslySetInnerHTML={{ __html: HomeSVG.body }}
2124
/>
2225
<Cube

src/components/Sponsors/Sponsors.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Link from "../Link/Link.jsx";
88
// Tailwind CSS is used for styling
99

1010
const Sponsors = () => (
11-
<div className="absolute h-full w-[250px] ml-[-250px] mr-2.5">
11+
<div className="sponsors-panel absolute h-full w-[250px] ml-[-250px] mr-2.5">
1212
<div className="sticky hidden xl:flex flex-wrap justify-center items-start border-r-2 border-gray-200 my-6 px-6 pb-12 overflow-hidden bg-transparent transition-colors duration-200 top-24">
1313
{/* AG Grid */}
1414
<div className="bg-white dark:bg-black shadow-lg rounded-lg m-2 transition-transform duration-200 hover:bg-gray-100 dark:hover:bg-gray-700 hover:scale-105 dark:shadow-[0_0_40px_rgba(255,255,255,0.18)]">

src/config/site.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const SITE_LANGUAGE = "ar";
2+
export const SITE_DIRECTION = "rtl";

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
<html lang="en">
2+
<html lang="ar" dir="rtl">
33
<head> </head>
44
<body>
55
<div id="root"></div>

src/server.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { StaticRouter } from "react-router";
77
import assets from "../dist/prod-assets-manifest.json";
88
import PrintScript from "./components/Print/PrintScript.jsx";
99
import Site from "./components/Site/Site.jsx";
10+
import { SITE_DIRECTION, SITE_LANGUAGE } from "./config/site.js";
1011

1112
function isPrintPage(url) {
1213
return url.includes("/printable");
@@ -42,5 +43,5 @@ export default (locals) => {
4243
const hoistedTags = headTagsMatch ? headTagsMatch[1] : "";
4344
const bodyHtml = renderedHtml.slice(hoistedTags.length);
4445

45-
return `<!DOCTYPE html><html><head>${css}${hoistedTags}</head><body><div id="root">${bodyHtml}</div>${scripts}</body></html>`;
46+
return `<!DOCTYPE html><html lang="${SITE_LANGUAGE}" dir="${SITE_DIRECTION}"><head>${css}${hoistedTags}</head><body><div id="root">${bodyHtml}</div>${scripts}</body></html>`;
4647
};

0 commit comments

Comments
 (0)