Skip to content

Commit

Permalink
Includes RTL support
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobmarin committed Jun 3, 2020
1 parent 4293b1f commit 1cc83a7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
36 changes: 32 additions & 4 deletions src/components/chat/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,29 @@ $avatar-size: 2.25rem;
.message {
box-sizing: border-box;
display: flex;
padding: 0 0 $padding $padding;
width: 100%;

[dir="ltr"] & {
padding: 0 0 $padding $padding;
}

[dir="rtl"] & {
padding: 0 $padding $padding 0;
}
}
}

.avatar-wrapper {
display: flex;
height: 100%;
margin: 0 $margin 0 0;

[dir="ltr"] & {
margin: 0 $margin 0 0;
}

[dir="rtl"] & {
margin: 0 0 0 $margin;
}

.inactive {
filter: opacity(50%);
Expand Down Expand Up @@ -112,14 +126,28 @@ $avatar-size: 2.25rem;
color: $gray-light;
display: flex;
font-size: x-small;
margin: 0 0 0 $margin;

[dir="ltr"] & {
margin: 0 0 0 $margin;
}

[dir="rtl"] & {
margin: 0 $margin 0 0;
}
}

.text {
box-sizing: border-box;
padding: 0 $padding-extra-small 0 0;
width: 100%;
word-break: break-word;

[dir="ltr"] & {
padding: 0 $padding-extra-small 0 0;
}

[dir="rtl"] & {
padding: 0 0 0 $padding-extra-small;
}
}

.inactive {
Expand Down
9 changes: 8 additions & 1 deletion src/components/thumbnails/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ $thumbnail-height: 90px;
overflow-y: auto;
padding: $padding-extra-small $padding-extra-small 0 $padding-extra-small;
position: fixed;
right: 0;
scroll-behavior: smooth;
top: $thumbnails-wrapper-top;
width: auto;
z-index: 1;

[dir="ltr"] & {
right: 0;
}

[dir="rtl"] & {
left: 0;
}

.active {
filter: opacity(50%);
}
Expand Down
12 changes: 12 additions & 0 deletions src/locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@ import messages from './messages';

const DEFAULT_LOCALE = 'en';

const RTL_LOCALES = ['ar'];

const setDirection = (locale) => {
if (RTL_LOCALES.includes(locale)) {
document.body.parentNode.setAttribute('dir', 'rtl');
} else {
document.body.parentNode.setAttribute('dir', 'ltr');
}
};

const getLocale = () => {
const locale = navigator.language.split(/[-_]/)[0];

setDirection(locale);

if (!messages[locale]) return DEFAULT_LOCALE;

return locale;
Expand Down
10 changes: 10 additions & 0 deletions src/locales/messages/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"error.wrapper.aria": "منطقة الخطأ",
"loader.wrapper.aria": "منطقة اللودر",
"player.wrapper.aria": "منطقة لاعب",
"player.chat.wrapper.aria": "منطقة الدردشة",
"player.presentation.wrapper.aria": "منطقة العرض",
"player.screenshare.wrapper.aria": "منطقة مشاركة الشاشة",
"player.thumbnails.wrapper.aria": "منطقة المصغرات",
"player.video.wrapper.aria": "منطقة الفيديو"
}
2 changes: 2 additions & 0 deletions src/locales/messages/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ar from './ar.json';
import de from './de.json';
import en from './en.json';
import es from './es.json';
Expand All @@ -8,6 +9,7 @@ import pt from './pt.json';
import ru from './ru.json';

export default {
ar,
de,
en,
es,
Expand Down

0 comments on commit 1cc83a7

Please sign in to comment.