mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-10 01:03:36 -05:00
feat(theme): add toggle for seasonal theme
This commit is contained in:
parent
5029d0ac86
commit
63164fe2d0
4 changed files with 55 additions and 16 deletions
|
@ -207,6 +207,24 @@ export const DisplayLigaturesShim = observer(() => {
|
|||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Component providing a way to toggle seasonal themes.
|
||||
*/
|
||||
export const DisplaySeasonalShim = observer(() => {
|
||||
const settings = useApplicationState().settings;
|
||||
|
||||
return (
|
||||
<p>
|
||||
<Checkbox
|
||||
checked={settings.get("appearance:seasonal") ?? true}
|
||||
onChange={(v) => settings.set("appearance:seasonal", v)}
|
||||
description="Displays effects in the home tab during holiday seasons.">
|
||||
Seasonal theme
|
||||
</Checkbox>
|
||||
</p>
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Component providing a way to change emoji pack.
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,7 @@ export interface ISettings {
|
|||
|
||||
"appearance:emoji": EmojiPack;
|
||||
"appearance:ligatures": boolean;
|
||||
"appearance:seasonal": boolean;
|
||||
|
||||
"appearance:theme:base": "dark" | "light";
|
||||
"appearance:theme:overrides": Partial<Overrides>;
|
||||
|
@ -137,6 +138,7 @@ export default class Settings
|
|||
|
||||
if (key === "appearance") {
|
||||
this.remove("appearance:emoji");
|
||||
this.remove("appearance:seasonal");
|
||||
} else {
|
||||
this.remove("appearance:ligatures");
|
||||
this.remove("appearance:theme:base");
|
||||
|
@ -163,7 +165,10 @@ export default class Settings
|
|||
|
||||
@computed toSyncable() {
|
||||
const data: Record<"appearance" | "theme", Partial<ISettings>> = {
|
||||
appearance: this.pullKeys(["appearance:emoji"]),
|
||||
appearance: this.pullKeys([
|
||||
"appearance:emoji",
|
||||
"appearance:seasonal",
|
||||
]),
|
||||
theme: this.pullKeys([
|
||||
"appearance:ligatures",
|
||||
"appearance:theme:base",
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
Cog,
|
||||
RightArrowCircle,
|
||||
} from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Link } from "react-router-dom";
|
||||
import styled, { css } from "styled-components";
|
||||
|
||||
|
@ -53,23 +54,31 @@ const Overlay = styled.div`
|
|||
}
|
||||
`;
|
||||
|
||||
export default function Home() {
|
||||
export default observer(() => {
|
||||
const client = useContext(AppContext);
|
||||
const layout = useApplicationState().layout;
|
||||
const state = useApplicationState();
|
||||
|
||||
const toggleChannelSidebar = () => {
|
||||
if (isTouchscreenDevice) {
|
||||
return;
|
||||
}
|
||||
|
||||
layout.toggleSectionState(SIDEBAR_CHANNELS, true);
|
||||
state.layout.toggleSectionState(SIDEBAR_CHANNELS, true);
|
||||
};
|
||||
|
||||
const toggleSeasonalTheme = () =>
|
||||
state.settings.set(
|
||||
"appearance:seasonal",
|
||||
!state.settings.get("appearance:seasonal"),
|
||||
);
|
||||
|
||||
const seasonalTheme = state.settings.get("appearance:seasonal") ?? true;
|
||||
const isDecember = new Date().getMonth() === 11;
|
||||
const snowflakes = useMemo(() => {
|
||||
const flakes = [];
|
||||
|
||||
// Disable outside of December
|
||||
if (new Date().getMonth() !== 11) return [];
|
||||
if (!isDecember) return [];
|
||||
|
||||
for (let i = 0; i < 15; i++) {
|
||||
flakes.push("❄️");
|
||||
|
@ -88,13 +97,15 @@ export default function Home() {
|
|||
return (
|
||||
<div className={styles.home}>
|
||||
<Overlay>
|
||||
<div class="snowfall">
|
||||
{snowflakes.map((emoji, index) => (
|
||||
<div key={index} class="snowflake">
|
||||
{emoji}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{seasonalTheme && (
|
||||
<div class="snowfall">
|
||||
{snowflakes.map((emoji, index) => (
|
||||
<div key={index} class="snowflake">
|
||||
{emoji}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="content">
|
||||
<Header placement="primary">
|
||||
<IconConainer onClick={toggleChannelSidebar}>
|
||||
|
@ -193,12 +204,15 @@ export default function Home() {
|
|||
</Link>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<Link to="/settings/appearance">
|
||||
<a>Turn off homescreen effects</a>
|
||||
</Link>
|
||||
{isDecember && (
|
||||
<a href="#" onClick={toggleSeasonalTheme}>
|
||||
Turn {seasonalTheme ? "off" : "on"} homescreen
|
||||
effects
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Overlay>{" "}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
DisplayLigaturesShim,
|
||||
DisplayEmojiShim,
|
||||
ThemeCustomCSSShim,
|
||||
DisplaySeasonalShim,
|
||||
} from "../../../components/settings/AppearanceShims";
|
||||
import ThemeOverrides from "../../../components/settings/appearance/ThemeOverrides";
|
||||
import ThemeTools from "../../../components/settings/appearance/ThemeTools";
|
||||
|
@ -24,6 +25,7 @@ export const Appearance = observer(() => {
|
|||
<ThemeBaseSelectorShim />
|
||||
<ThemeShopShim />
|
||||
<ThemeAccentShim />
|
||||
<DisplaySeasonalShim />
|
||||
|
||||
<DisplayFontShim />
|
||||
<DisplayLigaturesShim />
|
||||
|
|
Loading…
Reference in a new issue