import dayjs from "dayjs"; import styled, { css } from "styled-components"; import { Text } from "preact-i18n"; import { useMemo, useState } from "preact/hooks"; import { CategoryButton, Column, Modal } from "@revoltchat/ui"; import type { Action } from "@revoltchat/ui/esm/components/design/atoms/display/Modal"; import { noopTrue } from "../../../lib/js"; import { changelogEntries, changelogEntryArray, ChangelogPost, } from "../../../assets/changelogs"; import Markdown from "../../../components/markdown/Markdown"; import { ModalProps } from "../types"; const Image = styled.img<{ shadow?: boolean }>` border-radius: var(--border-radius); ${(props) => props.shadow && css` filter: drop-shadow(4px 4px 10px rgba(0, 0, 0, 0.5)); `} `; function RenderLog({ post }: { post: ChangelogPost }) { return ( {post.content.map((entry) => typeof entry === "string" ? ( ) : entry.type === "element" ? ( entry.element ) : ( ), )} ); } /** * Changelog modal */ export default function Changelog({ initial, onClose, signal, }: ModalProps<"changelog">) { const [log, setLog] = useState(initial); const entry = useMemo( () => (log ? changelogEntries[log] : undefined), [log], ); const actions = useMemo(() => { const arr: Action[] = [ { palette: "primary", children: , onClick: noopTrue, }, ]; if (log) { arr.push({ palette: "plain-secondary", children: , onClick: () => { setLog(undefined); return false; }, }); } return arr; }, [log]); return ( ) } description={ entry ? ( dayjs(entry.date).calendar() ) : ( ) } actions={actions} onClose={onClose} signal={signal}> {entry ? ( ) : ( {changelogEntryArray.map((entry, index) => ( setLog(index + 1)}> {entry.title} ))} )} ); }