mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-26 15:32:11 -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.
|
* Component providing a way to change emoji pack.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,6 +28,7 @@ export interface ISettings {
|
||||||
|
|
||||||
"appearance:emoji": EmojiPack;
|
"appearance:emoji": EmojiPack;
|
||||||
"appearance:ligatures": boolean;
|
"appearance:ligatures": boolean;
|
||||||
|
"appearance:seasonal": boolean;
|
||||||
|
|
||||||
"appearance:theme:base": "dark" | "light";
|
"appearance:theme:base": "dark" | "light";
|
||||||
"appearance:theme:overrides": Partial<Overrides>;
|
"appearance:theme:overrides": Partial<Overrides>;
|
||||||
|
@ -137,6 +138,7 @@ export default class Settings
|
||||||
|
|
||||||
if (key === "appearance") {
|
if (key === "appearance") {
|
||||||
this.remove("appearance:emoji");
|
this.remove("appearance:emoji");
|
||||||
|
this.remove("appearance:seasonal");
|
||||||
} else {
|
} else {
|
||||||
this.remove("appearance:ligatures");
|
this.remove("appearance:ligatures");
|
||||||
this.remove("appearance:theme:base");
|
this.remove("appearance:theme:base");
|
||||||
|
@ -163,7 +165,10 @@ export default class Settings
|
||||||
|
|
||||||
@computed toSyncable() {
|
@computed toSyncable() {
|
||||||
const data: Record<"appearance" | "theme", Partial<ISettings>> = {
|
const data: Record<"appearance" | "theme", Partial<ISettings>> = {
|
||||||
appearance: this.pullKeys(["appearance:emoji"]),
|
appearance: this.pullKeys([
|
||||||
|
"appearance:emoji",
|
||||||
|
"appearance:seasonal",
|
||||||
|
]),
|
||||||
theme: this.pullKeys([
|
theme: this.pullKeys([
|
||||||
"appearance:ligatures",
|
"appearance:ligatures",
|
||||||
"appearance:theme:base",
|
"appearance:theme:base",
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
Cog,
|
Cog,
|
||||||
RightArrowCircle,
|
RightArrowCircle,
|
||||||
} from "@styled-icons/boxicons-solid";
|
} from "@styled-icons/boxicons-solid";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import styled, { css } from "styled-components";
|
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 client = useContext(AppContext);
|
||||||
const layout = useApplicationState().layout;
|
const state = useApplicationState();
|
||||||
|
|
||||||
const toggleChannelSidebar = () => {
|
const toggleChannelSidebar = () => {
|
||||||
if (isTouchscreenDevice) {
|
if (isTouchscreenDevice) {
|
||||||
return;
|
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 snowflakes = useMemo(() => {
|
||||||
const flakes = [];
|
const flakes = [];
|
||||||
|
|
||||||
// Disable outside of December
|
// Disable outside of December
|
||||||
if (new Date().getMonth() !== 11) return [];
|
if (!isDecember) return [];
|
||||||
|
|
||||||
for (let i = 0; i < 15; i++) {
|
for (let i = 0; i < 15; i++) {
|
||||||
flakes.push("❄️");
|
flakes.push("❄️");
|
||||||
|
@ -88,13 +97,15 @@ export default function Home() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.home}>
|
<div className={styles.home}>
|
||||||
<Overlay>
|
<Overlay>
|
||||||
<div class="snowfall">
|
{seasonalTheme && (
|
||||||
{snowflakes.map((emoji, index) => (
|
<div class="snowfall">
|
||||||
<div key={index} class="snowflake">
|
{snowflakes.map((emoji, index) => (
|
||||||
{emoji}
|
<div key={index} class="snowflake">
|
||||||
</div>
|
{emoji}
|
||||||
))}
|
</div>
|
||||||
</div>
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<Header placement="primary">
|
<Header placement="primary">
|
||||||
<IconConainer onClick={toggleChannelSidebar}>
|
<IconConainer onClick={toggleChannelSidebar}>
|
||||||
|
@ -193,12 +204,15 @@ export default function Home() {
|
||||||
</Link>
|
</Link>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
<Link to="/settings/appearance">
|
{isDecember && (
|
||||||
<a>Turn off homescreen effects</a>
|
<a href="#" onClick={toggleSeasonalTheme}>
|
||||||
</Link>
|
Turn {seasonalTheme ? "off" : "on"} homescreen
|
||||||
|
effects
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Overlay>{" "}
|
</Overlay>{" "}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
DisplayLigaturesShim,
|
DisplayLigaturesShim,
|
||||||
DisplayEmojiShim,
|
DisplayEmojiShim,
|
||||||
ThemeCustomCSSShim,
|
ThemeCustomCSSShim,
|
||||||
|
DisplaySeasonalShim,
|
||||||
} from "../../../components/settings/AppearanceShims";
|
} from "../../../components/settings/AppearanceShims";
|
||||||
import ThemeOverrides from "../../../components/settings/appearance/ThemeOverrides";
|
import ThemeOverrides from "../../../components/settings/appearance/ThemeOverrides";
|
||||||
import ThemeTools from "../../../components/settings/appearance/ThemeTools";
|
import ThemeTools from "../../../components/settings/appearance/ThemeTools";
|
||||||
|
@ -24,6 +25,7 @@ export const Appearance = observer(() => {
|
||||||
<ThemeBaseSelectorShim />
|
<ThemeBaseSelectorShim />
|
||||||
<ThemeShopShim />
|
<ThemeShopShim />
|
||||||
<ThemeAccentShim />
|
<ThemeAccentShim />
|
||||||
|
<DisplaySeasonalShim />
|
||||||
|
|
||||||
<DisplayFontShim />
|
<DisplayFontShim />
|
||||||
<DisplayLigaturesShim />
|
<DisplayLigaturesShim />
|
||||||
|
|
Loading…
Reference in a new issue