Skip to content

Commit

Permalink
feat(react): add react bindings for vime
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Aug 13, 2020
1 parent 8940d70 commit 8ec4a11
Show file tree
Hide file tree
Showing 54 changed files with 861 additions and 87 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"plugin:@stencil/recommended"
],
"ignorePatterns": [
"ProviderTemplate.ts"
"media/",
"packages/react/src/"
],
"rules": {
"no-console": "off",
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ jobs:
run: cd packages/core && pnpx codecov
- name: Build
run: pnpm run build --filter @vime/core
- name: Release
- name: Release @vime/core
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm run release --filter @vime/core
run: pnpm run release --filter @vime/core
- name: Release @vime/react
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm run release --filter @vime/react
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ log.txt
*.sublime-project
*.sublime-workspace

/.pnp
.pnp.js
.eslintcache/
.nyc_output/
.stencil/
.idea/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ Vime is forward thinking and built for the modern web. All
[ES6 Compatible](https://caniuse.com/#feat=es6-module) browsers are supported, some of which are
listed below.

- Edge 16+
- Firefox 60+
- Edge 79+
- Firefox 68+
- Chrome 61+
- Safari 11+
- iOS Safari 11+
Expand Down
Empty file added examples/angular/.gitkeep
Empty file.
Empty file added examples/ember/.gitkeep
Empty file.
Empty file added examples/html/.gitkeep
Empty file.
Empty file added examples/preact/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions examples/react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Vime React Example

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app)
and demonstrates using Vime with React via the `@vime/react` package.


31 changes: 31 additions & 0 deletions examples/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@vime/react-example",
"version": "0.0.0",
"private": true,
"dependencies": {
"@vime/react": "^1.0.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added examples/react/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/react/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added examples/react/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/react/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/react/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions examples/react/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
4 changes: 4 additions & 0 deletions examples/react/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.container {
width: 100%;
max-width: 980px;
}
21 changes: 21 additions & 0 deletions examples/react/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import './App.css';
import { VimePlayer, VimeYoutube, VimeDefaultUi } from '@vime/react';
import '@vime/react/dist/vime.css'

function App() {
const onPlaying = (event: CustomEvent<boolean>) => {
console.log('playing:', event.detail);
};

return (
<div className="container">
<VimePlayer playsinline onVPlayingChange={onPlaying}>
<VimeYoutube videoId="DyTCOwB0DVw" />
<VimeDefaultUi />
</VimePlayer>
</div>
);
}

export default App;
13 changes: 13 additions & 0 deletions examples/react/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
html,
body,
#root {
width: 100%;
height: 100%;
}

#root {
margin: 0;
display: flex;
align-items: center;
justify-content: center;
}
11 changes: 11 additions & 0 deletions examples/react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
1 change: 1 addition & 0 deletions examples/react/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
15 changes: 15 additions & 0 deletions examples/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true
},
"include": [
"src"
]
}
Empty file added examples/svelte/.gitkeep
Empty file.
Empty file added examples/vue/.gitkeep
Empty file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"pnpm": ">=5"
},
"scripts": {
"lint": "eslint packages/*/src/**/*.{ts,tsx} packages/*/cypress/**/*.{js,ts} --ignore-path .gitignore --fix",
"lint": "eslint packages/*/src/**/*.{ts,tsx} packages/*/cypress/**/*.{js,ts} examples/*/src/**/*.{ts,tsx} tools/*.js scripts/*.js --fix --ignore-path .gitignore",
"script:size": "node scripts/core-dist-size.js"
},
"devDependencies": {
Expand All @@ -25,6 +25,7 @@
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"git-log-parser": "^1.2.0",
"gzip-size": "^5.1.1",
"husky": "^4.2.5",
Expand Down
Empty file added packages/angular/.gitkeep
Empty file.
12 changes: 7 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"es2015": "dist/esm/index.mjs",
"es2017": "dist/esm/index.mjs",
"types": "dist/types/index.d.ts",
"es2015": "dist/index.mjs",
"es2017": "dist/index.mjs",
"jsnext:main": "dist/index.mjs",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"unpkg": "dist/vime/vime.esm.js",
"jsdelivr": "dist/vime/vime.esm.js",
"types": "dist/types/index.d.ts",
"files": [
"dist/",
"loader/",
Expand Down Expand Up @@ -48,7 +49,8 @@
"@cypress/code-coverage": "^3.8.1",
"@cypress/skip-test": "^2.5.0",
"@cypress/webpack-preprocessor": "^5.4.1",
"@stencil/core": "1.17.3",
"@stencil/core": "2.0.0-1",
"@stencil/react-output-target": "^0.0.9",
"@stencil/sass": "^1.3.2",
"@types/hls.js": "^0.13.0",
"@types/jest": "^26.0.7",
Expand All @@ -66,7 +68,7 @@
"sirv-cli": "^1.0.3",
"start-server-and-test": "^1.11.3",
"ts-loader": "^8.0.1",
"webpack": "^4.44.0"
"webpack": "^4.44.1"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/components/core/player/Disposal.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export class Disposal {
constructor(
private dispose: (() => void)[] = []
private dispose: (() => void)[] = [],
) {}

add(callback: () => void) {
this.dispose.push(callback);
}

empty() {
this.dispose.forEach(fn => fn());
this.dispose.forEach((fn) => fn());
this.dispose = [];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Fullscreen {
get isActive() {
if (!this.isSupported) return false;
const fullscreenEl = (document as any)[this.api.fullscreenElement!] as Document['fullscreenElement'];
return (this.el === fullscreenEl)
return (this.el === fullscreenEl)
|| this.el.matches(`:${this.api.fullscreen}`)
|| this.el.contains(fullscreenEl);
}
Expand Down
Loading

0 comments on commit 8ec4a11

Please sign in to comment.