Skip to content

Commit

Permalink
chore: rm onMenuStateChange for menu component
Browse files Browse the repository at this point in the history
  • Loading branch information
nakedfool committed Sep 10, 2024
1 parent 9570ac3 commit cb4843a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 33 deletions.
5 changes: 1 addition & 4 deletions packages/react-app-revamp/components/Share/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ interface ShareDropdownProps {
contestName: string;
contestAddress: string;
chain: string;
onMenuStateChange?: (isOpen: boolean) => void;
}

const ShareDropdown: FC<ShareDropdownProps> = ({ contestName, contestAddress, chain, onMenuStateChange }) => {
const ShareDropdown: FC<ShareDropdownProps> = ({ contestName, contestAddress, chain }) => {
const [isCopied, setIsCopied] = useState(false);

useEffect(() => {
Expand All @@ -42,8 +41,6 @@ const ShareDropdown: FC<ShareDropdownProps> = ({ contestName, contestAddress, ch
return (
<Menu as="div" className="relative inline-block text-left">
{({ open }) => {
onMenuStateChange?.(open);

return (
<>
<MediaQuery maxWidth={768}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const ContestTab = () => {
const qualifiedToSubmit =
currentUserQualifiedToSubmit && currentUserProposalCount < contestMaxNumberSubmissionsPerUser;
const isMobile = useMediaQuery({ maxWidth: 768 });
const [blurProposals, setBlurProposals] = useState(false);
const isInPwaMode = window.matchMedia("(display-mode: standalone)").matches;
const { contestState } = useContestStateStore(state => state);
const isContestCanceled = contestState === ContestStateEnum.Canceled;
Expand Down Expand Up @@ -98,18 +97,11 @@ const ContestTab = () => {
<div className={`mt-4 ${isInPwaMode ? "mb-12" : "mb-0"}`}>
<div className="flex flex-col gap-2">
{contestStatus !== ContestStatus.ContestOpen && !isContestLoading && (
<ProposalStatistics
contestStatus={contestStatus}
onMenuStateChange={(value: boolean) => setBlurProposals(value)}
/>
<ProposalStatistics contestStatus={contestStatus} />
)}

{!isContestLoading && !isListProposalsLoading && isContestSuccess && isListProposalsSuccess && (
<div
className={`animate-reveal ${contestStatus !== ContestStatus.SubmissionOpen ? "mt-4" : "mt-0"} ${
blurProposals ? "blurProposals" : ""
}`}
>
<div className={`animate-reveal ${contestStatus !== ContestStatus.SubmissionOpen ? "mt-4" : "mt-0"}`}>
<ListProposals />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ const options = [
interface SortProposalsDropdownProps {
defaultValue: string;
onChange?: (value: string) => void;
onMenuStateChange?: (isOpen: boolean) => void;
}

const SortProposalsDropdown: FC<SortProposalsDropdownProps> = ({ defaultValue, onChange, onMenuStateChange }) => {
const SortProposalsDropdown: FC<SortProposalsDropdownProps> = ({ defaultValue, onChange }) => {
const [selectedValue, setSelectedValue] = useState(defaultValue);
const menuRef = useRef<HTMLDivElement>(null);

Expand All @@ -33,8 +32,6 @@ const SortProposalsDropdown: FC<SortProposalsDropdownProps> = ({ defaultValue, o
return (
<Menu as="div" className="relative inline-block text-left" ref={menuRef}>
{({ open }) => {
onMenuStateChange?.(open);

return (
<>
<MenuButton className="flex items-center gap-2 text-[16px] text-positive-11 w-full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import { chains } from "@config/wagmi";

interface ProposalStatisticsProps {
contestStatus: ContestStatus;
onMenuStateChange: (isOpen: boolean) => void;
}

const ProposalStatistics: FC<ProposalStatisticsProps> = ({ contestStatus, onMenuStateChange }) => {
const ProposalStatistics: FC<ProposalStatisticsProps> = ({ contestStatus }) => {
const asPath = usePathname();
const { chainName, address } = extractPathSegments(asPath ?? "");
const chainId = chains.filter(chain => chain.name.toLowerCase() === chainName.toLowerCase())[0]?.id;
Expand Down Expand Up @@ -62,11 +61,7 @@ const ProposalStatistics: FC<ProposalStatisticsProps> = ({ contestStatus, onMenu
<div className="flex flex-col md:flex-row gap-4 md:justify-between md:items-center border-b border-primary-2 pb-4">
<ProposalStatisticsPanel submissionsCount={submissionsCount} contestStatus={contestStatus} />
{submissionsCount > 1 ? (
<SortProposalsDropdown
defaultValue={sortBy ?? ""}
onChange={handleSortTypeChange}
onMenuStateChange={onMenuStateChange}
/>
<SortProposalsDropdown defaultValue={sortBy ?? ""} onChange={handleSortTypeChange} />
) : null}
</div>
</div>
Expand Down
10 changes: 2 additions & 8 deletions packages/react-app-revamp/layouts/LayoutViewContest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const LayoutViewContest = ({ children }: { children: React.ReactNode }) => {
const [tab, setTab] = useState<Tab>(Tab.Contest);
const isMobile = useMediaQuery({ maxWidth: 768 });
const bugReportLink = populateBugReportLink(url?.href ?? "", accountAddress ?? "", error ?? "");
const [fadeBg, setFadeBg] = useState(false);

useAccountEffect({
onConnect(data) {
Expand Down Expand Up @@ -253,12 +252,7 @@ const LayoutViewContest = ({ children }: { children: React.ReactNode }) => {
<Image src="/forward.svg" alt="share" width={15} height={13} />
</div>
) : (
<ShareDropdown
contestAddress={address}
chain={chainName}
contestName={contestName}
onMenuStateChange={setFadeBg}
/>
<ShareDropdown contestAddress={address} chain={chainName} contestName={contestName} />
)}

<div
Expand All @@ -269,7 +263,7 @@ const LayoutViewContest = ({ children }: { children: React.ReactNode }) => {
</div>
</div>
</div>
<div className={`${fadeBg ? "opacity-30" : "opacity-100"}`}>
<div>
<div className="mt-8 mb-8 gap-3 flex flex-col">
<ContestTabs tab={tab} onChange={tab => setTab(tab)} />
</div>
Expand Down

0 comments on commit cb4843a

Please sign in to comment.