[Update] Starting up: Adjust announcement button's design and animation.

This commit is contained in:
Sakamoto Shiina
2024-12-30 19:11:35 +09:00
parent c69cce00b6
commit f5b0252e79
2 changed files with 57 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ import { DownloadModelsContainer } from "./download_models_container/DownloadMod
import MegaphoneSvg from "@images/megaphone.svg?react";
import XMarkSvg from "@images/cancel.svg?react";
import { appWindow } from "@tauri-apps/api/window";
import clsx from "clsx";
export const SplashComponent = () => {
return (
@@ -17,33 +18,57 @@ export const SplashComponent = () => {
);
};
const AnnouncementsContainer = () => {
const labels = ["VRCT Real-Time Announcements", "VRCTからのお知らせ"];
const [currentLabelIndex, setCurrentLabelIndex] = useState(0);
const SHOW_MEGAPHONE_TIME = 1000;
const AnnouncementsContainer = () => {
const labels = ["Check the Latest Status", "最新の状況を確認"];
const [is_shown, setIsShown] = useState(0);
const [currentLabelIndex, setCurrentLabelIndex] = useState(0);
const [is_labels_active, setIsLabelsActive] = useState(false);
useEffect(() => {
const labelInterval = setInterval(() => {
setCurrentLabelIndex((prevIndex) => (prevIndex + 1) % labels.length);
}, 6000);
return () => clearInterval(labelInterval);
}, [labels.length]);
const showTimeout = setTimeout(() => {
setIsShown(true);
}, SHOW_MEGAPHONE_TIME);
const labelsTimeout = setTimeout(() => {
setIsLabelsActive(true);
}, SHOW_MEGAPHONE_TIME + 500);
let labelInterval;
if (is_labels_active) {
labelInterval = setInterval(() => {
setCurrentLabelIndex((prevIndex) => (prevIndex + 1) % labels.length);
}, 4000);
}
return () => {
clearTimeout(showTimeout);
clearTimeout(labelsTimeout);
if (labelInterval) clearInterval(labelInterval);
};
}, [is_labels_active, labels.length]);
return (
<a
className={clsx(styles.announcements_button_wrapper, { [styles.is_shown]: is_shown })}
href="https://docs.google.com/spreadsheets/d/1_L5i-1U6PB1dnaPPTE_5uKMfqOpkLziPyRkiMLi4mqU/edit?usp=sharing"
target="_blank"
rel="noreferrer"
>
<button className={styles.announcements_button}>
<MegaphoneSvg className={styles.announcements_link_svg} />
<p className={styles.announcements_label}>{labels[currentLabelIndex]}</p>
<p className={clsx(styles.announcements_label, { [styles.is_labels_active]: is_labels_active })}>
{labels[currentLabelIndex]}
</p>
</button>
</a>
);
};
const CloseButtonContainer = () => {
const close = () => {
appWindow.close();