This repository was archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from danestves/v2
feat: get types to pass params for iframe
- Loading branch information
Showing
5 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
"url": "git+https://github.com/danestves/react-youtube-lite.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Daniel Esteves <[email protected]> (@danestves)", | ||
"author": "Daniel Esteves <[email protected]> (https://danestves.com)", | ||
"main": "dist/index.js", | ||
"module": "dist/react-youtube-lite.mjs", | ||
"source": "src/index.ts", | ||
|
@@ -30,7 +30,7 @@ | |
"scripts": { | ||
"prebuild": "npm run clean", | ||
"build": "NODE_ENV=production parcel build", | ||
"clean": "rimraf .parcel-cache dist", | ||
"clean": "rimraf .parcel-cache dist types", | ||
"prestart": "npm run clean", | ||
"start": "parcel watch", | ||
"test": "jest" | ||
|
@@ -44,6 +44,7 @@ | |
"@parcel/packager-ts": "^2.3.2", | ||
"@parcel/transformer-typescript-types": "^2.3.2", | ||
"@types/react": "^17.0.39", | ||
"@types/youtube-player": "^5.5.5", | ||
"parcel": "^2.3.2", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Dependencies | ||
import type * as YouTube from 'youtube-player/dist/types'; | ||
|
||
type GetSrcSearchProps = { | ||
isPlaylist?: boolean; | ||
url: string; | ||
videoId: string; | ||
opts?: YouTube.Options['playerVars']; | ||
}; | ||
|
||
function getSrcSearch({ url, videoId, isPlaylist, opts }: GetSrcSearchProps) { | ||
let options: YouTube.Options['playerVars'] = { | ||
...(!isPlaylist | ||
? { | ||
autoplay: 1, | ||
} | ||
: { | ||
list: videoId, | ||
}), | ||
...opts, | ||
}; | ||
// @ts-ignore: we can use numbers on the values | ||
let params = new URLSearchParams(options); | ||
|
||
return `${url}?${params.toString()}`; | ||
} | ||
|
||
export type { GetSrcSearchProps }; | ||
export { getSrcSearch }; |