Skip to content

Commit 2f4bbb9

Browse files
committed
Prettify code
1 parent f756aad commit 2f4bbb9

File tree

11 files changed

+34
-39
lines changed

11 files changed

+34
-39
lines changed

frontend/src/CodeBlock/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function CodeBlock(props) {
3333
return content;
3434
}
3535

36-
3736
function copyCode() {
3837
setCopyText('Copied!');
3938
copyTextToClipboard(codeRef.current.textContent);
@@ -45,13 +44,13 @@ function CodeBlock(props) {
4544

4645
useEffect(() => {
4746
if (props.title) {
48-
setTitle(props.title)
47+
setTitle(props.title);
4948
} else if (props['data-node-asset']) {
5049
setTitle(props['data-node-asset']);
5150
} else if (props.src) {
5251
setTitle(props.src);
5352
}
54-
}, [props.title, props.src, props['data-node-asset']])
53+
}, [props.title, props.src, props['data-node-asset']]);
5554

5655
useEffect(() => {
5756
if (props.src) {
@@ -69,12 +68,12 @@ function CodeBlock(props) {
6968
content = trimInitialLine(content);
7069

7170
if (isEscaped) {
72-
setCode(<code className="code-block__code-content" dangerouslySetInnerHTML={{__html: content}} />);
71+
setCode(<code className="code-block__code-content" dangerouslySetInnerHTML={{ __html: content }} />);
7372
} else {
7473
setCode(<code className="code-block__code-content">{content}</code>);
7574
}
7675
}
77-
}, [props.src, props.children, isEscaped])
76+
}, [props.src, props.children, isEscaped]);
7877

