From 86fb9bf7040abdb3c90936f1cbd40c3db60dd4dc Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 2 May 2022 12:57:14 -0400 Subject: [PATCH] Add ProgressBar and dark mode support --- app/soapbox/components/progress_bar.tsx | 13 ---------- .../components/status-action-button.tsx | 1 - app/soapbox/components/ui/index.ts | 1 + .../ui/progress-bar/progress-bar.tsx | 13 ++++++++++ .../features/ui/components/funding_panel.tsx | 4 +-- .../modals/report-modal/report-modal.tsx | 25 ++++++++++++++++--- .../report-modal/steps/confirmation-step.tsx | 2 +- .../report-modal/steps/other-actions-step.tsx | 4 +-- .../modals/report-modal/steps/reason-step.tsx | 25 +++++++++---------- app/soapbox/reducers/reports.js | 2 ++ 10 files changed, 53 insertions(+), 37 deletions(-) delete mode 100644 app/soapbox/components/progress_bar.tsx create mode 100644 app/soapbox/components/ui/progress-bar/progress-bar.tsx diff --git a/app/soapbox/components/progress_bar.tsx b/app/soapbox/components/progress_bar.tsx deleted file mode 100644 index 24e4e6790..000000000 --- a/app/soapbox/components/progress_bar.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; - -interface IProgressBar { - progress: number, -} - -const ProgressBar: React.FC = ({ progress }) => ( -
-
-
-); - -export default ProgressBar; diff --git a/app/soapbox/components/status-action-button.tsx b/app/soapbox/components/status-action-button.tsx index d72bbbf9e..6bbd86fa8 100644 --- a/app/soapbox/components/status-action-button.tsx +++ b/app/soapbox/components/status-action-button.tsx @@ -56,7 +56,6 @@ const StatusActionButton = React.forwardRef((props: IStatusActionButton, ref: Re = ({ progress }) => ( +
+
+
+); + +export default ProgressBar; diff --git a/app/soapbox/features/ui/components/funding_panel.tsx b/app/soapbox/features/ui/components/funding_panel.tsx index fa2ad8911..57c5246ef 100644 --- a/app/soapbox/features/ui/components/funding_panel.tsx +++ b/app/soapbox/features/ui/components/funding_panel.tsx @@ -2,11 +2,9 @@ import React, { useEffect } from 'react'; import { FormattedMessage } from 'react-intl'; import { fetchPatronInstance } from 'soapbox/actions/patron'; -import { Widget, Button, Text } from 'soapbox/components/ui'; +import { Widget, Button, ProgressBar, Text } from 'soapbox/components/ui'; import { useAppSelector, useAppDispatch } from 'soapbox/hooks'; -import ProgressBar from '../../../components/progress_bar'; - /** Open link in a new tab. */ // https://stackoverflow.com/a/28374344/8811886 const openInNewTab = (href: string): void => { diff --git a/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx b/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx index 9213fc60c..2f46b6b3b 100644 --- a/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx +++ b/app/soapbox/features/ui/components/modals/report-modal/report-modal.tsx @@ -1,12 +1,12 @@ import { AxiosError } from 'axios'; import { Set as ImmutableSet } from 'immutable'; -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { blockAccount } from 'soapbox/actions/accounts'; import { submitReport, cancelReport, submitReportSuccess, submitReportFail } from 'soapbox/actions/reports'; import { expandAccountTimeline } from 'soapbox/actions/timelines'; -import { Modal } from 'soapbox/components/ui'; +import { Modal, ProgressBar, Stack } from 'soapbox/components/ui'; import { useAccount, useAppDispatch, useAppSelector } from 'soapbox/hooks'; import ConfirmationStep from './steps/confirmation-step'; @@ -103,6 +103,19 @@ const ReportModal = ({ onClose }: IReportModal) => { return isSubmitting || (shouldRequireRule && !ruleId) || selectedStatusIds.size === 0; }, [currentStep, isSubmitting, shouldRequireRule, ruleId, selectedStatusIds.size]); + const calculateProgress = useCallback(() => { + switch (currentStep) { + case Steps.ONE: + return 0.33; + case Steps.TWO: + return 0.66; + case Steps.THREE: + return 1; + default: + return 0; + } + }, [currentStep]); + useEffect(() => { if (account) { dispatch(expandAccountTimeline(account.id, { withReplies: true, maxId: null })); @@ -119,13 +132,17 @@ const ReportModal = ({ onClose }: IReportModal) => { @{account.acct} }} />} onClose={handleClose} - cancelAction={onClose} + cancelAction={currentStep === Steps.THREE ? undefined : onClose} confirmationAction={handleNextStep} confirmationText={confirmationText} confirmationDisabled={isConfirmationButtonDisabled} skipFocus > - + + + + + ); }; diff --git a/app/soapbox/features/ui/components/modals/report-modal/steps/confirmation-step.tsx b/app/soapbox/features/ui/components/modals/report-modal/steps/confirmation-step.tsx index 836624de4..c97ff9ba4 100644 --- a/app/soapbox/features/ui/components/modals/report-modal/steps/confirmation-step.tsx +++ b/app/soapbox/features/ui/components/modals/report-modal/steps/confirmation-step.tsx @@ -11,7 +11,7 @@ interface IOtherActionsStep { const ConfirmationStep = ({ account }: IOtherActionsStep) => { return ( - + Thanks for submitting your report. diff --git a/app/soapbox/features/ui/components/modals/report-modal/steps/other-actions-step.tsx b/app/soapbox/features/ui/components/modals/report-modal/steps/other-actions-step.tsx index bdba7bd4b..6efd904ee 100644 --- a/app/soapbox/features/ui/components/modals/report-modal/steps/other-actions-step.tsx +++ b/app/soapbox/features/ui/components/modals/report-modal/steps/other-actions-step.tsx @@ -97,7 +97,7 @@ const OtherActionsStep = ({ account }: IOtherActionsStep) => { {features.reportMultipleStatuses && ( - Include other statuses? + Include other statuses? { )} - Further actions: + Further actions: } diff --git a/app/soapbox/features/ui/components/modals/report-modal/steps/reason-step.tsx b/app/soapbox/features/ui/components/modals/report-modal/steps/reason-step.tsx index 50956734b..ea051fb85 100644 --- a/app/soapbox/features/ui/components/modals/report-modal/steps/reason-step.tsx +++ b/app/soapbox/features/ui/components/modals/report-modal/steps/reason-step.tsx @@ -8,7 +8,7 @@ import { changeReportComment, changeReportRule } from 'soapbox/actions/reports'; import { fetchRules } from 'soapbox/actions/rules'; import AttachmentThumbs from 'soapbox/components/attachment_thumbs'; import StatusContent from 'soapbox/components/status_content'; -import { FormGroup, Stack, Text, Textarea } from 'soapbox/components/ui'; +import { FormGroup, HStack, Stack, Text, Textarea } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account_container'; import { useAppSelector } from 'soapbox/hooks'; @@ -115,11 +115,11 @@ const ReasonStep = (_props: IReasonStep) => { {shouldRequireRule && ( - Reason for reporting + Reason for reporting
@@ -132,21 +132,20 @@ const ReasonStep = (_props: IReasonStep) => { data-testid={`rule-${rule.id}`} onClick={() => dispatch(changeReportRule(rule.id))} className={classNames({ - 'relative border border-solid border-gray-200 hover:bg-gray-50 text-left w-full p-4 flex justify-between items-center cursor-pointer': true, + 'relative border border-solid border-gray-200 dark:border-slate-900/75 hover:bg-gray-50 dark:hover:bg-slate-900/50 text-left w-full p-4 flex justify-between items-center cursor-pointer': true, 'rounded-tl-lg rounded-tr-lg': idx === 0, 'rounded-bl-lg rounded-br-lg': idx === rules.length - 1, - 'bg-gray-50': isSelected, + 'bg-gray-50 dark:bg-slate-900': isSelected, })} >
- {rule.text} - + {rule.subtext}
@@ -164,13 +163,13 @@ const ReasonStep = (_props: IReasonStep) => {