1.0.4-beta.1 • Published 2 years ago

@twreporter/scrollable-video v1.0.4-beta.1

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

scrollable-video

npm (latest) npm (rc)

Usage

Use buildEmbeddedCode

import { google } from 'googleapis'
import scrollableVideo from '@twreporter/scrollable-video'
import webpackAssets from '@twreporter/scrollable-video/dist/webpack-assets.json'

/* FETCH DATA */

const sheets = await new scrollableVideo.Sheets({
  spreadsheetId: 'your target spreadsheet id',
  auth: new google.auth.GoogleAuth({
    keyFile: 'your-key-file-path', // ex: path.resolve(__dirname, './service-account.json')
    scopes: ['https://www.googleapis.com/auth/spreadsheets.readonly'],
  }),
})

const data = await sheets.getJSONData()
// data schema:
// https://github.com/twreporter/orangutan-monorepo/tree/master/packages/scrollable-video/src/types.js

/* BUILD CODE */

const codeString = scrollableVideo.buildEmbeddedCode(data, webpackAssets)

Use the Component

Example:

import ScrollableVideo from '@twreporter/scrollable-video'

const { appProps, ...elseProps } = data
// data schema:
// https://github.com/twreporter/orangutan-monorepo/tree/master/packages/scrollable-video/src/types.js

<ScrollableVideo.Component
  {...appProps}
  {...elseProps}
/>

How to develop this package

Test dev code

The default dev data is the data of our news article: 從租用到迫遷 ── 南鐵東移,25 年政策與地貌的轉變

You can run makefile command to fetch the latest data:

make dev-fetch-data

# Or specify your spreadsheet ids with `in` variable (separate with commas)
make dev-fetch-data in=1qMXdqZXtANzpOVlKRJJfVhr6YBOuzHV65VJBoylvxk0,1JwQ95yOsr7NEaAv4eX2L0b_hgKFVNqB6L2LE_rW_UXc,1P-RjNv-dFpEH0TadDHr8bEg-L-58or4IxeOgTWPO6Mo

If you change the paths of default data (dev/data-1.json, dev/data-2.json, and dev/data-3.json), you need to update the dev/entry.js to to merge your data into the dev sire.

We use webpack-dev-server to render a mock article with all elements for development. You can start the server with:

make dev-server

If you need to change the hostname (usually due to the CORS reasons), add DEV_HOST=[your-custom-hostname] for giving webpack-dev-server the hostname. Example:

# Start the webpack-dev-server with custom hostname
DEV_HOST=testtest.twreporter.org make dev-server

If you need to test your own video files in your machine, you can place them to dev/static/[filename]. The files will be served with url http://localhost:8080/static/[filename] when the webpack-dev-server runs. Remember to update the src of video in your json files:

{
  "video": {
    "sources": [
      {
        "type": "video/mp4",
        "src": "http://localhost:8080/static/googleearth.mp4"
        /* ... */
      }
    ]
  }
  /* ... */
}
1.0.2

2 years ago

1.0.2-rc.0

2 years ago

1.0.3

2 years ago

1.0.4-beta.0

2 years ago

1.0.4-beta.1

2 years ago

1.0.3-rc.0

2 years ago

1.0.1

2 years ago

1.0.1-rc.0

2 years ago

1.0.1-beta.21

2 years ago

1.0.1-beta.22

2 years ago

1.0.1-beta.20

2 years ago

1.0.1-beta.25

2 years ago

1.0.1-beta.26

2 years ago

1.0.1-beta.23

2 years ago

1.0.1-beta.24

2 years ago

1.0.1-beta.27

2 years ago

1.0.1-beta.2

2 years ago

1.0.1-beta.1

2 years ago

1.0.1-beta.0

2 years ago

1.0.1-beta.6

2 years ago

1.0.1-beta.5

2 years ago

1.0.1-beta.4

2 years ago

1.0.1-beta.3

2 years ago

1.0.1-beta.9

2 years ago

1.0.1-beta.8

2 years ago

1.0.1-beta.7

2 years ago

1.0.1-beta.10

2 years ago

1.0.1-beta.14

2 years ago

1.0.1-beta.15

2 years ago

1.0.1-beta.12

2 years ago

1.0.1-beta.13

2 years ago

1.0.1-beta.18

2 years ago

1.0.1-beta.19

2 years ago

1.0.1-beta.16

2 years ago

1.0.1-beta.17

2 years ago

1.0.0

3 years ago

1.0.0-rc.4

3 years ago

1.0.0-beta.0

3 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-rc.0

4 years ago

0.0.0

4 years ago

0.0.0-beta.19

4 years ago

0.0.0-beta.17

4 years ago

0.0.0-beta.18

4 years ago

0.0.0-beta.16

4 years ago

0.0.0-beta.15

4 years ago

0.0.0-beta.14

4 years ago

0.0.0-beta.13

4 years ago

0.0.0-beta.12

4 years ago

0.0.0-beta.11

4 years ago

0.0.0-beta.10

4 years ago

0.0.0-beta.9

4 years ago

0.0.0-beta.7

4 years ago

0.0.0-beta.8

4 years ago

0.0.0-beta.5

4 years ago

0.0.0-beta.6

4 years ago

0.0.0-beta.4

4 years ago

0.0.0-beta.3

4 years ago

0.0.0-beta.2

4 years ago

0.0.0-beta.1

4 years ago

0.0.0-beta.0

4 years ago