Skip to content

[UI] Add RTL support#2658

Closed
Frenzie wants to merge 19 commits intoFreshRSS:devfrom
Frenzie:ui-rtl
Closed

[UI] Add RTL support#2658
Frenzie wants to merge 19 commits intoFreshRSS:devfrom
Frenzie:ui-rtl

Conversation

@Frenzie
Copy link
Copy Markdown
Member

@Frenzie Frenzie commented Nov 12, 2019

Fixes #673.


Now obviously this only fixes one thing when there are at least a dozen similar issues, but this principle is my proposed solution to all of them.

Edit: to clarify, basically anything that says something like position: absolute or fixed is likely affected. So are border-left/right. The good news is that anything that isn't absolutely positioned should largely Just Work™.


This change is Reviewable

@Frenzie Frenzie changed the base branch from master to dev November 12, 2019 11:38
Because holy @#$@# is that annoying. :-P
@Frenzie Frenzie added this to the 1.16.0 milestone Nov 12, 2019
@Frenzie Frenzie added the UI 🎨 User Interfaces label Nov 12, 2019
@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Nov 12, 2019

@mat-mo Does the previous/next article navigation in the bottom right look as expected? (I imagine it doesn't. ;-) )

Screenshot_2019-11-12 Your RSS feeds · FreshRSS

@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Nov 12, 2019

Besides the act of adding the relevant attributes to the HTML, this PR should pretty much be in a decent enough shape to be merged for testing in the dev branch. It resolves most (hopefully all of course ;-) ) issues.

LTR

Screenshot_2019-11-12 (1) Your RSS feeds · FreshRSS

RTL

Screenshot_2019-11-12 (1) Your RSS feeds · FreshRSS
Screenshot_2019-11-12 (1) ההזנות שלך · FreshRSS hebrew

border-radius: 3px 0 0 3px;
}

html:not(.rtl) .stick .btn + .btn,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we avoid the :not(.rtl) thanks to the .rtl below, overriding the properties?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite elegantly. Options include border-left-width: 0; instead of none, so you can easily restore it to some px value (probably the best alternative) and possibly also some invalid value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative looks like this:

diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.css
index 86210940..5f90fb1b 100644
--- a/p/themes/Origine/origine.css
+++ b/p/themes/Origine/origine.css
@@ -150,16 +150,16 @@ html.rtl .stick input:last-child {
        border-radius: 3px 0 0 3px;
 }
 
-html:not(.rtl) .stick .btn + .btn,
-html:not(.rtl) .stick .btn + input,
-html:not(.rtl) .stick .btn + .dropdown > .btn,
-html:not(.rtl) .stick input + .btn,
-html:not(.rtl) .stick input + input,
-html:not(.rtl) .stick input + .dropdown > .btn,
-html:not(.rtl) .stick .dropdown + .btn,
-html:not(.rtl) .stick .dropdown + input,
-html:not(.rtl) .stick .dropdown + .dropdown > .btn {
-       border-left: none;
+.stick .btn + .btn,
+.stick .btn + input,
+.stick .btn + .dropdown > .btn,
+.stick input + .btn,
+.stick input + input,
+.stick input + .dropdown > .btn,
+.stick .dropdown + .btn,
+.stick .dropdown + input,
+.stick .dropdown + .dropdown > .btn {
+       border-left-width: 0;
 }
 
 html.rtl .stick .btn + .btn,
@@ -171,7 +171,8 @@ html.rtl .stick input + .dropdown > .btn,
 html.rtl .stick .dropdown + .btn,
 html.rtl .stick .dropdown + input,
 html.rtl .stick .dropdown + .dropdown > .btn {
-       border-right: none;
+       border-left-width: 1px;
+       border-right-width: 0;
 }
 
 .stick input + .btn {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks a bit lighter, maybe? No strong preference

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with the current version because I figured it's slightly easier to parse (if not ltr then border-left:none, elseif ltr then border-right: none) but I'm fine with any approach. A similar option is to add html.ltr as well.

@Alkarex Alkarex marked this pull request as ready for review November 12, 2019 16:17
@Alkarex
Copy link
Copy Markdown
Member

Alkarex commented Nov 12, 2019

So we lack adding class="rtl", right? Should this be automatic based on the language selected?

@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Nov 12, 2019

Indeed. For testing I used this simple change, that should also be put in install.php.

diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 498cc447..d08261d7 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -1,6 +1,6 @@
 <?php FreshRSS::preLayout(); ?>
 <!DOCTYPE html>
-<html lang="<?= FreshRSS_Context::$user_conf->language ?>" xml:lang="<?= FreshRSS_Context::$user_conf->language ?>">
+<html lang="<?= FreshRSS_Context::$user_conf->language ?>" xml:lang="<?= FreshRSS_Context::$user_conf->language ?>" dir="rtl" class="rtl">
        <head>
                <meta charset="UTF-8" />
                <meta name="viewport" content="initial-scale=1.0" />

I was thinking it could perhaps be put in the app/i18n/<lang> folder as some kind of metadata, or alternatively it could simply be hardcoded in an array somewhere.

@Alkarex
Copy link
Copy Markdown
Member

Alkarex commented Nov 12, 2019

I suggest we add a line

'dir' => 'rtl',

in https://github.com/FreshRSS/FreshRSS/blob/dev/app/i18n/en/gen.php
were /en/ is to be replaced by RTL languages

@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Nov 12, 2019

@Alkarex Something like this? 0c06acb

Co-Authored-By: Alexandre Alapetite <[email protected]>
@Alkarex
Copy link
Copy Markdown
Member

Alkarex commented Nov 12, 2019

Yes @Frenzie , looks good 👍

@Alkarex Alkarex mentioned this pull request Nov 12, 2019
@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Nov 12, 2019

@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Nov 13, 2019

I'm thinking this CSSJanus approach may be better than this PR, mainly because it should require (almost) no effort to maintain, not to mention manually going through all the themes would add up even if it can be slowly spaced out.

Using the PHP port it could potentially even be integrated into the program itself.

The basic idea is a bit different though. Instead of localized overrides in the same CSS file, you'd generate a filename.ltr.css (or whatever you want to call it), and you'd load that one instead of the normal CSS file. There's an article about the principle illustrated with SASS here.

When minor touchups are required, the "current" approach (html.rtl etc) could still be used to perform specific overrides.

There are actually also newer CSS attributes that may mostly avoid the issue, but they're not supported by Edge yet.

https://drafts.csswg.org/css-writing-modes-4/#flow-relative
https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block-start

@marienfressinaud
Copy link
Copy Markdown
Member

Can we close this PR in favor of #2678?

@Frenzie
Copy link
Copy Markdown
Member Author

Frenzie commented Dec 7, 2019

I believe the other approach is much better in principle, yes.

@Frenzie Frenzie closed this Dec 7, 2019
@Frenzie Frenzie deleted the ui-rtl branch December 7, 2019 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

UI 🎨 User Interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTL support

3 participants