Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 0e7525f

Browse files
committed
feat(pdf): refactor pdf process
1 parent fef52c2 commit 0e7525f

File tree

10 files changed

+12344
-1557
lines changed

10 files changed

+12344
-1557
lines changed

packages/client/assets/style/common.css

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
html {
99
color: #333;
1010
font-size: 62.5%;
11+
-webkit-print-color-adjust: exact;
1112
}
1213

1314
body {

packages/client/assets/style/executableCode.css

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
:root {
2+
--color-white: #fff;
3+
--color-black: #333;
4+
}
5+
16
.executable-code-container {
27
display: flex;
38
order: 1; /* TODO: fix */
@@ -11,6 +16,7 @@
1116
border: 1px solid rgba(0, 20, 80, 0.1);
1217
box-shadow: 0 8px 16px rgba(0, 20, 80, 0.04), 0 4px 16px rgba(0, 0, 0, 0.08);
1318
border-radius: 4px;
19+
background: var(--color-white);
1420
color: var(--color-black);
1521
cursor: pointer;
1622
font-size: 1.8rem;
@@ -19,6 +25,8 @@
1925
}
2026

2127
.executable-code-result {
28+
background: var(--color-white);
29+
color: var(--color-black);
2230
max-height: 200px;
2331
overflow-x: auto;
2432
text-align: left;

packages/client/src/components/SlideCore.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@ import SwiperCore, {
1010
EffectFade,
1111
} from 'swiper';
1212
import { Swiper, SwiperSlide } from 'swiper/react';
13+
import { getSearchParams } from '../utils/getSearchParams';
1314

1415
const swiperComponents = [A11y, Keyboard, HashNavigation];
1516

16-
// TODO: check if the url has a param like pagination=true for thumbnail
1717
if (process.env.UI.PAGINATION) {
18-
swiperComponents.push(Pagination);
19-
import('swiper/components/pagination/pagination.min.css');
18+
if (getSearchParams().has('pagination')) {
19+
if (getSearchParams().get('pagination') !== 'false') {
20+
swiperComponents.push(Pagination);
21+
import('swiper/components/pagination/pagination.min.css');
22+
}
23+
} else {
24+
swiperComponents.push(Pagination);
25+
import('swiper/components/pagination/pagination.min.css');
26+
}
2027
}
2128

2229
if (process.env.UI.EFFECT === 'fade') {

packages/client/src/components/ToC.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React from 'react';
22

33
export const ToC = ({ list }) => () => (
4-
<div className="toc size-70 aligncenter">
4+
<div className="toc">
55
<ol>
66
{list.map(({ index, title }) => (
77
<li key={title}>
88
<a href={`#slide-${index}`} title={title}>
99
<span className="chapter">{title}</span>
10-
<span className="toc-page">{index}</span>
1110
</a>
1211
</li>
1312
))}

packages/fusuma/src/cli/index.js

100644100755
File mode changed.

packages/fusuma/src/tasks/pdf.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
const { join } = require('path');
44
const Spinner = require('../cli/Spinner');
5+
const { info } = require('../cli/log');
56
const lazyloadModule = require('../utils/lazyloadModule');
67

78
async function pdf(config) {
8-
if (config.slide.loop) {
9-
console.error('You must disable slide.loop.');
10-
process.exit(1);
11-
}
12-
139
const port = 3455;
1410
const { basePath, inputDirPath, filename } = config.internal;
15-
const output = join(basePath, filename);
11+
const { publicPath } = config.build;
1612
const spinner = new Spinner();
1713

1814
spinner.setContent({ text: 'Exporting as PDF...' });
@@ -28,9 +24,10 @@ async function pdf(config) {
2824
}
2925
});
3026

31-
await pdf(inputDirPath, output, port);
27+
await pdf(inputDirPath, publicPath, basePath, filename, port);
3228

3329
spinner.stop();
30+
info('pdf', `Generated ${filename}`);
3431
} catch (e) {
3532
console.error(e);
3633
process.exit(1);

0 commit comments

Comments
 (0)