-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flat-pages): add option to change background of whiteboard (#1931)
- Loading branch information
Showing
14 changed files
with
281 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
packages/flat-pages/src/components/PreferencesButton/GeneralSettings.tsx
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
packages/flat-pages/src/components/PreferencesButton/GeneralSettings/AvatarsSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import showAvatarsJPG from "../assets/show-avatars.jpg?url"; | ||
import hideAvatarsJPG from "../assets/hide-avatars.jpg?url"; | ||
|
||
import type { PreferencesButtonProps } from "../index"; | ||
|
||
import React from "react"; | ||
import { observer } from "mobx-react-lite"; | ||
import { Radio } from "antd"; | ||
import { useTranslate } from "@netless/flat-i18n"; | ||
|
||
export interface AvatarsSettingsProps extends PreferencesButtonProps {} | ||
|
||
export const AvatarsSettings = observer<AvatarsSettingsProps>(function AvatarsSettings({ | ||
classroom, | ||
}) { | ||
const t = useTranslate(); | ||
|
||
return ( | ||
<> | ||
<label className="preferences-modal-section-grid-label" htmlFor="avatars"> | ||
{t("general-settings-avatars")} | ||
</label> | ||
<Radio.Group | ||
className="preferences-modal-section-grid-content" | ||
id="avatars" | ||
name="avatars" | ||
value={classroom.isAvatarsVisible()} | ||
onChange={classroom.toggleAvatars} | ||
> | ||
<Radio className="preferences-modal-section-radio" value={true}> | ||
<img src={showAvatarsJPG} /> | ||
<span>{t("show")}</span> | ||
</Radio> | ||
<Radio className="preferences-modal-section-radio" value={false}> | ||
<img src={hideAvatarsJPG} /> | ||
<span>{t("hide")}</span> | ||
</Radio> | ||
</Radio.Group> | ||
</> | ||
); | ||
}); |
55 changes: 55 additions & 0 deletions
55
packages/flat-pages/src/components/PreferencesButton/GeneralSettings/BackgroundSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import frontZhSVG from "../assets/front-zh.svg"; | ||
import frontEnSVG from "../assets/front-en.svg"; | ||
|
||
import type { PreferencesButtonProps } from "../index"; | ||
|
||
import React, { useCallback, useContext } from "react"; | ||
import { Radio } from "antd"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
import { Background } from "@netless/flat-stores"; | ||
import { useLanguage, useTranslate } from "@netless/flat-i18n"; | ||
import { PreferencesStoreContext } from "../../StoreProvider"; | ||
|
||
export interface BackgroundSettingsProps extends PreferencesButtonProps {} | ||
|
||
const backgrounds: Background[] = ["default", "teal", "grey", "green"]; | ||
|
||
export const BackgroundSettings = observer<BackgroundSettingsProps>(function BackgroundSettings() { | ||
const t = useTranslate(); | ||
const language = useLanguage(); | ||
const preferences = useContext(PreferencesStoreContext); | ||
|
||
const changeBackground = useCallback( | ||
(ev: any) => preferences.updateBackground(ev.target.value), | ||
[preferences], | ||
); | ||
|
||
return ( | ||
<> | ||
<label className="preferences-modal-section-grid-label" htmlFor="background"> | ||
{t("general-settings-background")} | ||
</label> | ||
<Radio.Group | ||
className="preferences-modal-section-grid-content" | ||
id="background" | ||
name="background" | ||
value={preferences.background} | ||
onChange={changeBackground} | ||
> | ||
{backgrounds.map(background => ( | ||
<Radio className="preferences-modal-section-radio" value={background}> | ||
<span className={"preferences-modal-section-background " + background}> | ||
<img | ||
alt={t("online-interaction-to-synchronize-ideas")} | ||
className="preferences-modal-section-front" | ||
src={language === "zh-CN" ? frontZhSVG : frontEnSVG} | ||
/> | ||
</span> | ||
<span>{t("background." + background)}</span> | ||
</Radio> | ||
))} | ||
</Radio.Group> | ||
</> | ||
); | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/flat-pages/src/components/PreferencesButton/GeneralSettings/LanguageSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { PreferencesButtonProps } from "../index"; | ||
import React, { useCallback } from "react"; | ||
import { observer } from "mobx-react-lite"; | ||
import { Radio } from "antd"; | ||
import { FlatI18n, useLanguage, useTranslate } from "@netless/flat-i18n"; | ||
|
||
export interface LanguageSettingsProps extends PreferencesButtonProps {} | ||
|
||
export const LanguageSettings = observer<LanguageSettingsProps>(function LanguageSettings() { | ||
const t = useTranslate(); | ||
|
||
const language = useLanguage(); | ||
const changeLanguage = useCallback((ev: any) => FlatI18n.changeLanguage(ev.target.value), []); | ||
|
||
return ( | ||
<> | ||
<label className="preferences-modal-section-grid-label" htmlFor="language"> | ||
{t("language")} | ||
</label> | ||
<Radio.Group | ||
className="preferences-modal-section-grid-content" | ||
id="language" | ||
name="language" | ||
value={language} | ||
onChange={changeLanguage} | ||
> | ||
<Radio value="zh-CN"> | ||
<span>{t("chinese")}</span> | ||
</Radio> | ||
<Radio value="en"> | ||
<span>English</span> | ||
</Radio> | ||
</Radio.Group> | ||
</> | ||
); | ||
}); |
46 changes: 46 additions & 0 deletions
46
packages/flat-pages/src/components/PreferencesButton/GeneralSettings/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { PreferencesButtonProps } from "../index"; | ||
|
||
import React, { useCallback, useContext } from "react"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
import { useTranslate } from "@netless/flat-i18n"; | ||
import { RoomType } from "@netless/flat-server-api"; | ||
import { AppearancePicker } from "flat-components"; | ||
import { PreferencesStoreContext } from "../../StoreProvider"; | ||
import { AvatarsSettings } from "./AvatarsSettings"; | ||
import { BackgroundSettings } from "./BackgroundSettings"; | ||
import { LanguageSettings } from "./LanguageSettings"; | ||
|
||
export interface GeneralSettingsProps extends PreferencesButtonProps {} | ||
|
||
export const GeneralSettings = observer<GeneralSettingsProps>(function GeneralSettings({ | ||
classroom, | ||
}) { | ||
const t = useTranslate(); | ||
|
||
const preferences = useContext(PreferencesStoreContext); | ||
const changeAppearance = useCallback( | ||
(ev: any) => preferences.updatePrefersColorScheme(ev.target.value), | ||
[preferences], | ||
); | ||
|
||
const isSmallClass = classroom.roomType === RoomType.SmallClass; | ||
|
||
return ( | ||
<div className="preferences-modal-section" id="preferences-0"> | ||
<h3 className="preferences-modal-section-title">{t("general-settings")}</h3> | ||
<div className="preferences-modal-section-grid"> | ||
<LanguageSettings classroom={classroom} /> | ||
{isSmallClass && <AvatarsSettings classroom={classroom} />} | ||
<BackgroundSettings classroom={classroom} /> | ||
<label className="preferences-modal-section-grid-label" htmlFor="theme"> | ||
{t("theme")} | ||
</label> | ||
<AppearancePicker | ||
changeAppearance={changeAppearance} | ||
value={preferences.prefersColorScheme} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/flat-pages/src/components/PreferencesButton/assets/front-en.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.