mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-21 22:50:59 -05:00
feat(@ui): port Modal component
This commit is contained in:
parent
68b9d5ea79
commit
41e533ab59
21 changed files with 58 additions and 326 deletions
|
@ -1,263 +0,0 @@
|
||||||
/* eslint-disable react-hooks/rules-of-hooks */
|
|
||||||
import styled, { css, keyframes } from "styled-components/macro";
|
|
||||||
|
|
||||||
import { createPortal, useCallback, useEffect, useState } from "preact/compat";
|
|
||||||
|
|
||||||
import { Button } from "@revoltchat/ui";
|
|
||||||
import { Props as ButtonProps } from "@revoltchat/ui/esm/components/design/atoms/inputs/Button";
|
|
||||||
|
|
||||||
import { internalSubscribe } from "../../lib/eventEmitter";
|
|
||||||
|
|
||||||
import { Children } from "../../types/Preact";
|
|
||||||
|
|
||||||
const open = keyframes`
|
|
||||||
0% {opacity: 0;}
|
|
||||||
70% {opacity: 0;}
|
|
||||||
100% {opacity: 1;}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const close = keyframes`
|
|
||||||
0% {opacity: 1;}
|
|
||||||
70% {opacity: 0;}
|
|
||||||
100% {opacity: 0;}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const zoomIn = keyframes`
|
|
||||||
0% {transform: scale(0.5);}
|
|
||||||
98% {transform: scale(1.01);}
|
|
||||||
100% {transform: scale(1);}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const zoomOut = keyframes`
|
|
||||||
0% {transform: scale(1);}
|
|
||||||
100% {transform: scale(0.5);}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ModalBase = styled.div`
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: 9999;
|
|
||||||
position: fixed;
|
|
||||||
max-height: 100%;
|
|
||||||
user-select: none;
|
|
||||||
|
|
||||||
animation-name: ${open};
|
|
||||||
animation-duration: 0.2s;
|
|
||||||
|
|
||||||
display: grid;
|
|
||||||
overflow-y: auto;
|
|
||||||
place-items: center;
|
|
||||||
|
|
||||||
color: var(--foreground);
|
|
||||||
background: rgba(0, 0, 0, 0.8);
|
|
||||||
|
|
||||||
&.closing {
|
|
||||||
animation-name: ${close};
|
|
||||||
animation-fill-mode: forwards;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.closing > div {
|
|
||||||
animation-name: ${zoomOut};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ModalContainer = styled.div`
|
|
||||||
overflow: hidden;
|
|
||||||
max-width: calc(100vw - 20px);
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
|
|
||||||
animation-name: ${zoomIn};
|
|
||||||
animation-duration: 0.25s;
|
|
||||||
animation-timing-function: cubic-bezier(0.3, 0.3, 0.18, 1.1);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ModalContent = styled.div<
|
|
||||||
{ [key in "attachment" | "noBackground" | "border" | "padding"]?: boolean }
|
|
||||||
>`
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 14px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
margin: 0;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
color: var(--foreground);
|
|
||||||
}
|
|
||||||
|
|
||||||
h5 {
|
|
||||||
margin: 0;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--secondary-foreground);
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
|
|
||||||
> div {
|
|
||||||
margin: 0;
|
|
||||||
color: var(--secondary-foreground);
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.description {
|
|
||||||
color: var(--tertiary-foreground);
|
|
||||||
font-size: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
${(props) =>
|
|
||||||
!props.noBackground &&
|
|
||||||
css`
|
|
||||||
background: var(--secondary-header);
|
|
||||||
`}
|
|
||||||
|
|
||||||
${(props) =>
|
|
||||||
props.padding &&
|
|
||||||
css`
|
|
||||||
padding: 1rem;
|
|
||||||
min-width: 450px;
|
|
||||||
`}
|
|
||||||
|
|
||||||
${(props) =>
|
|
||||||
props.attachment &&
|
|
||||||
css`
|
|
||||||
border-radius: var(--border-radius) var(--border-radius) 0 0;
|
|
||||||
`}
|
|
||||||
|
|
||||||
${(props) =>
|
|
||||||
props.border &&
|
|
||||||
css`
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
border: 2px solid var(--secondary-background);
|
|
||||||
`}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ModalActions = styled.div`
|
|
||||||
gap: 8px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row-reverse;
|
|
||||||
padding: 1rem;
|
|
||||||
background: var(--secondary-background);
|
|
||||||
border-radius: 0 0 var(--border-radius) var(--border-radius);
|
|
||||||
`;
|
|
||||||
|
|
||||||
export type Action = Omit<
|
|
||||||
JSX.HTMLAttributes<HTMLButtonElement>,
|
|
||||||
"as" | "onClick"
|
|
||||||
> & {
|
|
||||||
palette?: ButtonProps["palette"];
|
|
||||||
confirmation?: boolean;
|
|
||||||
onClick: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
children?: Children;
|
|
||||||
title?: Children;
|
|
||||||
description?: Children;
|
|
||||||
|
|
||||||
disallowClosing?: boolean;
|
|
||||||
noBackground?: boolean;
|
|
||||||
dontModal?: boolean;
|
|
||||||
padding?: boolean;
|
|
||||||
|
|
||||||
onClose?: () => void;
|
|
||||||
actions?: Action[];
|
|
||||||
disabled?: boolean;
|
|
||||||
palette?: ButtonProps["palette"];
|
|
||||||
border?: boolean;
|
|
||||||
visible: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export let isModalClosing = false;
|
|
||||||
|
|
||||||
export default function Modal(props: Props) {
|
|
||||||
if (!props.visible) return null;
|
|
||||||
|
|
||||||
const content = (
|
|
||||||
<ModalContent
|
|
||||||
attachment={!!props.actions}
|
|
||||||
noBackground={props.noBackground}
|
|
||||||
border={props.border}
|
|
||||||
padding={props.padding ?? !props.dontModal}>
|
|
||||||
{props.title && <h3>{props.title}</h3>}
|
|
||||||
|
|
||||||
{props.description && <h5>{props.description}</h5>}
|
|
||||||
{props.children}
|
|
||||||
</ModalContent>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (props.dontModal) {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [animateClose, setAnimateClose] = useState(false);
|
|
||||||
isModalClosing = animateClose;
|
|
||||||
const onClose = useCallback(() => {
|
|
||||||
setAnimateClose(true);
|
|
||||||
setTimeout(() => props.onClose!(), 2e2);
|
|
||||||
}, [setAnimateClose, props]);
|
|
||||||
|
|
||||||
useEffect(() => internalSubscribe("Modal", "close", onClose), [onClose]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (props.disallowClosing) return;
|
|
||||||
|
|
||||||
function keyDown(e: KeyboardEvent) {
|
|
||||||
if (e.key === "Escape") {
|
|
||||||
onClose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.addEventListener("keydown", keyDown);
|
|
||||||
return () => document.body.removeEventListener("keydown", keyDown);
|
|
||||||
}, [props.disallowClosing, onClose]);
|
|
||||||
|
|
||||||
const confirmationAction = props.actions?.find(
|
|
||||||
(action) => action.confirmation,
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!confirmationAction) return;
|
|
||||||
|
|
||||||
// ! TODO: this may be done better if we
|
|
||||||
// ! can focus the button although that
|
|
||||||
// ! doesn't seem to work...
|
|
||||||
function keyDown(e: KeyboardEvent) {
|
|
||||||
if (e.key === "Enter") {
|
|
||||||
confirmationAction!.onClick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.body.addEventListener("keydown", keyDown);
|
|
||||||
return () => document.body.removeEventListener("keydown", keyDown);
|
|
||||||
}, [confirmationAction]);
|
|
||||||
|
|
||||||
return createPortal(
|
|
||||||
<ModalBase
|
|
||||||
className={animateClose ? "closing" : undefined}
|
|
||||||
onClick={(!props.disallowClosing && props.onClose) || undefined}>
|
|
||||||
<ModalContainer onClick={(e) => (e.cancelBubble = true)}>
|
|
||||||
{content}
|
|
||||||
{props.actions && (
|
|
||||||
<ModalActions>
|
|
||||||
{props.actions.map((x, index) => (
|
|
||||||
<Button
|
|
||||||
palette={props.palette}
|
|
||||||
key={index}
|
|
||||||
{...x}
|
|
||||||
disabled={props.disabled}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</ModalActions>
|
|
||||||
)}
|
|
||||||
</ModalContainer>
|
|
||||||
</ModalBase>,
|
|
||||||
document.body,
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -5,13 +5,13 @@ import { API, Channel, Message, Server, User } from "revolt.js";
|
||||||
import { createContext } from "preact";
|
import { createContext } from "preact";
|
||||||
import { useContext, useEffect, useMemo, useState } from "preact/hooks";
|
import { useContext, useEffect, useMemo, useState } from "preact/hooks";
|
||||||
|
|
||||||
|
import type { Action } from "@revoltchat/ui/esm/components/design/atoms/layout/Modal";
|
||||||
|
|
||||||
import { internalSubscribe } from "../../lib/eventEmitter";
|
import { internalSubscribe } from "../../lib/eventEmitter";
|
||||||
import { determineLink } from "../../lib/links";
|
import { determineLink } from "../../lib/links";
|
||||||
|
|
||||||
import { useApplicationState } from "../../mobx/State";
|
import { useApplicationState } from "../../mobx/State";
|
||||||
|
|
||||||
import { Action } from "../../components/ui/Modal";
|
|
||||||
|
|
||||||
import { Children } from "../../types/Preact";
|
import { Children } from "../../types/Preact";
|
||||||
import Modals from "./Modals";
|
import Modals from "./Modals";
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ export type Screen =
|
||||||
| { id: "clipboard"; text: string }
|
| { id: "clipboard"; text: string }
|
||||||
| { id: "token_reveal"; token: string; username: string }
|
| { id: "token_reveal"; token: string; username: string }
|
||||||
| { id: "external_link_prompt"; link: string }
|
| { id: "external_link_prompt"; link: string }
|
||||||
| { id: "sessions", confirm: () => void }
|
| { id: "sessions"; confirm: () => void }
|
||||||
| {
|
| {
|
||||||
id: "_prompt";
|
id: "_prompt";
|
||||||
question: Children;
|
question: Children;
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
import { internalEmit } from "../../lib/eventEmitter";
|
import { internalEmit } from "../../lib/eventEmitter";
|
||||||
|
|
||||||
import { isModalClosing } from "../../components/ui/Modal";
|
//import { isModalClosing } from "../../components/ui/Modal";
|
||||||
|
|
||||||
import { Screen } from "./Intermediate";
|
import { Screen } from "./Intermediate";
|
||||||
import { ClipboardModal } from "./modals/Clipboard";
|
import { ClipboardModal } from "./modals/Clipboard";
|
||||||
import { ErrorModal } from "./modals/Error";
|
import { ErrorModal } from "./modals/Error";
|
||||||
|
import { ExternalLinkModal } from "./modals/ExternalLinkPrompt";
|
||||||
import { InputModal } from "./modals/Input";
|
import { InputModal } from "./modals/Input";
|
||||||
import { OnboardingModal } from "./modals/Onboarding";
|
import { OnboardingModal } from "./modals/Onboarding";
|
||||||
import { PromptModal } from "./modals/Prompt";
|
import { PromptModal } from "./modals/Prompt";
|
||||||
import { SignedOutModal } from "./modals/SignedOut";
|
|
||||||
import { ExternalLinkModal} from "./modals/ExternalLinkPrompt";
|
|
||||||
import { SessionsModal } from "./modals/SessionsPrompt";
|
import { SessionsModal } from "./modals/SessionsPrompt";
|
||||||
|
import { SignedOutModal } from "./modals/SignedOut";
|
||||||
import { TokenRevealModal } from "./modals/TokenReveal";
|
import { TokenRevealModal } from "./modals/TokenReveal";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
@ -20,9 +19,9 @@ export interface Props {
|
||||||
|
|
||||||
export default function Modals({ screen, openScreen }: Props) {
|
export default function Modals({ screen, openScreen }: Props) {
|
||||||
const onClose = () =>
|
const onClose = () =>
|
||||||
isModalClosing || screen.id === "onboarding"
|
//isModalClosing || screen.id === "onboarding"
|
||||||
? openScreen({ id: "none" })
|
openScreen({ id: "none" });
|
||||||
: internalEmit("Modal", "close");
|
// : internalEmit("Modal", "close");
|
||||||
|
|
||||||
switch (screen.id) {
|
switch (screen.id) {
|
||||||
case "_prompt":
|
case "_prompt":
|
||||||
|
|
|
@ -2,8 +2,6 @@ import { useContext } from "preact/hooks";
|
||||||
|
|
||||||
import { internalEmit } from "../../lib/eventEmitter";
|
import { internalEmit } from "../../lib/eventEmitter";
|
||||||
|
|
||||||
import { isModalClosing } from "../../components/ui/Modal";
|
|
||||||
|
|
||||||
import { IntermediateContext, useIntermediate } from "./Intermediate";
|
import { IntermediateContext, useIntermediate } from "./Intermediate";
|
||||||
import { SpecialInputModal } from "./modals/Input";
|
import { SpecialInputModal } from "./modals/Input";
|
||||||
import { SpecialPromptModal } from "./modals/Prompt";
|
import { SpecialPromptModal } from "./modals/Prompt";
|
||||||
|
@ -21,9 +19,9 @@ export default function Popovers() {
|
||||||
const { openScreen } = useIntermediate();
|
const { openScreen } = useIntermediate();
|
||||||
|
|
||||||
const onClose = () =>
|
const onClose = () =>
|
||||||
isModalClosing
|
//isModalClosing
|
||||||
? openScreen({ id: "none" })
|
openScreen({ id: "none" });
|
||||||
: internalEmit("Modal", "close");
|
//: internalEmit("Modal", "close");
|
||||||
|
|
||||||
switch (screen.id) {
|
switch (screen.id) {
|
||||||
case "profile":
|
case "profile":
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
@ -10,7 +10,6 @@ interface Props {
|
||||||
export function ClipboardModal({ onClose, text }: Props) {
|
export function ClipboardModal({ onClose, text }: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id="app.special.modals.clipboard.unavailable" />}
|
title={<Text id="app.special.modals.clipboard.unavailable" />}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
@ -10,7 +10,6 @@ interface Props {
|
||||||
export function ErrorModal({ onClose, error }: Props) {
|
export function ErrorModal({ onClose, error }: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id="app.special.modals.error" />}
|
title={<Text id="app.special.modals.error" />}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import { useApplicationState } from "../../../mobx/State";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { useApplicationState } from "../../../mobx/State";
|
||||||
|
|
||||||
import { useIntermediate } from "../Intermediate";
|
import { useIntermediate } from "../Intermediate";
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ export function ExternalLinkModal({ onClose, link }: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id={"app.special.modals.external_links.title"} />}
|
title={<Text id={"app.special.modals.external_links.title"} />}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -4,9 +4,8 @@ import { Server } from "revolt.js";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useContext, useState } from "preact/hooks";
|
import { useContext, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Category, InputBox } from "@revoltchat/ui";
|
import { Category, InputBox, Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
import { Children } from "../../../types/Preact";
|
import { Children } from "../../../types/Preact";
|
||||||
import { I18nError } from "../../Locale";
|
import { I18nError } from "../../Locale";
|
||||||
import { AppContext } from "../../revoltjs/RevoltClient";
|
import { AppContext } from "../../revoltjs/RevoltClient";
|
||||||
|
@ -35,7 +34,6 @@ export function InputModal({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
title={question}
|
title={question}
|
||||||
description={description}
|
description={description}
|
||||||
disabled={processing}
|
disabled={processing}
|
||||||
|
|
|
@ -7,13 +7,13 @@ import styles from "./Prompt.module.scss";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useContext, useEffect, useState } from "preact/hooks";
|
import { useContext, useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Category, Error, InputBox, Radio } from "@revoltchat/ui";
|
import { Category, Modal, InputBox, Radio } from "@revoltchat/ui";
|
||||||
|
import type { Action } from "@revoltchat/ui/esm/components/design/atoms/layout/Modal";
|
||||||
|
|
||||||
import { TextReact } from "../../../lib/i18n";
|
import { TextReact } from "../../../lib/i18n";
|
||||||
|
|
||||||
import Message from "../../../components/common/messaging/Message";
|
import Message from "../../../components/common/messaging/Message";
|
||||||
import UserIcon from "../../../components/common/user/UserIcon";
|
import UserIcon from "../../../components/common/user/UserIcon";
|
||||||
import Modal, { Action } from "../../../components/ui/Modal";
|
|
||||||
import { Children } from "../../../types/Preact";
|
import { Children } from "../../../types/Preact";
|
||||||
import { I18nError } from "../../Locale";
|
import { I18nError } from "../../Locale";
|
||||||
import { AppContext } from "../../revoltjs/RevoltClient";
|
import { AppContext } from "../../revoltjs/RevoltClient";
|
||||||
|
@ -39,7 +39,6 @@ export function PromptModal({
|
||||||
}: Props) {
|
}: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
title={question}
|
title={question}
|
||||||
actions={actions}
|
actions={actions}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
@ -10,7 +10,6 @@ interface Props {
|
||||||
export function SessionsModal({ onClose, confirm }: Props) {
|
export function SessionsModal({ onClose, confirm }: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id={"app.special.modals.sessions.title"} />}
|
title={<Text id={"app.special.modals.sessions.title"} />}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
@ -9,7 +9,6 @@ interface Props {
|
||||||
export function SignedOutModal({ onClose }: Props) {
|
export function SignedOutModal({ onClose }: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id="app.special.modals.signed_out" />}
|
title={<Text id="app.special.modals.signed_out" />}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
@ -11,7 +11,6 @@ interface Props {
|
||||||
export function TokenRevealModal({ onClose, token, username }: Props) {
|
export function TokenRevealModal({ onClose, token, username }: Props) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={
|
title={
|
||||||
<Text
|
<Text
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { Channel } from "revolt.js";
|
||||||
|
|
||||||
import styles from "./ChannelInfo.module.scss";
|
import styles from "./ChannelInfo.module.scss";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import Markdown from "../../../components/markdown/Markdown";
|
import Markdown from "../../../components/markdown/Markdown";
|
||||||
import { getChannelName } from "../../revoltjs/util";
|
import { getChannelName } from "../../revoltjs/util";
|
||||||
|
@ -24,7 +24,7 @@ export const ChannelInfo = observer(({ channel, onClose }: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal visible={true} onClose={onClose}>
|
<Modal onClose={onClose}>
|
||||||
<div className={styles.info}>
|
<div className={styles.info}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<h1>{getChannelName(channel, true)}</h1>
|
<h1>{getChannelName(channel, true)}</h1>
|
||||||
|
|
|
@ -4,9 +4,8 @@ import { API } from "revolt.js";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useContext, useState } from "preact/hooks";
|
import { useContext, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Category } from "@revoltchat/ui";
|
import { Category, Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
import FormField from "../../../pages/login/FormField";
|
import FormField from "../../../pages/login/FormField";
|
||||||
import { I18nError } from "../../Locale";
|
import { I18nError } from "../../Locale";
|
||||||
import { AppContext } from "../../revoltjs/RevoltClient";
|
import { AppContext } from "../../revoltjs/RevoltClient";
|
||||||
|
@ -38,7 +37,6 @@ export function CreateBotModal({ onClose, onCreate }: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id="app.special.popovers.create_bot.title" />}
|
title={<Text id="app.special.popovers.create_bot.title" />}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -3,10 +3,10 @@ import { API } from "revolt.js";
|
||||||
|
|
||||||
import styles from "./ImageViewer.module.scss";
|
import styles from "./ImageViewer.module.scss";
|
||||||
|
|
||||||
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import AttachmentActions from "../../../components/common/messaging/attachments/AttachmentActions";
|
import AttachmentActions from "../../../components/common/messaging/attachments/AttachmentActions";
|
||||||
import EmbedMediaActions from "../../../components/common/messaging/embed/EmbedMediaActions";
|
import EmbedMediaActions from "../../../components/common/messaging/embed/EmbedMediaActions";
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
|
|
||||||
import { useClient } from "../../revoltjs/RevoltClient";
|
import { useClient } from "../../revoltjs/RevoltClient";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -28,7 +28,7 @@ export function ImageViewer({ attachment, embed, onClose }: Props) {
|
||||||
const client = useClient();
|
const client = useClient();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal visible={true} onClose={onClose} noBackground>
|
<Modal onClose={onClose} transparent maxHeight="100vh" maxWidth="100vw">
|
||||||
<div className={styles.viewer}>
|
<div className={styles.viewer}>
|
||||||
{attachment && (
|
{attachment && (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -3,9 +3,8 @@ import { SubmitHandler, useForm } from "react-hook-form";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useContext, useState } from "preact/hooks";
|
import { useContext, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Category, Error } from "@revoltchat/ui";
|
import { Category, Error, Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
import FormField from "../../../pages/login/FormField";
|
import FormField from "../../../pages/login/FormField";
|
||||||
import { AppContext } from "../../revoltjs/RevoltClient";
|
import { AppContext } from "../../revoltjs/RevoltClient";
|
||||||
import { takeError } from "../../revoltjs/util";
|
import { takeError } from "../../revoltjs/util";
|
||||||
|
@ -69,7 +68,6 @@ export function ModifyAccountModal({ onClose, field }: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id={`app.special.modals.account.change.${field}`} />}
|
title={<Text id={`app.special.modals.account.change.${field}`} />}
|
||||||
disabled={processing}
|
disabled={processing}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { User } from "revolt.js";
|
||||||
import styles from "./UserPicker.module.scss";
|
import styles from "./UserPicker.module.scss";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import { Friend } from "../../../pages/friends/Friend";
|
import { Friend } from "../../../pages/friends/Friend";
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ interface Props {
|
||||||
export const PendingRequests = observer(({ users, onClose }: Props) => {
|
export const PendingRequests = observer(({ users, onClose }: Props) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
title={<Text id="app.special.friends.pending" />}
|
title={<Text id="app.special.friends.pending" />}
|
||||||
onClose={onClose}>
|
onClose={onClose}>
|
||||||
<div className={styles.list}>
|
<div className={styles.list}>
|
||||||
|
|
|
@ -5,11 +5,10 @@ import styles from "./ServerIdentityModal.module.scss";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Button, Category, InputBox } from "@revoltchat/ui";
|
import { Button, Category, InputBox, Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import { noop } from "../../../lib/js";
|
import { noop } from "../../../lib/js";
|
||||||
|
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
import { FileUploader } from "../../revoltjs/FileUploads";
|
import { FileUploader } from "../../revoltjs/FileUploads";
|
||||||
import { useClient } from "../../revoltjs/RevoltClient";
|
import { useClient } from "../../revoltjs/RevoltClient";
|
||||||
|
|
||||||
|
@ -36,7 +35,6 @@ export const ServerIdentityModal = observer(({ server, onClose }: Props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
title={
|
title={
|
||||||
<Text
|
<Text
|
||||||
id={"app.special.popovers.server_identity.title"}
|
id={"app.special.popovers.server_identity.title"}
|
||||||
|
|
|
@ -2,8 +2,9 @@ import styles from "./UserPicker.module.scss";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
|
|
||||||
|
import { Modal } from "@revoltchat/ui";
|
||||||
|
|
||||||
import UserCheckbox from "../../../components/common/user/UserCheckbox";
|
import UserCheckbox from "../../../components/common/user/UserCheckbox";
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
import { useClient } from "../../revoltjs/RevoltClient";
|
import { useClient } from "../../revoltjs/RevoltClient";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -20,7 +21,6 @@ export function UserPicker(props: Props) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible={true}
|
|
||||||
title={<Text id="app.special.popovers.user_picker.select" />}
|
title={<Text id="app.special.popovers.user_picker.select" />}
|
||||||
onClose={props.onClose}
|
onClose={props.onClose}
|
||||||
actions={[
|
actions={[
|
||||||
|
|
|
@ -15,7 +15,14 @@ import styles from "./UserProfile.module.scss";
|
||||||
import { Localizer, Text } from "preact-i18n";
|
import { Localizer, Text } from "preact-i18n";
|
||||||
import { useContext, useEffect, useLayoutEffect, useState } from "preact/hooks";
|
import { useContext, useEffect, useLayoutEffect, useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Button, Category, Error, IconButton, Preloader } from "@revoltchat/ui";
|
import {
|
||||||
|
Button,
|
||||||
|
Category,
|
||||||
|
Error,
|
||||||
|
IconButton,
|
||||||
|
Modal,
|
||||||
|
Preloader,
|
||||||
|
} from "@revoltchat/ui";
|
||||||
|
|
||||||
import { noop } from "../../../lib/js";
|
import { noop } from "../../../lib/js";
|
||||||
|
|
||||||
|
@ -27,7 +34,6 @@ import UserIcon from "../../../components/common/user/UserIcon";
|
||||||
import { Username } from "../../../components/common/user/UserShort";
|
import { Username } from "../../../components/common/user/UserShort";
|
||||||
import UserStatus from "../../../components/common/user/UserStatus";
|
import UserStatus from "../../../components/common/user/UserStatus";
|
||||||
import Markdown from "../../../components/markdown/Markdown";
|
import Markdown from "../../../components/markdown/Markdown";
|
||||||
import Modal from "../../../components/ui/Modal";
|
|
||||||
import {
|
import {
|
||||||
ClientStatus,
|
ClientStatus,
|
||||||
StatusContext,
|
StatusContext,
|
||||||
|
@ -143,13 +149,8 @@ export const UserProfile = observer(
|
||||||
const badges = user.badges ?? 0;
|
const badges = user.badges ?? 0;
|
||||||
const flags = user.flags ?? 0;
|
const flags = user.flags ?? 0;
|
||||||
|
|
||||||
return (
|
const children = (
|
||||||
<Modal
|
<>
|
||||||
visible
|
|
||||||
border={dummy}
|
|
||||||
padding={false}
|
|
||||||
onClose={onClose}
|
|
||||||
dontModal={dummy}>
|
|
||||||
<div
|
<div
|
||||||
className={styles.header}
|
className={styles.header}
|
||||||
data-force={profile?.background ? "light" : undefined}
|
data-force={profile?.background ? "light" : undefined}
|
||||||
|
@ -437,6 +438,18 @@ export const UserProfile = observer(
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (dummy) return <div>{children}</div>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
onClose={onClose}
|
||||||
|
nonDismissable={dummy}
|
||||||
|
transparent
|
||||||
|
maxWidth="560px">
|
||||||
|
{children}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -128,8 +128,9 @@
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
display: grid;
|
flex-direction: column;
|
||||||
place-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
grid-template-columns: minmax(auto, 100%);
|
grid-template-columns: minmax(auto, 100%);
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
|
|
Loading…
Reference in a new issue