From 8e0e226ec6f9bcb6bcdb6a49751dcd4df411b4c1 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 4 Jul 2021 12:46:33 +0100 Subject: [PATCH 1/5] Fix: Defaults / dayjs will not always be present. --- src/context/Locale.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/context/Locale.tsx b/src/context/Locale.tsx index 0385745c..ea75394a 100644 --- a/src/context/Locale.tsx +++ b/src/context/Locale.tsx @@ -127,7 +127,7 @@ function Locale({ children, locale }: Props) { function transformLanguage(obj: { [key: string]: any }) { const dayjs = obj.dayjs; - const defaults = dayjs.defaults; + const defaults = dayjs?.defaults; const twelvehour = defaults?.twelvehour === 'yes' || true; const separator: '/' | '-' | '.' = defaults?.date_separator ?? '/'; From 4e28470d2dd23d8cb2aeb8e034f396dbaf4a2f92 Mon Sep 17 00:00:00 2001 From: nizune <9-nizune@users.noreply.gitlab.insrt.uk> Date: Sun, 4 Jul 2021 10:41:03 +0200 Subject: [PATCH 2/5] Fix: Small header fixes --- src/components/ui/Header.tsx | 2 +- src/pages/developer/Developer.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/ui/Header.tsx b/src/components/ui/Header.tsx index 37652397..d4e0e3f9 100644 --- a/src/components/ui/Header.tsx +++ b/src/components/ui/Header.tsx @@ -46,6 +46,6 @@ export default styled.div` ` } ${ props => props.borders && css` - border-end-start-radius: 8px; + border-start-start-radius: 8px; ` } `; diff --git a/src/pages/developer/Developer.tsx b/src/pages/developer/Developer.tsx index 1a392bc0..e8c3e187 100644 --- a/src/pages/developer/Developer.tsx +++ b/src/pages/developer/Developer.tsx @@ -4,6 +4,7 @@ import Header from "../../components/ui/Header"; import PaintCounter from "../../lib/PaintCounter"; import { AppContext } from "../../context/revoltjs/RevoltClient"; import { useUserPermission } from "../../context/revoltjs/hooks"; +import { Wrench } from "@styled-icons/boxicons-solid"; export default function Developer() { // const voice = useContext(VoiceContext); @@ -12,7 +13,10 @@ export default function Developer() { return (
-
Developer Tab
+
+ + Developer Tab +
From 1a08f50997c3900dc1c6a821242bb04e85b00729 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 4 Jul 2021 09:52:34 +0100 Subject: [PATCH 3/5] Move details styling into its own component. --- src/components/ui/Details.tsx | 28 ++++++++++++++++++++++++++++ src/lib/TextAreaAutoSize.tsx | 1 + src/pages/friends/Friend.module.scss | 27 --------------------------- src/pages/friends/Friends.tsx | 5 +++-- 4 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 src/components/ui/Details.tsx diff --git a/src/components/ui/Details.tsx b/src/components/ui/Details.tsx new file mode 100644 index 00000000..8bf47059 --- /dev/null +++ b/src/components/ui/Details.tsx @@ -0,0 +1,28 @@ +import styled from "styled-components"; + +export default styled.details` + summary { + outline: none; + list-style: none; + transition: .2s opacity; + + &::marker, &::-webkit-details-marker { + display: none; + } + + svg { + flex-shrink: 0; + transition: .2s ease transform; + } + } + + &:not([open]) { + summary { + opacity: .7; + } + + summary svg { + transform: rotateZ(-90deg); + } + } +`; diff --git a/src/lib/TextAreaAutoSize.tsx b/src/lib/TextAreaAutoSize.tsx index bfc515b0..c6026554 100644 --- a/src/lib/TextAreaAutoSize.tsx +++ b/src/lib/TextAreaAutoSize.tsx @@ -23,6 +23,7 @@ export default function TextAreaAutoSize(props: TextAreaAutoSizeProps) { const ref = useRef(); useEffect(() => { + if (isTouchscreenDevice) return; autoFocus && ref.current.focus(); }, [value]); diff --git a/src/pages/friends/Friend.module.scss b/src/pages/friends/Friend.module.scss index af867b28..fe103bf7 100644 --- a/src/pages/friends/Friend.module.scss +++ b/src/pages/friends/Friend.module.scss @@ -39,33 +39,6 @@ } } - details { - summary { - outline: none; - list-style: none; - transition: .2s opacity; - - &::marker, &::-webkit-details-marker { - display: none; - } - - svg { - flex-shrink: 0; - transition: .2s ease transform; - } - } - - &:not([open]) { - summary { - opacity: .7; - } - - summary svg { - transform: rotateZ(-90deg); - } - } - } - &[data-empty="true"] { img { height: 120px; diff --git a/src/pages/friends/Friends.tsx b/src/pages/friends/Friends.tsx index 7ccf4761..607f6d8f 100644 --- a/src/pages/friends/Friends.tsx +++ b/src/pages/friends/Friends.tsx @@ -14,6 +14,7 @@ import { ChevronDown, ChevronRight, ListPlus } from "@styled-icons/boxicons-regu import { UserDetail, MessageAdd, UserPlus } from "@styled-icons/boxicons-solid"; import { TextReact } from "../../lib/i18n"; import { Children } from "../../types/Preact"; +import Details from "../../components/ui/Details"; export default function Friends() { const { openScreen } = useIntermediate(); @@ -112,7 +113,7 @@ export default function Friends() { if (list.length === 0) return; return ( -
+
@@ -122,7 +123,7 @@ export default function Friends() { { list.map(x => ) } -
+
) }) } From 49e49f3952d2232d9f449abd496759479acedcc6 Mon Sep 17 00:00:00 2001 From: nizune <9-nizune@users.noreply.gitlab.insrt.uk> Date: Sun, 4 Jul 2021 13:41:52 +0200 Subject: [PATCH 4/5] Fix: Small changes to profile context menu --- src/components/navigation/right/MemberSidebar.tsx | 1 + src/pages/friends/Friend.module.scss | 1 - src/pages/friends/Friends.tsx | 2 +- src/pages/settings/server/Roles.tsx | 2 +- src/styles/_context-menu.scss | 8 +++++++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/navigation/right/MemberSidebar.tsx b/src/components/navigation/right/MemberSidebar.tsx index 96b3728f..e8cc3601 100644 --- a/src/components/navigation/right/MemberSidebar.tsx +++ b/src/components/navigation/right/MemberSidebar.tsx @@ -2,6 +2,7 @@ import { Text } from "preact-i18n"; import { useContext, useEffect, useState } from "preact/hooks"; import { User } from "revolt.js"; +import Details from "../../../components/ui/Details"; import Category from "../../ui/Category"; import { useParams } from "react-router"; import { UserButton } from "../items/ButtonItem"; diff --git a/src/pages/friends/Friend.module.scss b/src/pages/friends/Friend.module.scss index fe103bf7..d6338774 100644 --- a/src/pages/friends/Friend.module.scss +++ b/src/pages/friends/Friend.module.scss @@ -118,7 +118,6 @@ .divider { width: 1px; height: 24px; - margin: 0 8px; background: var(--primary-background); } diff --git a/src/pages/friends/Friends.tsx b/src/pages/friends/Friends.tsx index 607f6d8f..284641e7 100644 --- a/src/pages/friends/Friends.tsx +++ b/src/pages/friends/Friends.tsx @@ -57,7 +57,7 @@ export default function Friends() {
{/* openScreen({ id: 'special_input', type: 'create_group' })}> - +
*/} diff --git a/src/pages/settings/server/Roles.tsx b/src/pages/settings/server/Roles.tsx index db3887c3..0fea1988 100644 --- a/src/pages/settings/server/Roles.tsx +++ b/src/pages/settings/server/Roles.tsx @@ -49,7 +49,7 @@ export function Roles({ server }: Props) {

- + openScreen({ id: 'special_input', type: 'create_role', server: server._id, callback: id => setRole(id) })} />
{ [ 'default', ...Object.keys(roles) ] diff --git a/src/styles/_context-menu.scss b/src/styles/_context-menu.scss index 8f33978b..d5f15ee1 100644 --- a/src/styles/_context-menu.scss +++ b/src/styles/_context-menu.scss @@ -51,7 +51,13 @@ } .status { - font-size: .6rem; + max-width: 132px; + font-size: .625rem; + color: var(--secondary-foreground); + + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; } } From 098e28113b49b25237d786bf79a793e43e812f68 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 4 Jul 2021 13:02:32 +0100 Subject: [PATCH 5/5] Fix: Handle defaults before transforming languages. Remove Hardcore Mode. --- src/context/Locale.tsx | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/context/Locale.tsx b/src/context/Locale.tsx index ea75394a..4afc9f50 100644 --- a/src/context/Locale.tsx +++ b/src/context/Locale.tsx @@ -43,7 +43,6 @@ export enum Language { PIRATE = "pr", BOTTOM = "bottom", PIGLATIN = "piglatin", - HARDCORE = "hardcore", } export interface LanguageEntry { @@ -107,13 +106,6 @@ export const Languages: { [key in Language]: LanguageEntry } = { dayjs: "en-gb", alt: true }, - hardcore: { - display: "Hardcore Mode", - emoji: "🔥", - i18n: "hardcore", - dayjs: "en-gb", - alt: true - }, }; interface Props { @@ -125,9 +117,11 @@ function Locale({ children, locale }: Props) { const [defns, setDefinition] = useState(definition); const lang = Languages[locale]; - function transformLanguage(obj: { [key: string]: any }) { + function transformLanguage(source: { [key: string]: any }) { + const obj = defaultsDeep(source, definition); + const dayjs = obj.dayjs; - const defaults = dayjs?.defaults; + const defaults = dayjs.defaults; const twelvehour = defaults?.twelvehour === 'yes' || true; const separator: '/' | '-' | '.' = defaults?.date_separator ?? '/'; @@ -149,10 +143,10 @@ function Locale({ children, locale }: Props) { useEffect(() => { if (locale === "en") { - transformLanguage(definition); - setDefinition(definition); + const defn = transformLanguage(definition); + setDefinition(defn); dayjs.locale("en"); - dayjs.updateLocale('en', { calendar: definition.dayjs }); + dayjs.updateLocale('en', { calendar: defn.dayjs }); return; } @@ -164,8 +158,7 @@ function Locale({ children, locale }: Props) { import(`../../external/lang/${lang.i18n}.json`).then( async (lang_file) => { - const defn = lang_file.default; - transformLanguage(defn); + const defn = transformLanguage(lang_file.default); const target = lang.dayjs ?? lang.i18n; const dayjs_locale = await import(`../../node_modules/dayjs/esm/locale/${target}.js`); @@ -174,7 +167,7 @@ function Locale({ children, locale }: Props) { } dayjs.locale(dayjs_locale.default); - setDefinition(defaultsDeep(defn, definition)); + setDefinition(defn); } ); }, [locale, lang]);