From 53cc9da267e9757172a9e4dbb06e3b1f0d72140e Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Sat, 13 Aug 2022 00:31:54 +0300 Subject: [PATCH 1/2] perf: lazy load mocks package --- src/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index b0d76da..eef1fbf 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,10 +6,12 @@ import App from './App'; if (process.env.REACT_APP_ENABLE_MOCKS) { - const { worker } = require('./mocks/browser') - worker.start({ - onUnhandledRequest: 'bypass' - }) + import('./mocks/browser') + .then(({ worker }) => { + worker.start({ + onUnhandledRequest: 'bypass' + }) + }) } From 70374b2769dd512e756200e5e1c5977b50330b24 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Sat, 13 Aug 2022 18:37:27 +0300 Subject: [PATCH 2/2] fix: create a card component for all the cards, fix username overflow on mobile card, fix hottest page padding --- src/Components/Card/Card.stories.tsx | 23 ++++ src/Components/Card/Card.tsx | 33 ++++++ .../Comments/CommentCard/CommentCard.tsx | 6 +- .../CommentsSection/CommentsSection.tsx | 6 +- .../PostCard/StoryCard/StoryCard.tsx | 6 +- .../Components/TrendingCard/TrendingCard.tsx | 5 +- .../PopularTagsFilter/PopularTagsFilter.tsx | 7 +- .../Components/AuthorCard/AuthorCard.tsx | 5 +- .../StoryPageContent/StoryPageContent.tsx | 9 +- .../AccountCard/AccountCard.tsx | 11 +- .../pages/EditProfilePage/EditProfilePage.tsx | 13 +-- .../CommentsSettingsCard.stories.tsx | 0 .../CommentsSettingsCard.tsx | 102 ++++++++++++++++++ .../PreferencesTab/PreferencesTab.tsx | 21 ++++ .../SaveChangesCard/SaveChangesCard.tsx | 7 +- .../UpdateMyProfileTab.tsx} | 7 +- .../updateProfile.graphql | 0 .../pages/ProfilePage/AboutCard/AboutCard.tsx | 12 ++- .../CommentsSettingsCard.tsx | 102 ------------------ .../pages/ProfilePage/ProfilePage.tsx | 1 - .../ProfilePage/StoriesCard/StoriesCard.tsx | 5 +- .../pages/HottestPage/HottestPage.tsx | 2 +- src/mocks/data/users.ts | 2 +- src/utils/helperFunctions.tsx | 2 + 24 files changed, 238 insertions(+), 149 deletions(-) create mode 100644 src/Components/Card/Card.stories.tsx create mode 100644 src/Components/Card/Card.tsx rename src/features/Profiles/pages/{ProfilePage => EditProfilePage/PreferencesTab}/CommentsSettingsCard/CommentsSettingsCard.stories.tsx (100%) create mode 100644 src/features/Profiles/pages/EditProfilePage/PreferencesTab/CommentsSettingsCard/CommentsSettingsCard.tsx create mode 100644 src/features/Profiles/pages/EditProfilePage/PreferencesTab/PreferencesTab.tsx rename src/features/Profiles/pages/EditProfilePage/{UpdateMyProfileCard/UpdateMyProfileCard.tsx => UpdateMyProfileTab/UpdateMyProfileTab.tsx} (98%) rename src/features/Profiles/pages/EditProfilePage/{UpdateMyProfileCard => UpdateMyProfileTab}/updateProfile.graphql (100%) delete mode 100644 src/features/Profiles/pages/ProfilePage/CommentsSettingsCard/CommentsSettingsCard.tsx diff --git a/src/Components/Card/Card.stories.tsx b/src/Components/Card/Card.stories.tsx new file mode 100644 index 0000000..2cc58a4 --- /dev/null +++ b/src/Components/Card/Card.stories.tsx @@ -0,0 +1,23 @@ +import { ComponentStory, ComponentMeta } from '@storybook/react'; + +import Card from './Card'; + +export default { + title: 'Shared/Card', + component: Card, + argTypes: { + backgroundColor: { control: 'color' }, + }, +} as ComponentMeta; + + +const Template: ComponentStory = (args) =>

Lorem ipsum dolor sit amet consectetur, adipisicing elit. Voluptas corrupti molestias, accusantium porro vitae mollitia voluptatibus omnis. Itaque assumenda minus cum reprehenderit sit, cupiditate, impedit doloribus ad modi corporis maiores. Corrupti praesentium, dolor vero veniam suscipit architecto accusamus beatae minus iste sed ea harum aperiam quibusdam fugiat molestias dolores magni!

