浏览代码

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

vanilla_orig
Jed Fox 4 年前
父节点
当前提交
73cba59d2d
没有帐户链接到提交者的电子邮件

+ 0
- 1
CONTRIBUTING.md 查看文件

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

+ 2
- 1
src/components/CollabButton.scss 查看文件

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

+ 2
- 2
src/components/CollabButton.tsx 查看文件

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

+ 2
- 7
src/components/InitializeApp.tsx 查看文件

@@ -1,12 +1,7 @@
1 1
 import React from "react";
2 2
 
3 3
 import { LoadingMessage } from "./LoadingMessage";
4
-import {
5
-  defaultLang,
6
-  Language,
7
-  languages,
8
-  setLanguageFirstTime,
9
-} from "../i18n";
4
+import { defaultLang, Language, languages, setLanguage } from "../i18n";
10 5
 
11 6
 interface Props {
12 7
   langCode: Language["code"];
@@ -23,7 +18,7 @@ export class InitializeApp extends React.Component<Props, State> {
23 18
     const currentLang =
24 19
       languages.find((lang) => lang.code === this.props.langCode) ||
25 20
       defaultLang;
26
-    await setLanguageFirstTime(currentLang);
21
+    await setLanguage(currentLang);
27 22
     this.setState({
28 23
       isLoading: false,
29 24
     });

+ 2
- 2
src/components/LayerUI.scss 查看文件

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

+ 14
- 0
src/excalidraw-app/collab/RoomDialog.scss 查看文件

@@ -32,6 +32,16 @@
32 32
     display: flex;
33 33
     align-items: center;
34 34
     justify-content: center;
35
+    @media #{$is-mobile-query} {
36
+      flex-direction: column;
37
+      align-items: stretch;
38
+    }
39
+  }
40
+
41
+  @media #{$is-mobile-query} {
42
+    .RoomDialog-usernameLabel {
43
+      font-weight: bold;
44
+    }
35 45
   }
36 46
 
37 47
   .RoomDialog-username {
@@ -41,6 +51,10 @@
41 51
     min-width: 0;
42 52
     flex: 1 1 auto;
43 53
     margin-inline-start: 1em;
54
+    @media #{$is-mobile-query} {
55
+      margin-top: 0.5em;
56
+      margin-inline-start: 0;
57
+    }
44 58
     height: 2.5rem;
45 59
     font-size: 1em;
46 60
     line-height: 1.5;

+ 5
- 1
src/excalidraw-app/collab/RoomDialog.tsx 查看文件

@@ -119,7 +119,11 @@ const RoomDialog = ({
119 119
     );
120 120
   };
121 121
   return (
122
-    <Dialog small onCloseRequest={handleClose} title={t("labels.createRoom")}>
122
+    <Dialog
123
+      small
124
+      onCloseRequest={handleClose}
125
+      title={t("labels.liveCollaboration")}
126
+    >
123 127
       {renderRoomDialog()}
124 128
     </Dialog>
125 129
   );

+ 27
- 12
src/i18n.ts 查看文件

@@ -1,5 +1,6 @@
1 1
 import fallbackLangData from "./locales/en.json";
2 2
 import percentages from "./locales/percentages.json";
3
+import { ENV } from "./constants";
3 4
 
4 5
 const COMPLETION_THRESHOLD = 85;
5 6
 
@@ -55,6 +56,18 @@ export const languages: Language[] = allLanguages
55 56
       COMPLETION_THRESHOLD,
56 57
   );
57 58
 
59
+const TEST_LANG_CODE = "__test__";
60
+if (process.env.NODE_ENV === ENV.DEVELOPMENT) {
61
+  languages.unshift(
62
+    { code: TEST_LANG_CODE, label: "test language" },
63
+    {
64
+      code: `${TEST_LANG_CODE}.rtl`,
65
+      label: "\u{202a}test language (rtl)\u{202c}",
66
+      rtl: true,
67
+    },
68
+  );
69
+}
70
+
58 71
 let currentLang: Language = defaultLang;
59 72
 let currentLangData = {};
60 73
 
@@ -63,18 +76,13 @@ export const setLanguage = async (lang: Language) => {
63 76
   document.documentElement.dir = currentLang.rtl ? "rtl" : "ltr";
64 77
   document.documentElement.lang = currentLang.code;
65 78
 
66
-  currentLangData = await import(
67
-    /* webpackChunkName: "i18n-[request]" */ `./locales/${currentLang.code}.json`
68
-  );
69
-};
70
-
71
-export const setLanguageFirstTime = async (lang: Language) => {
72
-  currentLang = lang;
73
-  document.documentElement.dir = currentLang.rtl ? "rtl" : "ltr";
74
-
75
-  currentLangData = await import(
76
-    /* webpackChunkName: "i18n-[request]" */ `./locales/${currentLang.code}.json`
77
-  );
79
+  if (lang.code.startsWith(TEST_LANG_CODE)) {
80
+    currentLangData = {};
81
+  } else {
82
+    currentLangData = await import(
83
+      /* webpackChunkName: "i18n-[request]" */ `./locales/${currentLang.code}.json`
84
+    );
85
+  }
78 86
 };
79 87
 
80 88
 export const getLanguage = () => currentLang;
@@ -94,6 +102,13 @@ const findPartsForData = (data: any, parts: string[]) => {
94 102
 };
95 103
 
96 104
 export const t = (path: string, replacement?: { [key: string]: string }) => {
105
+  if (currentLang.code.startsWith(TEST_LANG_CODE)) {
106
+    const name = replacement
107
+      ? `${path}(${JSON.stringify(replacement).slice(1, -1)})`
108
+      : path;
109
+    return `\u{202a}[[${name}]]\u{202c}`;
110
+  }
111
+
97 112
   const parts = path.split(".");
98 113
   let translation =
99 114
     findPartsForData(currentLangData, parts) ||

+ 1
- 2
src/locales/en.json 查看文件

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

正在加载...
取消
保存