From f1ff06bc1d3dfb4d2ceff93d0793be9862ccfbe5 Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 6 Oct 2024 23:09:37 +0300 Subject: [PATCH] feed-styles-refactored --- src/components/Article/FullArticle.tsx | 3 +- src/components/Feed/Beside.tsx | 7 ++- .../Feed/{Group.scss => Group.module.scss} | 0 src/components/Feed/Group.tsx | 12 +++-- src/components/Feed/Row1.tsx | 8 +-- src/components/Feed/Row2.tsx | 3 +- src/components/Feed/Row3.tsx | 5 +- src/components/Feed/Row5.tsx | 5 +- src/components/Feed/RowShort.tsx | 3 +- src/components/Views/SearchView.tsx | 51 ++++++++++--------- 10 files changed, 53 insertions(+), 44 deletions(-) rename src/components/Feed/{Group.scss => Group.module.scss} (100%) diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index f11d302d..030dab97 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -36,6 +36,7 @@ import { CommentsTree } from './CommentsTree' import { SharePopup, getShareUrl } from './SharePopup' import { ShoutRatingControl } from './ShoutRatingControl' +import stylesFeed from '../Feed/Feed.module.scss' import stylesHeader from '../HeaderNav/Header.module.scss' import styles from './Article.module.scss' @@ -429,7 +430,7 @@ export const FullArticle = (props: Props) => { -
+
diff --git a/src/components/Feed/Beside.tsx b/src/components/Feed/Beside.tsx index 772054a8..bbf886a5 100644 --- a/src/components/Feed/Beside.tsx +++ b/src/components/Feed/Beside.tsx @@ -1,17 +1,16 @@ // TODO: additional entities list column + article -import type { Author, Shout, Topic } from '~/graphql/schema/core.gen' - import { clsx } from 'clsx' import { For, Show } from 'solid-js' import { useLocalize } from '~/context/localize' +import type { Author, Shout, Topic } from '~/graphql/schema/core.gen' import { AuthorBadge } from '../Author/AuthorBadge' import { TopicCard } from '../Topic/Card' import { Icon } from '../_shared/Icon' - import { ArticleCard } from './ArticleCard' import styles from './Beside.module.scss' +import stylesFeed from './Feed.module.scss' type Props = { title?: string @@ -31,7 +30,7 @@ export const Beside = (props: Props) => { return ( 0}> -
+
diff --git a/src/components/Feed/Group.scss b/src/components/Feed/Group.module.scss similarity index 100% rename from src/components/Feed/Group.scss rename to src/components/Feed/Group.module.scss diff --git a/src/components/Feed/Group.tsx b/src/components/Feed/Group.tsx index ceffa7f1..9193cefe 100644 --- a/src/components/Feed/Group.tsx +++ b/src/components/Feed/Group.tsx @@ -1,10 +1,12 @@ +import clsx from 'clsx' +import { For, Show } from 'solid-js' import type { JSX } from 'solid-js/jsx-runtime' import type { Shout } from '~/graphql/schema/core.gen' -import { For, Show } from 'solid-js' - import { ArticleCard } from './ArticleCard' -import './Group.scss' + +import stylesFeed from './Feed.module.scss' +import styles from './Group.module.scss' interface GroupProps { articles: Shout[] @@ -13,11 +15,11 @@ interface GroupProps { export default (props: GroupProps) => { return ( -
+
4}>
-
{props.header}
+
{props.header}
( -
+
diff --git a/src/components/Feed/Row2.tsx b/src/components/Feed/Row2.tsx index 4d757ef7..51df3471 100644 --- a/src/components/Feed/Row2.tsx +++ b/src/components/Feed/Row2.tsx @@ -3,6 +3,7 @@ import type { Shout } from '~/graphql/schema/core.gen' import { For, Show, createEffect, createSignal } from 'solid-js' import { ArticleCard } from './ArticleCard' +import stylesFeed from './Feed.module.scss' const columnSizes = ['col-md-12', 'col-md-8', 'col-md-16'] @@ -20,7 +21,7 @@ export const Row2 = (props: { return ( 0}> -
+
diff --git a/src/components/Feed/Row3.tsx b/src/components/Feed/Row3.tsx index 1de498d1..1742279d 100644 --- a/src/components/Feed/Row3.tsx +++ b/src/components/Feed/Row3.tsx @@ -4,6 +4,7 @@ import type { Shout } from '~/graphql/schema/core.gen' import { For, Show } from 'solid-js' import { ArticleCard } from './ArticleCard' +import stylesFeed from './Feed.module.scss' export const Row3 = (props: { articles: Shout[] @@ -14,11 +15,11 @@ export const Row3 = (props: { }) => { return ( 0}> -
+
-
{props.header}
+
{props.header}
{(a) => ( diff --git a/src/components/Feed/Row5.tsx b/src/components/Feed/Row5.tsx index d2db45bb..95e76167 100644 --- a/src/components/Feed/Row5.tsx +++ b/src/components/Feed/Row5.tsx @@ -1,10 +1,11 @@ +import clsx from 'clsx' import type { Shout } from '~/graphql/schema/core.gen' - import { ArticleCard } from './ArticleCard' +import stylesFeed from './Feed.module.scss' export const Row5 = (props: { articles: Shout[]; nodate?: boolean }) => { return ( -
+
diff --git a/src/components/Feed/RowShort.tsx b/src/components/Feed/RowShort.tsx index 1de0c9d2..197c08fd 100644 --- a/src/components/Feed/RowShort.tsx +++ b/src/components/Feed/RowShort.tsx @@ -2,10 +2,11 @@ import { For } from 'solid-js' import type { Shout } from '~/graphql/schema/core.gen' import { ArticleCard } from './ArticleCard' +import clsx from 'clsx' import styles from '~/styles/views/Feed.module.scss' export default (props: { articles: Shout[] }) => ( -
+
diff --git a/src/components/Views/SearchView.tsx b/src/components/Views/SearchView.tsx index 8a32a767..62db1f74 100644 --- a/src/components/Views/SearchView.tsx +++ b/src/components/Views/SearchView.tsx @@ -1,13 +1,15 @@ -import { For, Show, createSignal, onMount } from 'solid-js' - import { useSearchParams } from '@solidjs/router' -import { useFeed } from '~/context/feed' +import clsx from 'clsx' +import { For, Show, createSignal, onMount } from 'solid-js' +import { SHOUTS_PER_PAGE, useFeed } from '~/context/feed' import { useLocalize } from '~/context/localize' -import type { SearchResult } from '~/graphql/schema/core.gen' +import type { SearchResult, Shout } from '~/graphql/schema/core.gen' import { restoreScrollPosition, saveScrollPosition } from '~/utils/scroll' import { ArticleCard } from '../Feed/ArticleCard' +import { LoadMoreItems, LoadMoreWrapper } from '../_shared/LoadMoreWrapper' -import '~/styles/views/Search.module.scss' +import styles from '~/styles/views/Search.module.scss' +import stylesFeed from '../Feed/Feed.module.scss' type Props = { query: string @@ -31,19 +33,22 @@ export const SearchView = (props: Props) => { const loadMore = async () => { saveScrollPosition() + let result: Shout[] = [] if (query()) { console.log(query()) - const { hasMore } = await loadShoutsSearch({ + const { hasMore, newShouts } = await loadShoutsSearch({ text: query(), offset: offset(), limit: LOAD_MORE_PAGE_SIZE }) setIsLoadMoreButtonVisible(hasMore) setOffset(offset() + LOAD_MORE_PAGE_SIZE) + result = newShouts } else { console.warn('[SaerchView] no query found') } restoreScrollPosition() + return result as LoadMoreItems } onMount(() => { @@ -55,8 +60,8 @@ export const SearchView = (props: Props) => { // TODO: use score from the search results to sort by relevance return ( -
-
+
+
{ 0}>

{t('Publications')}

-
+
- - {(article) => ( -
- -
- )} -
- - - - +