From 246aa5c21416b069dac40f42625dc8d25cdd5b69 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sun, 12 Jun 2022 23:25:57 -0500 Subject: [PATCH 01/18] "add funds" => "get M$" --- web/components/add-funds-button.tsx | 2 +- web/components/nav/sidebar.tsx | 4 ++-- web/components/yes-no-selector.tsx | 5 +++-- web/pages/add-funds.tsx | 6 +++--- web/pages/create.tsx | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/web/components/add-funds-button.tsx b/web/components/add-funds-button.tsx index 566f4716..14c9b063 100644 --- a/web/components/add-funds-button.tsx +++ b/web/components/add-funds-button.tsx @@ -24,7 +24,7 @@ export function AddFundsButton(props: { className?: string }) { className )} > - Add funds + Get M$ diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 457b69ff..ba977827 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -69,7 +69,7 @@ function getMoreNavigation(user?: User | null) { } return [ - { name: 'Add funds', href: '/add-funds' }, + { name: 'Get M$', href: '/add-funds' }, { name: 'Leaderboards', href: '/leaderboards' }, { name: 'Blog', href: 'https://news.manifold.markets' }, { name: 'Discord', href: 'https://discord.gg/eHQBNBqXuh' }, @@ -104,7 +104,7 @@ const signedOutMobileNavigation = [ ] const mobileNavigation = [ - { name: 'Add funds', href: '/add-funds', icon: CashIcon }, + { name: 'Get M$', href: '/add-funds', icon: CashIcon }, ...signedOutMobileNavigation, ] diff --git a/web/components/yes-no-selector.tsx b/web/components/yes-no-selector.tsx index 1a5eabf5..d040eba9 100644 --- a/web/components/yes-no-selector.tsx +++ b/web/components/yes-no-selector.tsx @@ -168,7 +168,7 @@ export function FundsSelector(props: { {fundAmounts.map((amount) => ( diff --git a/web/pages/create.tsx b/web/pages/create.tsx index 259a5375..4c33834d 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -348,7 +348,7 @@ export function NewContract(props: { question: string; tag?: string }) { className="btn btn-xs btn-primary" onClick={() => (window.location.href = '/add-funds')} > - Add funds + Get M$ )} From 0d2204bb025f719dcdbfd3da0f6b84f7d5a6c763 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Sun, 12 Jun 2022 23:34:11 -0500 Subject: [PATCH 02/18] Put "Get M$" in sidebar --- web/components/nav/sidebar.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index ba977827..50b69b7b 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -51,7 +51,7 @@ function getNavigation(username: string) { icon: NotificationsIcon, }, - { name: 'Charity', href: '/charity', icon: HeartIcon }, + { name: 'Get M$', href: '/add-funds', icon: CashIcon }, ] } @@ -63,14 +63,15 @@ function getMoreNavigation(user?: User | null) { if (!user) { return [ { name: 'Leaderboards', href: '/leaderboards' }, + { name: 'Charity', href: '/charity' }, { name: 'Discord', href: 'https://discord.gg/eHQBNBqXuh' }, { name: 'Twitter', href: 'https://twitter.com/ManifoldMarkets' }, ] } return [ - { name: 'Get M$', href: '/add-funds' }, { name: 'Leaderboards', href: '/leaderboards' }, + { name: 'Charity', href: '/charity' }, { name: 'Blog', href: 'https://news.manifold.markets' }, { name: 'Discord', href: 'https://discord.gg/eHQBNBqXuh' }, { name: 'Twitter', href: 'https://twitter.com/ManifoldMarkets' }, From 816fc5d64c401478839673478ffd2d467fe98e7c Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Sun, 12 Jun 2022 21:42:41 -0700 Subject: [PATCH 03/18] Revert "Revert "Turn on no unused variables linting, kill dead code (#484)"" This reverts commit 5beda1ded724f7ad1a8d95ea022cf4930ca33b21. --- web/.eslintrc.js | 9 +- web/components/answers/answers-panel.tsx | 2 +- web/components/bets-list.tsx | 8 +- web/components/charity/charity-card.tsx | 2 +- web/components/choices-toggle-group.tsx | 3 +- web/components/confirmation-button.tsx | 4 +- web/components/contract/quick-bet.tsx | 8 +- web/components/feed-create.tsx | 99 +------------------ .../feed/feed-answer-comment-group.tsx | 2 +- web/components/feed/feed-items.tsx | 28 ------ web/components/folds/create-fold-button.tsx | 1 - web/components/liquidity-panel.tsx | 8 +- web/components/nav/profile-menu.tsx | 3 +- web/components/nav/sidebar.tsx | 5 - web/components/numeric-bet-panel.tsx | 1 - web/components/page.tsx | 3 +- web/hooks/use-fold.ts | 37 ------- web/lib/firebase/notifications.ts | 2 +- web/pages/activity.tsx | 2 +- web/pages/api/v0/market/[id].ts | 1 + web/pages/api/v0/slug/[slug].ts | 1 + web/pages/create.tsx | 6 +- web/pages/fold/[...slugs]/index.tsx | 11 --- web/pages/home.tsx | 2 +- web/pages/index.tsx | 2 +- web/pages/landing-page.tsx | 24 +---- web/pages/leaderboards.tsx | 4 +- web/pages/make-predictions.tsx | 10 -- web/pages/notifications.tsx | 6 +- web/pages/stats.tsx | 1 - 30 files changed, 43 insertions(+), 252 deletions(-) diff --git a/web/.eslintrc.js b/web/.eslintrc.js index 6c34b521..2f3ac31a 100644 --- a/web/.eslintrc.js +++ b/web/.eslintrc.js @@ -8,8 +8,15 @@ module.exports = { ], rules: { '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + }, + ], '@next/next/no-img-element': 'off', '@next/next/no-typos': 'off', 'lodash/import-scope': [2, 'member'], diff --git a/web/components/answers/answers-panel.tsx b/web/components/answers/answers-panel.tsx index c711abe8..eb992fe4 100644 --- a/web/components/answers/answers-panel.tsx +++ b/web/components/answers/answers-panel.tsx @@ -116,7 +116,7 @@ export function AnswersPanel(props: { contract: FreeResponseContract }) { {!resolveOption && (
- {answerItems.map((item, activityItemIdx) => ( + {answerItems.map((item) => (
diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index a4e90c35..d227ac88 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -138,9 +138,8 @@ export function BetsList(props: { user: User; hideBetsBefore?: number }) { return !hasSoldAll }) - const [settled, unsettled] = partition( - contracts, - (c) => c.isResolved || contractsMetrics[c.id].invested === 0 + const unsettled = contracts.filter( + (c) => !c.isResolved && contractsMetrics[c.id].invested !== 0 ) const currentInvested = sumBy( @@ -261,7 +260,7 @@ function ContractBets(props: { const isBinary = outcomeType === 'BINARY' - const { payout, profit, profitPercent, invested } = getContractBetMetrics( + const { payout, profit, profitPercent } = getContractBetMetrics( contract, bets ) @@ -657,7 +656,6 @@ function SellButton(props: { contract: Contract; bet: Bet }) { return ( txn.amount) diff --git a/web/components/choices-toggle-group.tsx b/web/components/choices-toggle-group.tsx index f974d72f..61c4e4fd 100644 --- a/web/components/choices-toggle-group.tsx +++ b/web/components/choices-toggle-group.tsx @@ -24,13 +24,12 @@ export function ChoicesToggleGroup(props: { null} + onChange={setChoice} > {Object.keys(choicesMap).map((choiceKey) => ( setChoice(choicesMap[choiceKey])} className={({ active }) => clsx( active ? 'ring-2 ring-indigo-500 ring-offset-2' : '', diff --git a/web/components/confirmation-button.tsx b/web/components/confirmation-button.tsx index e895467a..57a7bafe 100644 --- a/web/components/confirmation-button.tsx +++ b/web/components/confirmation-button.tsx @@ -5,7 +5,6 @@ import { Modal } from './layout/modal' import { Row } from './layout/row' export function ConfirmationButton(props: { - id: string openModalBtn: { label: string icon?: JSX.Element @@ -22,7 +21,7 @@ export function ConfirmationButton(props: { onSubmit: () => void children: ReactNode }) { - const { id, openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props + const { openModalBtn, cancelBtn, submitBtn, onSubmit, children } = props const [open, setOpen] = useState(false) @@ -67,7 +66,6 @@ export function ResolveConfirmationButton(props: { props return ( @@ -257,7 +257,7 @@ function QuickOutcomeView(props: { // If there's a preview prob, display that instead of the current prob const override = previewProb === undefined ? undefined : formatPercent(previewProb) - const textColor = `text-${getColor(contract, previewProb)}` + const textColor = `text-${getColor(contract)}` let display: string | undefined switch (outcomeType) { @@ -306,7 +306,7 @@ function getNumericScale(contract: NumericContract) { return (ev - min) / (max - min) } -export function getColor(contract: Contract, previewProb?: number) { +export function getColor(contract: Contract) { // TODO: Try injecting a gradient here // return 'primary' const { resolution } = contract diff --git a/web/components/feed-create.tsx b/web/components/feed-create.tsx index 98b56d69..0a9b77e3 100644 --- a/web/components/feed-create.tsx +++ b/web/components/feed-create.tsx @@ -1,16 +1,10 @@ -import { sample } from 'lodash' -import { SparklesIcon, XIcon } from '@heroicons/react/solid' -import { Avatar } from './avatar' -import { useEffect, useRef, useState } from 'react' +import { SparklesIcon } from '@heroicons/react/solid' import { Spacer } from './layout/spacer' -import { NewContract } from '../pages/create' -import { firebaseLogin, User } from 'web/lib/firebase/users' +import { firebaseLogin } from 'web/lib/firebase/users' import { ContractsGrid } from './contract/contracts-list' -import { Contract, MAX_QUESTION_LENGTH } from 'common/contract' +import { Contract } from 'common/contract' import { Col } from './layout/col' -import clsx from 'clsx' import { Row } from './layout/row' -import { ENV_CONFIG } from '../../common/envs/constants' import { SiteLink } from './site-link' import { formatMoney } from 'common/util/format' @@ -67,90 +61,3 @@ export function FeedPromo(props: { hotContracts: Contract[] }) { ) } - -export default function FeedCreate(props: { - user?: User - tag?: string - placeholder?: string - className?: string -}) { - const { user, tag, className } = props - const [question, setQuestion] = useState('') - const [isExpanded, setIsExpanded] = useState(false) - const inputRef = useRef() - - // Rotate through a new placeholder each day - // Easter egg idea: click your own name to shuffle the placeholder - // const daysSinceEpoch = Math.floor(Date.now() / 1000 / 60 / 60 / 24) - - // Take care not to produce a different placeholder on the server and client - const [defaultPlaceholder, setDefaultPlaceholder] = useState('') - useEffect(() => { - setDefaultPlaceholder(`e.g. ${sample(ENV_CONFIG.newQuestionPlaceholders)}`) - }, []) - - const placeholder = props.placeholder ?? defaultPlaceholder - - return ( -
{ - !isExpanded && inputRef.current?.focus() - }} - > -
- - -
- -

Ask a question...

- {isExpanded && ( - - )} -
-