revite/src/pages/home/Home.tsx

105 lines
3.4 KiB
TypeScript
Raw Normal View History

2021-07-05 06:23:23 -04:00
import { Home as HomeIcon } from "@styled-icons/boxicons-solid";
2021-06-19 15:24:11 -04:00
import { Link } from "react-router-dom";
2021-07-05 06:23:23 -04:00
import styles from "./Home.module.scss";
2021-06-19 15:24:11 -04:00
import { Text } from "preact-i18n";
2021-07-05 06:23:23 -04:00
import wideSVG from "../../assets/wide.svg";
2021-08-17 08:52:02 -04:00
import Emoji from "../../components/common/Emoji";
import Tooltip from "../../components/common/Tooltip";
2021-06-19 15:24:11 -04:00
import Header from "../../components/ui/Header";
2021-08-17 08:52:02 -04:00
import CategoryButton from "../../components/ui/fluent/CategoryButton";
import { dispatch, getState } from "../../redux";
import { useState } from "preact/hooks";
import styled, { css } from "styled-components";
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
const CHANNELS_SIDEBAR_KEY = "sidebar_channels";
const IconConainer = styled.div`
cursor: pointer;
color: var(--secondary-foreground);
${!isTouchscreenDevice && css`
&:hover {
color: var(--foreground);
}
`}
`
2021-06-19 07:34:53 -04:00
export default function Home() {
const [showChannels, setChannels] = useState(
getState().sectionToggle[CHANNELS_SIDEBAR_KEY] ?? true,
);
const toggleChannelSidebar = () => {
if (isTouchscreenDevice) {
return
}
setChannels(!showChannels);
if (showChannels) {
dispatch({
type: "SECTION_TOGGLE_SET",
id: CHANNELS_SIDEBAR_KEY,
state: false,
});
} else {
dispatch({
type: "SECTION_TOGGLE_UNSET",
id: CHANNELS_SIDEBAR_KEY,
});
}
}
2021-07-05 06:25:20 -04:00
return (
<div className={styles.home}>
<Header placement="primary">
<IconConainer onClick={toggleChannelSidebar} ><HomeIcon size={24} /></IconConainer>
2021-07-05 06:25:20 -04:00
<Text id="app.navigation.tabs.home" />
</Header>
<h3>
2021-08-02 17:03:59 -04:00
<Text id="app.special.modals.onboarding.welcome" />
<br />
2021-07-05 06:25:20 -04:00
<img src={wideSVG} />
</h3>
2021-07-09 11:23:06 -04:00
<div className={styles.actions}>
<Link to="/invite/Testers">
2021-08-17 08:52:02 -04:00
<CategoryButton
action="chevron"
icon={<Emoji emoji="😁" size={32} />}>
2021-07-09 11:23:06 -04:00
Join testers server
2021-08-17 08:52:02 -04:00
</CategoryButton>
2021-07-09 11:23:06 -04:00
</Link>
2021-08-02 17:03:59 -04:00
<a
href="https://insrt.uk/donate"
target="_blank"
rel="noreferrer">
2021-08-17 08:52:02 -04:00
<CategoryButton
action="external"
icon={<Emoji emoji="💷" size={32} />}>
2021-08-02 17:03:59 -04:00
Donate to Revolt
2021-08-17 08:52:02 -04:00
</CategoryButton>
2021-08-02 17:03:59 -04:00
</a>
2021-07-09 11:23:06 -04:00
<Link to="/settings/feedback">
2021-08-17 08:52:02 -04:00
<CategoryButton
action="chevron"
icon={<Emoji emoji="🎉" size={32} />}>
Give feedback
</CategoryButton>
</Link>
2021-08-17 08:52:02 -04:00
<Tooltip content="You can also right-click the user icon in the top left, or left click it if you're already home.">
<Link to="/settings">
<CategoryButton
action="chevron"
icon={<Emoji emoji="🔧" size={32} />}>
Settings
</CategoryButton>
</Link>
</Tooltip>
2021-07-09 11:23:06 -04:00
</div>
2021-07-05 06:25:20 -04:00
</div>
);
2021-06-19 07:34:53 -04:00
}