diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 19c2c453..7dfc69c2 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,41 +1,41 @@ module.exports = { - plugins: ['@typescript-eslint', 'import', 'sonarjs', 'unicorn', 'promise', 'solid', 'jest'], + plugins: ["@typescript-eslint", "import", "sonarjs", "unicorn", "promise", "solid", "jest"], extends: [ - 'eslint:recommended', - 'plugin:import/recommended', - 'plugin:import/typescript', - 'prettier', - 'plugin:sonarjs/recommended', - 'plugin:unicorn/recommended', - 'plugin:promise/recommended', - 'plugin:solid/recommended', - 'plugin:jest/recommended' + "eslint:recommended", + "plugin:import/recommended", + "plugin:import/typescript", + "prettier", + "plugin:sonarjs/recommended", + "plugin:unicorn/recommended", + "plugin:promise/recommended", + "plugin:solid/recommended", + "plugin:jest/recommended" ], overrides: [ { - files: ['**/*.ts', '**/*.tsx'], - parser: '@typescript-eslint/parser', + files: ["**/*.ts", "**/*.tsx"], + parser: "@typescript-eslint/parser", parserOptions: { ecmaVersion: 2021, ecmaFeatures: { jsx: true }, - sourceType: 'module', - project: './tsconfig.json' + sourceType: "module", + project: "./tsconfig.json" }, extends: [ - 'plugin:@typescript-eslint/recommended' + "plugin:@typescript-eslint/recommended" // Maybe one day... // 'plugin:@typescript-eslint/recommended-requiring-type-checking' ], rules: { - '@typescript-eslint/no-unused-vars': [ - 'warn', + "@typescript-eslint/no-unused-vars": [ + "warn", { - argsIgnorePattern: '^_' + argsIgnorePattern: "^_" } ], - '@typescript-eslint/no-non-null-assertion': 'error', + "@typescript-eslint/no-non-null-assertion": "error", // TODO: Remove any usage and enable - '@typescript-eslint/no-explicit-any': 'off' + "@typescript-eslint/no-explicit-any": "off" } } ], @@ -47,42 +47,60 @@ module.exports = { globals: {}, rules: { // Solid - 'solid/reactivity': 'off', // FIXME - 'solid/no-innerhtml': 'off', + "solid/reactivity": "off", // FIXME + "solid/no-innerhtml": "off", /** Unicorn **/ - 'unicorn/no-null': 'off', - 'unicorn/filename-case': 'off', - 'unicorn/no-array-for-each': 'off', - 'unicorn/no-array-reduce': 'off', - 'unicorn/prefer-string-replace-all': 'warn', - 'unicorn/prevent-abbreviations': 'off', - 'unicorn/prefer-module': 'off', - 'unicorn/import-style': 'off', - 'unicorn/numeric-separators-style': 'off', - 'unicorn/prefer-node-protocol': 'off', - 'unicorn/prefer-dom-node-append': 'off', // FIXME - 'unicorn/prefer-top-level-await': 'warn', - 'unicorn/consistent-function-scoping': 'warn', - 'unicorn/no-array-callback-reference': 'warn', - 'unicorn/no-array-method-this-argument': 'warn', - 'unicorn/no-for-loop': 'off', + "unicorn/no-null": "off", + "unicorn/filename-case": "off", + "unicorn/no-array-for-each": "off", + "unicorn/no-array-reduce": "off", + "unicorn/prefer-string-replace-all": "warn", + "unicorn/prevent-abbreviations": "off", + "unicorn/prefer-module": "off", + "unicorn/import-style": "off", + "unicorn/numeric-separators-style": "off", + "unicorn/prefer-node-protocol": "off", + "unicorn/prefer-dom-node-append": "off", // FIXME + "unicorn/prefer-top-level-await": "warn", + "unicorn/consistent-function-scoping": "warn", + "unicorn/no-array-callback-reference": "warn", + "unicorn/no-array-method-this-argument": "warn", + "unicorn/no-for-loop": "off", - 'sonarjs/no-duplicate-string': ['warn', { threshold: 5 }], + "sonarjs/no-duplicate-string": ["warn", { threshold: 5 }], // Promise // 'promise/catch-or-return': 'off', // Should be enabled - 'promise/always-return': 'off', + "promise/always-return": "off", - eqeqeq: 'error', - 'no-param-reassign': 'error', - 'no-nested-ternary': 'error', - 'no-shadow': 'error' + eqeqeq: "error", + "no-param-reassign": "error", + "no-nested-ternary": "error", + "no-shadow": "error", + + "import/order": ["warn", { + groups: ["type", "builtin", "external", "internal", "parent", "sibling", "index"], + distinctGroup: false, + pathGroups: [ + { + pattern: "*.scss", + patternOptions: { matchBase: true }, + group: "index", + position: "after" + } + ], + "newlines-between": "always", + alphabetize: { + order: "asc", + caseInsensitive: true + } + }] }, settings: { - 'import/resolver': { + "import/resolver": { typescript: true, node: true } } -} +}; diff --git a/.prettierrc.json b/.prettierrc.json index 0126822f..91956d70 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -4,7 +4,6 @@ "singleQuote": true, "proseWrap": "always", "printWidth": 108, - "trailingComma": "none", "plugins": [], "overrides": [ { diff --git a/api/edge-ssr.js b/api/edge-ssr.js index c810ed9b..113dd20a 100644 --- a/api/edge-ssr.js +++ b/api/edge-ssr.js @@ -1,7 +1,7 @@ import { renderPage } from 'vike/server' export const config = { - runtime: 'edge' + runtime: 'edge', } export default async function handler(request) { const { url, cookies } = request diff --git a/api/feedback.js b/api/feedback.js index 51f1d0fa..592ebdfa 100644 --- a/api/feedback.js +++ b/api/feedback.js @@ -15,7 +15,7 @@ export default async function handler(req, res) { from: 'Discours Feedback Robot ', to: 'welcome@discours.io', subject, - text + text, } try { diff --git a/api/newsletter.js b/api/newsletter.js index 49d99440..b8db4cb3 100644 --- a/api/newsletter.js +++ b/api/newsletter.js @@ -13,18 +13,18 @@ export default async (req, res) => { const response = await mg.lists.members.createMember('newsletter@discours.io', { address: email, subscribed: true, - upsert: 'yes' + upsert: 'yes', }) return res.status(200).json({ success: true, message: 'Email was added to newsletter list', - response: JSON.stringify(response) + response: JSON.stringify(response), }) } catch (error) { return res.status(400).json({ success: false, - message: error.message + message: error.message, }) } } diff --git a/src/components/App.tsx b/src/components/App.tsx index 2ad01f87..6cbfdb64 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,18 +1,15 @@ -import { hideModal, MODALS, showModal } from '../stores/ui' +import type { PageProps, RootSearchParams } from '../pages/types' + +import { Meta, MetaProvider } from '@solidjs/meta' import { Component, createEffect, createMemo } from 'solid-js' -import { ROUTES, useRouter } from '../stores/router' import { Dynamic } from 'solid-js/web' -import type { PageProps, RootSearchParams } from '../pages/types' -import { HomePage } from '../pages/index.page' -import { AllTopicsPage } from '../pages/allTopics.page' -import { TopicPage } from '../pages/topic.page' -import { AllAuthorsPage } from '../pages/allAuthors.page' -import { AuthorPage } from '../pages/author.page' -import { FeedPage } from '../pages/feed.page' -import { ArticlePage } from '../pages/article.page' -import { SearchPage } from '../pages/search.page' -import { FourOuFourPage } from '../pages/fourOuFour.page' +import { ConfirmProvider } from '../context/confirm' +import { EditorProvider } from '../context/editor' +import { LocalizeProvider } from '../context/localize' +import { NotificationsProvider } from '../context/notifications' +import { SessionProvider } from '../context/session' +import { SnackbarProvider } from '../context/snackbar' import { DiscussionRulesPage } from '../pages/about/discussionRules.page' import { DogmaPage } from '../pages/about/dogma.page' import { GuidePage } from '../pages/about/guide.page' @@ -23,22 +20,26 @@ import { PrinciplesPage } from '../pages/about/principles.page' import { ProjectsPage } from '../pages/about/projects.page' import { TermsOfUsePage } from '../pages/about/termsOfUse.page' import { ThanksPage } from '../pages/about/thanks.page' -import { CreatePage } from '../pages/create.page' -import { EditPage } from '../pages/edit.page' +import { AllAuthorsPage } from '../pages/allAuthors.page' +import { AllTopicsPage } from '../pages/allTopics.page' +import { ArticlePage } from '../pages/article.page' +import { AuthorPage } from '../pages/author.page' import { ConnectPage } from '../pages/connect.page' -import { InboxPage } from '../pages/inbox.page' -import { ExpoPage } from '../pages/expo/expo.page' -import { SessionProvider } from '../context/session' -import { ProfileSettingsPage } from '../pages/profile/profileSettings.page' -import { ProfileSecurityPage } from '../pages/profile/profileSecurity.page' -import { ProfileSubscriptionsPage } from '../pages/profile/profileSubscriptions.page' +import { CreatePage } from '../pages/create.page' import { DraftsPage } from '../pages/drafts.page' -import { SnackbarProvider } from '../context/snackbar' -import { LocalizeProvider } from '../context/localize' -import { ConfirmProvider } from '../context/confirm' -import { EditorProvider } from '../context/editor' -import { NotificationsProvider } from '../context/notifications' -import { Meta, MetaProvider } from '@solidjs/meta' +import { EditPage } from '../pages/edit.page' +import { ExpoPage } from '../pages/expo/expo.page' +import { FeedPage } from '../pages/feed.page' +import { FourOuFourPage } from '../pages/fourOuFour.page' +import { InboxPage } from '../pages/inbox.page' +import { HomePage } from '../pages/index.page' +import { ProfileSecurityPage } from '../pages/profile/profileSecurity.page' +import { ProfileSettingsPage } from '../pages/profile/profileSettings.page' +import { ProfileSubscriptionsPage } from '../pages/profile/profileSubscriptions.page' +import { SearchPage } from '../pages/search.page' +import { TopicPage } from '../pages/topic.page' +import { ROUTES, useRouter } from '../stores/router' +import { hideModal, MODALS, showModal } from '../stores/ui' // TODO: lazy load // const SomePage = lazy(() => import('./Pages/SomePage')) @@ -80,7 +81,7 @@ const pagesMap: Record> = { profileSettings: ProfileSettingsPage, profileSecurity: ProfileSecurityPage, profileSubscriptions: ProfileSubscriptionsPage, - fourOuFour: FourOuFourPage + fourOuFour: FourOuFourPage, } export const App = (props: PageProps) => { diff --git a/src/components/Article/AudioHeader/AudioHeader.tsx b/src/components/Article/AudioHeader/AudioHeader.tsx index ac8f38d4..af1541a0 100644 --- a/src/components/Article/AudioHeader/AudioHeader.tsx +++ b/src/components/Article/AudioHeader/AudioHeader.tsx @@ -1,11 +1,13 @@ import { clsx } from 'clsx' -import styles from './AudioHeader.module.scss' -import { MediaItem } from '../../../pages/types' import { createSignal, Show } from 'solid-js' -import { Icon } from '../../_shared/Icon' + import { Topic } from '../../../graphql/types.gen' -import { CardTopic } from '../../Feed/CardTopic' +import { MediaItem } from '../../../pages/types' +import { Icon } from '../../_shared/Icon' import { Image } from '../../_shared/Image' +import { CardTopic } from '../../Feed/CardTopic' + +import styles from './AudioHeader.module.scss' type Props = { title: string diff --git a/src/components/Article/AudioPlayer/AudioPlayer.tsx b/src/components/Article/AudioPlayer/AudioPlayer.tsx index eb5b5c2c..93ec8c52 100644 --- a/src/components/Article/AudioPlayer/AudioPlayer.tsx +++ b/src/components/Article/AudioPlayer/AudioPlayer.tsx @@ -1,8 +1,11 @@ import { createEffect, createMemo, createSignal, on, onMount, Show } from 'solid-js' + +import { MediaItem } from '../../../pages/types' + import { PlayerHeader } from './PlayerHeader' import { PlayerPlaylist } from './PlayerPlaylist' + import styles from './AudioPlayer.module.scss' -import { MediaItem } from '../../../pages/types' type Props = { media: MediaItem[] @@ -35,8 +38,8 @@ export const AudioPlayer = (props: Props) => { () => { setCurrentTrackDuration(0) }, - { defer: true } - ) + { defer: true }, + ), ) const handlePlayMedia = async (trackIndex: number) => { @@ -131,7 +134,7 @@ export const AudioPlayer = (props: Props) => {
diff --git a/src/components/Article/AudioPlayer/PlayerHeader.tsx b/src/components/Article/AudioPlayer/PlayerHeader.tsx index ff5019ed..eb5f7502 100644 --- a/src/components/Article/AudioPlayer/PlayerHeader.tsx +++ b/src/components/Article/AudioPlayer/PlayerHeader.tsx @@ -1,11 +1,11 @@ -import { createSignal, Show } from 'solid-js' import { clsx } from 'clsx' +import { createSignal, Show } from 'solid-js' -import { useOutsideClickHandler } from '../../../utils/useOutsideClickHandler' - -import { Icon } from '../../_shared/Icon' -import styles from './AudioPlayer.module.scss' import { MediaItem } from '../../../pages/types' +import { useOutsideClickHandler } from '../../../utils/useOutsideClickHandler' +import { Icon } from '../../_shared/Icon' + +import styles from './AudioPlayer.module.scss' type Props = { onPlayMedia: () => void @@ -18,7 +18,7 @@ type Props = { export const PlayerHeader = (props: Props) => { const volumeContainerRef: { current: HTMLDivElement } = { - current: null + current: null, } const [isVolumeBarOpened, setIsVolumeBarOpened] = createSignal(false) @@ -30,7 +30,7 @@ export const PlayerHeader = (props: Props) => { useOutsideClickHandler({ containerRef: volumeContainerRef, predicate: () => isVolumeBarOpened(), - handler: () => toggleVolumeBar() + handler: () => toggleVolumeBar(), }) return ( @@ -42,7 +42,7 @@ export const PlayerHeader = (props: Props) => { onClick={props.onPlayMedia} class={clsx( styles.playButton, - props.isPlaying ? styles.playButtonInvertPause : styles.playButtonInvertPlay + props.isPlaying ? styles.playButtonInvertPause : styles.playButtonInvertPlay, )} aria-label="Play" data-playing="false" diff --git a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx index 7f456f8b..1af16c7e 100644 --- a/src/components/Article/AudioPlayer/PlayerPlaylist.tsx +++ b/src/components/Article/AudioPlayer/PlayerPlaylist.tsx @@ -1,13 +1,15 @@ import { createSignal, For, Show } from 'solid-js' -import { SharePopup, getShareUrl } from '../SharePopup' -import { getDescription } from '../../../utils/meta' + import { useLocalize } from '../../../context/localize' -import { Popover } from '../../_shared/Popover' -import { Icon } from '../../_shared/Icon' -import styles from './AudioPlayer.module.scss' -import { GrowingTextarea } from '../../_shared/GrowingTextarea' import { MediaItem } from '../../../pages/types' +import { getDescription } from '../../../utils/meta' +import { GrowingTextarea } from '../../_shared/GrowingTextarea' +import { Icon } from '../../_shared/Icon' +import { Popover } from '../../_shared/Popover' import SimplifiedEditor from '../../Editor/SimplifiedEditor' +import { SharePopup, getShareUrl } from '../SharePopup' + +import styles from './AudioPlayer.module.scss' type Props = { media: MediaItem[] diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index 4bb7bc2f..2a8f6f7c 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -1,24 +1,22 @@ -import { Show, createMemo, createSignal, For, lazy, Suspense } from 'solid-js' -import { clsx } from 'clsx' import { getPagePath } from '@nanostores/router' +import { clsx } from 'clsx' +import { Show, createMemo, createSignal, For, lazy, Suspense } from 'solid-js' -import { Userpic } from '../../Author/Userpic' -import { CommentRatingControl } from '../CommentRatingControl' -import { CommentDate } from '../CommentDate' -import { ShowIfAuthenticated } from '../../_shared/ShowIfAuthenticated' -import { Icon } from '../../_shared/Icon' - -import { useSession } from '../../../context/session' +import { useConfirm } from '../../../context/confirm' import { useLocalize } from '../../../context/localize' import { useReactions } from '../../../context/reactions' +import { useSession } from '../../../context/session' import { useSnackbar } from '../../../context/snackbar' -import { useConfirm } from '../../../context/confirm' - import { Author, Reaction, ReactionKind } from '../../../graphql/types.gen' import { router } from '../../../stores/router' +import { Icon } from '../../_shared/Icon' +import { ShowIfAuthenticated } from '../../_shared/ShowIfAuthenticated' +import { AuthorLink } from '../../Author/AhtorLink' +import { Userpic } from '../../Author/Userpic' +import { CommentDate } from '../CommentDate' +import { CommentRatingControl } from '../CommentRatingControl' import styles from './Comment.module.scss' -import { AuthorLink } from '../../Author/AhtorLink' const SimplifiedEditor = lazy(() => import('../../Editor/SimplifiedEditor')) @@ -43,15 +41,15 @@ export const Comment = (props: Props) => { const { session } = useSession() const { - actions: { createReaction, deleteReaction, updateReaction } + actions: { createReaction, deleteReaction, updateReaction }, } = useReactions() const { - actions: { showConfirm } + actions: { showConfirm }, } = useConfirm() const { - actions: { showSnackbar } + actions: { showSnackbar }, } = useSnackbar() const isCommentAuthor = createMemo(() => props.comment.createdBy?.slug === session()?.user?.slug) @@ -65,7 +63,7 @@ export const Comment = (props: Props) => { confirmBody: t('Are you sure you want to delete this comment?'), confirmButtonLabel: t('Delete'), confirmButtonVariant: 'danger', - declineButtonVariant: 'primary' + declineButtonVariant: 'primary', }) if (isConfirmed) { @@ -86,7 +84,7 @@ export const Comment = (props: Props) => { kind: ReactionKind.Comment, replyTo: props.comment.id, body: value, - shout: props.comment.shout.id + shout: props.comment.shout.id, }) setClearEditor(true) setIsReplyVisible(false) @@ -107,7 +105,7 @@ export const Comment = (props: Props) => { await updateReaction(props.comment.id, { kind: ReactionKind.Comment, body: value, - shout: props.comment.shout.id + shout: props.comment.shout.id, }) setEditMode(false) setLoading(false) @@ -122,7 +120,7 @@ export const Comment = (props: Props) => {
  • props.lastSeen + [styles.isNew]: !isCommentAuthor() && createdAt > props.lastSeen, })} > @@ -135,7 +133,7 @@ export const Comment = (props: Props) => { name={comment().createdBy.name} userpic={comment().createdBy.userpic} class={clsx({ - [styles.compactUserpic]: props.compact + [styles.compactUserpic]: props.compact, })} /> diff --git a/src/components/Article/CommentDate/CommentDate.tsx b/src/components/Article/CommentDate/CommentDate.tsx index 7a31c5b3..3cca2d0e 100644 --- a/src/components/Article/CommentDate/CommentDate.tsx +++ b/src/components/Article/CommentDate/CommentDate.tsx @@ -1,8 +1,11 @@ -import { Show } from 'solid-js' -import { Icon } from '../../_shared/Icon' import type { Reaction } from '../../../graphql/types.gen' -import { useLocalize } from '../../../context/localize' + import { clsx } from 'clsx' +import { Show } from 'solid-js' + +import { useLocalize } from '../../../context/localize' +import { Icon } from '../../_shared/Icon' + import styles from './CommentDate.module.scss' type Props = { @@ -27,7 +30,7 @@ export const CommentDate = (props: Props) => {
    diff --git a/src/components/Article/CommentRatingControl.tsx b/src/components/Article/CommentRatingControl.tsx index a7a5895b..4f3d52f8 100644 --- a/src/components/Article/CommentRatingControl.tsx +++ b/src/components/Article/CommentRatingControl.tsx @@ -1,16 +1,19 @@ -import { clsx } from 'clsx' -import styles from './CommentRatingControl.module.scss' import type { Reaction } from '../../graphql/types.gen' -import { ReactionKind } from '../../graphql/types.gen' -import { useSession } from '../../context/session' -import { useReactions } from '../../context/reactions' + +import { clsx } from 'clsx' import { createMemo } from 'solid-js' + +import { useLocalize } from '../../context/localize' +import { useReactions } from '../../context/reactions' +import { useSession } from '../../context/session' +import { useSnackbar } from '../../context/snackbar' +import { ReactionKind } from '../../graphql/types.gen' import { loadShout } from '../../stores/zine/articles' import { Popup } from '../_shared/Popup' -import { useLocalize } from '../../context/localize' -import { useSnackbar } from '../../context/snackbar' import { VotersList } from '../_shared/VotersList' +import styles from './CommentRatingControl.module.scss' + type Props = { comment: Reaction } @@ -19,11 +22,11 @@ export const CommentRatingControl = (props: Props) => { const { t } = useLocalize() const { user } = useSession() const { - actions: { showSnackbar } + actions: { showSnackbar }, } = useSnackbar() const { reactionEntities, - actions: { createReaction, deleteReaction, loadReactionsBy } + actions: { createReaction, deleteReaction, loadReactionsBy }, } = useReactions() const checkReaction = (reactionKind: ReactionKind) => @@ -32,7 +35,7 @@ export const CommentRatingControl = (props: Props) => { r.kind === reactionKind && r.createdBy.slug === user()?.slug && r.shout.id === props.comment.shout.id && - r.replyTo === props.comment.id + r.replyTo === props.comment.id, ) const isUpvoted = createMemo(() => checkReaction(ReactionKind.Like)) const isDownvoted = createMemo(() => checkReaction(ReactionKind.Dislike)) @@ -43,8 +46,8 @@ export const CommentRatingControl = (props: Props) => { (r) => [ReactionKind.Like, ReactionKind.Dislike].includes(r.kind) && r.shout.id === props.comment.shout.id && - r.replyTo === props.comment.id - ) + r.replyTo === props.comment.id, + ), ) const deleteCommentReaction = async (reactionKind: ReactionKind) => { @@ -53,7 +56,7 @@ export const CommentRatingControl = (props: Props) => { r.kind === reactionKind && r.createdBy.slug === user()?.slug && r.shout.id === props.comment.shout.id && - r.replyTo === props.comment.id + r.replyTo === props.comment.id, ) return deleteReaction(reactionToDelete.id) } @@ -68,7 +71,7 @@ export const CommentRatingControl = (props: Props) => { await createReaction({ kind: isUpvote ? ReactionKind.Like : ReactionKind.Dislike, shout: props.comment.shout.id, - replyTo: props.comment.id + replyTo: props.comment.id, }) } } catch { @@ -77,7 +80,7 @@ export const CommentRatingControl = (props: Props) => { await loadShout(props.comment.shout.slug) await loadReactionsBy({ - by: { shout: props.comment.shout.slug } + by: { shout: props.comment.shout.slug }, }) } @@ -88,7 +91,7 @@ export const CommentRatingControl = (props: Props) => { disabled={!canVote() || !user()} onClick={() => handleRatingChange(true)} class={clsx(styles.commentRatingControl, styles.commentRatingControlUp, { - [styles.voted]: isUpvoted() + [styles.voted]: isUpvoted(), })} /> {
    0, - [styles.commentRatingNegative]: props.comment.stat.rating < 0 + [styles.commentRatingNegative]: props.comment.stat.rating < 0, })} > {props.comment.stat.rating || 0} @@ -114,7 +117,7 @@ export const CommentRatingControl = (props: Props) => { disabled={!canVote() || !user()} onClick={() => handleRatingChange(false)} class={clsx(styles.commentRatingControl, styles.commentRatingControlDown, { - [styles.voted]: isDownvoted() + [styles.voted]: isDownvoted(), })} />
    diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx index f17f1f74..649993f3 100644 --- a/src/components/Article/CommentsTree.tsx +++ b/src/components/Article/CommentsTree.tsx @@ -1,16 +1,19 @@ -import { Show, createMemo, createSignal, onMount, For } from 'solid-js' -import { Comment } from './Comment' -import styles from './Article.module.scss' import { clsx } from 'clsx' -import { Author, Reaction, ReactionKind } from '../../graphql/types.gen' -import { useSession } from '../../context/session' -import { Button } from '../_shared/Button' -import { useReactions } from '../../context/reactions' -import { byCreated } from '../../utils/sortby' -import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated' +import { Show, createMemo, createSignal, onMount, For } from 'solid-js' + import { useLocalize } from '../../context/localize' +import { useReactions } from '../../context/reactions' +import { useSession } from '../../context/session' +import { Author, Reaction, ReactionKind } from '../../graphql/types.gen' +import { byCreated } from '../../utils/sortby' +import { Button } from '../_shared/Button' +import { ShowIfAuthenticated } from '../_shared/ShowIfAuthenticated' import SimplifiedEditor from '../Editor/SimplifiedEditor' +import { Comment } from './Comment' + +import styles from './Article.module.scss' + type CommentsOrder = 'createdAt' | 'rating' | 'newOnly' const sortCommentsByRating = (a: Reaction, b: Reaction): -1 | 0 | 1 => { @@ -48,11 +51,11 @@ export const CommentsTree = (props: Props) => { const { reactionEntities, - actions: { createReaction } + actions: { createReaction }, } = useReactions() const comments = createMemo(() => - Object.values(reactionEntities).filter((reaction) => reaction.kind === 'COMMENT') + Object.values(reactionEntities).filter((reaction) => reaction.kind === 'COMMENT'), ) const sortedComments = createMemo(() => { @@ -96,7 +99,7 @@ export const CommentsTree = (props: Props) => { await createReaction({ kind: ReactionKind.Comment, body: value, - shout: props.shoutId + shout: props.shoutId, }) setClearEditor(true) } catch (error) { @@ -154,7 +157,7 @@ export const CommentsTree = (props: Props) => { a.slug === reaction.createdBy.slug) + props.articleAuthors.some((a) => a.slug === reaction.createdBy.slug), )} comment={reaction} clickedReply={(id) => setClickedReplyId(id)} diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index a4758800..88bef8be 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -1,34 +1,36 @@ +import type { Author, Shout } from '../../graphql/types.gen' + +import { getPagePath } from '@nanostores/router' +import { createPopper } from '@popperjs/core' +import { clsx } from 'clsx' import { createEffect, For, createMemo, onMount, Show, createSignal, onCleanup } from 'solid-js' -import { clsx } from 'clsx' -import { getPagePath } from '@nanostores/router' -import type { Author, Shout } from '../../graphql/types.gen' -import { useSession } from '../../context/session' import { useLocalize } from '../../context/localize' import { useReactions } from '../../context/reactions' +import { useSession } from '../../context/session' import { MediaItem } from '../../pages/types' import { DEFAULT_HEADER_OFFSET, router, useRouter } from '../../stores/router' +import { getImageUrl } from '../../utils/getImageUrl' import { getDescription } from '../../utils/meta' +import { Icon } from '../_shared/Icon' +import { Image } from '../_shared/Image' +import { Lightbox } from '../_shared/Lightbox' +import { Popover } from '../_shared/Popover' +import { ImageSwiper } from '../_shared/SolidSwiper' +import { VideoPlayer } from '../_shared/VideoPlayer' +import { AuthorBadge } from '../Author/AuthorBadge' +import { CardTopic } from '../Feed/CardTopic' +import { FeedArticlePopup } from '../Feed/FeedArticlePopup' import { TableOfContents } from '../TableOfContents' + +import { AudioHeader } from './AudioHeader' import { AudioPlayer } from './AudioPlayer' +import { CommentsTree } from './CommentsTree' import { getShareUrl, SharePopup } from './SharePopup' import { ShoutRatingControl } from './ShoutRatingControl' -import { CommentsTree } from './CommentsTree' -import stylesHeader from '../Nav/Header/Header.module.scss' -import { AudioHeader } from './AudioHeader' -import { Popover } from '../_shared/Popover' -import { VideoPlayer } from '../_shared/VideoPlayer' -import { Icon } from '../_shared/Icon' -import { ImageSwiper } from '../_shared/SolidSwiper' + import styles from './Article.module.scss' -import { CardTopic } from '../Feed/CardTopic' -import { createPopper } from '@popperjs/core' -import { AuthorBadge } from '../Author/AuthorBadge' -import { getImageUrl } from '../../utils/getImageUrl' -import { FeedArticlePopup } from '../Feed/FeedArticlePopup' -import { Lightbox } from '../_shared/Lightbox' -import { Image } from '../_shared/Image' -import article from '../Editor/extensions/Article' +import stylesHeader from '../Nav/Header/Header.module.scss' type Props = { article: Shout @@ -46,7 +48,7 @@ const scrollTo = (el: HTMLElement) => { window.scrollTo({ top: top + window.scrollY - DEFAULT_HEADER_OFFSET, left: 0, - behavior: 'smooth' + behavior: 'smooth', }) } @@ -57,7 +59,7 @@ export const FullArticle = (props: Props) => { const { user, isAuthenticated, - actions: { requireAuthentication } + actions: { requireAuthentication }, } = useSession() const [isReactionsLoaded, setIsReactionsLoaded] = createSignal(false) @@ -67,7 +69,7 @@ export const FullArticle = (props: Props) => { const mainTopic = createMemo( () => props.article.topics?.find((topic) => topic?.slug === props.article.mainTopic) || - props.article.topics[0] + props.article.topics[0], ) const canEdit = () => props.article.authors?.some((a) => a.slug === user()?.slug) @@ -121,7 +123,7 @@ export const FullArticle = (props: Props) => { if (searchParams()?.scrollTo === 'comments' && commentsRef.current) { scrollToComments() changeSearchParam({ - scrollTo: null + scrollTo: null, }) } }) @@ -129,7 +131,7 @@ export const FullArticle = (props: Props) => { createEffect(() => { if (searchParams().commentId && isReactionsLoaded()) { const commentElement = document.querySelector( - `[id='comment_${searchParams().commentId}']` + `[id='comment_${searchParams().commentId}']`, ) changeSearchParam({ commentId: null }) @@ -141,12 +143,12 @@ export const FullArticle = (props: Props) => { }) const { - actions: { loadReactionsBy } + actions: { loadReactionsBy }, } = useReactions() onMount(async () => { await loadReactionsBy({ - by: { shout: props.article.slug } + by: { shout: props.article.slug }, }) setIsReactionsLoaded(true) @@ -165,7 +167,7 @@ export const FullArticle = (props: Props) => { } const tooltipElements: NodeListOf = document.querySelectorAll( - '[data-toggle="tooltip"], footnote' + '[data-toggle="tooltip"], footnote', ) if (!tooltipElements) { return @@ -190,19 +192,19 @@ export const FullArticle = (props: Props) => { modifiers: [ { name: 'eventListeners', - options: { scroll: false } + options: { scroll: false }, }, { name: 'offset', options: { - offset: [0, 8] - } + offset: [0, 8], + }, }, { name: 'flip', - options: { fallbackPlacements: ['top'] } - } - ] + options: { fallbackPlacements: ['top'] }, + }, + ], }) tooltip.style.visibility = 'hidden' diff --git a/src/components/Article/SharePopup.tsx b/src/components/Article/SharePopup.tsx index d4da06e5..1393b176 100644 --- a/src/components/Article/SharePopup.tsx +++ b/src/components/Article/SharePopup.tsx @@ -1,12 +1,14 @@ -import { Icon } from '../_shared/Icon' +import type { PopupProps } from '../_shared/Popup' import { createSocialShare, TWITTER, VK, FACEBOOK, TELEGRAM } from '@solid-primitives/share' -import styles from '../_shared/Popup/Popup.module.scss' -import type { PopupProps } from '../_shared/Popup' -import { Popup } from '../_shared/Popup' -import { useLocalize } from '../../context/localize' import { createEffect, createSignal } from 'solid-js' + +import { useLocalize } from '../../context/localize' import { useSnackbar } from '../../context/snackbar' +import { Icon } from '../_shared/Icon' +import { Popup } from '../_shared/Popup' + +import styles from '../_shared/Popup/Popup.module.scss' type SharePopupProps = { title: string @@ -26,7 +28,7 @@ export const SharePopup = (props: SharePopupProps) => { const { t } = useLocalize() const [isVisible, setIsVisible] = createSignal(false) const { - actions: { showSnackbar } + actions: { showSnackbar }, } = useSnackbar() createEffect(() => { @@ -38,7 +40,7 @@ export const SharePopup = (props: SharePopupProps) => { const [share] = createSocialShare(() => ({ title: props.title, url: props.shareUrl, - description: props.description + description: props.description, })) const copyLink = async () => { diff --git a/src/components/Article/ShoutRatingControl.tsx b/src/components/Article/ShoutRatingControl.tsx index c7b4c6f9..0f592c2b 100644 --- a/src/components/Article/ShoutRatingControl.tsx +++ b/src/components/Article/ShoutRatingControl.tsx @@ -1,13 +1,15 @@ import { clsx } from 'clsx' import { createMemo, Show } from 'solid-js' + +import { useLocalize } from '../../context/localize' +import { useReactions } from '../../context/reactions' +import { useSession } from '../../context/session' import { ReactionKind, Shout } from '../../graphql/types.gen' import { loadShout } from '../../stores/zine/articles' -import { useSession } from '../../context/session' -import { useReactions } from '../../context/reactions' +import { Icon } from '../_shared/Icon' import { Popup } from '../_shared/Popup' import { VotersList } from '../_shared/VotersList' -import { useLocalize } from '../../context/localize' -import { Icon } from '../_shared/Icon' + import styles from './ShoutRatingControl.module.scss' interface ShoutRatingControlProps { @@ -19,12 +21,12 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => { const { t } = useLocalize() const { user, - actions: { requireAuthentication } + actions: { requireAuthentication }, } = useSession() const { reactionEntities, - actions: { createReaction, deleteReaction, loadReactionsBy } + actions: { createReaction, deleteReaction, loadReactionsBy }, } = useReactions() const checkReaction = (reactionKind: ReactionKind) => @@ -33,7 +35,7 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => { r.kind === reactionKind && r.createdBy.slug === user()?.slug && r.shout.id === props.shout.id && - !r.replyTo + !r.replyTo, ) const isUpvoted = createMemo(() => checkReaction(ReactionKind.Like)) @@ -45,8 +47,8 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => { (r) => [ReactionKind.Like, ReactionKind.Dislike].includes(r.kind) && r.shout.id === props.shout.id && - !r.replyTo - ) + !r.replyTo, + ), ) const deleteShoutReaction = async (reactionKind: ReactionKind) => { @@ -55,7 +57,7 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => { r.kind === reactionKind && r.createdBy.slug === user()?.slug && r.shout.id === props.shout.id && - !r.replyTo + !r.replyTo, ) return deleteReaction(reactionToDelete.id) } @@ -69,13 +71,13 @@ export const ShoutRatingControl = (props: ShoutRatingControlProps) => { } else { await createReaction({ kind: isUpvote ? ReactionKind.Like : ReactionKind.Dislike, - shout: props.shout.id + shout: props.shout.id, }) } loadShout(props.shout.slug) loadReactionsBy({ - by: { shout: props.shout.slug } + by: { shout: props.shout.slug }, }) }, 'vote') } diff --git a/src/components/AuthGuard/AuthGuard.tsx b/src/components/AuthGuard/AuthGuard.tsx index c9d50c20..c7b0c442 100644 --- a/src/components/AuthGuard/AuthGuard.tsx +++ b/src/components/AuthGuard/AuthGuard.tsx @@ -1,8 +1,9 @@ import { createEffect, JSX, Show } from 'solid-js' + import { useSession } from '../../context/session' -import { hideModal } from '../../stores/ui' -import { useRouter } from '../../stores/router' import { RootSearchParams } from '../../pages/types' +import { useRouter } from '../../stores/router' +import { hideModal } from '../../stores/ui' import { AuthModalSearchParams } from '../Nav/AuthModal/types' type Props = { @@ -25,9 +26,9 @@ export const AuthGuard = (props: Props) => { changeSearchParam( { source: 'authguard', - modal: 'auth' + modal: 'auth', }, - true + true, ) } } diff --git a/src/components/Author/AhtorLink/AuthorLink.tsx b/src/components/Author/AhtorLink/AuthorLink.tsx index ddc10cf4..9c6009de 100644 --- a/src/components/Author/AhtorLink/AuthorLink.tsx +++ b/src/components/Author/AhtorLink/AuthorLink.tsx @@ -1,8 +1,10 @@ import { clsx } from 'clsx' -import styles from './AhtorLink.module.scss' + import { Author } from '../../../graphql/types.gen' import { Userpic } from '../Userpic' +import styles from './AhtorLink.module.scss' + type Props = { author: Author size?: 'XS' | 'M' | 'L' diff --git a/src/components/Author/AuthorBadge/AuthorBadge.tsx b/src/components/Author/AuthorBadge/AuthorBadge.tsx index 910d2a68..9ab3f66b 100644 --- a/src/components/Author/AuthorBadge/AuthorBadge.tsx +++ b/src/components/Author/AuthorBadge/AuthorBadge.tsx @@ -1,17 +1,19 @@ +import { openPage } from '@nanostores/router' import { clsx } from 'clsx' +import { createMemo, createSignal, Match, Show, Switch } from 'solid-js' + +import { useLocalize } from '../../../context/localize' +import { useSession } from '../../../context/session' +import { Author, FollowingEntity } from '../../../graphql/types.gen' +import { router, useRouter } from '../../../stores/router' +import { follow, unfollow } from '../../../stores/zine/common' +import { Button } from '../../_shared/Button' +import { CheckButton } from '../../_shared/CheckButton' +import { Icon } from '../../_shared/Icon' +import { Userpic } from '../Userpic' + import styles from './AuthorBadge.module.scss' import stylesButton from '../../_shared/Button/Button.module.scss' -import { Userpic } from '../Userpic' -import { Author, FollowingEntity } from '../../../graphql/types.gen' -import { createMemo, createSignal, Match, Show, Switch } from 'solid-js' -import { useLocalize } from '../../../context/localize' -import { Button } from '../../_shared/Button' -import { useSession } from '../../../context/session' -import { follow, unfollow } from '../../../stores/zine/common' -import { CheckButton } from '../../_shared/CheckButton' -import { openPage } from '@nanostores/router' -import { router, useRouter } from '../../../stores/router' -import { Icon } from '../../_shared/Icon' type Props = { author: Author @@ -25,12 +27,12 @@ export const AuthorBadge = (props: Props) => { const { session, subscriptions, - actions: { loadSubscriptions, requireAuthentication } + actions: { loadSubscriptions, requireAuthentication }, } = useSession() const { changeSearchParam } = useRouter() const { t, formatDate } = useLocalize() const subscribed = createMemo(() => - subscriptions().authors.some((author) => author.slug === props.author.slug) + subscriptions().authors.some((author) => author.slug === props.author.slug), ) const subscribe = async (really = true) => { @@ -53,7 +55,7 @@ export const AuthorBadge = (props: Props) => { requireAuthentication(() => { openPage(router, `inbox`) changeSearchParam({ - initChat: props.author.id.toString() + initChat: props.author.id.toString(), }) }, 'discussions') } @@ -126,7 +128,7 @@ export const AuthorBadge = (props: Props) => { isSubscribeButton={true} class={clsx(styles.actionButton, { [styles.iconed]: props.iconButtons, - [stylesButton.subscribed]: subscribed() + [stylesButton.subscribed]: subscribed(), })} /> } @@ -151,7 +153,7 @@ export const AuthorBadge = (props: Props) => { isSubscribeButton={true} class={clsx(styles.actionButton, { [styles.iconed]: props.iconButtons, - [stylesButton.subscribed]: subscribed() + [stylesButton.subscribed]: subscribed(), })} /> diff --git a/src/components/Author/AuthorCard/AuthorCard.tsx b/src/components/Author/AuthorCard/AuthorCard.tsx index 62c7856b..e38ef986 100644 --- a/src/components/Author/AuthorCard/AuthorCard.tsx +++ b/src/components/Author/AuthorCard/AuthorCard.tsx @@ -1,22 +1,25 @@ import type { Author } from '../../../graphql/types.gen' -import { Userpic } from '../Userpic' -import { createEffect, createMemo, createSignal, For, Show } from 'solid-js' -import { translit } from '../../../utils/ru2en' -import { follow, unfollow } from '../../../stores/zine/common' -import { clsx } from 'clsx' -import { useSession } from '../../../context/session' -import { ShowOnlyOnClient } from '../../_shared/ShowOnlyOnClient' -import { FollowingEntity, Topic } from '../../../graphql/types.gen' -import { router, useRouter } from '../../../stores/router' + import { openPage, redirectPage } from '@nanostores/router' +import { clsx } from 'clsx' +import { createEffect, createMemo, createSignal, For, Show } from 'solid-js' + import { useLocalize } from '../../../context/localize' -import { Modal } from '../../Nav/Modal' +import { useSession } from '../../../context/session' +import { FollowingEntity, Topic } from '../../../graphql/types.gen' import { SubscriptionFilter } from '../../../pages/types' +import { router, useRouter } from '../../../stores/router' +import { follow, unfollow } from '../../../stores/zine/common' import { isAuthor } from '../../../utils/isAuthor' -import { AuthorBadge } from '../AuthorBadge' -import { TopicBadge } from '../../Topic/TopicBadge' +import { translit } from '../../../utils/ru2en' import { Button } from '../../_shared/Button' +import { ShowOnlyOnClient } from '../../_shared/ShowOnlyOnClient' import { getShareUrl, SharePopup } from '../../Article/SharePopup' +import { Modal } from '../../Nav/Modal' +import { TopicBadge } from '../../Topic/TopicBadge' +import { AuthorBadge } from '../AuthorBadge' +import { Userpic } from '../Userpic' + import styles from './AuthorCard.module.scss' import stylesButton from '../../_shared/Button/Button.module.scss' @@ -32,7 +35,7 @@ export const AuthorCard = (props: Props) => { session, subscriptions, isSessionLoaded, - actions: { loadSubscriptions, requireAuthentication } + actions: { loadSubscriptions, requireAuthentication }, } = useSession() const [isSubscribing, setIsSubscribing] = createSignal(false) @@ -40,7 +43,7 @@ export const AuthorCard = (props: Props) => { const [subscriptionFilter, setSubscriptionFilter] = createSignal('all') const subscribed = createMemo(() => - subscriptions().authors.some((author) => author.slug === props.author.slug) + subscriptions().authors.some((author) => author.slug === props.author.slug), ) const subscribe = async (really = true) => { @@ -74,7 +77,7 @@ export const AuthorCard = (props: Props) => { requireAuthentication(() => { openPage(router, `inbox`) changeSearchParam({ - initChat: props.author.id.toString() + initChat: props.author.id.toString(), }) }, 'discussions') } @@ -218,7 +221,7 @@ export const AuthorCard = (props: Props) => { value={followButtonText()} isSubscribeButton={true} class={clsx({ - [stylesButton.subscribed]: subscribed() + [stylesButton.subscribed]: subscribed(), })} />
    diff --git a/src/components/Feed/Row5.tsx b/src/components/Feed/Row5.tsx index b3d07c52..eb564fc5 100644 --- a/src/components/Feed/Row5.tsx +++ b/src/components/Feed/Row5.tsx @@ -1,4 +1,5 @@ import type { Shout } from '../../graphql/types.gen' + import { ArticleCard } from './ArticleCard' export const Row5 = (props: { articles: Shout[]; nodate?: boolean }) => { diff --git a/src/components/Feed/RowShort.tsx b/src/components/Feed/RowShort.tsx index 1dc5fda2..2fb773e2 100644 --- a/src/components/Feed/RowShort.tsx +++ b/src/components/Feed/RowShort.tsx @@ -1,5 +1,7 @@ -import { For } from 'solid-js' import type { Shout } from '../../graphql/types.gen' + +import { For } from 'solid-js' + import { ArticleCard } from './ArticleCard' export default (props: { articles: Shout[] }) => ( @@ -16,7 +18,7 @@ export default (props: { articles: Shout[] }) => ( isWithCover: true, isBigTitle: true, isVertical: true, - nodate: true + nodate: true, }} /> diff --git a/src/components/Feed/Sidebar/Sidebar.tsx b/src/components/Feed/Sidebar/Sidebar.tsx index a62441b1..04374e0b 100644 --- a/src/components/Feed/Sidebar/Sidebar.tsx +++ b/src/components/Feed/Sidebar/Sidebar.tsx @@ -1,14 +1,16 @@ +import { getPagePath } from '@nanostores/router' +import { clsx } from 'clsx' import { createSignal, For, Show } from 'solid-js' -import { Icon } from '../../_shared/Icon' + +import { useLocalize } from '../../../context/localize' +import { useSession } from '../../../context/session' +import { router, useRouter } from '../../../stores/router' import { useArticlesStore } from '../../../stores/zine/articles' import { useSeenStore } from '../../../stores/zine/seen' -import { useSession } from '../../../context/session' -import { useLocalize } from '../../../context/localize' -import styles from './Sidebar.module.scss' -import { clsx } from 'clsx' +import { Icon } from '../../_shared/Icon' import { Userpic } from '../../Author/Userpic' -import { getPagePath } from '@nanostores/router' -import { router, useRouter } from '../../../stores/router' + +import styles from './Sidebar.module.scss' export const Sidebar = () => { const { t } = useLocalize() @@ -33,7 +35,7 @@ export const Sidebar = () => { @@ -46,7 +48,7 @@ export const Sidebar = () => { @@ -59,7 +61,7 @@ export const Sidebar = () => { @@ -72,7 +74,7 @@ export const Sidebar = () => { @@ -85,7 +87,7 @@ export const Sidebar = () => { @@ -98,7 +100,7 @@ export const Sidebar = () => { diff --git a/src/components/Inbox/CreateModalContent.tsx b/src/components/Inbox/CreateModalContent.tsx index 07efd2e2..1a860da7 100644 --- a/src/components/Inbox/CreateModalContent.tsx +++ b/src/components/Inbox/CreateModalContent.tsx @@ -1,11 +1,14 @@ -import { createSignal, For, createEffect } from 'solid-js' -import styles from './CreateModalContent.module.scss' - -import InviteUser from './InviteUser' import type { Author } from '../../graphql/types.gen' -import { hideModal } from '../../stores/ui' + +import { createSignal, For, createEffect } from 'solid-js' + import { useInbox } from '../../context/inbox' import { useLocalize } from '../../context/localize' +import { hideModal } from '../../stores/ui' + +import InviteUser from './InviteUser' + +import styles from './CreateModalContent.module.scss' type inviteUser = Author & { selected: boolean } type Props = { @@ -46,7 +49,7 @@ const CreateModalContent = (props: Props) => { const handleClick = (user) => { setCollectionToInvite((userCollection) => { return userCollection.map((clickedUser) => - user.id === clickedUser.id ? { ...clickedUser, selected: !clickedUser.selected } : clickedUser + user.id === clickedUser.id ? { ...clickedUser, selected: !clickedUser.selected } : clickedUser, ) }) } diff --git a/src/components/Inbox/DialogAvatar.tsx b/src/components/Inbox/DialogAvatar.tsx index bb3382dc..875cdc98 100644 --- a/src/components/Inbox/DialogAvatar.tsx +++ b/src/components/Inbox/DialogAvatar.tsx @@ -1,8 +1,10 @@ -import { Show, createMemo } from 'solid-js' -import './DialogCard.module.scss' -import styles from './DialogAvatar.module.scss' import { clsx } from 'clsx' +import { Show, createMemo } from 'solid-js' + import { getImageUrl } from '../../utils/getImageUrl' +import './DialogCard.module.scss' + +import styles from './DialogAvatar.module.scss' type Props = { name: string @@ -25,7 +27,7 @@ const colors = [ '#668cff', '#c34cfe', '#e699ff', - '#6633ff' + '#6633ff', ] const getById = (letter: string) => @@ -42,7 +44,7 @@ const DialogAvatar = (props: Props) => { class={clsx(styles.DialogAvatar, props.class, { [styles.online]: props.online, [styles.bordered]: props.bordered, - [styles.small]: props.size === 'small' + [styles.small]: props.size === 'small', })} style={{ 'background-color': `${randomBg()}` }} > diff --git a/src/components/Inbox/DialogCard.tsx b/src/components/Inbox/DialogCard.tsx index 52465089..a3e0c4a4 100644 --- a/src/components/Inbox/DialogCard.tsx +++ b/src/components/Inbox/DialogCard.tsx @@ -1,12 +1,16 @@ -import { Show, Switch, Match, createMemo } from 'solid-js' -import DialogAvatar from './DialogAvatar' import type { ChatMember } from '../../graphql/types.gen' -import GroupDialogAvatar from './GroupDialogAvatar' + import { clsx } from 'clsx' -import styles from './DialogCard.module.scss' +import { Show, Switch, Match, createMemo } from 'solid-js' + import { useLocalize } from '../../context/localize' import { AuthorBadge } from '../Author/AuthorBadge' +import DialogAvatar from './DialogAvatar' +import GroupDialogAvatar from './GroupDialogAvatar' + +import styles from './DialogCard.module.scss' + type DialogProps = { online?: boolean message?: string @@ -22,14 +26,14 @@ type DialogProps = { const DialogCard = (props: DialogProps) => { const { t, formatTime } = useLocalize() const companions = createMemo( - () => props.members && props.members.filter((member) => member.id !== props.ownId) + () => props.members && props.members.filter((member) => member.id !== props.ownId), ) const names = createMemo( () => companions() ?.map((companion) => companion.name) - .join(', ') + .join(', '), ) return ( @@ -37,7 +41,7 @@ const DialogCard = (props: DialogProps) => {
    diff --git a/src/components/Inbox/DialogHeader.tsx b/src/components/Inbox/DialogHeader.tsx index 166b61a7..303c04ac 100644 --- a/src/components/Inbox/DialogHeader.tsx +++ b/src/components/Inbox/DialogHeader.tsx @@ -1,7 +1,9 @@ import type { Chat } from '../../graphql/types.gen' -import styles from './DialogHeader.module.scss' + import DialogCard from './DialogCard' +import styles from './DialogHeader.module.scss' + type DialogHeader = { chat: Chat ownId: number diff --git a/src/components/Inbox/GroupDialogAvatar.tsx b/src/components/Inbox/GroupDialogAvatar.tsx index 49df5ffe..dcd6dce9 100644 --- a/src/components/Inbox/GroupDialogAvatar.tsx +++ b/src/components/Inbox/GroupDialogAvatar.tsx @@ -1,10 +1,14 @@ -import { For } from 'solid-js' -import './DialogCard.module.scss' -import styles from './GroupDialogAvatar.module.scss' -import { clsx } from 'clsx' import type { ChatMember } from '../../graphql/types.gen' + +import { clsx } from 'clsx' +import { For } from 'solid-js' + import DialogAvatar from './DialogAvatar' +import './DialogCard.module.scss' + +import styles from './GroupDialogAvatar.module.scss' + type Props = { users: ChatMember[] } diff --git a/src/components/Inbox/InviteUser.tsx b/src/components/Inbox/InviteUser.tsx index 4fe85ed8..72d6b28c 100644 --- a/src/components/Inbox/InviteUser.tsx +++ b/src/components/Inbox/InviteUser.tsx @@ -1,8 +1,11 @@ -import styles from './InviteUser.module.scss' -import DialogAvatar from './DialogAvatar' import type { Author } from '../../graphql/types.gen' + import { Icon } from '../_shared/Icon' +import DialogAvatar from './DialogAvatar' + +import styles from './InviteUser.module.scss' + type DialogProps = { author: Author selected: boolean diff --git a/src/components/Inbox/Message.tsx b/src/components/Inbox/Message.tsx index c9a9df00..07bd66f0 100644 --- a/src/components/Inbox/Message.tsx +++ b/src/components/Inbox/Message.tsx @@ -1,12 +1,16 @@ -import { createSignal, Show } from 'solid-js' -import { clsx } from 'clsx' -import styles from './Message.module.scss' -import DialogAvatar from './DialogAvatar' import type { Message as MessageType, ChatMember } from '../../graphql/types.gen' + +import { clsx } from 'clsx' +import { createSignal, Show } from 'solid-js' + +import { useLocalize } from '../../context/localize' import { Icon } from '../_shared/Icon' + +import DialogAvatar from './DialogAvatar' import { MessageActionsPopup } from './MessageActionsPopup' import QuotedMessage from './QuotedMessage' -import { useLocalize } from '../../context/localize' + +import styles from './Message.module.scss' type Props = { content: MessageType diff --git a/src/components/Inbox/MessageActionsPopup.tsx b/src/components/Inbox/MessageActionsPopup.tsx index 9e0019bb..512f71cd 100644 --- a/src/components/Inbox/MessageActionsPopup.tsx +++ b/src/components/Inbox/MessageActionsPopup.tsx @@ -1,7 +1,9 @@ -import { createEffect, createSignal, For } from 'solid-js' import type { PopupProps } from '../_shared/Popup' -import { Popup } from '../_shared/Popup' + +import { createEffect, createSignal, For } from 'solid-js' + import { useLocalize } from '../../context/localize' +import { Popup } from '../_shared/Popup' export type MessageActionType = 'reply' | 'copy' | 'pin' | 'forward' | 'select' | 'delete' @@ -18,7 +20,7 @@ export const MessageActionsPopup = (props: MessageActionsPopupProps) => { { name: t('Pin'), action: 'pin' }, { name: t('Forward'), action: 'forward' }, { name: t('Select'), action: 'select' }, - { name: t('Delete'), action: 'delete' } + { name: t('Delete'), action: 'delete' }, ] createEffect(() => { if (props.actionSelect) props.actionSelect(selectedAction()) diff --git a/src/components/Inbox/MessagesFallback.tsx b/src/components/Inbox/MessagesFallback.tsx index e077f645..cbd29af2 100644 --- a/src/components/Inbox/MessagesFallback.tsx +++ b/src/components/Inbox/MessagesFallback.tsx @@ -1,4 +1,5 @@ import { Show } from 'solid-js' + import styles from './MessagesFallback.module.scss' type MessagesFallback = { diff --git a/src/components/Inbox/QuotedMessage.tsx b/src/components/Inbox/QuotedMessage.tsx index 605bff21..22c497cc 100644 --- a/src/components/Inbox/QuotedMessage.tsx +++ b/src/components/Inbox/QuotedMessage.tsx @@ -1,7 +1,9 @@ -import { Show } from 'solid-js' -import styles from './QuotedMessage.module.scss' -import { Icon } from '../_shared/Icon' import { clsx } from 'clsx' +import { Show } from 'solid-js' + +import { Icon } from '../_shared/Icon' + +import styles from './QuotedMessage.module.scss' type QuotedMessage = { body: string @@ -17,7 +19,7 @@ const QuotedMessage = (props: QuotedMessage) => { class={clsx(styles.QuotedMessage, { [styles.reply]: props.variant === 'reply', [styles.inline]: props.variant === 'inline', - [styles.own]: props.isOwn + [styles.own]: props.isOwn, })} > diff --git a/src/components/Inbox/Search.tsx b/src/components/Inbox/Search.tsx index 90ce7423..62bb4350 100644 --- a/src/components/Inbox/Search.tsx +++ b/src/components/Inbox/Search.tsx @@ -1,7 +1,9 @@ -import styles from './Search.module.scss' import { createSignal } from 'solid-js' + import { Icon } from '../_shared/Icon' +import styles from './Search.module.scss' + type Props = { placeholder: string onChange: (value: () => string) => void diff --git a/src/components/Nav/AuthModal/AuthModalHeader/AuthModalHeader.tsx b/src/components/Nav/AuthModal/AuthModalHeader/AuthModalHeader.tsx index 5aeff24a..80ad5330 100644 --- a/src/components/Nav/AuthModal/AuthModalHeader/AuthModalHeader.tsx +++ b/src/components/Nav/AuthModal/AuthModalHeader/AuthModalHeader.tsx @@ -1,9 +1,11 @@ -import styles from './AuthModalHeader.module.scss' import { Show } from 'solid-js' + import { useLocalize } from '../../../../context/localize' import { useRouter } from '../../../../stores/router' import { AuthModalSearchParams } from '../types' +import styles from './AuthModalHeader.module.scss' + type Props = { modalType: 'login' | 'register' } @@ -14,7 +16,7 @@ export const AuthModalHeader = (props: Props) => { const { source } = searchParams() const generateModalTextsFromSource = ( - modalType: 'login' | 'register' + modalType: 'login' | 'register', ): { title: string; description: string } => { const title = modalType === 'login' ? 'Welcome to Discours' : 'Create account' @@ -22,53 +24,53 @@ export const AuthModalHeader = (props: Props) => { case 'create': { return { title: t(`${title} to publish articles`), - description: '' + description: '', } } case 'bookmark': { return { title: t(`${title} to add to your bookmarks`), description: t( - 'In bookmarks, you can save favorite discussions and materials that you want to return to' - ) + 'In bookmarks, you can save favorite discussions and materials that you want to return to', + ), } } case 'discussions': { return { title: t(`${title} to participate in discussions`), description: t( - "You ll be able to participate in discussions, rate others' comments and learn about new responses" - ) + "You ll be able to participate in discussions, rate others' comments and learn about new responses", + ), } } case 'follow': { return { title: t(`${title} to subscribe`), description: t( - 'This way you ll be able to subscribe to authors, interesting topics and customize your feed' - ) + 'This way you ll be able to subscribe to authors, interesting topics and customize your feed', + ), } } case 'subscribe': { return { title: t(`${title} to subscribe to new publications`), description: t( - 'This way you ll be able to subscribe to authors, interesting topics and customize your feed' - ) + 'This way you ll be able to subscribe to authors, interesting topics and customize your feed', + ), } } case 'vote': { return { title: t(`${title} to vote`), description: t( - 'This way we ll realize that you re a real person and ll take your vote into account. And you ll see how others voted' - ) + 'This way we ll realize that you re a real person and ll take your vote into account. And you ll see how others voted', + ), } } default: { return { title: t(title), - description: '' + description: '', } } } diff --git a/src/components/Nav/AuthModal/EmailConfirm.tsx b/src/components/Nav/AuthModal/EmailConfirm.tsx index d9bf9828..fa57007c 100644 --- a/src/components/Nav/AuthModal/EmailConfirm.tsx +++ b/src/components/Nav/AuthModal/EmailConfirm.tsx @@ -1,18 +1,21 @@ -import styles from './AuthModal.module.scss' -import { clsx } from 'clsx' -import { hideModal } from '../../../stores/ui' -import { createMemo, createSignal, onMount, Show } from 'solid-js' -import { useRouter } from '../../../stores/router' import type { ConfirmEmailSearchParams } from './types' -import { ApiError } from '../../../utils/apiClient' -import { useSession } from '../../../context/session' + +import { clsx } from 'clsx' +import { createMemo, createSignal, onMount, Show } from 'solid-js' + import { useLocalize } from '../../../context/localize' +import { useSession } from '../../../context/session' +import { useRouter } from '../../../stores/router' +import { hideModal } from '../../../stores/ui' +import { ApiError } from '../../../utils/apiClient' + +import styles from './AuthModal.module.scss' export const EmailConfirm = () => { const { t } = useLocalize() const { session, - actions: { confirmEmail } + actions: { confirmEmail }, } = useSession() const [isTokenExpired, setIsTokenExpired] = createSignal(false) diff --git a/src/components/Nav/AuthModal/ForgotPasswordForm.tsx b/src/components/Nav/AuthModal/ForgotPasswordForm.tsx index 4d28d027..31c59da7 100644 --- a/src/components/Nav/AuthModal/ForgotPasswordForm.tsx +++ b/src/components/Nav/AuthModal/ForgotPasswordForm.tsx @@ -1,14 +1,18 @@ -import styles from './AuthModal.module.scss' +import type { AuthModalSearchParams } from './types' + import { clsx } from 'clsx' import { createSignal, JSX, Show } from 'solid-js' -import { useRouter } from '../../../stores/router' -import { email, setEmail } from './sharedLogic' -import type { AuthModalSearchParams } from './types' -import { ApiError } from '../../../utils/apiClient' -import { signSendLink } from '../../../stores/auth' + import { useLocalize } from '../../../context/localize' +import { signSendLink } from '../../../stores/auth' +import { useRouter } from '../../../stores/router' +import { ApiError } from '../../../utils/apiClient' import { validateEmail } from '../../../utils/validateEmail' +import { email, setEmail } from './sharedLogic' + +import styles from './AuthModal.module.scss' + type FormFields = { email: string } @@ -83,7 +87,7 @@ export const ForgotPasswordForm = () => {
    { onClick={(event) => { event.preventDefault() changeSearchParam({ - mode: 'register' + mode: 'register', }) }} > @@ -138,7 +142,7 @@ export const ForgotPasswordForm = () => { class={styles.authLink} onClick={() => changeSearchParam({ - mode: 'login' + mode: 'login', }) } > diff --git a/src/components/Nav/AuthModal/LoginForm.tsx b/src/components/Nav/AuthModal/LoginForm.tsx index f468d230..25f45594 100644 --- a/src/components/Nav/AuthModal/LoginForm.tsx +++ b/src/components/Nav/AuthModal/LoginForm.tsx @@ -1,19 +1,23 @@ -import styles from './AuthModal.module.scss' -import { clsx } from 'clsx' -import { SocialProviders } from './SocialProviders' -import { ApiError } from '../../../utils/apiClient' -import { createSignal, Show } from 'solid-js' -import { email, setEmail } from './sharedLogic' -import { useRouter } from '../../../stores/router' import type { AuthModalSearchParams } from './types' -import { hideModal } from '../../../stores/ui' -import { useSession } from '../../../context/session' -import { signSendLink } from '../../../stores/auth' -import { validateEmail } from '../../../utils/validateEmail' -import { useSnackbar } from '../../../context/snackbar' + +import { clsx } from 'clsx' +import { createSignal, Show } from 'solid-js' + import { useLocalize } from '../../../context/localize' +import { useSession } from '../../../context/session' +import { useSnackbar } from '../../../context/snackbar' +import { signSendLink } from '../../../stores/auth' +import { useRouter } from '../../../stores/router' +import { hideModal } from '../../../stores/ui' +import { ApiError } from '../../../utils/apiClient' +import { validateEmail } from '../../../utils/validateEmail' import { Icon } from '../../_shared/Icon' + import { AuthModalHeader } from './AuthModalHeader' +import { email, setEmail } from './sharedLogic' +import { SocialProviders } from './SocialProviders' + +import styles from './AuthModal.module.scss' type FormFields = { email: string @@ -36,11 +40,11 @@ export const LoginForm = () => { const authFormRef: { current: HTMLFormElement } = { current: null } const { - actions: { showSnackbar } + actions: { showSnackbar }, } = useSnackbar() const { - actions: { signIn } + actions: { signIn }, } = useSession() const { changeSearchParam } = useRouter() @@ -144,7 +148,7 @@ export const LoginForm = () => {
    {
    { class="link" onClick={() => changeSearchParam({ - mode: 'forgot-password' + mode: 'forgot-password', }) } > @@ -215,7 +219,7 @@ export const LoginForm = () => { class={styles.authLink} onClick={() => changeSearchParam({ - mode: 'register' + mode: 'register', }) } > diff --git a/src/components/Nav/AuthModal/RegisterForm.tsx b/src/components/Nav/AuthModal/RegisterForm.tsx index 152c0ad5..d2f9c9f2 100644 --- a/src/components/Nav/AuthModal/RegisterForm.tsx +++ b/src/components/Nav/AuthModal/RegisterForm.tsx @@ -1,20 +1,24 @@ -import { Show, createSignal } from 'solid-js' -import type { JSX } from 'solid-js' -import styles from './AuthModal.module.scss' -import { clsx } from 'clsx' -import { SocialProviders } from './SocialProviders' -import { ApiError } from '../../../utils/apiClient' -import { email, setEmail } from './sharedLogic' -import { useRouter } from '../../../stores/router' import type { AuthModalSearchParams } from './types' -import { hideModal } from '../../../stores/ui' -import { checkEmail, useEmailChecks } from '../../../stores/emailChecks' -import { register } from '../../../stores/auth' +import type { JSX } from 'solid-js' + +import { clsx } from 'clsx' +import { Show, createSignal } from 'solid-js' + import { useLocalize } from '../../../context/localize' +import { register } from '../../../stores/auth' +import { checkEmail, useEmailChecks } from '../../../stores/emailChecks' +import { useRouter } from '../../../stores/router' +import { hideModal } from '../../../stores/ui' +import { ApiError } from '../../../utils/apiClient' import { validateEmail } from '../../../utils/validateEmail' -import { AuthModalHeader } from './AuthModalHeader' import { Icon } from '../../_shared/Icon' +import { AuthModalHeader } from './AuthModalHeader' +import { email, setEmail } from './sharedLogic' +import { SocialProviders } from './SocialProviders' + +import styles from './AuthModal.module.scss' + type FormFields = { fullName: string email: string @@ -126,7 +130,7 @@ export const RegisterForm = () => { await register({ name: cleanName, email: cleanEmail, - password: password() + password: password(), }) setIsSuccess(true) @@ -156,7 +160,7 @@ export const RegisterForm = () => {
    {
    { onClick={(event) => { event.preventDefault() changeSearchParam({ - mode: 'login' + mode: 'login', }) }} > @@ -211,7 +215,7 @@ export const RegisterForm = () => {
    { class={styles.authLink} onClick={() => changeSearchParam({ - mode: 'login' + mode: 'login', }) } > diff --git a/src/components/Nav/AuthModal/SocialProviders.tsx b/src/components/Nav/AuthModal/SocialProviders.tsx index e23f9dfa..f80f593c 100644 --- a/src/components/Nav/AuthModal/SocialProviders.tsx +++ b/src/components/Nav/AuthModal/SocialProviders.tsx @@ -1,9 +1,9 @@ -import { Icon } from '../../_shared/Icon' +import { useLocalize } from '../../../context/localize' import { hideModal } from '../../../stores/ui' +import { apiBaseUrl } from '../../../utils/config' +import { Icon } from '../../_shared/Icon' import styles from './SocialProviders.module.scss' -import { apiBaseUrl } from '../../../utils/config' -import { useLocalize } from '../../../context/localize' type Provider = 'facebook' | 'google' | 'vk' | 'github' diff --git a/src/components/Nav/AuthModal/index.tsx b/src/components/Nav/AuthModal/index.tsx index 7a2a8e27..0823d5b3 100644 --- a/src/components/Nav/AuthModal/index.tsx +++ b/src/components/Nav/AuthModal/index.tsx @@ -1,22 +1,26 @@ -import { Dynamic } from 'solid-js/web' -import { Show, Component, createEffect, createMemo } from 'solid-js' -import { hideModal } from '../../../stores/ui' -import { useRouter } from '../../../stores/router' -import { clsx } from 'clsx' -import styles from './AuthModal.module.scss' -import { LoginForm } from './LoginForm' -import { isMobile } from '../../../utils/media-query' -import { RegisterForm } from './RegisterForm' -import { ForgotPasswordForm } from './ForgotPasswordForm' -import { EmailConfirm } from './EmailConfirm' import type { AuthModalMode, AuthModalSearchParams } from './types' + +import { clsx } from 'clsx' +import { Show, Component, createEffect, createMemo } from 'solid-js' +import { Dynamic } from 'solid-js/web' + import { useLocalize } from '../../../context/localize' +import { useRouter } from '../../../stores/router' +import { hideModal } from '../../../stores/ui' +import { isMobile } from '../../../utils/media-query' + +import { EmailConfirm } from './EmailConfirm' +import { ForgotPasswordForm } from './ForgotPasswordForm' +import { LoginForm } from './LoginForm' +import { RegisterForm } from './RegisterForm' + +import styles from './AuthModal.module.scss' const AUTH_MODAL_MODES: Record = { login: LoginForm, register: RegisterForm, 'forgot-password': ForgotPasswordForm, - 'confirm-email': EmailConfirm + 'confirm-email': EmailConfirm, } export const AuthModal = () => { @@ -40,7 +44,7 @@ export const AuthModal = () => {
    @@ -54,7 +58,7 @@ export const AuthModal = () => {

    {t(`Join the global community of authors!`)}

    {t( - 'Get to know the most intelligent people of our time, edit and discuss the articles, share your expertise, rate and decide what to publish in the magazine' + 'Get to know the most intelligent people of our time, edit and discuss the articles, share your expertise, rate and decide what to publish in the magazine', )} .  {t('New stories every day and even more!')} @@ -77,7 +81,7 @@ export const AuthModal = () => {

    diff --git a/src/components/Nav/ConfirmModal/ConfirmModal.tsx b/src/components/Nav/ConfirmModal/ConfirmModal.tsx index 63f6a767..767eb535 100644 --- a/src/components/Nav/ConfirmModal/ConfirmModal.tsx +++ b/src/components/Nav/ConfirmModal/ConfirmModal.tsx @@ -1,6 +1,7 @@ import { useConfirm } from '../../../context/confirm' import { useLocalize } from '../../../context/localize' import { Button } from '../../_shared/Button' + import styles from './ConfirmModal.module.scss' export const ConfirmModal = () => { @@ -8,7 +9,7 @@ export const ConfirmModal = () => { const { confirmMessage, - actions: { resolveConfirm } + actions: { resolveConfirm }, } = useConfirm() return ( diff --git a/src/components/Nav/Confirmed.tsx b/src/components/Nav/Confirmed.tsx index 09adf3c2..fe615284 100644 --- a/src/components/Nav/Confirmed.tsx +++ b/src/components/Nav/Confirmed.tsx @@ -1,5 +1,6 @@ import './Confirmed.scss' import { onMount } from 'solid-js' + import { useLocalize } from '../../context/localize' export const Confirmed = (props: { token?: string }) => { diff --git a/src/components/Nav/Header/Header.tsx b/src/components/Nav/Header/Header.tsx index 7dbe5026..0c1a8087 100644 --- a/src/components/Nav/Header/Header.tsx +++ b/src/components/Nav/Header/Header.tsx @@ -1,29 +1,28 @@ -import { Show, createSignal, createEffect, onMount, onCleanup, For } from 'solid-js' -import { getPagePath, redirectPage } from '@nanostores/router' -import { clsx } from 'clsx' - -import { Modal } from '../Modal' -import { AuthModal } from '../AuthModal' -import { HeaderAuth } from '../HeaderAuth' -import { ConfirmModal } from '../ConfirmModal' -import { getShareUrl, SharePopup } from '../../Article/SharePopup' -import { Snackbar } from '../Snackbar' -import { Icon } from '../../_shared/Icon' import type { Topic } from '../../../graphql/types.gen' -import { useModalStore } from '../../../stores/ui' -import { router, ROUTES, useRouter } from '../../../stores/router' - -import { getDescription } from '../../../utils/meta' +import { getPagePath, redirectPage } from '@nanostores/router' +import { clsx } from 'clsx' +import { Show, createSignal, createEffect, onMount, onCleanup, For } from 'solid-js' import { useLocalize } from '../../../context/localize' import { useSession } from '../../../context/session' +import { router, ROUTES, useRouter } from '../../../stores/router' +import { useModalStore } from '../../../stores/ui' +import { apiClient } from '../../../utils/apiClient' +import { getDescription } from '../../../utils/meta' +import { Icon } from '../../_shared/Icon' +import { Subscribe } from '../../_shared/Subscribe' +import { getShareUrl, SharePopup } from '../../Article/SharePopup' +import { RANDOM_TOPICS_COUNT } from '../../Views/Home' +import { AuthModal } from '../AuthModal' +import { ConfirmModal } from '../ConfirmModal' +import { HeaderAuth } from '../HeaderAuth' +import { Modal } from '../Modal' +import { Snackbar } from '../Snackbar' + +import { Link } from './Link' import styles from './Header.module.scss' -import { apiClient } from '../../../utils/apiClient' -import { RANDOM_TOPICS_COUNT } from '../../Views/Home' -import { Link } from './Link' -import { Subscribe } from '../../_shared/Subscribe' type Props = { title?: string @@ -47,7 +46,7 @@ export const Header = (props: Props) => { const { modal } = useModalStore() const { page } = useRouter() const { - actions: { requireAuthentication } + actions: { requireAuthentication }, } = useSession() const { searchParams } = useRouter() @@ -167,7 +166,7 @@ export const Header = (props: Props) => { [styles.headerScrolledTop]: !getIsScrollingBottom() && getIsScrolled(), [styles.headerScrolledBottom]: (getIsScrollingBottom() && getIsScrolled() && !isProfilePopupVisible()) || isSharePopupVisible(), - [styles.headerWithTitle]: Boolean(props.title) + [styles.headerWithTitle]: Boolean(props.title), }} > {

    diff --git a/src/components/Nav/Header/Link.tsx b/src/components/Nav/Header/Link.tsx index bbad79b9..67cf5318 100644 --- a/src/components/Nav/Header/Link.tsx +++ b/src/components/Nav/Header/Link.tsx @@ -1,8 +1,10 @@ -import styles from './Header.module.scss' -import { router, ROUTES, useRouter } from '../../../stores/router' -import { clsx } from 'clsx' -import { ConditionalWrapper } from '../../_shared/ConditionalWrapper' import { getPagePath } from '@nanostores/router' +import { clsx } from 'clsx' + +import { router, ROUTES, useRouter } from '../../../stores/router' +import { ConditionalWrapper } from '../../_shared/ConditionalWrapper' + +import styles from './Header.module.scss' type Props = { onMouseOver: (event?: MouseEvent, time?: number) => void diff --git a/src/components/Nav/HeaderAuth.tsx b/src/components/Nav/HeaderAuth.tsx index 1ca47d3b..f1784d9a 100644 --- a/src/components/Nav/HeaderAuth.tsx +++ b/src/components/Nav/HeaderAuth.tsx @@ -1,19 +1,22 @@ -import styles from './Header/Header.module.scss' -import { clsx } from 'clsx' -import { router, useRouter } from '../../stores/router' -import { Icon } from '../_shared/Icon' -import { createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js' -import { ProfilePopup } from './ProfilePopup' -import { Userpic } from '../Author/Userpic' -import { showModal } from '../../stores/ui' -import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' -import { useSession } from '../../context/session' -import { useLocalize } from '../../context/localize' import { getPagePath } from '@nanostores/router' -import { Button } from '../_shared/Button' +import { clsx } from 'clsx' +import { createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js' + import { useEditorContext } from '../../context/editor' -import { Popover } from '../_shared/Popover' +import { useLocalize } from '../../context/localize' import { useNotifications } from '../../context/notifications' +import { useSession } from '../../context/session' +import { router, useRouter } from '../../stores/router' +import { showModal } from '../../stores/ui' +import { Button } from '../_shared/Button' +import { Icon } from '../_shared/Icon' +import { Popover } from '../_shared/Popover' +import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' +import { Userpic } from '../Author/Userpic' + +import { ProfilePopup } from './ProfilePopup' + +import styles from './Header/Header.module.scss' type Props = { setIsProfilePopupVisible: (value: boolean) => void @@ -32,12 +35,12 @@ export const HeaderAuth = (props: Props) => { const { session, isSessionLoaded, isAuthenticated } = useSession() const { unreadNotificationsCount, - actions: { showNotificationsPanel } + actions: { showNotificationsPanel }, } = useNotifications() const { form, - actions: { toggleEditorPanel, saveShout, publishShout } + actions: { toggleEditorPanel, saveShout, publishShout }, } = useEditorContext() const handleBellIconClick = (event: Event) => { @@ -158,7 +161,7 @@ export const HeaderAuth = (props: Props) => { {renderIconedButton({ value: t('Save'), icon: 'save', - action: handleSaveButtonClick + action: handleSaveButtonClick, })}
    @@ -166,7 +169,7 @@ export const HeaderAuth = (props: Props) => { {renderIconedButton({ value: t('Publish'), icon: 'publish', - action: handlePublishButtonClick + action: handlePublishButtonClick, })}
    diff --git a/src/components/Nav/Modal/Modal.tsx b/src/components/Nav/Modal/Modal.tsx index 0b6e1415..a1fe5380 100644 --- a/src/components/Nav/Modal/Modal.tsx +++ b/src/components/Nav/Modal/Modal.tsx @@ -1,13 +1,15 @@ -import { createEffect, createMemo, createSignal, Show } from 'solid-js' import type { JSX } from 'solid-js' + +import { redirectPage } from '@nanostores/router' import { clsx } from 'clsx' +import { createEffect, createMemo, createSignal, Show } from 'solid-js' + +import { router } from '../../../stores/router' import { hideModal, useModalStore } from '../../../stores/ui' import { useEscKeyDownHandler } from '../../../utils/useEscKeyDownHandler' +import { Icon } from '../../_shared/Icon' import styles from './Modal.module.scss' -import { redirectPage } from '@nanostores/router' -import { router } from '../../../stores/router' -import { Icon } from '../../_shared/Icon' interface Props { name: string @@ -50,7 +52,7 @@ export const Modal = (props: Props) => { [styles.narrow]: props.variant === 'narrow', ['col-auto col-md-20 offset-md-2 col-lg-14 offset-lg-5']: props.variant === 'medium', [styles.noPadding]: props.noPadding, - [styles.maxHeight]: props.maxHeight + [styles.maxHeight]: props.maxHeight, })} onClick={(event) => event.stopPropagation()} > diff --git a/src/components/Nav/Modal/Opener.tsx b/src/components/Nav/Modal/Opener.tsx index b13e0007..a56d7f69 100644 --- a/src/components/Nav/Modal/Opener.tsx +++ b/src/components/Nav/Modal/Opener.tsx @@ -1,5 +1,6 @@ -import type { JSX } from 'solid-js/jsx-runtime' import type { ModalType } from '../../../stores/ui' +import type { JSX } from 'solid-js/jsx-runtime' + import { showModal } from '../../../stores/ui' export default (props: { name: ModalType; children: JSX.Element }) => { diff --git a/src/components/Nav/ProfilePopup.tsx b/src/components/Nav/ProfilePopup.tsx index 6e6efba5..3427fd52 100644 --- a/src/components/Nav/ProfilePopup.tsx +++ b/src/components/Nav/ProfilePopup.tsx @@ -1,17 +1,20 @@ -import { useSession } from '../../context/session' import type { PopupProps } from '../_shared/Popup' -import { Popup } from '../_shared/Popup' -import styles from '../_shared/Popup/Popup.module.scss' + import { getPagePath } from '@nanostores/router' -import { router } from '../../stores/router' + import { useLocalize } from '../../context/localize' +import { useSession } from '../../context/session' +import { router } from '../../stores/router' +import { Popup } from '../_shared/Popup' + +import styles from '../_shared/Popup/Popup.module.scss' type ProfilePopupProps = Omit export const ProfilePopup = (props: ProfilePopupProps) => { const { user, - actions: { signOut } + actions: { signOut }, } = useSession() const { t } = useLocalize() diff --git a/src/components/Nav/ProfileSettingsNavigation/ProfileSettingsNavigation.tsx b/src/components/Nav/ProfileSettingsNavigation/ProfileSettingsNavigation.tsx index 76e96c85..228f0b0a 100644 --- a/src/components/Nav/ProfileSettingsNavigation/ProfileSettingsNavigation.tsx +++ b/src/components/Nav/ProfileSettingsNavigation/ProfileSettingsNavigation.tsx @@ -1,8 +1,10 @@ -import styles from './ProfileSettingsNavigation.module.scss' import { clsx } from 'clsx' + import { useLocalize } from '../../../context/localize' import { useRouter } from '../../../stores/router' +import styles from './ProfileSettingsNavigation.module.scss' + export const ProfileSettingsNavigation = () => { const { t } = useLocalize() const { page } = useRouter() diff --git a/src/components/Nav/Snackbar.tsx b/src/components/Nav/Snackbar.tsx index ac9b1091..59bbc634 100644 --- a/src/components/Nav/Snackbar.tsx +++ b/src/components/Nav/Snackbar.tsx @@ -1,11 +1,13 @@ -import { Show } from 'solid-js' -import { useSnackbar } from '../../context/snackbar' -import styles from './Snackbar.module.scss' -import { Transition } from 'solid-transition-group' import { clsx } from 'clsx' +import { Show } from 'solid-js' +import { Transition } from 'solid-transition-group' + +import { useSnackbar } from '../../context/snackbar' import { Icon } from '../_shared/Icon' import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' +import styles from './Snackbar.module.scss' + export const Snackbar = () => { const { snackbarMessage } = useSnackbar() @@ -13,7 +15,7 @@ export const Snackbar = () => {
    diff --git a/src/components/Nav/Topics/Topics.tsx b/src/components/Nav/Topics/Topics.tsx index 11662329..2248a639 100644 --- a/src/components/Nav/Topics/Topics.tsx +++ b/src/components/Nav/Topics/Topics.tsx @@ -1,9 +1,11 @@ -import { Icon } from '../../_shared/Icon' -import { useLocalize } from '../../../context/localize' -import styles from './Topics.module.scss' -import { clsx } from 'clsx' -import { router, useRouter } from '../../../stores/router' import { getPagePath } from '@nanostores/router' +import { clsx } from 'clsx' + +import { useLocalize } from '../../../context/localize' +import { router, useRouter } from '../../../stores/router' +import { Icon } from '../../_shared/Icon' + +import styles from './Topics.module.scss' export const Topics = () => { const { t } = useLocalize() diff --git a/src/components/NotificationsPanel/EmptyMessage/EmptyMessage.tsx b/src/components/NotificationsPanel/EmptyMessage/EmptyMessage.tsx index 855009ff..39e0e597 100644 --- a/src/components/NotificationsPanel/EmptyMessage/EmptyMessage.tsx +++ b/src/components/NotificationsPanel/EmptyMessage/EmptyMessage.tsx @@ -1,7 +1,9 @@ import { clsx } from 'clsx' -import styles from './EmptyMessage.module.scss' + import { useLocalize } from '../../../context/localize' +import styles from './EmptyMessage.module.scss' + export const EmptyMessage = () => { const { t } = useLocalize() diff --git a/src/components/NotificationsPanel/NotificationView/NotificationView.tsx b/src/components/NotificationsPanel/NotificationView/NotificationView.tsx index ae5b1dd9..5751884b 100644 --- a/src/components/NotificationsPanel/NotificationView/NotificationView.tsx +++ b/src/components/NotificationsPanel/NotificationView/NotificationView.tsx @@ -1,15 +1,18 @@ -import { clsx } from 'clsx' import type { Notification } from '../../../graphql/types.gen' -import { createMemo, createSignal, onMount, Show } from 'solid-js' -import { NotificationType } from '../../../graphql/types.gen' -import { getPagePath, openPage } from '@nanostores/router' -import { router, useRouter } from '../../../stores/router' -import { useNotifications } from '../../../context/notifications' -import { useLocalize } from '../../../context/localize' import type { ArticlePageSearchParams } from '../../Article/FullArticle' -import { TimeAgo } from '../../_shared/TimeAgo' -import styles from './NotificationView.module.scss' + +import { getPagePath, openPage } from '@nanostores/router' +import { clsx } from 'clsx' +import { createMemo, createSignal, onMount, Show } from 'solid-js' + +import { useLocalize } from '../../../context/localize' +import { useNotifications } from '../../../context/notifications' +import { NotificationType } from '../../../graphql/types.gen' +import { router, useRouter } from '../../../stores/router' import { GroupAvatar } from '../../_shared/GroupAvatar' +import { TimeAgo } from '../../_shared/TimeAgo' + +import styles from './NotificationView.module.scss' type Props = { notification: Notification @@ -36,7 +39,7 @@ type NotificationData = { export const NotificationView = (props: Props) => { const { - actions: { markNotificationAsRead, hideNotificationsPanel } + actions: { markNotificationAsRead, hideNotificationsPanel }, } = useNotifications() const { changeSearchParam } = useRouter() @@ -89,7 +92,7 @@ export const NotificationView = (props: Props) => { return ( <> {t('NotificationNewCommentText1', { - commentsCount: props.notification.occurrences + commentsCount: props.notification.occurrences, })}{' '} {shoutTitle} @@ -99,7 +102,7 @@ export const NotificationView = (props: Props) => { {lastUser().name} {' '} {t('NotificationNewCommentText3', { - restUsersCount: data().users.length - 1 + restUsersCount: data().users.length - 1, })} ) @@ -108,7 +111,7 @@ export const NotificationView = (props: Props) => { return ( <> {t('NotificationNewReplyText1', { - commentsCount: props.notification.occurrences + commentsCount: props.notification.occurrences, })}{' '} {shoutTitle} @@ -118,7 +121,7 @@ export const NotificationView = (props: Props) => { {lastUser().name} {' '} {t('NotificationNewReplyText3', { - restUsersCount: data().users.length - 1 + restUsersCount: data().users.length - 1, })} ) @@ -158,7 +161,7 @@ export const NotificationView = (props: Props) => {
    diff --git a/src/components/NotificationsPanel/NotificationsPanel.tsx b/src/components/NotificationsPanel/NotificationsPanel.tsx index 30619e70..72ed3780 100644 --- a/src/components/NotificationsPanel/NotificationsPanel.tsx +++ b/src/components/NotificationsPanel/NotificationsPanel.tsx @@ -1,16 +1,19 @@ import { clsx } from 'clsx' -import styles from './NotificationsPanel.module.scss' +import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from 'solid-js' +import { throttle } from 'throttle-debounce' + +import { useLocalize } from '../../context/localize' +import { PAGE_SIZE, useNotifications } from '../../context/notifications' +import { useSession } from '../../context/session' import { useEscKeyDownHandler } from '../../utils/useEscKeyDownHandler' import { useOutsideClickHandler } from '../../utils/useOutsideClickHandler' -import { useLocalize } from '../../context/localize' -import { Icon } from '../_shared/Icon' -import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from 'solid-js' -import { PAGE_SIZE, useNotifications } from '../../context/notifications' -import { NotificationView } from './NotificationView' -import { EmptyMessage } from './EmptyMessage' import { Button } from '../_shared/Button' -import { throttle } from 'throttle-debounce' -import { useSession } from '../../context/session' +import { Icon } from '../_shared/Icon' + +import { EmptyMessage } from './EmptyMessage' +import { NotificationView } from './NotificationView' + +import styles from './NotificationsPanel.module.scss' type Props = { isOpen: boolean @@ -51,20 +54,20 @@ export const NotificationsPanel = (props: Props) => { unreadNotificationsCount, loadedNotificationsCount, totalNotificationsCount, - actions: { loadNotifications, markAllNotificationsAsRead } + actions: { loadNotifications, markAllNotificationsAsRead }, } = useNotifications() const handleHide = () => { props.onClose() } const panelRef: { current: HTMLDivElement } = { - current: null + current: null, } useOutsideClickHandler({ containerRef: panelRef, predicate: () => props.isOpen, - handler: () => handleHide() + handler: () => handleHide(), }) let windowScrollTop = 0 @@ -150,14 +153,14 @@ export const NotificationsPanel = (props: Props) => { await loadNextPage() setIsLoading(false) } - } - ) + }, + ), ) return (
    (panelRef.current = el)} class={styles.panel}> diff --git a/src/components/TableOfContents/TableOfContents.tsx b/src/components/TableOfContents/TableOfContents.tsx index d35601e9..23632214 100644 --- a/src/components/TableOfContents/TableOfContents.tsx +++ b/src/components/TableOfContents/TableOfContents.tsx @@ -1,12 +1,14 @@ -import { For, Show, createSignal, createEffect, on, onMount, onCleanup } from 'solid-js' import { clsx } from 'clsx' -import { DEFAULT_HEADER_OFFSET } from '../../stores/router' -import { useLocalize } from '../../context/localize' -import { Icon } from '../_shared/Icon' -import styles from './TableOfContents.module.scss' -import { isDesktop } from '../../utils/media-query' +import { For, Show, createSignal, createEffect, on, onMount, onCleanup } from 'solid-js' import { throttle, debounce } from 'throttle-debounce' +import { useLocalize } from '../../context/localize' +import { DEFAULT_HEADER_OFFSET } from '../../stores/router' +import { isDesktop } from '../../utils/media-query' +import { Icon } from '../_shared/Icon' + +import styles from './TableOfContents.module.scss' + interface Props { variant: 'article' | 'editor' parentSelector: string @@ -23,7 +25,7 @@ const scrollToHeader = (element) => { top: element.getBoundingClientRect().top - document.body.getBoundingClientRect().top - - DEFAULT_HEADER_OFFSET + DEFAULT_HEADER_OFFSET, }) } @@ -43,7 +45,7 @@ export const TableOfContents = (props: Props) => { const updateHeadings = () => { setHeadings( // eslint-disable-next-line unicorn/prefer-spread - Array.from(document.querySelector(props.parentSelector).querySelectorAll('h2, h3, h4')) + Array.from(document.querySelector(props.parentSelector).querySelectorAll('h2, h3, h4')), ) setAreHeadingsLoaded(true) } @@ -58,8 +60,8 @@ export const TableOfContents = (props: Props) => { createEffect( on( () => props.body, - () => debouncedUpdateHeadings() - ) + () => debouncedUpdateHeadings(), + ), ) onMount(() => { @@ -75,7 +77,7 @@ export const TableOfContents = (props: Props) => { >
    @@ -92,7 +94,7 @@ export const TableOfContents = (props: Props) => { class={clsx(styles.TableOfContentsHeadingsItem, { [styles.TableOfContentsHeadingsItemH3]: h.nodeName === 'H3', [styles.TableOfContentsHeadingsItemH4]: h.nodeName === 'H4', - [styles.active]: index() === activeHeaderIndex() + [styles.active]: index() === activeHeaderIndex(), })} innerHTML={h.textContent} onClick={(e) => { @@ -111,9 +113,9 @@ export const TableOfContents = (props: Props) => { class={clsx( styles.TableOfContentsPrimaryButton, { - [styles.TableOfContentsPrimaryButtonLefted]: props.variant === 'editor' && !isVisible() + [styles.TableOfContentsPrimaryButtonLefted]: props.variant === 'editor' && !isVisible(), }, - 'd-none d-xl-block' + 'd-none d-xl-block', )} onClick={(e) => { e.preventDefault() @@ -149,9 +151,9 @@ export const TableOfContents = (props: Props) => { class={clsx( styles.TableOfContentsPrimaryButton, { - [styles.TableOfContentsPrimaryButtonLefted]: props.variant === 'editor' && !isVisible() + [styles.TableOfContentsPrimaryButtonLefted]: props.variant === 'editor' && !isVisible(), }, - 'd-xl-none' + 'd-xl-none', )} onClick={(e) => { e.preventDefault() diff --git a/src/components/Topic/Card.tsx b/src/components/Topic/Card.tsx index 7dab0cf0..584aaed5 100644 --- a/src/components/Topic/Card.tsx +++ b/src/components/Topic/Card.tsx @@ -1,19 +1,20 @@ -import { createMemo, createSignal, Show } from 'solid-js' import type { Topic } from '../../graphql/types.gen' -import { FollowingEntity } from '../../graphql/types.gen' -import { follow, unfollow } from '../../stores/zine/common' import { clsx } from 'clsx' -import { useSession } from '../../context/session' -import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' -import { Icon } from '../_shared/Icon' +import { createMemo, createSignal, Show } from 'solid-js' + import { useLocalize } from '../../context/localize' -import { CardTopic } from '../Feed/CardTopic' -import { CheckButton } from '../_shared/CheckButton' +import { useSession } from '../../context/session' +import { FollowingEntity } from '../../graphql/types.gen' +import { follow, unfollow } from '../../stores/zine/common' import { capitalize } from '../../utils/capitalize' +import { Button } from '../_shared/Button' +import { CheckButton } from '../_shared/CheckButton' +import { Icon } from '../_shared/Icon' +import { ShowOnlyOnClient } from '../_shared/ShowOnlyOnClient' +import { CardTopic } from '../Feed/CardTopic' import styles from './Card.module.scss' -import { Button } from '../_shared/Button' import stylesButton from '../_shared/Button/Button.module.scss' interface TopicProps { @@ -38,7 +39,7 @@ export const TopicCard = (props: TopicProps) => { const { subscriptions, isSessionLoaded, - actions: { loadSubscriptions, requireAuthentication } + actions: { loadSubscriptions, requireAuthentication }, } = useSession() const [isSubscribing, setIsSubscribing] = createSignal(false) @@ -89,7 +90,7 @@ export const TopicCard = (props: TopicProps) => { classList={{ row: !props.subscribeButtonBottom, [styles.topicCompact]: props.compact, - [styles.topicInRow]: props.isTopicInRow + [styles.topicInRow]: props.isTopicInRow, }} >
    { [clsx('col-sm-18 col-md-24 col-lg-14 col-xl-15', styles.topicDetails)]: props.isNarrow, [clsx('col-24 col-sm-17 col-md-18', styles.topicDetails)]: props.compact, [clsx('col-sm-17 col-md-18', styles.topicDetails)]: - !props.subscribeButtonBottom && !props.isNarrow && !props.compact + !props.subscribeButtonBottom && !props.isNarrow && !props.compact, }} > @@ -132,7 +133,7 @@ export const TopicCard = (props: TopicProps) => { classList={{ 'col-sm-6 col-md-24 col-lg-10 col-xl-9': props.isNarrow, 'col-24 col-sm-7 col-md-6': props.compact, - 'col-sm-7 col-md-6': !props.subscribeButtonBottom && !props.isNarrow && !props.compact + 'col-sm-7 col-md-6': !props.subscribeButtonBottom && !props.isNarrow && !props.compact, }} > @@ -151,7 +152,7 @@ export const TopicCard = (props: TopicProps) => { isSubscribeButton={true} class={clsx(styles.actionButton, { [styles.isSubscribing]: isSubscribing(), - [stylesButton.subscribed]: subscribed() + [stylesButton.subscribed]: subscribed(), })} disabled={isSubscribing()} /> diff --git a/src/components/Topic/FloorHeader.tsx b/src/components/Topic/FloorHeader.tsx index 6f8557de..84977c26 100644 --- a/src/components/Topic/FloorHeader.tsx +++ b/src/components/Topic/FloorHeader.tsx @@ -1,7 +1,9 @@ import type { Topic } from '../../graphql/types.gen' -import { Icon } from '../_shared/Icon' -import './FloorHeader.scss' + import { useLocalize } from '../../context/localize' +import { Icon } from '../_shared/Icon' + +import './FloorHeader.scss' export default (props: { topic: Topic; color: string }) => { const { t } = useLocalize() diff --git a/src/components/Topic/Full.tsx b/src/components/Topic/Full.tsx index 9ce2a389..0109b464 100644 --- a/src/components/Topic/Full.tsx +++ b/src/components/Topic/Full.tsx @@ -1,14 +1,16 @@ -import { createMemo, Show } from 'solid-js' import type { Topic } from '../../graphql/types.gen' -import { FollowingEntity } from '../../graphql/types.gen' -import styles from './Full.module.scss' -import { follow, unfollow } from '../../stores/zine/common' import { clsx } from 'clsx' -import { useSession } from '../../context/session' +import { createMemo, Show } from 'solid-js' + import { useLocalize } from '../../context/localize' +import { useSession } from '../../context/session' +import { FollowingEntity } from '../../graphql/types.gen' +import { follow, unfollow } from '../../stores/zine/common' import { Button } from '../_shared/Button' +import styles from './Full.module.scss' + type Props = { topic: Topic } @@ -16,13 +18,13 @@ type Props = { export const FullTopic = (props: Props) => { const { subscriptions, - actions: { requireAuthentication, loadSubscriptions } + actions: { requireAuthentication, loadSubscriptions }, } = useSession() const { t } = useLocalize() const subscribed = createMemo(() => - subscriptions().topics.some((topic) => topic.slug === props.topic?.slug) + subscriptions().topics.some((topic) => topic.slug === props.topic?.slug), ) const handleSubscribe = (really: boolean) => { diff --git a/src/components/Topic/TopicBadge/TopicBadge.tsx b/src/components/Topic/TopicBadge/TopicBadge.tsx index 3387a2e8..9ad6da66 100644 --- a/src/components/Topic/TopicBadge/TopicBadge.tsx +++ b/src/components/Topic/TopicBadge/TopicBadge.tsx @@ -1,13 +1,15 @@ import { clsx } from 'clsx' -import styles from './TopicBadge.module.scss' -import { FollowingEntity, Topic } from '../../../graphql/types.gen' import { createMemo, createSignal, Show } from 'solid-js' -import { Button } from '../../_shared/Button' -import { useSession } from '../../../context/session' + import { useLocalize } from '../../../context/localize' +import { useSession } from '../../../context/session' +import { FollowingEntity, Topic } from '../../../graphql/types.gen' import { follow, unfollow } from '../../../stores/zine/common' -import { CheckButton } from '../../_shared/CheckButton' import { getImageUrl } from '../../../utils/getImageUrl' +import { Button } from '../../_shared/Button' +import { CheckButton } from '../../_shared/CheckButton' + +import styles from './TopicBadge.module.scss' type Props = { topic: Topic @@ -20,11 +22,11 @@ export const TopicBadge = (props: Props) => { const { isAuthenticated, subscriptions, - actions: { loadSubscriptions } + actions: { loadSubscriptions }, } = useSession() const subscribed = createMemo(() => - subscriptions().topics.some((topic) => topic.slug === props.topic.slug) + subscriptions().topics.some((topic) => topic.slug === props.topic.slug), ) const subscribe = async (really = true) => { @@ -45,7 +47,7 @@ export const TopicBadge = (props: Props) => { class={clsx(styles.picture, { [styles.withImage]: props.topic.pic })} style={ props.topic.pic && { - 'background-image': `url('${getImageUrl(props.topic.pic, { width: 40, height: 40 })}')` + 'background-image': `url('${getImageUrl(props.topic.pic, { width: 40, height: 40 })}')`, } } /> diff --git a/src/components/Views/AllAuthors.tsx b/src/components/Views/AllAuthors.tsx index 4bd74962..6d01a23f 100644 --- a/src/components/Views/AllAuthors.tsx +++ b/src/components/Views/AllAuthors.tsx @@ -1,12 +1,14 @@ -import { createEffect, createMemo, createSignal, For, Show } from 'solid-js' import type { Author } from '../../graphql/types.gen' -import { setAuthorsSort, useAuthorsStore } from '../../stores/zine/authors' -import { useRouter } from '../../stores/router' + import { clsx } from 'clsx' -import { SearchField } from '../_shared/SearchField' -import { scrollHandler } from '../../utils/scroll' +import { createEffect, createMemo, createSignal, For, Show } from 'solid-js' + import { useLocalize } from '../../context/localize' +import { useRouter } from '../../stores/router' +import { setAuthorsSort, useAuthorsStore } from '../../stores/zine/authors' import { dummyFilter } from '../../utils/dummyFilter' +import { scrollHandler } from '../../utils/scroll' +import { SearchField } from '../_shared/SearchField' import { AuthorBadge } from '../Author/AuthorBadge' import styles from './AllAuthors.module.scss' @@ -28,7 +30,7 @@ export const AllAuthorsView = (props: AllAuthorsViewProps) => { const { searchParams, changeSearchParam } = useRouter() const { sortedAuthors } = useAuthorsStore({ authors: props.authors, - sortBy: searchParams().by || 'shouts' + sortBy: searchParams().by || 'shouts', }) const [searchQuery, setSearchQuery] = createSignal('') @@ -36,7 +38,7 @@ export const AllAuthorsView = (props: AllAuthorsViewProps) => { createEffect(() => { if (!searchParams().by) { changeSearchParam({ - by: 'shouts' + by: 'shouts', }) } }) @@ -64,7 +66,7 @@ export const AllAuthorsView = (props: AllAuthorsViewProps) => { acc[letter].push(author) return acc }, - {} as { [letter: string]: Author[] } + {} as { [letter: string]: Author[] }, ) }) @@ -88,7 +90,7 @@ export const AllAuthorsView = (props: AllAuthorsViewProps) => {
    • {t('By shouts')} diff --git a/src/components/Views/AllTopics.tsx b/src/components/Views/AllTopics.tsx index decf7abe..c440f4f5 100644 --- a/src/components/Views/AllTopics.tsx +++ b/src/components/Views/AllTopics.tsx @@ -1,15 +1,16 @@ -import { createEffect, createMemo, createSignal, For, Show } from 'solid-js' import type { Topic } from '../../graphql/types.gen' -import { setTopicsSort, useTopicsStore } from '../../stores/zine/topics' -import { useRouter } from '../../stores/router' -import { TopicCard } from '../Topic/Card' import { clsx } from 'clsx' -import { useSession } from '../../context/session' -import { SearchField } from '../_shared/SearchField' -import { scrollHandler } from '../../utils/scroll' +import { createEffect, createMemo, createSignal, For, Show } from 'solid-js' + import { useLocalize } from '../../context/localize' +import { useSession } from '../../context/session' +import { useRouter } from '../../stores/router' +import { setTopicsSort, useTopicsStore } from '../../stores/zine/topics' import { dummyFilter } from '../../utils/dummyFilter' +import { scrollHandler } from '../../utils/scroll' +import { SearchField } from '../_shared/SearchField' +import { TopicCard } from '../Topic/Card' import styles from './AllTopics.module.scss' @@ -31,7 +32,7 @@ export const AllTopicsView = (props: AllTopicsViewProps) => { const { sortedTopics } = useTopicsStore({ topics: props.topics, - sortBy: searchParams().by || 'shouts' + sortBy: searchParams().by || 'shouts', }) const { subscriptions } = useSession() @@ -39,7 +40,7 @@ export const AllTopicsView = (props: AllTopicsViewProps) => { createEffect(() => { if (!searchParams().by) { changeSearchParam({ - by: 'shouts' + by: 'shouts', }) } }) @@ -57,7 +58,7 @@ export const AllTopicsView = (props: AllTopicsViewProps) => { acc[letter].push(topic) return acc }, - {} as { [letter: string]: Topic[] } + {} as { [letter: string]: Topic[] }, ) }) diff --git a/src/components/Views/Author/Author.tsx b/src/components/Views/Author/Author.tsx index d5123465..a0463ffc 100644 --- a/src/components/Views/Author/Author.tsx +++ b/src/components/Views/Author/Author.tsx @@ -1,23 +1,26 @@ -import { Show, createMemo, createSignal, Switch, onMount, For, Match, createEffect } from 'solid-js' import type { Author, Shout, Topic } from '../../../graphql/types.gen' + +import { getPagePath } from '@nanostores/router' +import { clsx } from 'clsx' +import { Show, createMemo, createSignal, Switch, onMount, For, Match, createEffect } from 'solid-js' + +import { useLocalize } from '../../../context/localize' +import { router, useRouter } from '../../../stores/router' +import { loadShouts, useArticlesStore } from '../../../stores/zine/articles' +import { useAuthorsStore } from '../../../stores/zine/authors' +import { apiClient } from '../../../utils/apiClient' +import { restoreScrollPosition, saveScrollPosition } from '../../../utils/scroll' +import { splitToPages } from '../../../utils/splitToPages' +import { Loading } from '../../_shared/Loading' +import { Comment } from '../../Article/Comment' +import { AuthorCard } from '../../Author/AuthorCard' +import { AuthorRatingControl } from '../../Author/AuthorRatingControl' import { Row1 } from '../../Feed/Row1' import { Row2 } from '../../Feed/Row2' import { Row3 } from '../../Feed/Row3' -import { useAuthorsStore } from '../../../stores/zine/authors' -import { loadShouts, useArticlesStore } from '../../../stores/zine/articles' -import { router, useRouter } from '../../../stores/router' -import { restoreScrollPosition, saveScrollPosition } from '../../../utils/scroll' -import { splitToPages } from '../../../utils/splitToPages' + import styles from './Author.module.scss' import stylesArticle from '../../Article/Article.module.scss' -import { clsx } from 'clsx' -import { AuthorCard } from '../../Author/AuthorCard' -import { apiClient } from '../../../utils/apiClient' -import { Comment } from '../../Article/Comment' -import { useLocalize } from '../../../context/localize' -import { AuthorRatingControl } from '../../Author/AuthorRatingControl' -import { getPagePath } from '@nanostores/router' -import { Loading } from '../../_shared/Loading' type Props = { shouts: Shout[] @@ -47,7 +50,7 @@ export const AuthorView = (props: Props) => { try { const [getAuthors, getTopics] = await Promise.all([ apiClient.getAuthorFollowingUsers({ slug: props.authorSlug }), - apiClient.getAuthorFollowingTopics({ slug: props.authorSlug }) + apiClient.getAuthorFollowingTopics({ slug: props.authorSlug }), ]) const authors = getAuthors const topics = getTopics @@ -90,7 +93,7 @@ export const AuthorView = (props: Props) => { const { hasMore } = await loadShouts({ filters: { author: props.authorSlug }, limit: LOAD_MORE_PAGE_SIZE, - offset: sortedArticles().length + offset: sortedArticles().length, }) setIsLoadMoreButtonVisible(hasMore) restoreScrollPosition() @@ -106,7 +109,7 @@ export const AuthorView = (props: Props) => { // }) const pages = createMemo(() => - splitToPages(sortedArticles(), PRERENDERED_ARTICLES_COUNT, LOAD_MORE_PAGE_SIZE) + splitToPages(sortedArticles(), PRERENDERED_ARTICLES_COUNT, LOAD_MORE_PAGE_SIZE), ) const [commented, setCommented] = createSignal([]) @@ -115,7 +118,7 @@ export const AuthorView = (props: Props) => { if (getPage().route === 'authorComments') { try { const data = await apiClient.getReactionsBy({ - by: { comment: true, createdBy: props.authorSlug } + by: { comment: true, createdBy: props.authorSlug }, }) setCommented(data) } catch (error) { diff --git a/src/components/Views/DraftsView/DraftsView.tsx b/src/components/Views/DraftsView/DraftsView.tsx index d98efe08..7eda20d1 100644 --- a/src/components/Views/DraftsView/DraftsView.tsx +++ b/src/components/Views/DraftsView/DraftsView.tsx @@ -1,13 +1,15 @@ +import { openPage } from '@nanostores/router' import { clsx } from 'clsx' -import styles from './DraftsView.module.scss' import { createSignal, For, onMount, Show } from 'solid-js' -import { Draft } from '../../Draft' + +import { useEditorContext } from '../../../context/editor' import { useSession } from '../../../context/session' import { Shout } from '../../../graphql/types.gen' -import { apiClient } from '../../../utils/apiClient' -import { useEditorContext } from '../../../context/editor' -import { openPage } from '@nanostores/router' import { router } from '../../../stores/router' +import { apiClient } from '../../../utils/apiClient' +import { Draft } from '../../Draft' + +import styles from './DraftsView.module.scss' export const DraftsView = () => { const { isAuthenticated, isSessionLoaded } = useSession() @@ -24,7 +26,7 @@ export const DraftsView = () => { }) const { - actions: { publishShoutById, deleteShout } + actions: { publishShoutById, deleteShout }, } = useEditorContext() const handleDraftDelete = (shout: Shout) => { diff --git a/src/components/Views/Edit.tsx b/src/components/Views/Edit.tsx index c7168333..501c5c06 100644 --- a/src/components/Views/Edit.tsx +++ b/src/components/Views/Edit.tsx @@ -1,30 +1,33 @@ -import { Accessor, createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js' -import { useLocalize } from '../../context/localize' -import { clsx } from 'clsx' - import type { Shout, Topic } from '../../graphql/types.gen' -import { useRouter } from '../../stores/router' -import { ShoutForm, useEditorContext } from '../../context/editor' -import { Editor, Panel } from '../Editor' -import { Icon } from '../_shared/Icon' -import styles from './Edit.module.scss' -import { GrowingTextarea } from '../_shared/GrowingTextarea' -import { VideoUploader } from '../Editor/VideoUploader' -import { AudioUploader } from '../Editor/AudioUploader' -import { slugify } from '../../utils/slugify' -import { ImageSwiper } from '../_shared/SolidSwiper' -import { DropArea } from '../_shared/DropArea' -import { LayoutType, MediaItem } from '../../pages/types' -import { clone } from '../../utils/clone' + +import { clsx } from 'clsx' import deepEqual from 'fast-deep-equal' -import { AutoSaveNotice } from '../Editor/AutoSaveNotice' -import { PublishSettings } from './PublishSettings' +import { Accessor, createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js' import { createStore } from 'solid-js/store' -import SimplifiedEditor from '../Editor/SimplifiedEditor' -import { isDesktop } from '../../utils/media-query' -import { TableOfContents } from '../TableOfContents' + +import { ShoutForm, useEditorContext } from '../../context/editor' +import { useLocalize } from '../../context/localize' +import { LayoutType, MediaItem } from '../../pages/types' +import { useRouter } from '../../stores/router' +import { clone } from '../../utils/clone' import { getImageUrl } from '../../utils/getImageUrl' +import { isDesktop } from '../../utils/media-query' +import { slugify } from '../../utils/slugify' +import { DropArea } from '../_shared/DropArea' +import { GrowingTextarea } from '../_shared/GrowingTextarea' +import { Icon } from '../_shared/Icon' import { Popover } from '../_shared/Popover' +import { ImageSwiper } from '../_shared/SolidSwiper' +import { Editor, Panel } from '../Editor' +import { AudioUploader } from '../Editor/AudioUploader' +import { AutoSaveNotice } from '../Editor/AutoSaveNotice' +import SimplifiedEditor from '../Editor/SimplifiedEditor' +import { VideoUploader } from '../Editor/VideoUploader' +import { TableOfContents } from '../TableOfContents' + +import { PublishSettings } from './PublishSettings' + +import styles from './Edit.module.scss' type Props = { shout: Shout @@ -33,7 +36,7 @@ type Props = { export const MAX_HEADER_LIMIT = 100 export const EMPTY_TOPIC: Topic = { id: -1, - slug: '' + slug: '', } const AUTO_SAVE_INTERVAL = 5000 @@ -41,7 +44,7 @@ const handleScrollTopButtonClick = (e) => { e.preventDefault() window.scrollTo({ top: 0, - behavior: 'smooth' + behavior: 'smooth', }) } @@ -54,7 +57,7 @@ export const EditView = (props: Props) => { const { form, formErrors, - actions: { setForm, setFormErrors, saveDraft, saveDraftToLocalStorage, getDraftFromLocalStorage } + actions: { setForm, setFormErrors, saveDraft, saveDraftToLocalStorage, getDraftFromLocalStorage }, } = useEditorContext() const shoutTopics = props.shout.topics || [] @@ -75,7 +78,7 @@ export const EditView = (props: Props) => { body: props.shout.body, coverImageUrl: props.shout.cover, media: props.shout.media, - layout: props.shout.layout + layout: props.shout.layout, }) } @@ -106,7 +109,7 @@ export const EditView = (props: Props) => { const handleBeforeUnload = (event) => { if (!deepEqual(prevForm, form)) { event.returnValue = t( - `There are unsaved changes in your publishing settings. Are you sure you want to leave the page without saving?` + `There are unsaved changes in your publishing settings. Are you sure you want to leave the page without saving?`, ) } } @@ -145,7 +148,7 @@ export const EditView = (props: Props) => { const [baseAudioFields, setBaseAudioFields] = createSignal({ artist: '', date: '', - genre: '' + genre: '', }) const handleBaseFieldsChange = (key, value) => { @@ -219,7 +222,7 @@ export const EditView = (props: Props) => {