Skip to content

Commit fb69c74

Browse files
authored
Fixing "Toggle Progress" For RTL Support & correct display & Fixing Translate (#363)
* Fixing "Toggle Progress" For RTL Support * Fix correct display of regex in RTL * Fixing Persian Translate For lesson 49
1 parent 89ac905 commit fb69c74

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

src/components/CheatsheetCollapse.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const CheatsheetCollapse = ({ title, data }: CheatsheetCollapseProps) => {
3636
aria-controls={`Collapse-${data.title}`}
3737
>
3838
<div className="w-14 inline-block">
39-
<span className="p-1 text-xs font-mono text-neutral-100 bg-[#333] rounded-md">
39+
<span className="p-1 text-xs font-mono text-neutral-100 bg-[#333] rounded-md" dir='ltr'>
4040
{data.code}
4141
</span>
4242
</div>

src/components/LearnProgress.tsx

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useIntl } from 'react-intl';
44
import Icon from './Icon';
55
import { InteractiveAreaContext } from 'src/context/InteractiveAreaContext';
66
import HighlightedText from './HighlightedText';
7+
import { useLanguageDirection } from "src/utils/useLanguageDirection";
78

89
const LearnProgress = () => {
910
const [open, setOpen] = useState(false);
@@ -27,11 +28,22 @@ const LearnProgress = () => {
2728

2829
const toggleProgress = () => setOpen(!open);
2930

31+
const direction = useLanguageDirection();
32+
33+
// list lesson (ToggleProgress For RTL/LTR)
34+
const listOpen = direction === 'rtl' ? 'left-0' : 'right-0';
35+
const listClose = direction === 'rtl' ? '-left-[244px]' : '-right-[244px]';
36+
const listOpenInner = direction === 'rtl' ? '-left-10' : '-right-10';
37+
const listCloseInner = direction === 'rtl' ? 'left-[204px]' : 'right-[204px]';
38+
const listIconName = direction === 'rtl' ? 'arrow-right' : 'arrow-left';
39+
const listStepDirection = direction === 'rtl' ? 'left-[7px]' : 'right-[7px]';
40+
41+
3042
return (
3143
<div
3244
className={clsx(
3345
'hidden lg:block text-xs top-[50%] -translate-y-[50%] absolute z-10 transition-all select-none',
34-
open ? 'right-0 ' : '-right-[244px]',
46+
open ? listOpen : listClose,
3547
)}
3648
>
3749
<div
@@ -41,15 +53,17 @@ const LearnProgress = () => {
4153
<div
4254
onClick={toggleProgress}
4355
className={clsx(
44-
'w-10 h-10 cursor-pointer rounded-full flex fixed top-[50%] -translate-x-[50%] -translate-y-[50%] transition-all duration-50',
45-
open ? '-right-10 bg-neutral-600/40' : 'right-[204px] bg-emerald-600',
56+
direction === 'rtl' ? 'translate-x-[50%]' : '-translate-x-[50%]',
57+
`w-10 h-10 cursor-pointer rounded-full flex fixed top-[50%] transition-all duration-50`,
58+
open ? `${listOpenInner} bg-neutral-600/40` : `${listCloseInner} bg-emerald-600`,
4659
)}
4760
>
4861
<Icon
49-
icon="arrow-left"
62+
icon={listIconName}
5063
size={15}
5164
className={clsx(
52-
'mr-auto my-auto ml-1 text-neutral-100',
65+
direction === 'rtl' ? 'ml-auto mr-1' : 'mr-auto ml-1',
66+
`my-auto text-neutral-100`,
5367
open ? 'rotate-180' : 'rotate-0',
5468
)}
5569
/>
@@ -66,17 +80,26 @@ const LearnProgress = () => {
6680
},
6781
'step-item relative truncate max-w-[80%] flex flex-row-reverse items-center',
6882
index !== lessonData.length - 1 &&
69-
"pb-6 after:content-[''] after:block after:w-[2px] after:h-8 after:bg-neutral-700 after:rounded-md after:right-[7px] after:top-8 after:absolute",
83+
`pb-6 after:content-[''] after:block after:w-[2px] after:h-8 after:bg-neutral-700 after:rounded-md after:${listStepDirection} after:top-8 after:absolute`,
7084
)}
7185
>
7286
{step === index && (
73-
<Icon icon="play" size={16} className="text-green-400 ml-2 flex-shrink-0" />
87+
<Icon icon="play" size={16} className={clsx(
88+
direction === 'ltr' ? 'ml-2' : 'mr-2',
89+
"text-green-400 flex-shrink-0"
90+
)} />
7491
)}
7592
{lastStep >= index && step !== index && (
76-
<Icon icon="check" size={16} className="text-green-400 ml-2 flex-shrink-0" />
93+
<Icon icon="check" size={16} className={clsx(
94+
direction === 'ltr' ? 'ml-2' : 'mr-2',
95+
"text-green-400 flex-shrink-0"
96+
)} />
7797
)}
7898
{lastStep < index && (
79-
<Icon icon="lock-closed" size={16} className="text-neutral-500 ml-2 flex-shrink-0" />
99+
<Icon icon="lock-closed" size={16} className={clsx(
100+
direction === 'ltr' ? 'ml-2' : 'mr-2',
101+
"text-neutral-500 flex-shrink-0"
102+
)} />
80103
)}
81104

82105
<HighlightedText

src/components/Step.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const Step = () => {
4343
text={formatMessage({ id: data.title })}
4444
attrs={{
4545
className: 'px-2 my-1 bg-neutral-700 rounded-md mx-1 whitespace-nowrap',
46+
dir: 'ltr'
4647
}}
4748
/>
4849
<HighlightedText
@@ -51,6 +52,7 @@ const Step = () => {
5152
text={formatMessage({ id: data.description })}
5253
attrs={{
5354
className: 'p-1 text-xs whitespace-nowrap rounded-md bg-neutral-700 tracking-widest',
55+
dir: 'ltr'
5456
}}
5557
/>
5658
</div>

src/localization/fa/learn.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@
137137
"steps.positiveLookbehind.title": "بررسی رو به عقب مثبت: `(?<=)`",
138138
"steps.positiveLookbehind.description": "برای مثال می خواهیم مقدار قیمت را در متن انتخاب کنیم. بنابراین، برای انتخاب فقط مقادیر عددی که بعد از علامت $ هستند، باید بررسی رو به عقب مثبت (Positive Lookbehind) `(?<=)` را قبل از عبارت خود بنویسیم. بعد از علامت `=` داخل پرانتز، `\\$` را اضافه کنید.",
139139

140-
"steps.negativeLookbehind.title": "بررسی رو به عقب منفی: `(؟<!)`",
141-
"steps.negativeLookbehind.description": "به عنوان مثال، می خواهیم در متن اعدادی غیر از مقدار قیمت انتخاب کنیم. بنابراین، برای انتخاب فقط مقادیر عددی که بعد از `$` نیستند، باید قبل از عبارت، بررسی رو به عقب منفی (Negative Lookbehind) `(?<!)` را بنویسیم. بعد از علامت `!` داخل پرانتز `\\$` را اضافه کنید.",
140+
"steps.negativeLookbehind.title": "بررسی رو به عقب منفی: `(?&lt;!)`",
141+
"steps.negativeLookbehind.description": "به عنوان مثال، می خواهیم در متن اعدادی غیر از مقدار قیمت انتخاب کنیم. بنابراین، برای انتخاب فقط مقادیر عددی که بعد از `$` نیستند، باید قبل از عبارت، بررسی رو به عقب منفی (Negative Lookbehind) `(?&lt;!)` را بنویسیم. بعد از علامت `!` داخل پرانتز `\\$` را اضافه کنید.",
142142

143143
"steps.flags.title": "پرچم ها",
144144
"steps.flags.description": "پرچم ها خروجی عبارت را تغییر می دهند. به همین دلیل است که پرجم ها را اصلاح کننده (`modifiers`) نیز مینامند. پرچمها تعیین میکنند که آیا عبارت تایپ شده متن را به عنوان خطوط جداگانه در نظر میگیرد، به حروف کوچک و بزرگ حساس است و یا همه موارد تطابق را پیدا میکند یا خیر. برای یادگیری پرچم ها به مرحله بعدی بروید.",

0 commit comments

Comments
 (0)