shiveshnavin commited on
Commit
9221bcd
·
1 Parent(s): 4334de7

Added CoverPages

Browse files
src/Compositions.tsx CHANGED
@@ -216,8 +216,8 @@ export const Compositions: React.FC = () => {
216
  component={PaperDriveHorizontalCoverComposition}
217
  durationInFrames={duration}
218
  fps={fps}
219
- width={Script.meta?.resolution?.width || 1920}
220
- height={Script.meta?.resolution?.height || 1080}
221
  defaultProps={Object.assign(Script, {
222
  bgMusic: RenderUtils.getFileName(Script.bgMusic, "mp3"),
223
  contents: contents,
 
216
  component={PaperDriveHorizontalCoverComposition}
217
  durationInFrames={duration}
218
  fps={fps}
219
+ height={Script.meta?.resolution?.width || 1920}
220
+ width={Script.meta?.resolution?.height || 1080}
221
  defaultProps={Object.assign(Script, {
222
  bgMusic: RenderUtils.getFileName(Script.bgMusic, "mp3"),
223
  contents: contents,
src/paperdrive/PaperDriveComposition.tsx CHANGED
@@ -1,7 +1,8 @@
1
  import { Series } from "remotion";
2
  import { OriginalManuscript } from 'common-utils';
3
- import { PaperDrivePage, PaperDrivePageExtras } from './PaperDrivePage';
4
  import { PaperDriveIndex } from './PaperDriveIndex';
 
5
 
6
  export const PaperDriveComposition = (props: OriginalManuscript) => {
7
  let { meta } = props
 
1
  import { Series } from "remotion";
2
  import { OriginalManuscript } from 'common-utils';
3
+ import { PaperDrivePage } from './PaperDrivePage';
4
  import { PaperDriveIndex } from './PaperDriveIndex';
5
+ import { PaperDrivePageExtras } from "./types";
6
 
7
  export const PaperDriveComposition = (props: OriginalManuscript) => {
8
  let { meta } = props
src/paperdrive/PaperDriveHorizontalCoverComposition.tsx CHANGED
@@ -1,127 +1,190 @@
1
  import { AbsoluteFill, Img, staticFile } from 'remotion';
2
- import React from 'react'
3
- import { PaperDrivePoster } from './types';
4
- import { loadFont } from '@remotion/google-fonts/Lato';
5
-
6
-
7
- export const PaperDriveHorizontalCoverComposition: React.FC<PaperDrivePoster> = (props: PaperDrivePoster) => {
8
- const data = [
9
- {
10
- "title": "ClassPad",
11
- "text": "By Paper Drive",
12
- "index": 0,
13
- "status": true,
14
- "durationInSeconds": 1,
15
- "extras": {
16
- "url": "https://app.mypaperdrive.com/notebooks/landing",
17
- "marginLeft": "5vh",
18
- "marginTop": "5vh",
19
- "marginBottom": "5vh",
20
- "leftMarginLineColor": "#e0e0e0",
21
- "lineColor": "#bdbdbd",
22
- "backgroundColor": "white",
23
- "qr": {
24
- "qrStyle": "dots",
25
- "color": "#1a1a1c",
26
- "logo": "./logo-transparent-grey.png",
27
- "logoOpacity": 0.1,
28
- "size": "7vh",
29
- "position": {
30
- "zIndex": 1000,
31
- "borderWidth": 2,
32
- "borderColor": "lightgray",
33
- "borderRadius": 10,
34
- "backgroundColor": "#fff",
35
- "padding": 0.1,
36
- "margin": 5,
37
- "position": "absolute",
38
- "top": 0,
39
- "right": 0
40
- }
41
- },
42
- "header": {
43
- "fontFamily": "Lato, sans-serif",
44
- "color": "lightgray",
45
- "text_title": "Topic&nbsp;:",
46
- "text_date": "Date&nbsp;&nbsp;:",
47
- "text_page": "Page No. 1",
48
- "underline_style": {
49
- "textDecoration": "underline",
50
- "borderBottom": "1px dotted black"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
- },
53
- "footer": {
54
- "text": "Scan the QR to view or attach photos, videos and other files on this page or Visit mypaperdrive.com/p/1",
55
- "text_style": {
56
- "fontSize": "1.1rem",
57
- "fontFamily": "Lato, sans-serif",
58
- "color": "lightgray"
59
  }
60
- }
61
- }
62
- },
63
- {
64
- "text": "Scan me",
65
- "index": 0,
66
- "status": true,
67
- "title": "Page 0",
68
- "extras": {
69
- "url": "https://app.mypaperdrive.com/notebooks/page?page=0",
70
- "marginLeft": "5vh",
71
- "marginTop": "5vh",
72
- "marginBottom": "5vh",
73
- "leftMarginLineColor": "#e0e0e0",
74
- "lineColor": "#bdbdbd",
75
- "backgroundColor": "white",
76
- "qr": {
77
- "qrStyle": "dots",
78
- "color": "#1a1a1c",
79
- "logo": "./logo-transparent-grey.png",
80
- "logoOpacity": 0.1,
81
- "size": "7vh",
82
- "position": {
83
- "zIndex": 1000,
84
- "borderWidth": 2,
85
- "borderColor": "lightgray",
86
- "borderRadius": 10,
87
- "backgroundColor": "#fff",
88
- "padding": 0.1,
89
- "margin": 5,
90
- "position": "absolute",
91
- "top": 0,
92
- "right": 0
93
  }
94
- },
95
- "header": {
96
- "fontFamily": "Lato, sans-serif",
97
- "color": "lightgray",
98
- "text_title": "Topic&nbsp;:",
99
- "text_date": "Date&nbsp;&nbsp;:",
100
- "text_page": "Page No. 0",
101
- "underline_style": {
102
- "textDecoration": "underline",
103
- "borderBottom": "1px dotted black"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
- },
106
- "footer": {
107
- "text": "Scan the QR to view or attach photos, videos and other files on this page or Visit mypaperdrive.com/p/0",
108
- "text_style": {
109
- "fontSize": "1.1rem",
110
- "fontFamily": "Lato, sans-serif",
111
- "color": "lightgray"
 
 
112
  }
113
- }
114
- },
115
- "imageAbsPaths": [],
116
- "durationInSeconds": 1
117
- }
118
- ]
119
- loadFont();
 
 
 
 
 
 
 
 
 
120
 
121
  return (
122
- <AbsoluteFill>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
 
125
- </AbsoluteFill >
126
- );
127
- };
 
1
  import { AbsoluteFill, Img, staticFile } from 'remotion';
2
+ import React, { CSSProperties } from 'react'
3
+ import { PaperDrivePageExtras } from './types';
4
+ import { loadFont as loadMontserrat } from '@remotion/google-fonts/Montserrat';
5
+ import { OriginalManuscript, Transcript } from 'common-utils';
6
+ import { RenderUtils } from '../RenderUtils';
7
+ import { QRCode } from 'react-qrcode-logo';
8
+
9
+
10
+ export const PaperDriveHorizontalCoverComposition = (props: OriginalManuscript) => {
11
+ const data = props.transcript
12
+ .filter(v => ["front-cover", "back-cover"].includes(v.extras?.template))
13
+
14
+ const frontData = data[0]
15
+ const backData = data[1]
16
+
17
+ return (
18
+ <AbsoluteFill style={{
19
+ padding: 0,
20
+ margin: 0,
21
+ display: 'flex',
22
+ width: '100%',
23
+ height: '100%',
24
+ flexDirection: 'row',
25
+ }}>
26
+ {frontData && <PaperDriveBackCover transcript={backData} style={{
27
+ width: '50%',
28
+ height: '100%',
29
+ paddingRight: 50,
30
+ }} />}
31
+ {backData && <PaperDriveFrontCover transcript={frontData} style={{
32
+ width: '50%',
33
+ height: '100%',
34
+ paddingLeft: 50,
35
+ }} />}
36
+ </AbsoluteFill>
37
+ );
38
+ };
39
+
40
+
41
+ export function PaperDriveFrontCover({ transcript, style }: { transcript: Transcript, style?: CSSProperties }) {
42
+ const extras = transcript.extras as PaperDrivePageExtras
43
+ const { fontFamily: Montserrat } = loadMontserrat();
44
+
45
+ const qrImageBlend = extras?.qr?.logo
46
+ const defaultQrSize = RenderUtils.convertVHToPixels(extras?.marginTop ?? '10vh')
47
+ const logo = qrImageBlend ? staticFile(RenderUtils.getFileName(qrImageBlend)!) : undefined
48
+ let qrSize = defaultQrSize
49
+ if (extras?.qr?.size?.includes("vh")) {
50
+ qrSize = RenderUtils.convertVHToPixels(extras?.qr?.size)
51
+ } else if (extras?.qr?.size?.includes("vw")) {
52
+ qrSize = RenderUtils.convertVWToPixels(extras?.qr?.size)
53
+ } else if (extras?.qr?.size) {
54
+ qrSize = parseInt(extras?.qr?.size)
55
+ }
56
+
57
+
58
+ return (
59
+ <div style={{
60
+ backgroundColor: extras?.backgroundColor ?? "black",
61
+ ...style
62
+ }}>
63
+ <div style={{
64
+ height: '100%',
65
+ display: 'flex',
66
+ flexDirection: 'column',
67
+ alignItems: 'center',
68
+ color: 'white',
69
+ justifyContent: 'space-around'
70
+ }}>
71
+ <div style={{
72
+ ...extras.header?.position
73
+ }}>
74
+ {(transcript.title || extras.header?.text_title) && <h1 style={{
75
+ color: extras?.header?.color ?? '#1a1a1c',
76
+ fontFamily: extras?.header?.fontFamily ?? Montserrat,
77
+ ...extras?.header?.title_style
78
+ }}>{extras.header?.text_title || transcript.title}</h1>
79
  }
80
+ {
81
+ transcript.text && <h1 style={{
82
+ fontFamily: extras?.header?.fontFamily ?? Montserrat,
83
+ ...extras?.header?.text_style
84
+ }}>
85
+ {transcript.text}
86
+ </h1>
87
  }
88
+ {
89
+ extras?.header?.graphic && (
90
+ <Img
91
+ src={staticFile(RenderUtils.getFileName(extras?.header?.graphic?.source)!)}
92
+ style={{
93
+ ...extras?.header?.graphic?.position
94
+ }} />
95
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
+ </div>
98
+ <center>
99
+
100
+ <QRCode
101
+ style={extras?.qr?.position ?? {
102
+ zIndex: 1000,
103
+ position: 'absolute',
104
+ top: 50,
105
+ left: 50
106
+ }}
107
+ bgColor={extras?.qr?.backgroundColor ?? 'transparent'}
108
+ fgColor={extras?.qr?.color ?? 'black'}
109
+ size={qrSize ?? defaultQrSize}
110
+ value={extras?.url}
111
+ qrStyle={extras?.qr?.qrStyle ?? 'squares'}
112
+ logoImage={logo}
113
+ logoWidth={qrSize ?? defaultQrSize}
114
+ logoHeight={qrSize ?? defaultQrSize}
115
+ logoOpacity={extras?.qr?.logoOpacity ?? 0.1}
116
+ removeQrCodeBehindLogo={false}
117
+ />
118
+ {
119
+ extras?.header?.text_sec && (
120
+ <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_sec }} style={{
121
+ fontFamily: Montserrat
122
+ }} />
123
+ )
124
  }
125
+ {
126
+ extras?.header?.text_ter &&
127
+ <div
128
+ style={{
129
+ fontFamily: Montserrat
130
+ }}
131
+ dangerouslySetInnerHTML={{ __html: extras?.header?.text_ter }}>
132
+
133
+ </div>
134
  }
135
+
136
+ </center>
137
+ </div>
138
+ </div>
139
+ )
140
+
141
+ }
142
+
143
+
144
+
145
+
146
+
147
+ export function PaperDriveBackCover({ transcript, style }: { transcript: Transcript, style?: CSSProperties }) {
148
+ const extras = transcript.extras as PaperDrivePageExtras
149
+
150
+ const { fontFamily: Montserrat } = loadMontserrat();
151
 
152
  return (
153
+ <div style={{
154
+ backgroundColor: extras?.backgroundColor ?? "black",
155
+ ...style
156
+ }}>
157
+ <div style={{
158
+ fontFamily: Montserrat,
159
+ padding: 50,
160
+ flex: 1,
161
+ height: '100%',
162
+ flexDirection: 'column',
163
+ justifyContent: 'space-between',
164
+ display: 'flex',
165
+ color: 'white'
166
+ }}>
167
+ <div style={{
168
+ ...extras.header?.position
169
+ }}>
170
+ <h2 dangerouslySetInnerHTML={{ __html: transcript.title }} />
171
+ <span dangerouslySetInnerHTML={{ __html: transcript.text }} />
172
+ </div>
173
+
174
+ <div>
175
+ {
176
+ extras?.footer?.text && <h2
177
+ dangerouslySetInnerHTML={{ __html: extras?.footer?.text }}
178
+ style={{
179
+ ...extras?.footer?.text_style
180
+ }}
181
+ />
182
+ }
183
+ </div>
184
+ </div>
185
+ </div>
186
+ )
187
+
188
+ }
189
 
190
 
 
 
 
src/paperdrive/PaperDriveIndex.tsx CHANGED
@@ -3,8 +3,8 @@ import { CSSProperties, } from "react"
3
  import { AbsoluteFill } from "remotion"
4
  import { loadFont as loadLato } from "@remotion/google-fonts/Lato";
5
  import { loadFont as loadPoppins } from "@remotion/google-fonts/Poppins";
6
- import { PaperDrivePageExtras } from "./PaperDrivePage";
7
  import './PaperDriveIndex.css'
 
8
 
9
  const tableHeadStyles: CSSProperties = {
10
  textAlign: 'center'
 
3
  import { AbsoluteFill } from "remotion"
4
  import { loadFont as loadLato } from "@remotion/google-fonts/Lato";
5
  import { loadFont as loadPoppins } from "@remotion/google-fonts/Poppins";
 
6
  import './PaperDriveIndex.css'
7
+ import { PaperDrivePageExtras } from "./types";
8
 
9
  const tableHeadStyles: CSSProperties = {
10
  textAlign: 'center'
src/paperdrive/PaperDrivePage.tsx CHANGED
@@ -5,54 +5,11 @@ import { QRCode } from 'react-qrcode-logo';
5
  import { RenderUtils } from '../RenderUtils';
6
  import { loadFont as loadLato } from "@remotion/google-fonts/Lato";
7
  import { loadFont as loadPoppins } from "@remotion/google-fonts/Poppins";
 
8
 
9
- export type PaperDrivePageExtras = {
10
- backgroundColor: string;
11
- marginBottom: string;
12
- url: string,
13
- leftMarginLineColor?: string,
14
- lineColor?: string,
15
- marginLeft: string // "10%"
16
- marginTop: string // "10%"
17
- template?: "page" | "index" | "one-cover" | "two-cover"
18
- qr?: {
19
- logoOpacity?: number;
20
- logo?: string;
21
- color?: string | undefined;
22
- size?: string //200 10vh 10vw
23
- qrStyle?: "squares" | "dots" | "fluid"
24
- position?: {
25
- position: "static" | "relative" | "absolute" | "sticky" | "fixed" // "right"
26
- top?: number // 0
27
- left?: number // 0
28
- bottom?: number // 0
29
- right?: number // 0
30
- }
31
- },
32
- header?: {
33
- underline_style?: CSSProperties
34
- fontFamily?: string // Lato, sans-serif
35
- color?: string // black
36
- text_title?: string // Title
37
- text_date?: string // Date
38
- text_page?: string // Page
39
- position?: CSSProperties
40
- },
41
- footer?: {
42
- text?: string // Lorem ipsum dolor
43
- text_style?: CSSProperties,
44
- position?: CSSProperties
45
- },
46
- index?: {
47
- pageCount: number,
48
- columns: { text: string, width: string }[]
49
- }
50
- }
51
  export function PaperDrivePage({ transcript }: { transcript: Transcript }) {
52
  const extras = transcript.extras as PaperDrivePageExtras
53
- const qrImageBlend = extras?.qr?.logo
54
- const defaultQrSize = RenderUtils.convertVHToPixels(extras?.marginTop ?? '10vh')
55
- const logo = qrImageBlend ? staticFile(RenderUtils.getFileName(qrImageBlend)!) : undefined
56
  const watermark = transcript.imageAbsPaths?.[0]
57
  let watermarkPath = undefined
58
  if (watermark) {
@@ -61,6 +18,9 @@ export function PaperDrivePage({ transcript }: { transcript: Transcript }) {
61
  loadLato();
62
  loadPoppins();
63
 
 
 
 
64
  let qrSize = defaultQrSize
65
  if (extras?.qr?.size?.includes("vh")) {
66
  qrSize = RenderUtils.convertVHToPixels(extras?.qr?.size)
@@ -146,7 +106,7 @@ export function PaperDrivePage({ transcript }: { transcript: Transcript }) {
146
  <td style={{
147
  textAlign: 'left'
148
  }}>
149
- <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_title }} />
150
  </td>
151
  <td style={{
152
  textAlign: 'left',
@@ -165,10 +125,10 @@ export function PaperDrivePage({ transcript }: { transcript: Transcript }) {
165
 
166
  )}
167
  {
168
- extras?.header?.text_date &&
169
  <tr>
170
  <td >
171
- <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_date }} />
172
  </td>
173
  <td style={{
174
  textAlign: 'left',
@@ -188,10 +148,10 @@ export function PaperDrivePage({ transcript }: { transcript: Transcript }) {
188
  }
189
 
190
  {
191
- extras?.header?.text_page &&
192
  <tr>
193
  <td>
194
- <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_page }} />
195
  </td>
196
  </tr>
197
 
 
5
  import { RenderUtils } from '../RenderUtils';
6
  import { loadFont as loadLato } from "@remotion/google-fonts/Lato";
7
  import { loadFont as loadPoppins } from "@remotion/google-fonts/Poppins";
8
+ import { PaperDrivePageExtras } from "./types";
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  export function PaperDrivePage({ transcript }: { transcript: Transcript }) {
11
  const extras = transcript.extras as PaperDrivePageExtras
12
+
 
 
13
  const watermark = transcript.imageAbsPaths?.[0]
14
  let watermarkPath = undefined
15
  if (watermark) {
 
18
  loadLato();
19
  loadPoppins();
20
 
21
+ const qrImageBlend = extras?.qr?.logo
22
+ const defaultQrSize = RenderUtils.convertVHToPixels(extras?.marginTop ?? '10vh')
23
+ const logo = qrImageBlend ? staticFile(RenderUtils.getFileName(qrImageBlend)!) : undefined
24
  let qrSize = defaultQrSize
25
  if (extras?.qr?.size?.includes("vh")) {
26
  qrSize = RenderUtils.convertVHToPixels(extras?.qr?.size)
 
106
  <td style={{
107
  textAlign: 'left'
108
  }}>
109
+ <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_title }} style={extras?.header?.title_style} />
110
  </td>
111
  <td style={{
112
  textAlign: 'left',
 
125
 
126
  )}
127
  {
128
+ extras?.header?.text_sec &&
129
  <tr>
130
  <td >
131
+ <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_sec }} style={extras?.header?.text_style} />
132
  </td>
133
  <td style={{
134
  textAlign: 'left',
 
148
  }
149
 
150
  {
151
+ extras?.header?.text_ter &&
152
  <tr>
153
  <td>
154
+ <span dangerouslySetInnerHTML={{ __html: extras?.header?.text_ter }} style={extras?.header?.text_style} />
155
  </td>
156
  </tr>
157
 
src/paperdrive/types/index.ts CHANGED
@@ -1,3 +1,51 @@
1
- export type PaperDrivePoster = {
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  }
 
1
+ import { CSSProperties } from "react";
2
 
3
+ export type PaperDrivePageExtras = {
4
+ backgroundColor: string;
5
+ marginBottom: string;
6
+ url: string,
7
+ leftMarginLineColor?: string,
8
+ lineColor?: string,
9
+ marginLeft: string // "10%"
10
+ marginTop: string // "10%"
11
+ template?: "page" | "index" | "front-cover" | "back-cover"
12
+ qr?: { // only for "page"
13
+ logoOpacity?: number;
14
+ logo?: string;
15
+ color?: string | undefined;
16
+ backgroundColor?: string | undefined;
17
+ size?: string //200 10vh 10vw
18
+ qrStyle?: "squares" | "dots" | "fluid"
19
+ position?: {
20
+ position: "static" | "relative" | "absolute" | "sticky" | "fixed" // "right"
21
+ top?: number // 0
22
+ left?: number // 0
23
+ bottom?: number // 0
24
+ right?: number // 0
25
+ }
26
+ },
27
+ header?: { // only for "page" and "index" and "front-cover" and "back-cover"
28
+ underline_style?: CSSProperties
29
+ fontFamily?: string // Lato, sans-serif
30
+ color?: string // black
31
+ graphic?: {
32
+ source: string,
33
+ position?: CSSProperties
34
+ },
35
+ title_style?: CSSProperties,
36
+ text_style?: CSSProperties,
37
+ text_title?: string // Title
38
+ text_sec?: string // Date
39
+ text_ter?: string // Page
40
+ position?: CSSProperties
41
+ },
42
+ footer?: { // only for "page"
43
+ text?: string // Lorem ipsum dolor
44
+ text_style?: CSSProperties,
45
+ position?: CSSProperties
46
+ },
47
+ index?: { // only for "index"
48
+ pageCount: number,
49
+ columns: { text: string, width: string }[]
50
+ },
51
  }