diff --git a/web/components/bio/editable-bio.tsx b/web/components/bio/editable-bio.tsx index 83facabe..02ebbd10 100644 --- a/web/components/bio/editable-bio.tsx +++ b/web/components/bio/editable-bio.tsx @@ -12,6 +12,7 @@ import {useEffect, useState} from "react"; import ReactMarkdown from "react-markdown"; import Link from "next/link" import {MIN_BIO_LENGTH} from "common/constants"; +import {ShowMore} from 'web/components/widgets/show-more' const placeHolder = "Tell us about yourself — and what you're looking for!"; @@ -26,32 +27,11 @@ Write a clear and engaging bio to help others understand who you are and the con ` export function BioTips() { - const [showMoreInfo, setShowMoreInfo] = useState(false) - return ( -
- - {showMoreInfo && ( -
- {tips} - Read full tips for writing a high-quality bio -
- )} -
+ + {tips} + Read full tips for writing a high-quality bio + ) } diff --git a/web/components/votes/vote-info.tsx b/web/components/votes/vote-info.tsx index 5f1bbcea..a06b4769 100644 --- a/web/components/votes/vote-info.tsx +++ b/web/components/votes/vote-info.tsx @@ -15,6 +15,7 @@ import toast from "react-hot-toast"; import {Vote, VoteItem} from 'web/components/votes/vote-item' import Link from "next/link"; import {formLink} from "common/constants"; +import { ShowMore } from "../widgets/show-more"; export function VoteComponent() { const user = useUser() @@ -37,15 +38,9 @@ export function VoteComponent() {

You can discuss any of those proposals through the contact form, the feedback form, or any of our socials.

- {votes && votes.length > 0 && - {votes.map((vote: Vote) => { - return ( - - ) - })} - } + {user && - Add a new proposal + )} + } + + {votes && votes.length > 0 && + {votes.map((vote: Vote) => { + return ( + + ) + })} + } + ) } diff --git a/web/components/widgets/show-more.tsx b/web/components/widgets/show-more.tsx new file mode 100644 index 00000000..25d2f9bd --- /dev/null +++ b/web/components/widgets/show-more.tsx @@ -0,0 +1,38 @@ +import {useState, ReactNode} from 'react' + +interface ShowMoreProps { + labelClosed?: string + labelOpen?: string + children: ReactNode + className?: string +} + +export function ShowMore(props: ShowMoreProps) { + const {labelClosed = 'Show more', labelOpen = 'Hide', children, className} = props + const [showMoreInfo, setShowMoreInfo] = useState(false) + + return ( +
+ + {showMoreInfo && ( +
+ {children} +
+ )} +
+ ) +}