From cb071fc9b3a23649c0048118ca930cc9f1098b54 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Mon, 7 Mar 2022 18:34:49 -0800 Subject: [PATCH] Generify most of the customizable brand stuff --- common/envs/prod.ts | 10 +++++++++- common/envs/theoremone.ts | 7 +++++++ common/util/format.ts | 6 +++++- web/components/feed-create.tsx | 13 ++----------- web/components/manifold-logo.tsx | 26 +++++++++++++++++++++++++- web/lib/firebase/init.ts | 6 ++---- web/pages/_document.tsx | 3 ++- 7 files changed, 52 insertions(+), 19 deletions(-) diff --git a/common/envs/prod.ts b/common/envs/prod.ts index e25c2661..20866429 100644 --- a/common/envs/prod.ts +++ b/common/envs/prod.ts @@ -11,6 +11,7 @@ export type EnvConfig = { moneyMoniker: string // e.g. 'M$' faviconPath?: string // Should be a file in /public navbarLogoPath?: string + newQuestionPlaceholders: string[] } type FirebaseConfig = { @@ -40,8 +41,15 @@ export const PROD_CONFIG: EnvConfig = { 'taowell@gmail.com', // Stephen 'manticmarkets@gmail.com', // Manifold ], - moneyMoniker: 'M$', visibility: 'PUBLIC', + + moneyMoniker: 'M$', navbarLogoPath: '', faviconPath: '/favicon.ico', + newQuestionPlaceholders: [ + 'Will anyone I know get engaged this year?', + 'Will humans set foot on Mars by the end of 2030?', + 'Will any cryptocurrency eclipse Bitcoin by market cap this year?', + 'Will the Democrats win the 2024 presidential election?', + ], } diff --git a/common/envs/theoremone.ts b/common/envs/theoremone.ts index 3cd9d0d8..ebe504d9 100644 --- a/common/envs/theoremone.ts +++ b/common/envs/theoremone.ts @@ -16,4 +16,11 @@ export const THEOREMONE_CONFIG: EnvConfig = { moneyMoniker: 'T$', visibility: 'PRIVATE', faviconPath: '/theoremone/logo.ico', + navbarLogoPath: '/theoremone/TheoremOne-Logo.svg', + newQuestionPlaceholders: [ + 'Will we have at least 5 new team members by the end of this quarter?', + 'Will we meet or exceed our goals this sprint?', + 'Will we sign on 3 or more new clients this month?', + 'Will Paul shave his beard by the end of the month?', + ], } diff --git a/common/util/format.ts b/common/util/format.ts index 00fb6077..5a9a3208 100644 --- a/common/util/format.ts +++ b/common/util/format.ts @@ -1,3 +1,5 @@ +import { ENV_CONFIG } from '../access' + const formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', @@ -6,7 +8,9 @@ const formatter = new Intl.NumberFormat('en-US', { }) export function formatMoney(amount: number) { - return 'T$ ' + formatter.format(amount).replace('$', '') + return ( + ENV_CONFIG.moneyMoniker + ' ' + formatter.format(amount).replace('$', '') + ) } export function formatWithCommas(amount: number) { diff --git a/web/components/feed-create.tsx b/web/components/feed-create.tsx index c8d838ca..90b99837 100644 --- a/web/components/feed-create.tsx +++ b/web/components/feed-create.tsx @@ -9,6 +9,7 @@ import { Contract } from '../../common/contract' import { Col } from './layout/col' import clsx from 'clsx' import { Row } from './layout/row' +import { ENV_CONFIG } from '../../common/access' export function FeedPromo(props: { hotContracts: Contract[] }) { const { hotContracts } = props @@ -72,20 +73,10 @@ export default function FeedCreate(props: { const [isExpanded, setIsExpanded] = useState(false) const inputRef = useRef() - const placeholders = [ - // 'Will anyone I know get engaged this year?', - // 'Will humans set foot on Mars by the end of 2030?', - // 'Will any cryptocurrency eclipse Bitcoin by market cap this year?', - // 'Will the Democrats win the 2024 presidential election?', - 'Will we have at least 5 new team members by the end of this quarter?', - 'Will we meet or exceed our goals this sprint?', - 'Will we sign on 3 or more new clients this month?', - 'Will Paul shave his beard by the end of the month?', - ] + const placeholders = ENV_CONFIG.newQuestionPlaceholders // 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) - const [randIndex] = useState( Math.floor(Math.random() * 1e10) % placeholders.length ) diff --git a/web/components/manifold-logo.tsx b/web/components/manifold-logo.tsx index ff57f5da..8654e269 100644 --- a/web/components/manifold-logo.tsx +++ b/web/components/manifold-logo.tsx @@ -2,6 +2,7 @@ import Link from 'next/link' import clsx from 'clsx' import { useUser } from '../hooks/use-user' +import { ENV_CONFIG } from '../../common/access' export function ManifoldLogo(props: { className?: string @@ -20,7 +21,30 @@ export function ManifoldLogo(props: { width={45} height={45} /> - + {ENV_CONFIG.navbarLogoPath ? ( + + ) : ( + <> +
+ Manifold +
+ Markets +
+ + + )} ) diff --git a/web/lib/firebase/init.ts b/web/lib/firebase/init.ts index c82e72d6..7b2e7862 100644 --- a/web/lib/firebase/init.ts +++ b/web/lib/firebase/init.ts @@ -1,13 +1,11 @@ import { getFirestore } from '@firebase/firestore' import { initializeApp, getApps, getApp } from 'firebase/app' -import { FIREBASE_CONFIGS } from '../../../common/access' +import { FIREBASE_CONFIG } from '../../../common/access' const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD' // TODO: Move this to access.ts export const IS_PRIVATE_MANIFOLD = !['PROD', 'DEV'].includes(ENV) -// @ts-ignore -const firebaseConfig = FIREBASE_CONFIGS[ENV] // Initialize Firebase -export const app = getApps().length ? getApp() : initializeApp(firebaseConfig) +export const app = getApps().length ? getApp() : initializeApp(FIREBASE_CONFIG) export const db = getFirestore(app) diff --git a/web/pages/_document.tsx b/web/pages/_document.tsx index 5e8e262e..5cae7052 100644 --- a/web/pages/_document.tsx +++ b/web/pages/_document.tsx @@ -1,10 +1,11 @@ import { Html, Head, Main, NextScript } from 'next/document' +import { ENV_CONFIG } from '../../common/access' export default function Document() { return ( - +