Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
093354c6
Unverified
Commit
093354c6
authored
Nov 23, 2022
by
Max Proske
Committed by
GitHub
Nov 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `with-videojs`, `with-yoga`, `with-zones` examples to TypeScript (#43280)
parent
ee974817
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
167 additions
and
113 deletions
+167
-113
Player.tsx
examples/with-videojs/components/Player.tsx
+10
-5
PlayerCss.tsx
examples/with-videojs/components/PlayerCss.tsx
+1
-3
package.json
examples/with-videojs/package.json
+10
-3
_app.tsx
examples/with-videojs/pages/_app.tsx
+6
-0
index.tsx
examples/with-videojs/pages/index.tsx
+1
-3
tsconfig.json
examples/with-videojs/tsconfig.json
+20
-0
videojs.d.ts
examples/with-videojs/videojs.d.ts
+1
-0
next.config.js
examples/with-yoga/next.config.js
+0
-3
package.json
examples/with-yoga/package.json
+8
-3
_app.js
examples/with-yoga/pages/_app.js
+0
-22
_app.tsx
examples/with-yoga/pages/_app.tsx
+10
-0
_document.js
examples/with-yoga/pages/_document.js
+0
-30
index.tsx
examples/with-yoga/pages/index.tsx
+0
-0
tsconfig.json
examples/with-yoga/tsconfig.json
+20
-0
yoga.d.ts
examples/with-yoga/yoga.d.ts
+1
-0
next.config.js
examples/with-zones/blog/next.config.js
+3
-1
package.json
examples/with-zones/blog/package.json
+6
-1
index.tsx
examples/with-zones/blog/pages/index.tsx
+1
-10
[id].tsx
examples/with-zones/blog/pages/post/[id].tsx
+1
-0
nextjs.png
examples/with-zones/blog/public/static/nextjs.png
+0
-0
tsconfig.json
examples/with-zones/blog/tsconfig.json
+20
-0
Header.js
examples/with-zones/home/components/Header.js
+0
-7
Header.tsx
examples/with-zones/home/components/Header.tsx
+7
-0
next.config.js
examples/with-zones/home/next.config.js
+3
-1
package.json
examples/with-zones/home/package.json
+6
-1
about.js
examples/with-zones/home/pages/about.js
+0
-13
about.tsx
examples/with-zones/home/pages/about.tsx
+12
-0
index.tsx
examples/with-zones/home/pages/index.tsx
+0
-7
nextjs.png
examples/with-zones/home/public/static/nextjs.png
+0
-0
vercel.png
examples/with-zones/home/public/static/vercel.png
+0
-0
tsconfig.json
examples/with-zones/home/tsconfig.json
+20
-0
No files found.
examples/with-videojs/components/Player.
js
→
examples/with-videojs/components/Player.
tsx
View file @
093354c6
...
...
@@ -2,9 +2,16 @@ import { useCallback, useEffect, useState } from 'react'
import
videojs
from
'video.js'
import
'videojs-youtube'
const
Player
=
(
props
)
=>
{
const
[
videoEl
,
setVideoEl
]
=
useState
(
null
)
const
onVideo
=
useCallback
((
el
)
=>
{
interface
PlayerProps
{
techOrder
:
string
[]
autoplay
:
boolean
controls
:
boolean
sources
:
{
src
:
string
;
type
:
string
}[]
}
export
default
function
Player
(
props
:
PlayerProps
)
{
const
[
videoEl
,
setVideoEl
]
=
useState
<
HTMLVideoElement
|
null
>
(
null
)
const
onVideo
=
useCallback
((
el
:
HTMLVideoElement
)
=>
{
setVideoEl
(
el
)
},
[])
...
...
@@ -25,5 +32,3 @@ const Player = (props) => {
</>
)
}
export
default
Player
examples/with-videojs/components/PlayerCss.
js
→
examples/with-videojs/components/PlayerCss.
tsx
View file @
093354c6
import
'videojs-youtube'
const
PlayerCSS
=
()
=>
{
export
default
function
PlayerCSS
()
{
return
(
<>
<
h1
>
The implementation below is without react functions
</
h1
>
...
...
@@ -17,5 +17,3 @@ const PlayerCSS = () => {
</>
)
}
export
default
PlayerCSS
examples/with-videojs/package.json
View file @
093354c6
...
...
@@ -6,10 +6,17 @@
"start"
:
"next start"
},
"dependencies"
:
{
"next"
:
"
^9.1.8-canary.11
"
,
"next"
:
"
latest
"
,
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
,
"video.js"
:
"^6.7.3"
,
"videojs-youtube"
:
"^2.4.1"
"video.js"
:
"^7.20.3"
,
"videojs-youtube"
:
"^2.6.1"
},
"devDependencies"
:
{
"@types/node"
:
"^18.11.9"
,
"@types/react"
:
"^18.0.25"
,
"@types/react-dom"
:
"^18.0.9"
,
"@types/video.js"
:
"^7.3.49"
,
"typescript"
:
"^4.9.3"
}
}
examples/with-videojs/pages/_app.
js
→
examples/with-videojs/pages/_app.
tsx
View file @
093354c6
import
type
{
AppProps
}
from
'next/app'
import
'video.js/dist/video-js.css'
function
MyApp
({
Component
,
pageProps
}
)
{
export
default
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
return
<
Component
{
...
pageProps
}
/>
}
export
default
MyApp
examples/with-videojs/pages/index.
js
→
examples/with-videojs/pages/index.
tsx
View file @
093354c6
import
Player
from
'../components/Player'
import
PlayerCSS
from
'../components/PlayerCss'
const
Index
=
()
=>
{
export
default
function
Index
()
{
const
videoJsOptions
=
{
techOrder
:
[
'youtube'
],
autoplay
:
false
,
...
...
@@ -21,5 +21,3 @@ const Index = () => {
</>
)
}
export
default
Index
examples/with-videojs/tsconfig.json
0 → 100644
View file @
093354c6
{
"compilerOptions"
:
{
"target"
:
"es5"
,
"lib"
:
[
"dom"
,
"dom.iterable"
,
"esnext"
],
"allowJs"
:
true
,
"skipLibCheck"
:
true
,
"strict"
:
true
,
"forceConsistentCasingInFileNames"
:
true
,
"noEmit"
:
true
,
"esModuleInterop"
:
true
,
"module"
:
"esnext"
,
"moduleResolution"
:
"node"
,
"resolveJsonModule"
:
true
,
"isolatedModules"
:
true
,
"jsx"
:
"preserve"
,
"incremental"
:
true
},
"include"
:
[
"next-env.d.ts"
,
"**/*.ts"
,
"**/*.tsx"
,
"videojs.d.ts"
],
"exclude"
:
[
"node_modules"
]
}
examples/with-videojs/videojs.d.ts
0 → 100644
View file @
093354c6
declare
module
'videojs-youtube'
examples/with-yoga/next.config.js
View file @
093354c6
/** @type {import('next').NextConfig} */
const
nextConfig
=
{
reactStrictMode
:
true
,
compiler
:
{
styledComponents
:
true
,
},
}
module
.
exports
=
nextConfig
examples/with-yoga/package.json
View file @
093354c6
...
...
@@ -7,10 +7,15 @@
"lint"
:
"next lint"
},
"dependencies"
:
{
"@gympass/yoga"
:
"^7.
28
.0"
,
"@gympass/yoga"
:
"^7.
61
.0"
,
"next"
:
"latest"
,
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
,
"styled-components"
:
"^4.4.1"
"react-dom"
:
"^18.2.0"
},
"devDependencies"
:
{
"@types/node"
:
"^18.11.9"
,
"@types/react"
:
"^18.0.25"
,
"@types/react-dom"
:
"^18.0.9"
,
"typescript"
:
"^4.9.3"
}
}
examples/with-yoga/pages/_app.js
deleted
100644 → 0
View file @
ee974817
import
{
ThemeProvider
,
FontLoader
}
from
'@gympass/yoga'
import
{
createGlobalStyle
}
from
'styled-components'
const
GlobalStyle
=
createGlobalStyle
`
body {
margin: 20px;
padding: 0;
box-sizing: border-box;
}
`
function
MyApp
({
Component
,
pageProps
})
{
return
(
<
ThemeProvider
>
<
GlobalStyle
/>
<
FontLoader
/>
<
Component
{...
pageProps
}
/
>
<
/ThemeProvider
>
)
}
export
default
MyApp
examples/with-yoga/pages/_app.tsx
0 → 100644
View file @
093354c6
import
type
{
AppProps
}
from
'next/app'
import
{
ThemeProvider
}
from
'@gympass/yoga'
export
default
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
return
(
<
ThemeProvider
>
<
Component
{
...
pageProps
}
/>
</
ThemeProvider
>
)
}
examples/with-yoga/pages/_document.js
deleted
100644 → 0
View file @
ee974817
import
Document
from
'next/document'
import
{
ServerStyleSheet
}
from
'styled-components'
export
default
class
MyDocument
extends
Document
{
static
async
getInitialProps
(
ctx
)
{
const
sheet
=
new
ServerStyleSheet
()
const
originalRenderPage
=
ctx
.
renderPage
try
{
ctx
.
renderPage
=
()
=>
originalRenderPage
({
enhanceApp
:
(
App
)
=>
(
props
)
=>
sheet
.
collectStyles
(
<
App
{...
props
}
/>
)
,
})
const
initialProps
=
await
Document
.
getInitialProps
(
ctx
)
return
{
...
initialProps
,
styles
:
(
<>
{
initialProps
.
styles
}
{
sheet
.
getStyleElement
()}
<
/
>
),
}
}
finally
{
sheet
.
seal
()
}
}
}
examples/with-yoga/pages/index.
js
→
examples/with-yoga/pages/index.
tsx
View file @
093354c6
File moved
examples/with-yoga/tsconfig.json
0 → 100644
View file @
093354c6
{
"compilerOptions"
:
{
"target"
:
"es5"
,
"lib"
:
[
"dom"
,
"dom.iterable"
,
"esnext"
],
"allowJs"
:
true
,
"skipLibCheck"
:
true
,
"strict"
:
true
,
"forceConsistentCasingInFileNames"
:
true
,
"noEmit"
:
true
,
"esModuleInterop"
:
true
,
"module"
:
"esnext"
,
"moduleResolution"
:
"node"
,
"resolveJsonModule"
:
true
,
"isolatedModules"
:
true
,
"jsx"
:
"preserve"
,
"incremental"
:
true
},
"include"
:
[
"next-env.d.ts"
,
"**/*.ts"
,
"**/*.tsx"
,
"yoga.d.ts"
],
"exclude"
:
[
"node_modules"
]
}
examples/with-yoga/yoga.d.ts
0 → 100644
View file @
093354c6
declare
module
'@gympass/yoga'
examples/with-zones/blog/next.config.js
View file @
093354c6
/** @type {import('next').NextConfig} */
module
.
exports
=
{
const
nextConfig
=
{
basePath
:
'/blog'
,
}
module
.
exports
=
nextConfig
examples/with-zones/blog/package.json
View file @
093354c6
...
...
@@ -10,5 +10,10 @@
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
},
"license"
:
"MIT"
"devDependencies"
:
{
"@types/node"
:
"^18.11.9"
,
"@types/react"
:
"^18.0.25"
,
"@types/react-dom"
:
"^18.0.9"
,
"typescript"
:
"^4.9.3"
}
}
examples/with-zones/blog/pages/index.
js
→
examples/with-zones/blog/pages/index.
tsx
View file @
093354c6
import
Link
from
'next/link'
import
Image
from
'next/image'
export
default
function
Blog
()
{
return
(
...
...
@@ -13,15 +12,7 @@ export default function Blog() {
<
Link
href=
"/post/2"
>
Post 2
</
Link
>
</
li
>
</
ul
>
<
a
href
=
"/"
>
Home
<
/a
>
<
div
>
<
Image
src
=
"/blog/static/nextjs.png"
alt
=
"Next.js logo"
width
=
{
200
}
height
=
{
160
}
/
>
<
/div
>
<
Link
href=
"/"
>
Home
</
Link
>
</
div
>
)
}
examples/with-zones/blog/pages/post/[id].
js
→
examples/with-zones/blog/pages/post/[id].
tsx
View file @
093354c6
...
...
@@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
export
default
function
Post
()
{
const
router
=
useRouter
()
return
(
<
div
>
<
h3
>
Post #
{
router
.
query
.
id
}
</
h3
>
...
...
examples/with-zones/blog/public/static/nextjs.png
deleted
100644 → 0
View file @
ee974817
68.5 KB
examples/with-zones/blog/tsconfig.json
0 → 100644
View file @
093354c6
{
"compilerOptions"
:
{
"target"
:
"es5"
,
"lib"
:
[
"dom"
,
"dom.iterable"
,
"esnext"
],
"allowJs"
:
true
,
"skipLibCheck"
:
true
,
"strict"
:
true
,
"forceConsistentCasingInFileNames"
:
true
,
"noEmit"
:
true
,
"esModuleInterop"
:
true
,
"module"
:
"esnext"
,
"moduleResolution"
:
"node"
,
"resolveJsonModule"
:
true
,
"isolatedModules"
:
true
,
"jsx"
:
"preserve"
,
"incremental"
:
true
},
"include"
:
[
"next-env.d.ts"
,
"**/*.ts"
,
"**/*.tsx"
],
"exclude"
:
[
"node_modules"
]
}
examples/with-zones/home/components/Header.js
deleted
100644 → 0
View file @
ee974817
const
Header
=
()
=>
(
<
div
>
<
h2
>
The
Company
<
/h2
>
<
/div
>
)
export
default
Header
examples/with-zones/home/components/Header.tsx
0 → 100644
View file @
093354c6
export
default
function
Header
()
{
return
(
<
div
>
<
h2
>
The Company
</
h2
>
</
div
>
)
}
examples/with-zones/home/next.config.js
View file @
093354c6
const
{
BLOG_URL
}
=
process
.
env
/** @type {import('next').NextConfig} */
module
.
exports
=
{
const
nextConfig
=
{
async
rewrites
()
{
return
[
{
...
...
@@ -19,3 +19,5 @@ module.exports = {
]
},
}
module
.
exports
=
nextConfig
examples/with-zones/home/package.json
View file @
093354c6
...
...
@@ -10,5 +10,10 @@
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
},
"license"
:
"MIT"
"devDependencies"
:
{
"@types/node"
:
"^18.11.9"
,
"@types/react"
:
"^18.0.25"
,
"@types/react-dom"
:
"^18.0.9"
,
"typescript"
:
"^4.9.3"
}
}
examples/with-zones/home/pages/about.js
deleted
100644 → 0
View file @
ee974817
import
Link
from
'next/link'
const
About
=
()
=>
(
<
div
>
<
p
>
This
is
the
about
page
.
<
/p
>
<
div
>
<
Link
href
=
"/"
>
Go
Back
<
/Link
>
<
/div
>
<
img
width
=
{
200
}
src
=
"/static/vercel.png"
/>
<
/div
>
)
export
default
About
examples/with-zones/home/pages/about.tsx
0 → 100644
View file @
093354c6
import
Link
from
'next/link'
export
default
function
About
()
{
return
(
<
div
>
<
p
>
This is the about page.
</
p
>
<
div
>
<
Link
href=
"/"
>
Go Back
</
Link
>
</
div
>
</
div
>
)
}
examples/with-zones/home/pages/index.
js
→
examples/with-zones/home/pages/index.
tsx
View file @
093354c6
import
Link
from
'next/link'
import
dynamic
from
'next/dynamic'
import
Image
from
'next/image'
const
Header
=
dynamic
(
import
(
'../components/Header'
))
...
...
@@ -15,12 +14,6 @@ export default function Home() {
<
div
>
<
Link
href=
"/about"
>
About us
</
Link
>
</
div
>
<
Image
src
=
"/static/nextjs.png"
alt
=
"Next.js logo"
width
=
{
200
}
height
=
{
160
}
/
>
</
div
>
)
}
examples/with-zones/home/public/static/nextjs.png
deleted
100644 → 0
View file @
ee974817
68.5 KB
examples/with-zones/home/public/static/vercel.png
deleted
100644 → 0
View file @
ee974817
58.5 KB
examples/with-zones/home/tsconfig.json
0 → 100644
View file @
093354c6
{
"compilerOptions"
:
{
"target"
:
"es5"
,
"lib"
:
[
"dom"
,
"dom.iterable"
,
"esnext"
],
"allowJs"
:
true
,
"skipLibCheck"
:
true
,
"strict"
:
true
,
"forceConsistentCasingInFileNames"
:
true
,
"noEmit"
:
true
,
"esModuleInterop"
:
true
,
"module"
:
"esnext"
,
"moduleResolution"
:
"node"
,
"resolveJsonModule"
:
true
,
"isolatedModules"
:
true
,
"jsx"
:
"preserve"
,
"incremental"
:
true
},
"include"
:
[
"next-env.d.ts"
,
"**/*.ts"
,
"**/*.tsx"
],
"exclude"
:
[
"node_modules"
]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment