From 11d3a6c27410f0561de243fced241dd0347370e0 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Fri, 29 Dec 2023 09:39:16 +0300 Subject: [PATCH] Markup for mobile fix-pack (#349) * mediaQuery context provider * Fix header styles * User list markup fix --- src/components/App.tsx | 25 +++-- .../AuthorBadge/AuthorBadge.module.scss | 1 - .../Author/AuthorBadge/AuthorBadge.tsx | 18 ++- .../Author/AuthorCard/AuthorCard.tsx | 5 +- src/components/Nav/Header/Header.module.scss | 4 +- src/components/Nav/Header/Header.tsx | 12 +- src/components/Nav/Modal/Modal.module.scss | 24 +++- src/components/Nav/Modal/Modal.tsx | 28 ++++- src/components/Nav/Topics/Topics.module.scss | 2 + .../Topic/TopicBadge/TopicBadge.module.scss | 49 ++++----- .../Topic/TopicBadge/TopicBadge.tsx | 103 +++++++++--------- src/components/Views/AllAuthors.module.scss | 5 + .../SearchField/SearchField.module.scss | 1 + src/context/mediaQuery.tsx | 31 ++++++ 14 files changed, 198 insertions(+), 110 deletions(-) create mode 100644 src/context/mediaQuery.tsx diff --git a/src/components/App.tsx b/src/components/App.tsx index f6a22fe1..7d3b3bdc 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -7,6 +7,7 @@ import { Dynamic } from 'solid-js/web' import { ConfirmProvider } from '../context/confirm' import { EditorProvider } from '../context/editor' import { LocalizeProvider } from '../context/localize' +import { MediaQueryProvider } from '../context/mediaQuery' import { NotificationsProvider } from '../context/notifications' import { SessionProvider } from '../context/session' import { SnackbarProvider } from '../context/snackbar' @@ -115,17 +116,19 @@ export const App = (props: Props) => { - - - - - - - - - - - + + + + + + + + + + + + + ) diff --git a/src/components/Author/AuthorBadge/AuthorBadge.module.scss b/src/components/Author/AuthorBadge/AuthorBadge.module.scss index f119cb5d..0863304e 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.module.scss +++ b/src/components/Author/AuthorBadge/AuthorBadge.module.scss @@ -2,7 +2,6 @@ align-items: flex-start; display: flex; gap: 1rem; - margin-bottom: 3rem; &.nameOnly { align-items: center; diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx index b744df32..af053079 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.tsx +++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx @@ -1,8 +1,9 @@ import { openPage } from '@nanostores/router' import { clsx } from 'clsx' -import { createMemo, createSignal, Match, Show, Switch } from 'solid-js' +import { createEffect, createMemo, createSignal, Match, Show, Switch } from 'solid-js' import { useLocalize } from '../../../context/localize' +import { useMediaQuery } from '../../../context/mediaQuery' import { useSession } from '../../../context/session' import { Author, FollowingEntity } from '../../../graphql/types.gen' import { router, useRouter } from '../../../stores/router' @@ -23,7 +24,14 @@ type Props = { nameOnly?: boolean } export const AuthorBadge = (props: Props) => { + const { mediaMatches } = useMediaQuery() + const [isMobileView, setIsMobileView] = createSignal(false) const [isSubscribing, setIsSubscribing] = createSignal(false) + + createEffect(() => { + setIsMobileView(!mediaMatches.sm) + }) + const { session, subscriptions, @@ -65,7 +73,7 @@ export const AuthorBadge = (props: Props) => {
{ fallback={
- + + ) } diff --git a/src/components/Views/AllAuthors.module.scss b/src/components/Views/AllAuthors.module.scss index e1f6f06f..94d4302c 100644 --- a/src/components/Views/AllAuthors.module.scss +++ b/src/components/Views/AllAuthors.module.scss @@ -75,4 +75,9 @@ .viewSwitcher { margin-bottom: 2rem; + width: 100%; + + @include media-breakpoint-down(sm) { + overflow-x: auto; + } } diff --git a/src/components/_shared/SearchField/SearchField.module.scss b/src/components/_shared/SearchField/SearchField.module.scss index 03811331..5f0ff538 100644 --- a/src/components/_shared/SearchField/SearchField.module.scss +++ b/src/components/_shared/SearchField/SearchField.module.scss @@ -2,6 +2,7 @@ display: flex; justify-content: flex-end; position: relative; + min-width: 100px; &.bordered { border: 2px solid var(--black-100); diff --git a/src/context/mediaQuery.tsx b/src/context/mediaQuery.tsx new file mode 100644 index 00000000..37a444e5 --- /dev/null +++ b/src/context/mediaQuery.tsx @@ -0,0 +1,31 @@ +import type { JSX } from 'solid-js' + +import { createBreakpoints } from '@solid-primitives/media' +import { createContext, useContext } from 'solid-js' + +const breakpoints = { + xs: '0', + sm: '576px', + md: '768px', + lg: '992px', + xl: '1200px', + xxl: '1400px', +} + +type MediaQueryContextType = { + mediaMatches: ReturnType +} + +const MediaQueryContext = createContext() + +export function useMediaQuery() { + return useContext(MediaQueryContext) +} + +export const MediaQueryProvider = (props: { children: JSX.Element }) => { + const mediaMatches = createBreakpoints(breakpoints) + + const value: MediaQueryContextType = { mediaMatches } + + return {props.children} +}