Skip to content

Commit 093354c

Browse files
authored
Convert with-videojs, with-yoga, with-zones examples to TypeScript (vercel#43280)
1 parent ee97481 commit 093354c

32 files changed

+167
-120
lines changed

examples/with-videojs/components/Player.js examples/with-videojs/components/Player.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ import { useCallback, useEffect, useState } from 'react'
22
import videojs from 'video.js'
33
import 'videojs-youtube'
44

5-
const Player = (props) => {
6-
const [videoEl, setVideoEl] = useState(null)
7-
const onVideo = useCallback((el) => {
5+
interface PlayerProps {
6+
techOrder: string[]
7+
autoplay: boolean
8+
controls: boolean
9+
sources: { src: string; type: string }[]
10+
}
11+
12+
export default function Player(props: PlayerProps) {
13+
const [videoEl, setVideoEl] = useState<HTMLVideoElement | null>(null)
14+
const onVideo = useCallback((el: HTMLVideoElement) => {
815
setVideoEl(el)
916
}, [])
1017

@@ -25,5 +32,3 @@ const Player = (props) => {
2532
</>
2633
)
2734
}
28-
29-
export default Player

examples/with-videojs/components/PlayerCss.js examples/with-videojs/components/PlayerCss.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'videojs-youtube'
22

3-
const PlayerCSS = () => {
3+
export default function PlayerCSS() {
44
return (
55
<>
66
<h1>The implementation below is without react functions</h1>
@@ -17,5 +17,3 @@ const PlayerCSS = () => {
1717
</>
1818
)
1919
}
20-
21-
export default PlayerCSS

examples/with-videojs/package.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
"start": "next start"
77
},
88
"dependencies": {
9-
"next": "^9.1.8-canary.11",
9+
"next": "latest",
1010
"react": "^18.2.0",
1111
"react-dom": "^18.2.0",
12-
"video.js": "^6.7.3",
13-
"videojs-youtube": "^2.4.1"
12+
"video.js": "^7.20.3",
13+
"videojs-youtube": "^2.6.1"
14+
},
15+
"devDependencies": {
16+
"@types/node": "^18.11.9",
17+
"@types/react": "^18.0.25",
18+
"@types/react-dom": "^18.0.9",
19+
"@types/video.js": "^7.3.49",
20+
"typescript": "^4.9.3"
1421
}
1522
}

examples/with-videojs/pages/_app.js

-7
This file was deleted.

examples/with-videojs/pages/_app.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { AppProps } from 'next/app'
2+
import 'video.js/dist/video-js.css'
3+
4+
export default function MyApp({ Component, pageProps }: AppProps) {
5+
return <Component {...pageProps} />
6+
}

examples/with-videojs/pages/index.js examples/with-videojs/pages/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Player from '../components/Player'
22
import PlayerCSS from '../components/PlayerCss'
33

4-
const Index = () => {
4+
export default function Index() {
55
const videoJsOptions = {
66
techOrder: ['youtube'],
77
autoplay: false,
@@ -21,5 +21,3 @@ const Index = () => {
2121
</>
2222
)
2323
}
24-
25-
export default Index

examples/with-videojs/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"esModuleInterop": true,
11+
"module": "esnext",
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"isolatedModules": true,
15+
"jsx": "preserve",
16+
"incremental": true
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "videojs.d.ts"],
19+
"exclude": ["node_modules"]
20+
}

examples/with-videojs/videojs.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'videojs-youtube'

examples/with-yoga/next.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
33
reactStrictMode: true,
4-
compiler: {
5-
styledComponents: true,
6-
},
74
}
85

96
module.exports = nextConfig

examples/with-yoga/package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
"lint": "next lint"
88
},
99
"dependencies": {
10-
"@gympass/yoga": "^7.28.0",
10+
"@gympass/yoga": "^7.61.0",
1111
"next": "latest",
1212
"react": "^18.2.0",
13-
"react-dom": "^18.2.0",
14-
"styled-components": "^4.4.1"
13+
"react-dom": "^18.2.0"
14+
},
15+
"devDependencies": {
16+
"@types/node": "^18.11.9",
17+
"@types/react": "^18.0.25",
18+
"@types/react-dom": "^18.0.9",
19+
"typescript": "^4.9.3"
1520
}
1621
}

examples/with-yoga/pages/_app.js

-22
This file was deleted.

examples/with-yoga/pages/_app.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { AppProps } from 'next/app'
2+
import { ThemeProvider } from '@gympass/yoga'
3+
4+
export default function MyApp({ Component, pageProps }: AppProps) {
5+
return (
6+
<ThemeProvider>
7+
<Component {...pageProps} />
8+
</ThemeProvider>
9+
)
10+
}

examples/with-yoga/pages/_document.js

-30
This file was deleted.
File renamed without changes.

examples/with-yoga/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"esModuleInterop": true,
11+
"module": "esnext",
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"isolatedModules": true,
15+
"jsx": "preserve",
16+
"incremental": true
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "yoga.d.ts"],
19+
"exclude": ["node_modules"]
20+
}

