Skip to content

Commit 681a676

Browse files
committed
Add open with processing to examples
1 parent 142c9de commit 681a676

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

src/components/CopyButton.module.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.root {
2-
position: absolute;
3-
right: var(--gutter);
42
height: 32px;
53
padding: 6px 12px;
64
font-size: var(--text-small);

src/components/OpenWithButton.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import classnames from 'classnames';
3+
4+
import ProcessingIcon from '../images/logo-processing.svg';
5+
6+
import * as css from './CopyButton.module.css';
7+
8+
const OpenWithButton = ({ text }) => {
9+
const openWithProcessing = () => {
10+
window.open('pde://sketch/base64/' + btoa(text));
11+
};
12+
13+
return (
14+
<button
15+
type="button"
16+
onClick={openWithProcessing}
17+
className={classnames(css.root)}
18+
>
19+
<ProcessingIcon /> {'Open With Processing'}
20+
</button>
21+
)
22+
}
23+
24+
export default OpenWithButton;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.root {
2+
height: 32px;
3+
padding: 6px 12px;
4+
font-size: var(--text-small);
5+
font-weight: bold;
6+
color: var(--darkgray);
7+
cursor: pointer;
8+
fill: var(--darkgray);
9+
10+
& svg {
11+
height: 12px;
12+
width: auto;
13+
}
14+
}
15+
16+
.root:hover {
17+
color: var(--darkergray);
18+
fill: var(--darkergray);
19+
}
20+
21+
.root:active {
22+
color: var(--processing-blue-mid);
23+
fill: var(--processing-blue-mid);
24+
}

src/components/Tabs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import classnames from 'classnames';
33

44
import Button from './Button';
55
import CopyButton from './CopyButton';
6+
import OpenWithButton from './OpenWithButton';
67

78
import { useHighlight } from '../hooks';
89
import { escapeHtml } from '../utils';
@@ -40,7 +41,10 @@ const Tabs = ({ pdes, className }) => {
4041
[css.activeCode]: pde.name === active
4142
})}
4243
key={key}>
43-
<CopyButton text={pde.code} />
44+
<div className={css.actions}>
45+
<CopyButton text={pde.code} />
46+
<OpenWithButton text={pde.code} />
47+
</div>
4448
<pre className={css.codeBlock}>
4549
<code
4650
dangerouslySetInnerHTML={{

src/components/Tabs.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@
3737
padding-bottom: var(--gutter-double);
3838
white-space: break-spaces;
3939
}
40+
41+
.actions{
42+
position: absolute;
43+
right: var(--gutter);
44+
}

0 commit comments

Comments
 (0)