Skip to content

Commit f6b508f

Browse files
committed
tests
1 parent 19a939e commit f6b508f

File tree

10 files changed

+273
-171
lines changed

10 files changed

+273
-171
lines changed

components/content/ContentHead.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Content, UserPublic } from 'data/graphql-generated';
22
import { buildUrl, contentUrl, profileUrl } from 'util/url-factory';
33

44
import Head from 'next/head';
5-
import { themes } from 'styles/theme';
65
import { useTheme } from 'components';
76

87
export default function ContentHead(props: {
@@ -26,7 +25,6 @@ export default function ContentHead(props: {
2625
favicon,
2726
rss,
2827
webmentionUrl = '';
29-
let fontHeader = '';
3028

3129
if (contentOwner) {
3230
const resource = profileUrl(username, undefined, host);
@@ -36,16 +34,11 @@ export default function ContentHead(props: {
3634
rss = <link rel="alternate" type="application/atom+xml" title={title} href={feedUrl} />;
3735
viewport = contentOwner.viewport || viewport;
3836
webmentionUrl = buildUrl({ host, pathname: '/api/social/webmention', searchParams: { resource } });
39-
const ownerTheme = themes[contentOwner.theme as keyof typeof themes];
40-
fontHeader = (ownerTheme.typography.h1.fontFamily as unknown as string).split(',')[0].replace(/['"]/g, '');
4137
}
4238

4339
return (
4440
<Head>
4541
<title>{title}</title>
46-
{/* TODO refactor to allow different fonts */}
47-
{/* eslint-disable-next-line */}
48-
<link href={`https://fonts.googleapis.com/css2?family=${fontHeader}&display=block`} rel="stylesheet" />
4942
{contentOwner ? (
5043
<link rel="author" href={contentUrl({ username, section: 'main', album: '', name: 'about' })} />
5144
) : null}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"micro": "9.4.1",
8383
"mime": "3.0.0",
8484
"nanoid": "4.0.0",
85-
"next": "13.0.0",
85+
"next": "13.2.3",
8686
"node-forge": "1.3.1",
8787
"node-schedule": "2.1.0",
8888
"prisma": "4.5.0",
@@ -146,7 +146,7 @@
146146
"babel-jest": "29.2.2",
147147
"cross-fetch": "3.1.5",
148148
"eslint": "8.26.0",
149-
"eslint-config-next": "13.0.0",
149+
"eslint-config-next": "13.2.3",
150150
"eslint-plugin-formatjs": "4.3.4",
151151
"eslint-plugin-testing-library": "5.9.1",
152152
"husky": "8.0.1",

pages/_app.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ApolloProvider, NormalizedCacheObject, gql } from '@apollo/client';
77
import { CacheProvider, EmotionCache } from '@emotion/react';
88
import { Footer, Header } from 'components';
99
import { IntlProvider, setupCreateIntl } from 'i18n';
10+
import { Marck_Script, Press_Start_2P } from 'next/font/google';
1011
import { createEmotionCache, muiTheme } from 'styles';
1112
import { disposeAnalytics, setupAnalytics } from 'app/analytics';
1213
import { useEffect, useState } from 'react';
@@ -24,6 +25,20 @@ import { UserProvider } from '@auth0/nextjs-auth0';
2425
import clientHealthCheck from 'app/clientHealthCheck';
2526
import { useRouter } from 'next/router';
2627

28+
// If loading a variable font, you don't need to specify the font weight
29+
const pressStart2P = Press_Start_2P({
30+
weight: '400',
31+
subsets: ['latin'],
32+
variable: '--font-press-start-2p',
33+
display: 'swap',
34+
});
35+
const marckScript = Marck_Script({
36+
weight: '400',
37+
subsets: ['latin'],
38+
variable: '--font-marck-script',
39+
display: 'swap',
40+
});
41+
2742
export { reportWebVitals } from 'app/reportWebVitals';
2843

2944
// Client-side cache, shared for the whole session of the user in the browser.
@@ -101,7 +116,12 @@ function MyApp({ Component, emotionCache = clientSideEmotionCache, pageProps }:
101116
<UserProvider>
102117
<UserContext.Provider value={{ user: currentUser }}>
103118
<ErrorBoundary>
104-
<div className={process.env.NODE_ENV === 'development' ? 'App App-is-development' : 'App'}>
119+
<div
120+
className={
121+
(process.env.NODE_ENV === 'development' ? 'App App-is-development' : 'App') +
122+
` ${pressStart2P.variable} ${marckScript.variable}`
123+
}
124+
>
105125
<Header />
106126
<Head>
107127
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />

pages/_document.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createEmotionCache } from 'styles';
55
import createEmotionServer from '@emotion/server/create-instance';
66
import crypto from 'crypto';
77
import { v4 } from 'uuid';
8-
import { withRouter } from 'next/router';
98

109
const generateCsp = (): [csp: string, nonce: string] => {
1110
const hash = crypto.createHash('sha256');
@@ -34,7 +33,7 @@ const generateCsp = (): [csp: string, nonce: string] => {
3433
'prefetch-src': ["'self'"],
3534
// TODO(mime)
3635
//'report-uri': ['/api/report-csp-violation'],
37-
'script-src': ["'self'", 'https://cdn.auth0.com', 'https://storage.googleapis.com'].concat(
36+
'script-src': ["'self'", 'https://cdn.auth0.com'].concat(
3837
isDevelopment ? ["'unsafe-inline'", "'unsafe-eval'"] : [`'nonce-${nonce}'`]
3938
),
4039

@@ -55,7 +54,7 @@ export interface CustomDocumentInitialProps extends DocumentInitialProps {
5554
emotionStyleTags: ReactNode[];
5655
}
5756

58-
class MyDocument extends Document {
57+
export default class MyDocument extends Document {
5958
// Based off of: https://github.com/mui-org/material-ui/blob/master/examples/nextjs/pages/_document.js
6059
static async getInitialProps(ctx: DocumentContext): Promise<CustomDocumentInitialProps> {
6160
const originalRenderPage = ctx.renderPage;
@@ -104,11 +103,6 @@ class MyDocument extends Document {
104103
<meta charSet="utf-8" />
105104
<meta property="csp-nonce" content={nonce} />
106105
<meta httpEquiv="Content-Security-Policy" content={csp} />
107-
<link rel="preconnect" href="https://fonts.gstatic.com" />
108-
{/* This is because of the withRouter */}
109-
{/* eslint-disable-next-line @next/next/no-page-custom-font */}
110-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
111-
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
112106
<link rel="author" href={`/humans.txt`} />
113107
<meta name="generator" content="Hello, world. https://github.com/mimecuvalo/helloworld" />
114108
{/*
@@ -133,9 +127,6 @@ class MyDocument extends Document {
133127
}
134128
}
135129

136-
// @ts-ignore not sure how to fix this yet
137-
export default withRouter(MyDocument);
138-
139130
// If there is an error that occurs upon page load, i.e. when executing the initial app code,
140131
// then we send the error up to the server via this mechanism.
141132
// Once the app is loaded, then the rest of error reporting goes through error.js -> logError.

pages/dashboard.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ export default function Dashboard() {
136136
<title>Dashboard – {user.title}</title>
137137
<link rel="icon" href={user.favicon || `/favicon.jpg`} />
138138
<link rel="shortcut icon" href={user.favicon || `/favicon.jpg`} />
139-
{/* TODO refactor to allow different fonts */}
140-
{/* eslint-disable-next-line */}
141-
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=block" rel="stylesheet" />
142139
</Head>
143140
<Hamburger
144141
aria-label={menuButtonLabel}

public/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<link rel="author" href="%PUBLIC_URL%/humans.txt" />
1111
<link rel="icon" href="%PUBLIC_URL%/favicon.jpg" />
1212
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.jpg" />
13-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
14-
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
1513
<meta name="viewport" content="width=device-width, initial-scale=1" />
1614
<meta name="theme-color" content="#000000" />
1715
<meta name="generator" content="Hello, world. https://github.com/mimecuvalo/helloworld" />

styles/flowers/typography.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const SYSTEM_FONTS =
44
'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
55

66
const constants = {
7-
fontFamily: `'Marck Script', cursive, ${SYSTEM_FONTS}`,
8-
fontFamilyHeader: `'Marck Script', cursive, ${SYSTEM_FONTS}`,
7+
fontFamily: `var(--font-marck-script), cursive, ${SYSTEM_FONTS}`,
8+
fontFamilyHeader: `var(--font-marck-script), cursive, ${SYSTEM_FONTS}`,
99
fontMonospace:
1010
'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
1111

styles/typography.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const SYSTEM_FONTS =
55

66
const constants = {
77
fontFamily: `${SYSTEM_FONTS}`,
8-
fontFamilyHeader: `'Press Start 2P', ${SYSTEM_FONTS}`,
8+
fontFamilyHeader: `var(--font-press-start-2p), ${SYSTEM_FONTS}`,
99
fontMonospace:
1010
'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
1111

util/testing.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RenderOptions, render } from '@testing-library/react';
44

55
import { IntlProvider } from 'i18n';
66
import { MockedProvider } from '@apollo/client/testing';
7-
import { ThemeProvider } from '@mui/material';
7+
import { ThemeProvider } from '@mui/material/styles';
88
import { muiTheme } from 'styles';
99

1010
const cache = new InMemoryCache();

0 commit comments

Comments
 (0)