examples/with-yoga/yoga.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '@gympass/yoga'
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/** @type {import('next').NextConfig} */
2-
module.exports = {
2+
const nextConfig = {
33
basePath: '/blog',
44
}
5+
6+
module.exports = nextConfig

examples/with-zones/blog/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"react": "^18.2.0",
1111
"react-dom": "^18.2.0"
1212
},
13-
"license": "MIT"
13+
"devDependencies": {
14+
"@types/node": "^18.11.9",
15+
"@types/react": "^18.0.25",
16+
"@types/react-dom": "^18.0.9",
17+
"typescript": "^4.9.3"
18+
}
1419
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Link from 'next/link'
2-
import Image from 'next/image'
32

43
export default function Blog() {
54
return (
@@ -13,15 +12,7 @@ export default function Blog() {
1312
<Link href="/post/2">Post 2</Link>
1413
</li>
1514
</ul>
16-
<a href="/">Home</a>
17-
<div>
18-
<Image
19-
src="/blog/static/nextjs.png"
20-
alt="Next.js logo"
21-
width={200}
22-
height={160}
23-
/>
24-
</div>
15+
<Link href="/">Home</Link>
2516
</div>
2617
)
2718
}

examples/with-zones/blog/pages/post/[id].js examples/with-zones/blog/pages/post/[id].tsx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
33

44
export default function Post() {
55
const router = useRouter()
6+
67
return (
78
<div>
89
<h3>Post #{router.query.id}</h3>
-68.5 KB
Binary file not shown.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": ["dom", "dom.iterable", "esnext"],
5+
"allowJs": true,
6+
"skipLibCheck": true,
7+
"strict": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"noEmit": true,
10+
"esModuleInterop": true,
11+
"module": "esnext",
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"isolatedModules": true,
15+
"jsx": "preserve",
16+
"incremental": true
17+
},
18+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19+
"exclude": ["node_modules"]
20+
}

examples/with-zones/home/components/Header.js

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function Header() {
2+
return (
3+
<div>
4+
<h2>The Company</h2>
5+
</div>
6+
)
7+
}

examples/with-zones/home/next.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { BLOG_URL } = process.env
22

33
/** @type {import('next').NextConfig} */
4-
module.exports = {
4+
const nextConfig = {
55
async rewrites() {
66
return [
77
{
@@ -19,3 +19,5 @@ module.exports = {
1919
]
2020
},
2121
}
22+
23+
module.exports = nextConfig

examples/with-zones/home/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@
1010
"react": "^18.2.0",
1111
"react-dom": "^18.2.0"
1212
},
13-
"license": "MIT"
13+
"devDependencies": {
14+
"@types/node": "^18.11.9",
15+
"@types/react": "^18.0.25",
16+
"@types/react-dom": "^18.0.9",
17+
"typescript": "^4.9.3"
18+
}
1419
}

examples/with-zones/home/pages/about.js

-13
This file was deleted.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Link from 'next/link'
2+
3+
export default function About() {
4+
return (
5+
<div>
6+
<p>This is the about page.</p>
7+
<div>
8+
<Link href="/">Go Back</Link>
9+
</div>
10+
</div>
11+
)
12+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Link from 'next/link'
22
import dynamic from 'next/dynamic'
3-
import Image from 'next/image'
43

54
const Header = dynamic(import('../components/Header'))
65

@@ -15,12 +14,6 @@ export default function Home() {
1514
<div>
1615
<Link href="/about">About us</Link>
1716
</div>
18-
<Image
19-
src="/static/nextjs.png"
20-
alt="Next.js logo"
21-
width={200}
22-
height={160}
23-
/>
2417
</div>
2518
)
2619
}
-68.5 KB
Binary file not shown.
-58.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)