+
+ +export const Default = Template.bind({}); + + +export const Primary = Template.bind({}); +Primary.args = { + onlyMd: true +} diff --git a/src/Components/Card/Card.tsx b/src/Components/Card/Card.tsx new file mode 100644 index 0000000..edc6123 --- /dev/null +++ b/src/Components/Card/Card.tsx @@ -0,0 +1,33 @@ + +import React, { PropsWithChildren } from 'react' + +interface Props extends React.ComponentPropsWithoutRef<'div'> { + onlyMd?: boolean; + defaultPadding?: boolean + +} + +const Card = React.forwardRef>(({ + onlyMd = false, + defaultPadding = true, + className, + ...props +}, ref) => { + + + return ( +
+ ) +}) + +export default Card; \ No newline at end of file diff --git a/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx b/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx index 8005b24..30055a9 100644 --- a/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx +++ b/src/features/Posts/Components/Comments/CommentCard/CommentCard.tsx @@ -7,6 +7,7 @@ import DOMPurify from 'dompurify'; import { Vote_Item_Type } from "src/graphql"; import { useVote } from "src/utils/hooks"; import { useState } from "react"; +import Card from "src/Components/Card/Card"; interface Props { @@ -25,13 +26,12 @@ export default function CommentCard({ comment, canReply, onReply }: Props) { }); return ( -
+
-
Reply }
-
+ ) } diff --git a/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx b/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx index 2dbce3d..f35d36b 100644 --- a/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx +++ b/src/features/Posts/Components/Comments/CommentsSection/CommentsSection.tsx @@ -10,6 +10,7 @@ import { AiOutlineClose } from 'react-icons/ai' import { Link, useLocation } from 'react-router-dom' import { createRoute, PAGES_ROUTES } from 'src/utils/routing' import Preferences from 'src/services/preferences.service' +import Card from 'src/Components/Card/Card'; // const createWorker = createWorkerFactory(() => import('./comments.worker')); @@ -44,8 +45,7 @@ export default function CommentsSection({ type, id }: Props) { return ( -
- +
Discussion
{connectionStatus.status === 'Connected' &&
Connected to {connectionStatus.connectedRelaysCount} relays 📡
} @@ -88,6 +88,6 @@ export default function CommentsSection({ type, id }: Props) { onReply={content => handleNewComment(content, comment.nostr_id.toString())} />)}
-
+ ) } diff --git a/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx b/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx index fb5813a..286a316 100644 --- a/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx +++ b/src/features/Posts/Components/PostCard/StoryCard/StoryCard.tsx @@ -7,6 +7,7 @@ import { Author, Tag, Vote_Item_Type } from 'src/graphql'; import Badge from "src/Components/Badge/Badge" import { createRoute } from "src/utils/routing" import { BiComment } from "react-icons/bi" +import Card from "src/Components/Card/Card" export type StoryCardType = Pick + {story.cover_image && }
@@ -56,6 +57,7 @@ export default function StoryCard({ story }: Props) {
- + +
) } diff --git a/src/features/Posts/Components/TrendingCard/TrendingCard.tsx b/src/features/Posts/Components/TrendingCard/TrendingCard.tsx index f411466..99f5cfd 100644 --- a/src/features/Posts/Components/TrendingCard/TrendingCard.tsx +++ b/src/features/Posts/Components/TrendingCard/TrendingCard.tsx @@ -1,5 +1,6 @@ import Skeleton from 'react-loading-skeleton' import { Link } from 'react-router-dom' +import Card from 'src/Components/Card/Card' import Avatar from 'src/features/Profiles/Components/Avatar/Avatar' import { useTrendingPostsQuery } from 'src/graphql' import { random } from 'src/utils/helperFunctions' @@ -12,7 +13,7 @@ export default function TrendingCard() { return ( -
+

Trending on BOLT.FUN

    { @@ -34,6 +35,6 @@ export default function TrendingCard() { } )}
-
+ ) } diff --git a/src/features/Posts/pages/FeedPage/PopularTagsFilter/PopularTagsFilter.tsx b/src/features/Posts/pages/FeedPage/PopularTagsFilter/PopularTagsFilter.tsx index e1e9baa..b52c5e5 100644 --- a/src/features/Posts/pages/FeedPage/PopularTagsFilter/PopularTagsFilter.tsx +++ b/src/features/Posts/pages/FeedPage/PopularTagsFilter/PopularTagsFilter.tsx @@ -4,6 +4,7 @@ import Slider from 'src/Components/Slider/Slider'; import { Tag, usePopularTagsQuery } from 'src/graphql'; import { MEDIA_QUERIES } from 'src/utils/theme'; import { capitalize } from 'src/utils/helperFunctions'; +import Card from 'src/Components/Card/Card'; export type FilterTag = Pick @@ -30,7 +31,8 @@ export default function PopularTagsFilter({ value, onChange }: Props) { return (
{isMdScreen ? -
+ +

Popular Tags

    {tagsQuery.loading ? @@ -60,7 +62,8 @@ export default function PopularTagsFilter({ value, onChange }: Props) { )}
-
+ + : <> { diff --git a/src/features/Posts/pages/PostDetailsPage/Components/AuthorCard/AuthorCard.tsx b/src/features/Posts/pages/PostDetailsPage/Components/AuthorCard/AuthorCard.tsx index 8a79f61..aa7b86a 100644 --- a/src/features/Posts/pages/PostDetailsPage/Components/AuthorCard/AuthorCard.tsx +++ b/src/features/Posts/pages/PostDetailsPage/Components/AuthorCard/AuthorCard.tsx @@ -1,6 +1,7 @@ import dayjs from "dayjs"; import { Link } from "react-router-dom"; import Button from "src/Components/Button/Button"; +import Card from "src/Components/Card/Card"; import { Author } from "src/features/Posts/types"; import Avatar from "src/features/Profiles/Components/Avatar/Avatar"; import { trimText } from "src/utils/helperFunctions"; @@ -16,7 +17,7 @@ interface Props { export default function AuthorCard({ author }: Props) { return ( -
+
@@ -31,6 +32,6 @@ export default function AuthorCard({ author }: Props) { className="mt-16"> Maker's Profile -
+ ) } diff --git a/src/features/Posts/pages/PostDetailsPage/Components/StoryPageContent/StoryPageContent.tsx b/src/features/Posts/pages/PostDetailsPage/Components/StoryPageContent/StoryPageContent.tsx index 4a3de4b..810bd82 100644 --- a/src/features/Posts/pages/PostDetailsPage/Components/StoryPageContent/StoryPageContent.tsx +++ b/src/features/Posts/pages/PostDetailsPage/Components/StoryPageContent/StoryPageContent.tsx @@ -9,6 +9,7 @@ import { useAppSelector } from "src/utils/hooks"; import { useUpdateStory } from './useUpdateStory' import { FaPen } from "react-icons/fa"; import DOMPurify from 'dompurify'; +import Card from "src/Components/Card/Card"; interface Props { @@ -26,9 +27,8 @@ export default function StoryPageContent({ story }: Props) { return ( <> -
- - +
+ {story.cover_image &&
-
+ +
{/*
*/} diff --git a/src/features/Profiles/pages/EditProfilePage/AccountCard/AccountCard.tsx b/src/features/Profiles/pages/EditProfilePage/AccountCard/AccountCard.tsx index b27b49e..d423710 100644 --- a/src/features/Profiles/pages/EditProfilePage/AccountCard/AccountCard.tsx +++ b/src/features/Profiles/pages/EditProfilePage/AccountCard/AccountCard.tsx @@ -1,6 +1,7 @@ import Button from 'src/Components/Button/Button'; import { useAppDispatch } from 'src/utils/hooks'; import { openModal } from 'src/redux/features/modals.slice'; +import Card from 'src/Components/Card/Card'; interface Props { @@ -17,10 +18,8 @@ export default function AccountCard({ }: Props) { return ( -
-

Account Settings

- - + +

🔒 Linking Accounts

Linked Wallets

@@ -32,8 +31,6 @@ export default function AccountCard({ }: Props) { Connect new wallet âš¡

- - -
+ ) } diff --git a/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx b/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx index cbfc3fa..380a716 100644 --- a/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx +++ b/src/features/Profiles/pages/EditProfilePage/EditProfilePage.tsx @@ -4,11 +4,12 @@ import NotFoundPage from "src/features/Shared/pages/NotFoundPage/NotFoundPage"; import Slider from "src/Components/Slider/Slider"; import { useProfileQuery } from "src/graphql"; import { useAppSelector, useMediaQuery } from "src/utils/hooks"; -import CommentsSettingsCard from "../ProfilePage/CommentsSettingsCard/CommentsSettingsCard"; -import UpdateMyProfileCard from "./UpdateMyProfileCard/UpdateMyProfileCard"; +import UpdateMyProfileTab from "./UpdateMyProfileTab/UpdateMyProfileTab"; import { Helmet } from 'react-helmet' import { MEDIA_QUERIES } from "src/utils/theme"; import AccountCard from "./AccountCard/AccountCard"; +import PreferencesTab from "./PreferencesTab/PreferencesTab"; +import Card from "src/Components/Card/Card"; const links = [ @@ -56,7 +57,7 @@ export default function EditProfilePage() {