From 0e23cf34508c737da7d6b99e59db7800db440aa6 Mon Sep 17 00:00:00 2001 From: sashamaryl Date: Thu, 29 Feb 2024 17:45:07 -0500 Subject: [PATCH 1/2] add stories billinfoheader, testimonyitem, userinfoheader, remove css module remove delete option on Testimony item -- users will note be able to directly delete their testimony remove viewTestimony.modal.css file --- components/TestimonyCard/BillInfoHeader.tsx | 5 +- components/TestimonyCard/TestimonyItem.tsx | 99 +------------------ components/TestimonyCard/UserInfoHeader.tsx | 15 ++- .../TestimonyCard/ViewTestimony.module.css | 48 --------- .../Testimony/BillInfoHeader.stories.tsx | 38 +++++++ .../Testimony/TetimonyItem.stories.tsx | 38 +++++++ .../Testimony/UserInfoHeader.stories.tsx | 36 +++++++ 7 files changed, 128 insertions(+), 151 deletions(-) delete mode 100644 components/TestimonyCard/ViewTestimony.module.css create mode 100644 stories/organisms/Testimony/BillInfoHeader.stories.tsx create mode 100644 stories/organisms/Testimony/TetimonyItem.stories.tsx create mode 100644 stories/organisms/Testimony/UserInfoHeader.stories.tsx diff --git a/components/TestimonyCard/BillInfoHeader.tsx b/components/TestimonyCard/BillInfoHeader.tsx index ebb5c6f70..29c092811 100644 --- a/components/TestimonyCard/BillInfoHeader.tsx +++ b/components/TestimonyCard/BillInfoHeader.tsx @@ -2,7 +2,6 @@ import { Col, Row } from "react-bootstrap" import { Internal } from "components/links" import { Testimony } from "components/db" import { formatBillId } from "components/formatting" -import styles from "./ViewTestimony.module.css" import { PositionLabel } from "./PositionBug" export const BillInfoHeader = ({ @@ -19,7 +18,7 @@ export const BillInfoHeader = ({

- + {formatBillId(testimony.billId)}

@@ -30,7 +29,7 @@ export const BillInfoHeader = ({
-
+
{" "} {testimony.billTitle ? testimony.billTitle : "Bill Title"}
diff --git a/components/TestimonyCard/TestimonyItem.tsx b/components/TestimonyCard/TestimonyItem.tsx index ea4075407..ffe188263 100644 --- a/components/TestimonyCard/TestimonyItem.tsx +++ b/components/TestimonyCard/TestimonyItem.tsx @@ -15,7 +15,6 @@ import { ReportModal, RequestDeleteOwnTestimonyModal } from "./ReportModal" import { useState } from "react" import { TestimonyContent } from "components/testimony" import { ViewAttachment } from "components/ViewAttachment" -import styles from "./ViewTestimony.module.css" import { UseAsyncReturn } from "react-async-hook" import { useTranslation } from "next-i18next" import { trimContent } from "components/TestimonyCallout/TestimonyCallout" @@ -26,54 +25,6 @@ const FooterButton = styled(Button)` padding: 0; text-decoration: none; ` -const StyledCol = styled(Col)` - font-size: 0.75rem; - - .choice { - padding: 0.2rem 0.5rem 0.2rem 0.5rem; - border-radius: 0.75rem; - color: white; - margin: 0; - font-size: 0.75rem; - - align-items: center; - } -` - -const ArchiveTestimonyConfirmation = ({ - show, - onHide, - archiveTestimony -}: { - show: boolean - onHide: () => void - archiveTestimony: UseAsyncReturn | undefined -}) => { - const { t } = useTranslation("testimony") - - return ( - <> - {t("testimonyItem.deleteTestimonyConfirmation")} - - - - - - ) -} export const TestimonyItem = ({ testimony, @@ -113,20 +64,15 @@ export const TestimonyItem = ({ : trimContent(testimonyContent.slice(0, snippetChars), snippetChars) const canExpand = snippet.length !== testimonyContent.length - const [showConfirm, setShowConfirm] = useState(false) - const { deleteTestimony } = usePublishService() ?? {} - const { t } = useTranslation("testimony") return ( -
+
{isMobile && isUser && ( <> - {/** - * visually-hidden until delete is ready at a later stage - */} - - {t("testimonyItem.deleteIcon") - )}
@@ -189,7 +120,7 @@ export const TestimonyItem = ({ {t("testimonyItem.moreDetails")} @@ -210,7 +141,7 @@ export const TestimonyItem = ({ {t("testimonyItem.edit")} @@ -218,28 +149,6 @@ export const TestimonyItem = ({ )} - - {canDelete && ( - <> - {/* - setShowConfirm(s => !s)} - variant="link" - > - {t("testimonyItem.rescind")} - - */} - - {showConfirm && ( - setShowConfirm(false)} - archiveTestimony={deleteTestimony} - /> - )} - - )} )} {/* report */} diff --git a/components/TestimonyCard/UserInfoHeader.tsx b/components/TestimonyCard/UserInfoHeader.tsx index afde4ba10..25e6eff1a 100644 --- a/components/TestimonyCard/UserInfoHeader.tsx +++ b/components/TestimonyCard/UserInfoHeader.tsx @@ -2,7 +2,6 @@ import { Col, Row, Stack } from "react-bootstrap" import { Internal } from "components/links" import { Author } from "./Author" import { Testimony } from "components/db" -import styles from "./ViewTestimony.module.css" import { ProfilePositionLabel } from "./ProfilePositionBug" import { useTranslation } from "next-i18next" @@ -33,16 +32,22 @@ export const UserInfoHeader = ({ - - {publishedDate} + + {publishedDate} {testimony.version > 1 && ( -

{t("userInfoHeader.edited")}

+ <> +

+ {t("userInfoHeader.edited")} +

+ )}
-
+
) diff --git a/components/TestimonyCard/ViewTestimony.module.css b/components/TestimonyCard/ViewTestimony.module.css deleted file mode 100644 index f966ae511..000000000 --- a/components/TestimonyCard/ViewTestimony.module.css +++ /dev/null @@ -1,48 +0,0 @@ -.toggleIcon::after { - content: url("/angle-down-solid.svg"); - display: inline-block; - width: 1rem; - margin-left: 0.25rem; - position: relative; - top: 0.38rem; -} - -.link { - text-decoration: none; -} - -.link2 { - text-decoration: none; - color: var(color); -} - -.bottomborder { - padding: 1rem 2rem; - border-bottom: 1px solid #cecece; -} -.nobottomborder { - padding: 1rem 2rem; -} - -.heading { - margin-bottom: 0; -} - -.editbug { - margin-bottom: 0; - font-size: 14px; - background-color: #1a3185; - padding: 0.2rem 0.5rem; - border-radius: 0.5rem; - color: white; -} - -.publishdate { - font-size: 14px; - margin-bottom: 0; -} - -.hr { - margin: 0; - border-bottom: 3px solid #cecece; -} diff --git a/stories/organisms/Testimony/BillInfoHeader.stories.tsx b/stories/organisms/Testimony/BillInfoHeader.stories.tsx new file mode 100644 index 000000000..b474aaf70 --- /dev/null +++ b/stories/organisms/Testimony/BillInfoHeader.stories.tsx @@ -0,0 +1,38 @@ +import { Meta, StoryObj } from "@storybook/react" +import { BillInfoHeader } from "components/TestimonyCard/BillInfoHeader" +import { createMockTestimony } from "components/moderation/setUp/MockRecords" +import { Providers } from "components/providers" +import { wrapper } from "components/store" +import { Provider as Redux } from "react-redux" + +// TODO: move into components directory + +const meta: Meta = { + title: "Organisms/Testimony/BillInfoHeader", + component: BillInfoHeader, + decorators: [ + (Story, ...rest) => { + const { store, props } = wrapper.useWrappedStore(...rest) + + return ( + + + + + + ) + } + ] +} +export default meta + +type Story = StoryObj + +export const Primary: Story = { + args: { + testimony: createMockTestimony("H1002", "userId"), + billLink: "#", + publishedDate: "2021-08-11" + }, + name: "BillInfoHeader" +} diff --git a/stories/organisms/Testimony/TetimonyItem.stories.tsx b/stories/organisms/Testimony/TetimonyItem.stories.tsx new file mode 100644 index 000000000..0eb39f750 --- /dev/null +++ b/stories/organisms/Testimony/TetimonyItem.stories.tsx @@ -0,0 +1,38 @@ +import { Meta, StoryObj } from "@storybook/react" +import { TestimonyItem } from "components/TestimonyCard/TestimonyItem" +import { createMockTestimony } from "components/moderation/setUp/MockRecords" +import { Providers } from "components/providers" +import { wrapper } from "components/store" +import { Provider as Redux } from "react-redux" + +const meta: Meta = { + title: "Organisms/Testimony/Testimony Item", + component: TestimonyItem, + decorators: [ + (Story, ...rest) => { + const { store, props } = wrapper.useWrappedStore(...rest) + + return ( + + + + + + ) + } + ] +} +export default meta + +type Story = StoryObj + +export const Primary: Story = { + args: { + testimony: createMockTestimony("H1002", "userId"), + isUser: true, + canEdit: true, + canDelete: true, + onProfilePage: true + }, + name: "Testimony Item" +} diff --git a/stories/organisms/Testimony/UserInfoHeader.stories.tsx b/stories/organisms/Testimony/UserInfoHeader.stories.tsx new file mode 100644 index 000000000..1b1776709 --- /dev/null +++ b/stories/organisms/Testimony/UserInfoHeader.stories.tsx @@ -0,0 +1,36 @@ +import { Meta, StoryObj } from "@storybook/react" +import { UserInfoHeader } from "components/TestimonyCard/UserInfoHeader" +import { createMockTestimony } from "components/moderation/setUp/MockRecords" +import { Providers } from "components/providers" +import { wrapper } from "components/store" +import { Provider as Redux } from "react-redux" + +const meta: Meta = { + title: "Organisms/Testimony/UserInfoHeader", + component: UserInfoHeader, + decorators: [ + (Story, ...rest) => { + const { store, props } = wrapper.useWrappedStore(...rest) + + return ( + + + + + + ) + } + ] +} +export default meta + +type Story = StoryObj + +export const Primary: Story = { + args: { + testimony: createMockTestimony("H1002", "userId"), + billLink: "#", + publishedDate: "2021-08-11" + }, + name: "UserInfoHeader" +} From 2b09a4613c93ad7bf4bd7d825074114db70515bc Mon Sep 17 00:00:00 2001 From: sashamaryl Date: Fri, 1 Mar 2024 19:00:45 -0500 Subject: [PATCH 2/2] finish up migration for testimony Item --- components/TestimonyCard/TestimonyItem.tsx | 59 +++++++++++++--------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/components/TestimonyCard/TestimonyItem.tsx b/components/TestimonyCard/TestimonyItem.tsx index ffe188263..4948afd10 100644 --- a/components/TestimonyCard/TestimonyItem.tsx +++ b/components/TestimonyCard/TestimonyItem.tsx @@ -1,30 +1,41 @@ +import { trimContent } from "components/TestimonyCallout/TestimonyCallout" +import { ViewAttachment } from "components/ViewAttachment" +import { useReportTestimony } from "components/api/report" +import { flags } from "components/featureFlags" import { formUrl } from "components/publish/hooks" -import Image from "react-bootstrap/Image" +import { TestimonyContent } from "components/testimony" +import { useTranslation } from "next-i18next" +import { ReactNode, useState } from "react" +import { ButtonProps } from "react-admin" import { ToastContainer } from "react-bootstrap" -import { useReportTestimony } from "components/api/report" -import ReportToast from "./ReportToast" +import Image from "react-bootstrap/Image" import { useMediaQuery } from "usehooks-ts" -import { usePublishService } from "components/publish/hooks" -import { Col, Row, Stack, Button, Spinner } from "../bootstrap" -import styled from "styled-components" +import { Button, Col, Row, Stack } from "../bootstrap" import { Testimony } from "../db" import { Internal, maple } from "../links" -import { UserInfoHeader } from "./UserInfoHeader" import { BillInfoHeader } from "./BillInfoHeader" import { ReportModal, RequestDeleteOwnTestimonyModal } from "./ReportModal" -import { useState } from "react" -import { TestimonyContent } from "components/testimony" -import { ViewAttachment } from "components/ViewAttachment" -import { UseAsyncReturn } from "react-async-hook" -import { useTranslation } from "next-i18next" -import { trimContent } from "components/TestimonyCallout/TestimonyCallout" -import { flags } from "components/featureFlags" +import ReportToast from "./ReportToast" +import { UserInfoHeader } from "./UserInfoHeader" -const FooterButton = styled(Button)` - margin: 0; - padding: 0; - text-decoration: none; -` +type FooterButtonProps = Omit & { + className?: string + children?: ReactNode +} +const FooterButton = ({ + variant = "text", + className, + children +}: FooterButtonProps) => { + return ( + + ) +} export const TestimonyItem = ({ testimony, @@ -109,7 +120,7 @@ export const TestimonyItem = ({ {canExpand && ( setShowAllTestimony(true)} > {t("testimonyItem.expand")} @@ -118,7 +129,7 @@ export const TestimonyItem = ({ )} {testimony.id && ( - + - + @@ -139,7 +150,7 @@ export const TestimonyItem = ({ <> {onProfilePage && ( - + - setIsReporting(true)}> + setIsReporting(true)}> Report