7978
return (
8079
<div className="code-block">

frontend/src/CodeBlock/index.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ description: &gt;
6060
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore
6161
magna aliquyam erat, sed diam voluptua.
6262
`;
63-
expect(component.find('code').html()).toEqual(
64-
`<code class="code-block__code-content">${expected}</code>`
65-
);
63+
expect(component.find('code').html()).toEqual(`<code class="code-block__code-content">${expected}</code>`);
6664
});
6765

6866
it('renders component build up content', () => {
@@ -74,7 +72,5 @@ it('renders component build up content', () => {
7472

7573
const expected = `&lt;div&gt;test&lt;/div&gt;`;
7674

77-
expect(component.find('code').html()).toEqual(
78-
`<code class="code-block__code-content">${expected}</code>`
79-
);
75+
expect(component.find('code').html()).toEqual(`<code class="code-block__code-content">${expected}</code>`);
8076
});

frontend/src/ComponentDemo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function ComponentDemo(props) {
108108
return (
109109
<div className={classes.join(' ')}>
110110
<div className="component-demo__stage" style={style}>
111-
<div className="component-demo__stage-content">{props.children}</div>
111+
<div className="component-demo__stage-content">{props.children}</div>
112112
<div className="component-demo__annotation-marker-stage">{annotationMarkers}</div>
113113
</div>
114114
{annotations.length > 0 && <div className="component-demo__annotations">{annotations}</div>}

frontend/src/Doc/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function Doc(props) {
3131
// has finished.
3232
window.requestAnimationFrame(() => {
3333
if (props.onRender) {
34-
props.onRender()
35-
};
34+
props.onRender();
35+
}
3636
});
3737
});
3838

@@ -48,7 +48,7 @@ function Doc(props) {
4848

4949
const transforms = {
5050
Banner: props => <Banner {...props} />,
51-
CodeBlock: (props) => {
51+
CodeBlock: props => {
5252
// When using <CodeBlock> directly within documents, its contents aren't
5353
// automatically protected from interpration as HTML, when they processed
5454
// by the DocTransformer. Thus we expect users to wrap their literal code
@@ -73,22 +73,20 @@ function Doc(props) {
7373
h3: props => <Heading {...props} level="gamma" docTitle={docTitle} isJumptarget={true} />,
7474
h4: props => <Heading {...props} level="delta" docTitle={docTitle} isJumptarget={true} />,
7575
img: props => <Image {...props} />,
76-
pre: (props) => {
76+
pre: props => {
7777
// When Markdown fenced code blocks get converted to <pre> they
7878
// additionally include inner <code>. We cannot use orphans as this create
7979
// empty "ghost" elements.
8080
let children = props.children.replace(/^<code>/, '').replace(/<\/code>$/, '');
8181

8282
return <CodeBlock escaped {...props} children={children} />;
83-
}
83+
},
8484
};
8585

8686
const orphans = Object.keys(transforms)
8787
.filter(k => k !== 'a')
8888
.map(k => `p > ${k}`)
89-
.concat([
90-
'p > video'
91-
]);
89+
.concat(['p > video']);
9290

9391
let transformedContent = transform(props.htmlContent, transforms, orphans, {
9492
isPreformatted: type => type === 'pre' || type === 'CodeBlock'.toLowerCase(),

frontend/src/FigmaEmbed/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useGlobal } from 'reactn';
88
import './FigmaEmbed.css';
99

1010
function FigmaEmbed(props) {
11-
const [config, setConfig] = useGlobal("config");
11+
const [config, setConfig] = useGlobal('config');
1212
const [image, setImage] = useState(null);
1313
const [frameId, setFrameId] = useState(null);
1414
const [errorMessage, setErrorMessage] = useState(null);
@@ -17,7 +17,9 @@ function FigmaEmbed(props) {
1717
// Retrieves document.
1818
useEffect(() => {
1919
if (!config.figma.accessToken) {
20-
setErrorMessage('Missing personal access token, please visit: https://rundsk.com/tree/The-Frontend/Configuration');
20+
setErrorMessage(
21+
'Missing personal access token, please visit: https://rundsk.com/tree/The-Frontend/Configuration'
22+
);
2123
return;
2224
}
2325
if (!props.document) {
@@ -29,8 +31,8 @@ function FigmaEmbed(props) {
2931
fetch(`https://api.figma.com/v1/files/${props.document}`, {
3032
method: 'GET',
3133
headers: new Headers({
32-
'X-Figma-Token': config.figma.accessToken
33-
})
34+
'X-Figma-Token': config.figma.accessToken,
35+
}),
3436
})
3537
.then(response => {
3638
if (response.status === 200) {
@@ -77,8 +79,8 @@ function FigmaEmbed(props) {
7779
return fetch(`https://api.figma.com/v1/images/${props.document}?ids=${nodeId}`, {
7880
method: 'GET',
7981
headers: new Headers({
80-
'X-Figma-Token': config.figma.accessToken
81-
})
82+
'X-Figma-Token': config.figma.accessToken,
83+
}),
8284
})
8385
.then(response => {
8486
if (response.status === 200) {

frontend/src/Heading/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Heading(props) {
2525

2626
let id;
2727

28-
if (typeof props.children === "object") {
28+
if (typeof props.children === 'object') {
2929
id = slugify(props.children[0]);
3030
} else {
3131
id = slugify(props.children);

frontend/src/Page/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ function Page(props) {
145145
}
146146

147147
if (activeDoc && activeDoc.content) {
148-
doc = <Doc title={activeDoc.title} onRender={docDidRender}>{activeDoc.content}</Doc>;
148+
doc = (
149+
<Doc title={activeDoc.title} onRender={docDidRender}>
150+
{activeDoc.content}
151+
</Doc>
152+
);
149153
}
150154
}
151155

@@ -193,11 +197,8 @@ function Page(props) {
193197

194198
return (
195199
<div className="page">
196-
<Helmet
197-
titleTemplate={`%s – ${props.baseTitle}`}
198-
defaultTitle={props.baseTitle}
199-
>
200-
<title>{props.url !== '' && props.title}</title>
200+
<Helmet titleTemplate={`%s – ${props.baseTitle}`} defaultTitle={props.baseTitle}>
201+
<title>{props.url !== '' && props.title}</title>
201202
<meta name="description" content={props.description} />
202203
</Helmet>
203204
<div className="page__header">

frontend/src/Search/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function Search(props) {
8585
hideSearch();
8686
}
8787

88-
if (event.key === 's' && event.target.nodeName !== "INPUT") {
88+
if (event.key === 's' && event.target.nodeName !== 'INPUT') {
8989
event.preventDefault();
9090
focus();
9191
}

frontend/src/TreeNavigation/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function TreeNavigation(props) {
2323
blurFilter();
2424
}
2525

26-
if (event.key === 'f' && event.target.nodeName !== "INPUT") {
26+
if (event.key === 'f' && event.target.nodeName !== 'INPUT') {
2727
event.preventDefault();
2828
focusFilter();
2929
}

js/dsk/Client.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
// Client for accessing the DSK APIv2.
77
export default class Client {
8-
98
static hello() {
109
return this.fetch('/api/v2/hello');
1110
}
@@ -112,7 +111,7 @@ export default class Client {
112111
resolve(xhr.response);
113112
}
114113
});
115-
xhr.addEventListener('error', (ev) => {
114+
xhr.addEventListener('error', ev => {
116115
reject(new Error(`Fetching '${url}' failed :-S: ${ev}`));
117116
});
118117
xhr.open('GET', url);
@@ -138,7 +137,7 @@ export default class Client {
138137
}
139138
}
140139
});
141-
xhr.addEventListener('error', (ev) => {
140+
xhr.addEventListener('error', ev => {
142141
reject(new Error(`Pinging '${url}' failed :-S: ${ev}`));
143142
});
144143
xhr.open('HEAD', url);

0 commit comments

Comments
 (0)