feat: Updates to Collaboration and RTL UX (#2994)

This commit is contained in:
Jed Fox 2021-02-08 15:43:51 -05:00 committed by GitHub
parent 4085071347
commit 73cba59d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 28 deletions

View File

@ -35,7 +35,6 @@ Make sure the title starts with a semantic prefix:
- **feat**: A new feature
- **fix**: A bug fix
- **improvement**: An improvement to a current feature
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- **refactor**: A code change that neither fixes a bug nor adds a feature

View File

@ -4,7 +4,8 @@
.CollabButton.is-collaborating {
background-color: var(--button-special-active-background-color);
.ToolIcon__icon svg {
.ToolIcon__icon svg,
.ToolIcon__label {
color: var(--icon-green-fill-color);
}
}

View File

@ -25,8 +25,8 @@ const CollabButton = ({
onClick={onClick}
icon={users}
type="button"
title={t("buttons.roomDialog")}
aria-label={t("buttons.roomDialog")}
title={t("labels.liveCollaboration")}
aria-label={t("labels.liveCollaboration")}
showAriaLabel={useIsMobile()}
>
{collaboratorCount > 0 && (

View File

@ -1,12 +1,7 @@
import React from "react";
import { LoadingMessage } from "./LoadingMessage";
import {
defaultLang,
Language,
languages,
setLanguageFirstTime,
} from "../i18n";
import { defaultLang, Language, languages, setLanguage } from "../i18n";
interface Props {
langCode: Language["code"];
@ -23,7 +18,7 @@ export class InitializeApp extends React.Component<Props, State> {
const currentLang =
languages.find((lang) => lang.code === this.props.langCode) ||
defaultLang;
await setLanguageFirstTime(currentLang);
await setLanguage(currentLang);
this.setState({
isLoading: false,
});

View File

@ -19,9 +19,9 @@
}
a {
margin-left: auto;
margin-inline-start: auto;
// 17px for scrollbar (needed for overlay scrollbars on Big Sur?) + 1px extra
padding-right: 18px;
padding-inline-end: 18px;
white-space: nowrap;
}
}

View File

@ -32,6 +32,16 @@
display: flex;
align-items: center;
justify-content: center;
@media #{$is-mobile-query} {
flex-direction: column;
align-items: stretch;
}
}
@media #{$is-mobile-query} {
.RoomDialog-usernameLabel {
font-weight: bold;
}
}
.RoomDialog-username {
@ -41,6 +51,10 @@
min-width: 0;
flex: 1 1 auto;
margin-inline-start: 1em;
@media #{$is-mobile-query} {
margin-top: 0.5em;
margin-inline-start: 0;
}
height: 2.5rem;
font-size: 1em;
line-height: 1.5;

View File

@ -119,7 +119,11 @@ const RoomDialog = ({
);
};
return (
<Dialog small onCloseRequest={handleClose} title={t("labels.createRoom")}>
<Dialog
small
onCloseRequest={handleClose}
title={t("labels.liveCollaboration")}
>
{renderRoomDialog()}
</Dialog>
);

View File

@ -1,5 +1,6 @@
import fallbackLangData from "./locales/en.json";
import percentages from "./locales/percentages.json";
import { ENV } from "./constants";
const COMPLETION_THRESHOLD = 85;
@ -55,6 +56,18 @@ export const languages: Language[] = allLanguages
COMPLETION_THRESHOLD,
);
const TEST_LANG_CODE = "__test__";
if (process.env.NODE_ENV === ENV.DEVELOPMENT) {
languages.unshift(
{ code: TEST_LANG_CODE, label: "test language" },
{
code: `${TEST_LANG_CODE}.rtl`,
label: "\u{202a}test language (rtl)\u{202c}",
rtl: true,
},
);
}
let currentLang: Language = defaultLang;
let currentLangData = {};
@ -63,18 +76,13 @@ export const setLanguage = async (lang: Language) => {
document.documentElement.dir = currentLang.rtl ? "rtl" : "ltr";
document.documentElement.lang = currentLang.code;
currentLangData = await import(
/* webpackChunkName: "i18n-[request]" */ `./locales/${currentLang.code}.json`
);
};
export const setLanguageFirstTime = async (lang: Language) => {
currentLang = lang;
document.documentElement.dir = currentLang.rtl ? "rtl" : "ltr";
currentLangData = await import(
/* webpackChunkName: "i18n-[request]" */ `./locales/${currentLang.code}.json`
);
if (lang.code.startsWith(TEST_LANG_CODE)) {
currentLangData = {};
} else {
currentLangData = await import(
/* webpackChunkName: "i18n-[request]" */ `./locales/${currentLang.code}.json`
);
}
};
export const getLanguage = () => currentLang;
@ -94,6 +102,13 @@ const findPartsForData = (data: any, parts: string[]) => {
};
export const t = (path: string, replacement?: { [key: string]: string }) => {
if (currentLang.code.startsWith(TEST_LANG_CODE)) {
const name = replacement
? `${path}(${JSON.stringify(replacement).slice(1, -1)})`
: path;
return `\u{202a}[[${name}]]\u{202c}`;
}
const parts = path.split(".");
let translation =
findPartsForData(currentLangData, parts) ||

View File

@ -68,7 +68,7 @@
"layers": "Layers",
"actions": "Actions",
"language": "Language",
"createRoom": "Share a live-collaboration session",
"liveCollaboration": "Live Collaboration",
"duplicateSelection": "Duplicate",
"untitled": "Untitled",
"name": "Name",
@ -117,7 +117,6 @@
"edit": "Edit",
"undo": "Undo",
"redo": "Redo",
"roomDialog": "Start live collaboration",
"createNewRoom": "Create new room",
"fullScreen": "Full screen",
"darkMode": "Dark mode",