From 3d5c7ab9cea41ed71df9d92fa67237a47e1940b6 Mon Sep 17 00:00:00 2001 From: TaiAurori <31465218+TaiAurori@users.noreply.github.com> Date: Tue, 21 Sep 2021 14:02:38 -0400 Subject: [PATCH 1/3] invite embed tweaks --- .../common/messaging/embed/EmbedInvite.tsx | 146 +++++++++++------- 1 file changed, 86 insertions(+), 60 deletions(-) diff --git a/src/components/common/messaging/embed/EmbedInvite.tsx b/src/components/common/messaging/embed/EmbedInvite.tsx index f9e91697..e9b4d3d9 100644 --- a/src/components/common/messaging/embed/EmbedInvite.tsx +++ b/src/components/common/messaging/embed/EmbedInvite.tsx @@ -3,7 +3,7 @@ import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; import { RetrievedInvite } from "revolt-api/types/Invites"; import { Message } from "revolt.js/dist/maps/Messages"; -import styled from "styled-components"; +import styled, { css } from "styled-components"; import { useContext, useEffect, useState } from "preact/hooks"; @@ -21,7 +21,8 @@ import { takeError } from "../../../../context/revoltjs/util"; import ServerIcon from "../../../../components/common/ServerIcon"; import Button from "../../../../components/ui/Button"; import Preloader from "../../../ui/Preloader"; - +import { isTouchscreenDevice } from "../../../../lib/isTouchscreenDevice"; +import Overline from "../../../ui/Overline"; const EmbedInviteBase = styled.div` width: 400px; height: 80px; @@ -31,15 +32,37 @@ const EmbedInviteBase = styled.div` align-items: center; padding: 0 12px; margin-top: 2px; + ${() => + isTouchscreenDevice && + css` + flex-wrap: wrap; + height: 130px; + padding-top: 8px; + padding-bottom: 10px; + width: 100%; + > button { + width: 100%; + } + ` + } `; const EmbedInviteDetails = styled.div` flex-grow: 1; padding-left: 12px; + ${() => + isTouchscreenDevice && + css` + width: calc(100% - 55px); + ` + } `; const EmbedInviteName = styled.div` font-weight: bold; + line-height: 1rem; + max-height: 2rem; + overflow: hidden; `; const EmbedInviteMemberCount = styled.div` @@ -57,6 +80,7 @@ export function EmbedInvite(props: Props) { const code = props.code; const [processing, setProcessing] = useState(false); const [error, setError] = useState(undefined); + const [joinError, setJoinError] = useState(undefined); const [invite, setInvite] = useState( undefined, ); @@ -89,68 +113,70 @@ export function EmbedInvite(props: Props) { } return ( - - - - {invite.server_name} - - {invite.member_count.toLocaleString()} members - - - {processing ? ( -
- -
- ) : ( - - )} -
+ }}> + {client.servers.get(invite.server_id) ? "Joined" : "Join"} + + )} + + {joinError && } + ); } From f7f101f7b297bef567bd4e3da286dde6866903d8 Mon Sep 17 00:00:00 2001 From: TaiAurori <31465218+TaiAurori@users.noreply.github.com> Date: Tue, 21 Sep 2021 14:13:41 -0400 Subject: [PATCH 2/3] move imports --- src/components/common/messaging/embed/EmbedInvite.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/common/messaging/embed/EmbedInvite.tsx b/src/components/common/messaging/embed/EmbedInvite.tsx index e9b4d3d9..b71cf646 100644 --- a/src/components/common/messaging/embed/EmbedInvite.tsx +++ b/src/components/common/messaging/embed/EmbedInvite.tsx @@ -8,6 +8,7 @@ import styled, { css } from "styled-components"; import { useContext, useEffect, useState } from "preact/hooks"; import { defer } from "../../../../lib/defer"; +import { isTouchscreenDevice } from "../../../../lib/isTouchscreenDevice"; import { dispatch } from "../../../../redux"; @@ -20,9 +21,9 @@ import { takeError } from "../../../../context/revoltjs/util"; import ServerIcon from "../../../../components/common/ServerIcon"; import Button from "../../../../components/ui/Button"; -import Preloader from "../../../ui/Preloader"; -import { isTouchscreenDevice } from "../../../../lib/isTouchscreenDevice"; import Overline from "../../../ui/Overline"; +import Preloader from "../../../ui/Preloader"; + const EmbedInviteBase = styled.div` width: 400px; height: 80px; From 21122583aa129fe23544129f20faf1405d26a766 Mon Sep 17 00:00:00 2001 From: TaiAurori <31465218+TaiAurori@users.noreply.github.com> Date: Tue, 21 Sep 2021 14:41:57 -0400 Subject: [PATCH 3/3] singular form of "members" when only one member --- src/components/common/messaging/embed/EmbedInvite.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/messaging/embed/EmbedInvite.tsx b/src/components/common/messaging/embed/EmbedInvite.tsx index b71cf646..830c5695 100644 --- a/src/components/common/messaging/embed/EmbedInvite.tsx +++ b/src/components/common/messaging/embed/EmbedInvite.tsx @@ -124,7 +124,7 @@ export function EmbedInvite(props: Props) { {invite.server_name} - {invite.member_count.toLocaleString()} members + {invite.member_count.toLocaleString()} {invite.member_count === 1 ? "member" : "members"} {processing ? (