Skip to content

Commit

Permalink
Support RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 10, 2025
1 parent 60fdbf1 commit a4e164d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function getStyle() {
::part(%EXTRA_CONTENTS_PART% container) {
bottom: 0;
direction: ltr;
left: 0;
inset-inline-start: 0;
line-height: 1;
overflow: hidden;
position: absolute;
Expand Down Expand Up @@ -82,7 +82,7 @@ function getStyle() {
}
::part(%EXTRA_CONTENTS_PART% handle following) {
margin-left: -1px;
margin-inline-start: -1px;
}
::part(%EXTRA_CONTENTS_PART% handle-image) {
Expand Down
22 changes: 22 additions & 0 deletions common/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,25 @@ export async function getTSTVersion() {
}
return '0.0';
}

const RTL_LANGUAGES = new Set([
'ar',
'he',
'fa',
'ur',
'ps',
'sd',
'ckb',
'prs',
'rhg',
]);

export function isRTL() {
const lang = (
navigator.language ||
navigator.userLanguage ||
//(new Intl.DateTimeFormat()).resolvedOptions().locale ||
''
).split('-')[0];
return RTL_LANGUAGES.has(lang);
}
4 changes: 3 additions & 1 deletion options/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
'use strict';

import {
configs
configs,
isRTL,
} from '/common/common.js';
import Options from '/extlib/Options.js';
import '/extlib/l10n.js';
Expand All @@ -29,6 +30,7 @@ configs.$addObserver(onConfigChanged);
*/

window.addEventListener('DOMContentLoaded', async () => {
document.documentElement.classList.toggle('rtl', isRTL());
await configs.$loaded;

//options.buildUIForAllConfigs(document.querySelector('#debug-configs'));
Expand Down
4 changes: 4 additions & 0 deletions options/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
opacity: 0;
}

:root.rtl {
direction: rtl;
}

body {
background: var(--bg-color);
color: var(--text-color);
Expand Down

0 comments on commit a4e164d

Please sign in to comment.