From 221f4a05fdb698e2504e4f92e76b2729f5f4edbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Andrietti?= Date: Wed, 22 Jan 2025 10:31:52 +0100 Subject: [PATCH 1/2] fix rtl functions with all language codes --- src/js/utils/isRTL.js | 20 +++++++++++++++----- src/scss/02-tools/_m-rtl.scss | 32 ++++++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/js/utils/isRTL.js b/src/js/utils/isRTL.js index e76edb9e..0fb72ec4 100644 --- a/src/js/utils/isRTL.js +++ b/src/js/utils/isRTL.js @@ -1,7 +1,17 @@ export default function isRTL() { - return ( - document.documentElement.dir === 'rtl' || - document.documentElement.lang === 'ar' || - document.documentElement.lang === 'iw' - ) + const rtlLanguages = [ + 'ar', // Arabic + 'fa', // Persian (Farsi) + 'he', // Hebrew (modern code) + 'iw', // Hebrew (legacy code) + 'ur', // Urdu + 'ps', // Pashto + 'sd', // Sindhi + 'ug', // Uyghur + 'dv', // Divehi (Maldivian) + 'ku', // Kurdish (Sorani) + 'yi', // Yiddish + ] + + return document.documentElement.dir === 'rtl' || rtlLanguages.includes(document.documentElement.lang) } diff --git a/src/scss/02-tools/_m-rtl.scss b/src/scss/02-tools/_m-rtl.scss index 63820995..c7b4ec4b 100644 --- a/src/scss/02-tools/_m-rtl.scss +++ b/src/scss/02-tools/_m-rtl.scss @@ -1,5 +1,5 @@ /** - * Support for rtl text, explicit support for Arabic and Hebrew + * Support for rtl text, explicit support for all RTL languages * * @author Cédric Andrietti * @@ -13,17 +13,33 @@ * */ +$rtl-languages: ( + "ar", // Arabic + "fa", // Persian (Farsi) + "he", // Hebrew (modern code) + "iw", // Hebrew (legacy code) + "ur", // Urdu + "ps", // Pashto + "sd", // Sindhi + "ug", // Uyghur + "dv", // Divehi (Maldivian) + "ku", // Kurdish (Sorani) + "yi" // Yiddish +); + @mixin rtl { - *[dir="rtl"] &, - :root:lang(ar) &, - :root:lang(iw) & { - @content; + @each $lang in $rtl-languages { + *[dir="rtl"] &, + :root:lang(#{$lang}) & { + @content; + } } } @mixin set-rtl-direction { - &:lang(ar), - &:lang(iw) { - direction: rtl; + @each $lang in $rtl-languages { + &:lang(#{$lang}) { + direction: rtl; + } } } From f4e836cd527c98f3ee696cc895d98355fc1d48a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Andrietti?= Date: Wed, 22 Jan 2025 11:25:04 +0100 Subject: [PATCH 2/2] fix rtl text align --- src/scss/08-template-parts/_header.scss | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/scss/08-template-parts/_header.scss b/src/scss/08-template-parts/_header.scss index e0da6c64..26c3da95 100644 --- a/src/scss/08-template-parts/_header.scss +++ b/src/scss/08-template-parts/_header.scss @@ -260,11 +260,7 @@ width: column(9); > div { - text-align: right; - - @include rtl { - text-align: left; - } + text-align: end; } } @@ -277,11 +273,7 @@ > li { display: inline; - text-align: left; - - @include rtl { - text-align: right; - } + text-align: start; + li { margin-inline-start: 28px;