diff --git a/package-lock.json b/package-lock.json index 5e8d20ca77c..6d36260d25c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,6 +79,7 @@ "react-helmet-async": "^2.0.3", "react-hook-form": "^7.45.2", "react-hooks-visible": "^1.1.1", + "react-intersection-observer": "^9.8.2", "react-intl": "^6.6.1", "react-modal": "^3.15.1", "react-popper": "^2.3.0", @@ -45606,6 +45607,20 @@ "react": ">=16.8" } }, + "node_modules/react-intersection-observer": { + "version": "9.8.2", + "resolved": "https://registry.npmjs.org/react-intersection-observer/-/react-intersection-observer-9.8.2.tgz", + "integrity": "sha512-901naEiiZmse3p+AmtbQ3NL9xx+gQ8TXLiGDc+8GiE3JKJkNV3vP737aGuWTAXBA+1QqxPrDDE+fIEgYpGDlrQ==", + "peerDependencies": { + "react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "react-dom": { + "optional": true + } + } + }, "node_modules/react-intl": { "version": "6.6.1", "license": "BSD-3-Clause", diff --git a/package.json b/package.json index 33fde5a48a5..0b145c8f61b 100644 --- a/package.json +++ b/package.json @@ -211,6 +211,7 @@ "react-helmet-async": "^2.0.3", "react-hook-form": "^7.45.2", "react-hooks-visible": "^1.1.1", + "react-intersection-observer": "^9.8.2", "react-intl": "^6.6.1", "react-modal": "^3.15.1", "react-popper": "^2.3.0", diff --git a/src/components/common/Extensions/UserHubButton/UserHubButton.tsx b/src/components/common/Extensions/UserHubButton/UserHubButton.tsx index b7b19487ad3..4aaa429fccf 100644 --- a/src/components/common/Extensions/UserHubButton/UserHubButton.tsx +++ b/src/components/common/Extensions/UserHubButton/UserHubButton.tsx @@ -141,7 +141,7 @@ const UserHubButton: FC = () => { splitWalletAddress(walletAddress ?? ADDRESS_ZERO); return ( -
+
{fileSize} - + ); diff --git a/src/components/v5/common/ObjectiveBox/ObjectiveBox.tsx b/src/components/v5/common/ObjectiveBox/ObjectiveBox.tsx index 13af4e79676..6f74a8ff27f 100644 --- a/src/components/v5/common/ObjectiveBox/ObjectiveBox.tsx +++ b/src/components/v5/common/ObjectiveBox/ObjectiveBox.tsx @@ -37,7 +37,10 @@ const ObjectiveBox: FC = ({ objective }) => { ) : formatMessage(MSG.noObjectiveBoxDescription)}

