Skip to content

Commit

Permalink
feat(pdf): refactor pdf process
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jan 30, 2021
1 parent fef52c2 commit 0e7525f
Show file tree
Hide file tree
Showing 10 changed files with 12,344 additions and 1,557 deletions.
1 change: 1 addition & 0 deletions packages/client/assets/style/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
html {
color: #333;
font-size: 62.5%;
-webkit-print-color-adjust: exact;
}

body {
Expand Down
8 changes: 8 additions & 0 deletions packages/client/assets/style/executableCode.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
:root {
--color-white: #fff;
--color-black: #333;
}

.executable-code-container {
display: flex;
order: 1; /* TODO: fix */
Expand All @@ -11,6 +16,7 @@
border: 1px solid rgba(0, 20, 80, 0.1);
box-shadow: 0 8px 16px rgba(0, 20, 80, 0.04), 0 4px 16px rgba(0, 0, 0, 0.08);
border-radius: 4px;
background: var(--color-white);
color: var(--color-black);
cursor: pointer;
font-size: 1.8rem;
Expand All @@ -19,6 +25,8 @@
}

.executable-code-result {
background: var(--color-white);
color: var(--color-black);
max-height: 200px;
overflow-x: auto;
text-align: left;
Expand Down
13 changes: 10 additions & 3 deletions packages/client/src/components/SlideCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ import SwiperCore, {
EffectFade,
} from 'swiper';
import { Swiper, SwiperSlide } from 'swiper/react';
import { getSearchParams } from '../utils/getSearchParams';

const swiperComponents = [A11y, Keyboard, HashNavigation];

// TODO: check if the url has a param like pagination=true for thumbnail
if (process.env.UI.PAGINATION) {
swiperComponents.push(Pagination);
import('swiper/components/pagination/pagination.min.css');
if (getSearchParams().has('pagination')) {
if (getSearchParams().get('pagination') !== 'false') {
swiperComponents.push(Pagination);
import('swiper/components/pagination/pagination.min.css');
}
} else {
swiperComponents.push(Pagination);
import('swiper/components/pagination/pagination.min.css');
}
}

if (process.env.UI.EFFECT === 'fade') {
Expand Down
3 changes: 1 addition & 2 deletions packages/client/src/components/ToC.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react';

export const ToC = ({ list }) => () => (
<div className="toc size-70 aligncenter">
<div className="toc">
<ol>
{list.map(({ index, title }) => (
<li key={title}>
<a href={`#slide-${index}`} title={title}>
<span className="chapter">{title}</span>
<span className="toc-page">{index}</span>
</a>
</li>
))}
Expand Down
Empty file modified packages/fusuma/src/cli/index.js
100644 → 100755
Empty file.
11 changes: 4 additions & 7 deletions packages/fusuma/src/tasks/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

const { join } = require('path');
const Spinner = require('../cli/Spinner');
const { info } = require('../cli/log');
const lazyloadModule = require('../utils/lazyloadModule');

async function pdf(config) {
if (config.slide.loop) {
console.error('You must disable slide.loop.');
process.exit(1);
}

const port = 3455;
const { basePath, inputDirPath, filename } = config.internal;
const output = join(basePath, filename);
const { publicPath } = config.build;
const spinner = new Spinner();

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

await pdf(inputDirPath, output, port);
await pdf(inputDirPath, publicPath, basePath, filename, port);

spinner.stop();
info('pdf', `Generated ${filename}`);
} catch (e) {
console.error(e);
process.exit(1);
Expand Down
Loading

0 comments on commit 0e7525f

Please sign in to comment.