Skip to content

Commit

Permalink
feat(client): add assitant for development
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroppy committed Jan 26, 2021
1 parent 2dda8ec commit db67b30
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 15 deletions.
26 changes: 11 additions & 15 deletions packages/client/assets/style/code.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,23 @@ code {
font-family: 'Source Code Pro', monospace;
}

section {
& > pre[class*='language-'] {
margin: 0.5em auto;
pre[class*='language-'] {
margin: 0.5em auto !important;
}

& > code[class*='language-'] {
& .token.operator {
background: inherit;
}
}
}
.token.operator {
background: inherit;
}

section > pre > code[class*='language-'],
section > pre[class*='language-'] {
font-size: 1.4rem;
pre > code[class*='language-'],
pre[class*='language-'] {
font-size: 1.4rem !important;
line-height: 1.2;
}

@media screen and (min-width: 768px) {
section > pre > code[class*='language-'],
section > pre[class*='language-'] {
font-size: 2rem;
pre > code[class*='language-'],
pre[class*='language-'] {
font-size: 2rem !important;
}
}
6 changes: 6 additions & 0 deletions packages/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
"screenfull": "^5.1.0",
"vm-browserify": "^1.1.2",
"webslides": "^1.5.0"
},
"devDependencies": {
"react-accessible-accordion": "^3.3.3"
}
}
197 changes: 197 additions & 0 deletions packages/client/src/components/Assistant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
import React from 'react';
import {
Accordion,
AccordionItem,
AccordionItemHeading,
AccordionItemButton,
AccordionItemPanel,
} from 'react-accessible-accordion';
import 'react-accessible-accordion/dist/fancy-example.css';

const outerCss = {
background: '#f5f5f5',
fontSize: '16px',
right: 0,
margin: 12,
position: 'absolute',
width: 400,
};

const buttonCss = {
padding: '8px 18px',
};

const itemCss = {
padding: '4px 8px',
};

const hrCss = {
margin: '4px 0',
};

const smallTitleCss = {
borderBottom: '1px solid #ccc',
marginBottom: '4px',
};

const A = ({ url, children }) => (
<a href={url} target="_blank" rel="noreferrer" style={{ color: '#7bb7fa' }}>
{children}
</a>
);

const Item = ({ title, children }) => (
<AccordionItem>
<AccordionItemHeading>
<AccordionItemButton style={buttonCss}>{title}</AccordionItemButton>
</AccordionItemHeading>
<AccordionItemPanel style={itemCss}>{children}</AccordionItemPanel>
</AccordionItem>
);

const SmallTitle = ({ children }) => <p style={smallTitleCss}>{children}</p>;

const Lines = ({ items }) => (
<>
{items.map(({ title, content, url }) => (
<div key={title} style={{ marginBottom: '6px' }}>
{title}:<A url={url}>{content}</A>
</div>
))}
</>
);

export const Assistant = () => (
<div style={outerCss}>
<Accordion allowMultipleExpanded allowZeroExpanded>
<AccordionItem>
<AccordionItemHeading>
<AccordionItemButton style={buttonCss}>
Reference (only development env)
</AccordionItemButton>
</AccordionItemHeading>
<AccordionItemPanel style={itemCss}>
<Item title="CSS Classes">
<SmallTitle>WebSlides</SmallTitle>
<Lines
items={[
{
title: 'Grid System',
content: <code>{`.gird > .column`}</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=15',
},
{
title: 'Sidebar + Main',
content: <code>{`.gird.sm > .column`}</code>,
url: 'https://webslides.tv/demos/components#slide=11',
},
{
title: 'Main + Sidebar',
content: <code>{`.gird.ms > .column`}</code>,
url: 'https://webslides.tv/demos/components#slide=12',
},
{
title: 'Position',
content: <code>.content-left|right|top|bottom</code>,
url: 'https://webslides.tv/demos/components#slide=14',
},
{
title: 'Animation',
content: <code>.fadeIn, .zoomIn</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=33',
},
{
title: 'Fullscreen',
content: <code>.fullscreen</code>,
url: 'https://webslides.tv/demos/components#slide=76',
},
{
title: 'Card',
content: <code>.card-50</code>,
url: 'https://webslides.tv/demos/components#slide=76',
},
]}
/>
<A url="https://webslides.tv/demos/components#slide=2">Others</A>
<hr style={hrCss} />
<SmallTitle>Fusuma</SmallTitle>
<code>{`<!-- sectionTitle -->`}</code>:
<A url="https://hiroppy.github.io/fusuma/intro/#slide=16">
<code>.section-title</code>
</A>
<br />
Code:
<A url="https://hiroppy.github.io/fusuma/intro/#slide=15">
<code>{`pre > code[class*='language-']`}</code>
</A>
<br />
</Item>
<Item title="Slide Syntaxes">
<Lines
items={[
{
title: 'Splitting Slides',
content: <code>{`---`}</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=13',
},
]}
/>
<hr style={hrCss} />
<SmallTitle>
HTML Comments<code>{`<!-- -->`}</code>
</SmallTitle>
<Lines
items={[
{
title: 'Adding Classes',
content: <code>{`classes: title`}</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=14',
},
{
title: 'Creating div Tag',
content: <code>{`block-start: ?className`}</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=15',
},
{
title: 'Closing div Tag',
content: <code>block-end</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=15',
},
{
title: 'Adding Title to Sidebar',
content: <code>{`sectionTitle: title`}</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=16',
},
{
title: 'Adding Agenda UI via SectionTitle',
content: <code>contents</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=17',
},
{
title: 'Adding Speaker Note',
content: <code>note hello~~~~</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=18',
},
{
title: 'Executing JavaScript Code',
content: <code>executable-code</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=19',
},
{
title: 'Capturing Screen Contents',
content: <code>screen</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=20',
},
{
title: 'Generating QR Code',
content: <code>{`qr: https://~~~`}</code>,
url: 'https://hiroppy.github.io/fusuma/intro/#slide=20', // TODO: fix
},
]}
/>
</Item>
</AccordionItemPanel>
</AccordionItem>
</Accordion>
</div>
);
16 changes: 16 additions & 0 deletions packages/client/src/entryPoints/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ createBody(slidesInfo.slides);
if (process.env.TARGET_BLANK) {
setTargetBlank();
}

if (process.env.NODE_ENV !== 'production') {
(async () => {
// for tree shaking
const { Assistant } = await import('../components/Assistant');
const el = document.createElement('div');

el.style.position = 'absolute';
el.style.top = 0;
el.style.width = '100%';
el.setAttribute('id', 'reference');
document.body.appendChild(el);

render(<Assistant />, document.getElementById('reference'));
})();
}

0 comments on commit db67b30

Please sign in to comment.