- + ); }; diff --git a/src/components/v5/frame/ColonyHome/partials/Objective/Objective.tsx b/src/components/v5/frame/ColonyHome/partials/Objective/Objective.tsx index 99b4ab3caeb..64e9bcc336d 100644 --- a/src/components/v5/frame/ColonyHome/partials/Objective/Objective.tsx +++ b/src/components/v5/frame/ColonyHome/partials/Objective/Objective.tsx @@ -53,8 +53,7 @@ const Objective = () => {

diff --git a/src/components/v5/shared/MenuWithStatusText/MenuWithStatusText.tsx b/src/components/v5/shared/MenuWithStatusText/MenuWithStatusText.tsx index 89c72aa293b..a0edbc30b75 100644 --- a/src/components/v5/shared/MenuWithStatusText/MenuWithStatusText.tsx +++ b/src/components/v5/shared/MenuWithStatusText/MenuWithStatusText.tsx @@ -10,8 +10,6 @@ const displayName = 'v5.shared.MenuWithStatusText'; const MenuWithStatusText: React.FC = ({ statusTextSectionProps, sections, - footer, - footerClassName, }) => { const { content, ...restStatusTextSectionProps } = statusTextSectionProps; @@ -29,13 +27,7 @@ const MenuWithStatusText: React.FC = ({ ...sections, ]; - return ( - - ); + return ; }; MenuWithStatusText.displayName = displayName; diff --git a/src/components/v5/shared/ProgressBar/ProgressBar.tsx b/src/components/v5/shared/ProgressBar/ProgressBar.tsx index 16015d393c9..925fc20d4a1 100644 --- a/src/components/v5/shared/ProgressBar/ProgressBar.tsx +++ b/src/components/v5/shared/ProgressBar/ProgressBar.tsx @@ -5,8 +5,8 @@ import { type ProgressBarProps } from './types.ts'; const ProgressBar: FC = ({ progress, + progressLabel, isTall, - additionalText, threshold = null, max = 100, barClassName, @@ -17,7 +17,7 @@ const ProgressBar: FC = ({ } return ( -
+
= ({ /> )}
- - {progress} + + {progressLabel || progress} - {additionalText && ( - - {additionalText} - - )}
); }; diff --git a/src/components/v5/shared/ProgressBar/types.ts b/src/components/v5/shared/ProgressBar/types.ts index bd2108b0fd3..5f69781fc49 100644 --- a/src/components/v5/shared/ProgressBar/types.ts +++ b/src/components/v5/shared/ProgressBar/types.ts @@ -1,7 +1,7 @@ export interface ProgressBarProps { progress: number; + progressLabel?: JSX.Element | string; isTall?: boolean; - additionalText?: React.ReactNode; threshold?: number; max?: number; barClassName?: string; diff --git a/src/components/v5/shared/StatusText/StatusText.tsx b/src/components/v5/shared/StatusText/StatusText.tsx index 4b3c949eca5..fed9beda42a 100644 --- a/src/components/v5/shared/StatusText/StatusText.tsx +++ b/src/components/v5/shared/StatusText/StatusText.tsx @@ -30,7 +30,7 @@ const StatusText: FC> = ({ return (
> = ({ className={clsx(iconClassName, 'flex-shrink-0')} /> )} -

{children}

+ {children && typeof children === 'string' && ( +

{children}

+ )} + {children && typeof children !== 'string' && ( +
{children}
+ )}
); }; diff --git a/src/components/v5/shared/Stepper/Stepper.tsx b/src/components/v5/shared/Stepper/Stepper.tsx index c2aa3a2d749..7cd9f906e54 100644 --- a/src/components/v5/shared/Stepper/Stepper.tsx +++ b/src/components/v5/shared/Stepper/Stepper.tsx @@ -2,6 +2,7 @@ import { CaretLeft, CaretRight } from '@phosphor-icons/react'; import clsx from 'clsx'; import { motion } from 'framer-motion'; import React, { useEffect, useState } from 'react'; +import { InView } from 'react-intersection-observer'; import { accordionAnimation } from '~constants/accordionAnimation.ts'; import { useMobile } from '~hooks/index.ts'; @@ -19,6 +20,7 @@ function Stepper({ items, }: StepperProps): JSX.Element | null { const activeItemIndex = items.findIndex(({ key }) => key === activeStepKey); + const [hiddenItem, setHiddenItem] = useState(undefined); const [openItemIndex, setOpenItemIndex] = useState(activeItemIndex); const isMobile = useMobile(); const openedItem = items[openItemIndex]; @@ -47,14 +49,14 @@ function Stepper({ } }; - useEffect(() => { - const handleResize = () => { - const element = listRef.current; - if (element) { - setIsScrollableList(element.scrollWidth > element.clientWidth); - } - }; + const handleResize = () => { + const element = listRef.current; + if (element) { + setIsScrollableList(element.scrollWidth > element.clientWidth); + } + }; + useEffect(() => { handleResize(); window.addEventListener('resize', handleResize); @@ -66,8 +68,30 @@ function Stepper({ useEffect(() => { setOpenItemIndex(activeItemIndex); + handleResize(); }, [activeItemIndex]); + const handleChange = (name: TKey, inView: boolean) => { + if (!inView) { + setHiddenItem(name); + } else { + setHiddenItem(undefined); + } + }; + + useEffect(() => { + if (hiddenItem && listRef.current && isMobile && isScrollableList) { + const index = items.findIndex(({ key }) => key === hiddenItem); + if (index > -1) { + listRef.current.scrollBy({ + left: 70 * index, + behavior: 'smooth', + }); + } + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [openItemIndex, isMobile]); + return items.length ? ( <>
@@ -145,7 +169,11 @@ function Stepper({ }, )} > -
+ handleChange(key, inView)} + className="flex flex-col items-start gap-[.375rem] sm:flex-row sm:items-center" + > ({ } onClick={() => { setOpenItemIndex(index); + setHiddenItem(undefined); if (index > activeItemIndex && setActiveStepKey) { setActiveStepKey(key); @@ -168,7 +197,7 @@ function Stepper({ {...restHeading} /> {decor || null} -
+ {!isMobile && !itemDisabled && !!content && (
= ({ ) : ( {content} diff --git a/src/i18n/en.json b/src/i18n/en.json index d85a87d30b3..1c3ad550fc4 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1387,8 +1387,7 @@ "motion.revealStep.title": "You voted:", "motion.revealStep.statusText": "Ends when timer ends; or all voters have revealed.", "motion.revealStep.warning": "You must reveal your vote for it to count and to claim your reward.", - "motion.revealStep.votesRevealed": "votes revealed", - "motion.revealStep.voteRevealed": "vote revealed", + "motion.revealStep.votesRevealed": "{votes} {votes, plural, one {vote} other {votes}} revealed", "motion.revealStep.submit": "Reveal vote", "motion.revealStep.buttonHide": "Hide reveal information", "motion.revealStep.buttonShow": "Show reveal information", @@ -1396,7 +1395,7 @@ "motion.revealStep.emptyDescription": "You did not vote so do not need to reveal. Please wait for all required voters to reveal or the reveal stage to end.", "motion.votingStep.statusText": "Voting ends when either time runs out, or {thresholdPercent}% of reputation in this domain has voted.", "motion.votingStep.title": "Vote to support or oppose?", - "motion.votingStep.additionalText": "% Rep", + "motion.votingStep.additionalText": "{progress}% Rep", "motion.votingStep.votingMethod": "Voting method", "motion.votingStep.teamReputation": "Team reputation", "motion.votingStep.rewardRange": "Reward range", diff --git a/src/stories/shared/ProgressBar.stories.tsx b/src/stories/shared/ProgressBar.stories.tsx index bf34d5c06ab..17a8efa07d1 100644 --- a/src/stories/shared/ProgressBar.stories.tsx +++ b/src/stories/shared/ProgressBar.stories.tsx @@ -24,12 +24,6 @@ const meta: Meta = { type: 'range', }, }, - additionalText: { - name: 'Additional text', - control: { - type: 'text', - }, - }, isTall: { name: 'Is tall?', control: { @@ -53,11 +47,3 @@ export const WithData: Story = { progress: 40, }, }; - -export const WithAdditionalText: Story = { - args: { - progress: 50, - additionalText: 'Rep', - isTall: true, - }, -};