From 9c42f452b7854b855dffac21b1c61a3212b74a0e Mon Sep 17 00:00:00 2001 From: WaDadidou Date: Wed, 18 Dec 2024 12:08:09 -0500 Subject: [PATCH] fix(articles): Style ul, style mode buttons, remove ipfs url hack --- assets/icons/eye.svg | 5 ++ assets/icons/splitted-square.svg | 7 ++ .../cards/SocialArticleMarkdownCard.tsx | 6 +- .../ArticleContentEditor.tsx | 2 +- .../Toolbar/ModeButtons.tsx | 74 +++++++++++++++++++ .../ArticleContentEditor/Toolbar/Toolbar.tsx | 56 +++----------- packages/utils/feed/markdown.ts | 9 +++ 7 files changed, 108 insertions(+), 51 deletions(-) create mode 100644 assets/icons/eye.svg create mode 100644 assets/icons/splitted-square.svg create mode 100644 packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/ModeButtons.tsx diff --git a/assets/icons/eye.svg b/assets/icons/eye.svg new file mode 100644 index 000000000..6afc7667c --- /dev/null +++ b/assets/icons/eye.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/icons/splitted-square.svg b/assets/icons/splitted-square.svg new file mode 100644 index 000000000..6634f661d --- /dev/null +++ b/assets/icons/splitted-square.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx b/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx index afab9d2fe..cb19f2f43 100644 --- a/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx +++ b/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx @@ -68,11 +68,7 @@ export const SocialArticleMarkdownCard: FC<{ setLocalPost(post); }, [post]); - const thumbnailURI = thumbnailImage?.url - ? thumbnailImage.url.includes("://") - ? thumbnailImage.url - : "ipfs://" + thumbnailImage.url // we need this hack because ipfs "urls" in feed are raw CIDs - : defaultThumbnailImage; + const thumbnailURI = thumbnailImage?.url || defaultThumbnailImage; return ( = ({ width }) => { }} > {/* ==== Toolbar */} - + {/* ==== Edition and preview */} diff --git a/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/ModeButtons.tsx b/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/ModeButtons.tsx new file mode 100644 index 000000000..afaa209e6 --- /dev/null +++ b/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/ModeButtons.tsx @@ -0,0 +1,74 @@ +import { Dispatch, FC, SetStateAction, useState } from "react"; + +import eyeSVG from "@/assets/icons/eye.svg"; +import penSVG from "@/assets/icons/pen.svg"; +import splittedSquareSVG from "@/assets/icons/splitted-square.svg"; +import { SVG } from "@/components/SVG"; +import { CustomPressable } from "@/components/buttons/CustomPressable"; +import { SpacerRow } from "@/components/spacer"; +import { ContentMode } from "@/utils/feed/markdown"; +import { neutral11, neutral33, neutralFF } from "@/utils/style/colors"; +import { layout } from "@/utils/style/layout"; + +interface Props { + setMode: Dispatch>; + mode: ContentMode; +} + +export const ModeButtons: FC = ({ setMode, mode }) => { + const [hoveredButton, setHoveredButton] = useState(null); + + return ( + <> + setMode("EDITION")} + style={{ + backgroundColor: mode === "EDITION" ? neutral33 : neutral11, + padding: layout.spacing_x0_5, + borderRadius: 6, + borderWidth: 1, + borderColor: hoveredButton === "EDITION" ? neutralFF : neutral11, + }} + onHoverIn={() => setHoveredButton("EDITION")} + onHoverOut={() => setHoveredButton(null)} + > + + + + setMode("BOTH")} + style={{ + backgroundColor: mode === "BOTH" ? neutral33 : neutral11, + padding: layout.spacing_x0_5, + borderRadius: 6, + borderWidth: 1, + borderColor: hoveredButton === "BOTH" ? neutralFF : neutral11, + }} + onHoverIn={() => setHoveredButton("BOTH")} + onHoverOut={() => setHoveredButton(null)} + > + + + + setMode("PREVIEW")} + style={{ + backgroundColor: mode === "PREVIEW" ? neutral33 : neutral11, + padding: layout.spacing_x0_5, + borderRadius: 6, + borderWidth: 1, + borderColor: hoveredButton === "PREVIEW" ? neutralFF : neutral11, + }} + onHoverIn={() => setHoveredButton("PREVIEW")} + onHoverOut={() => setHoveredButton(null)} + > + + + + ); +}; diff --git a/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/Toolbar.tsx b/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/Toolbar.tsx index 96e765fd2..fd13ac724 100644 --- a/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/Toolbar.tsx +++ b/packages/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/Toolbar.tsx @@ -1,61 +1,27 @@ import { Dispatch, FC, SetStateAction } from "react"; -import { View } from "react-native"; -import { BrandText } from "@/components/BrandText"; -import { CustomPressable } from "@/components/buttons/CustomPressable"; -import { SpacerRow } from "@/components/spacer"; +import { TertiaryBox } from "@/components/boxes/TertiaryBox"; +import { ModeButtons } from "@/screens/FeedNewArticle/components/ArticleContentEditor/Toolbar/ModeButtons"; import { ContentMode } from "@/utils/feed/markdown"; -import { neutral1A } from "@/utils/style/colors"; -import { fontSemibold12 } from "@/utils/style/fonts"; +import { neutral11 } from "@/utils/style/colors"; import { layout } from "@/utils/style/layout"; interface Props { setMode: Dispatch>; + mode: ContentMode; } -export const Toolbar: FC = ({ setMode }) => { +export const Toolbar: FC = ({ setMode, mode }) => { return ( - - - setMode("EDITION")} - style={{ - backgroundColor: neutral1A, - padding: layout.spacing_x1, - borderRadius: 8, - }} - > - Edition - - - setMode("BOTH")} - style={{ - backgroundColor: neutral1A, - padding: layout.spacing_x1, - borderRadius: 8, - }} - > - Edition | Preview - - - setMode("PREVIEW")} - style={{ - backgroundColor: neutral1A, - padding: layout.spacing_x1, - borderRadius: 8, - }} - > - Preview - - - + + ); }; diff --git a/packages/utils/feed/markdown.ts b/packages/utils/feed/markdown.ts index 5c6db6868..f353a5c30 100644 --- a/packages/utils/feed/markdown.ts +++ b/packages/utils/feed/markdown.ts @@ -29,6 +29,15 @@ export const markdownTagStyles: MixedStyleRecord = { fontFamily: "Exo_500Medium", fontWeight: "500", }, + ul: { + marginVertical: 4, + color: neutralA3, + fontSize: 14, + letterSpacing: -(14 * 0.04), + lineHeight: 20, + fontFamily: "Exo_500Medium", + fontWeight: "500", + }, code: { color: neutralA3, fontSize: 13,