react-rx 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/compiler.xml +1 -1
- package/.idea/inspectionProfiles/Project_Default.xml +1 -0
- package/.idea/markdown.xml +9 -0
- package/.idea/misc.xml +0 -6
- package/dist/cjs/displayName.js +1 -1
- package/dist/cjs/useAsObservable.js +9 -17
- package/dist/cjs/useObservable.js +25 -30
- package/dist/cjs/withPropsStream.js +5 -1
- package/dist/es2015/useAsObservable.js +10 -18
- package/dist/es2015/useObservable.js +24 -31
- package/dist/esm/displayName.js +1 -1
- package/dist/esm/useAsObservable.js +10 -18
- package/dist/esm/useObservable.js +26 -31
- package/package.json +6 -4
- package/src/useAsObservable.ts +13 -18
- package/src/useObservable.ts +39 -34
- package/.idea/workspace.xml +0 -226
- package/jest.config.js +0 -5
- package/website/.babelrc +0 -21
- package/website/.prettierrc +0 -7
- package/website/README.mdx +0 -1
- package/website/package.json +0 -84
- package/website/src/@types/babel.d.ts +0 -4
- package/website/src/@types/mdx.d.ts +0 -11
- package/website/src/@types/react-css-burger.d.ts +0 -4
- package/website/src/App.tsx +0 -68
- package/website/src/components/Header.tsx +0 -118
- package/website/src/components/Link.tsx +0 -18
- package/website/src/components/LoadPage.tsx +0 -60
- package/website/src/components/Sidebar.tsx +0 -88
- package/website/src/components/logos/Github.tsx +0 -10
- package/website/src/components/logos/React.tsx +0 -27
- package/website/src/components/logos/ReactRxLogo.tsx +0 -39
- package/website/src/components/logos/RxJs.tsx +0 -69
- package/website/src/components/repl/Checkerboard.tsx +0 -25
- package/website/src/components/repl/CodeBlock.tsx +0 -147
- package/website/src/components/repl/CodeMirror.tsx +0 -37
- package/website/src/components/repl/CodeMirrorMode.tsx +0 -67
- package/website/src/components/repl/EvalCode.tsx +0 -55
- package/website/src/components/repl/Prelude.tsx +0 -50
- package/website/src/components/repl/ShowError.tsx +0 -27
- package/website/src/components/repl/codemirror-lib.ts +0 -8
- package/website/src/components/repl/codemirror-theme.css +0 -131
- package/website/src/components/repl/compile/babel.ts +0 -21
- package/website/src/components/repl/eval/evalCallback.ts +0 -27
- package/website/src/components/repl/eval/evalCode.ts +0 -7
- package/website/src/components/repl/eval/evalExpression.ts +0 -4
- package/website/src/components/repl/eval/evalReactDomRender.ts +0 -23
- package/website/src/components/repl/index.ts +0 -1
- package/website/src/components/repl/runMode.ts +0 -42
- package/website/src/datastores/location.ts +0 -14
- package/website/src/datastores/page.ts +0 -11
- package/website/src/datastores/pageTransition.ts +0 -97
- package/website/src/entries/main.css +0 -2
- package/website/src/entries/main.tsx +0 -6
- package/website/src/examples/FizzBuzz/FizzBuzzExample.tsx +0 -39
- package/website/src/examples/FizzBuzz/index.tsx +0 -9
- package/website/src/examples/_utils/globalScope.ts +0 -45
- package/website/src/examples/animation/AnimationExample.tsx +0 -152
- package/website/src/examples/animation/easings.ts +0 -0
- package/website/src/examples/animation/index.tsx +0 -15
- package/website/src/examples/context/Context.example.jsx +0 -67
- package/website/src/examples/context/index.tsx +0 -9
- package/website/src/examples/errors/Errors.example.jsx +0 -69
- package/website/src/examples/errors/index.tsx +0 -9
- package/website/src/examples/event-handlers/EventHandlersExample.tsx +0 -48
- package/website/src/examples/event-handlers/index.tsx +0 -9
- package/website/src/examples/fetch/FetchExample.jsx +0 -43
- package/website/src/examples/fetch/a.txt +0 -1
- package/website/src/examples/fetch/b.txt +0 -1
- package/website/src/examples/fetch/index.tsx +0 -9
- package/website/src/examples/form-data/FormDataExample.jsx +0 -119
- package/website/src/examples/form-data/index.tsx +0 -12
- package/website/src/examples/form-data/storage.ts +0 -27
- package/website/src/examples/forward-ref/ForwardRefExample.tsx +0 -55
- package/website/src/examples/forward-ref/index.tsx +0 -9
- package/website/src/examples/hello-world/HelloWorld.example.jsx +0 -6
- package/website/src/examples/hello-world/index.tsx +0 -9
- package/website/src/examples/hooks-interop/HooksInterop.example.tsx +0 -42
- package/website/src/examples/hooks-interop/index.tsx +0 -9
- package/website/src/examples/passthrough-props/PassThroughPropsExample.jsx +0 -57
- package/website/src/examples/passthrough-props/index.tsx +0 -11
- package/website/src/examples/reactive-state/ReactiveState.example.jsx +0 -43
- package/website/src/examples/reactive-state/index.ts +0 -9
- package/website/src/examples/readme-examples/README.mdx +0 -0
- package/website/src/examples/readme-examples/index.ts +0 -11
- package/website/src/examples/shared-state/SharedState.example.tsx +0 -59
- package/website/src/examples/shared-state/index.tsx +0 -9
- package/website/src/examples/simple/Counter.example.tsx +0 -14
- package/website/src/examples/simple/index.tsx +0 -9
- package/website/src/examples/sync/Sync.example.tsx +0 -9
- package/website/src/examples/sync/index.tsx +0 -9
- package/website/src/examples/tick/TickExample.jsx +0 -51
- package/website/src/examples/tick/index.ts +0 -9
- package/website/src/examples/todo-app/TodoApp.example.tsx +0 -88
- package/website/src/examples/todo-app/index.tsx +0 -12
- package/website/src/examples/todo-app/storage.ts +0 -27
- package/website/src/examples/use-element/UseElementExample.tsx +0 -70
- package/website/src/examples/use-element/index.tsx +0 -9
- package/website/src/examples/use-observable/search/SearchExample.tsx +0 -82
- package/website/src/examples/use-observable/search/index.tsx +0 -8
- package/website/src/examples/use-observable/use-observable/UseObservableExample.tsx +0 -70
- package/website/src/examples/use-observable/use-observable/index.tsx +0 -9
- package/website/src/index.html +0 -10
- package/website/src/mdx-components.tsx +0 -74
- package/website/src/pages/Api/Api.mdx +0 -134
- package/website/src/pages/Api/ApiPage.tsx +0 -25
- package/website/src/pages/Examples/Examples.tsx +0 -105
- package/website/src/pages/Examples/ExamplesPage.tsx +0 -13
- package/website/src/pages/Guide/Guide.mdx +0 -275
- package/website/src/pages/Guide/GuidePage.tsx +0 -25
- package/website/src/pages/Index/IndexPage.tsx +0 -50
- package/website/src/pages/Index/ReactRxReadme.md +0 -20
- package/website/src/pages/NotFound.tsx +0 -3
- package/website/src/pages/pages.ts +0 -46
- package/website/src/pages/styles.tsx +0 -24
- package/website/src/theme.ts +0 -61
- package/website/src/utils/parseCodeFenceHeader.ts +0 -32
- package/website/tsconfig.json +0 -30
- package/website/vercel.json +0 -4
- package/website/webpack/config.js +0 -5
- package/website/webpack/createConfig.js +0 -95
- package/website/webpack/mdx-toc-loader.js +0 -38
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
import {COLORS, media} from '../theme'
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import Burger from 'react-css-burger'
|
|
5
|
-
|
|
6
|
-
const SidebarContentInner = styled.div`
|
|
7
|
-
${media.greaterThan('large')} {
|
|
8
|
-
position: fixed;
|
|
9
|
-
}
|
|
10
|
-
> ul {
|
|
11
|
-
overflow-y: auto;
|
|
12
|
-
bottom: 2em;
|
|
13
|
-
height: calc(100vh - 18em);
|
|
14
|
-
}
|
|
15
|
-
ul {
|
|
16
|
-
padding: 0 0 0 0.5em;
|
|
17
|
-
li {
|
|
18
|
-
padding: 0.3em 0;
|
|
19
|
-
list-style: none;
|
|
20
|
-
a,
|
|
21
|
-
a:link,
|
|
22
|
-
a:visited {
|
|
23
|
-
color: ${COLORS.link};
|
|
24
|
-
}
|
|
25
|
-
a.selected {
|
|
26
|
-
border-bottom: 3px solid ${COLORS.secondary};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
const SidebarWrapper = styled.div<{isOpen: boolean}>`
|
|
33
|
-
${media.lessThan('large')} {
|
|
34
|
-
position: fixed;
|
|
35
|
-
left: 0;
|
|
36
|
-
padding: 0;
|
|
37
|
-
z-index: 2000;
|
|
38
|
-
top: 4.8em;
|
|
39
|
-
}
|
|
40
|
-
${media.greaterThan('large')} {
|
|
41
|
-
button {
|
|
42
|
-
display: none;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
${media.lessThan('large')} {
|
|
46
|
-
border-radius: 0 0.5em 0.5em 0;
|
|
47
|
-
box-shadow: ${props =>
|
|
48
|
-
props.isOpen ? `0 4px 10px 0 ${COLORS.shadow}` : '0'};
|
|
49
|
-
background-color: ${props =>
|
|
50
|
-
props.isOpen ? '#eff0f3' : COLORS.header.background};
|
|
51
|
-
}
|
|
52
|
-
`
|
|
53
|
-
const SidebarContent = styled.div<{isOpen: boolean}>`
|
|
54
|
-
padding: 2em 0 0 1em;
|
|
55
|
-
width: 250px;
|
|
56
|
-
max-height: calc(100vh - 12em);
|
|
57
|
-
|
|
58
|
-
${media.lessThan('large')} {
|
|
59
|
-
display: ${(props: any) => (props.isOpen ? '' : 'none')};
|
|
60
|
-
}
|
|
61
|
-
${media.greaterThan('large')} {
|
|
62
|
-
width: 230px;
|
|
63
|
-
}
|
|
64
|
-
`
|
|
65
|
-
|
|
66
|
-
export const Sidebar = (props: {
|
|
67
|
-
heading: string
|
|
68
|
-
children: React.ReactNode
|
|
69
|
-
}) => {
|
|
70
|
-
const [isOpen, setOpen] = React.useState(false)
|
|
71
|
-
return (
|
|
72
|
-
<SidebarWrapper isOpen={isOpen}>
|
|
73
|
-
<Burger
|
|
74
|
-
scale={0.6}
|
|
75
|
-
active={isOpen}
|
|
76
|
-
marginLeft="0"
|
|
77
|
-
marginTop="0"
|
|
78
|
-
onClick={() => setOpen(isOpen => !isOpen)}
|
|
79
|
-
/>
|
|
80
|
-
<SidebarContent onClick={e => setOpen(false)} isOpen={isOpen}>
|
|
81
|
-
<SidebarContentInner>
|
|
82
|
-
<h4>{props.heading}</h4>
|
|
83
|
-
{props.children}
|
|
84
|
-
</SidebarContentInner>
|
|
85
|
-
</SidebarContent>
|
|
86
|
-
</SidebarWrapper>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
export const GithubLogo = (props: React.ComponentProps<'svg'>) => (
|
|
4
|
-
<svg {...props} viewBox="0 0 496 512" fill="currentColor">
|
|
5
|
-
<path
|
|
6
|
-
fill="currentColor"
|
|
7
|
-
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"
|
|
8
|
-
/>
|
|
9
|
-
</svg>
|
|
10
|
-
)
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
export const ReactLogo = (props: React.ComponentProps<'svg'>) => (
|
|
4
|
-
<svg
|
|
5
|
-
{...props}
|
|
6
|
-
viewBox="0 0 256 230"
|
|
7
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
-
preserveAspectRatio="xMinYMin meet"
|
|
9
|
-
>
|
|
10
|
-
<path
|
|
11
|
-
d="M.754 114.75c0 19.215 18.763 37.152 48.343 47.263-5.907 29.737-1.058 53.706 15.136 63.045 16.645 9.6 41.443 2.955 64.98-17.62 22.943 19.744 46.13 27.514 62.31 18.148 16.63-9.627 21.687-35.221 15.617-65.887 30.81-10.186 48.044-25.481 48.044-44.949 0-18.769-18.797-35.006-47.979-45.052 6.535-31.933.998-55.32-15.867-65.045-16.259-9.376-39.716-1.204-62.996 19.056C104.122 2.205 80.897-4.36 64.05 5.392 47.806 14.795 43.171 39.2 49.097 69.487 20.515 79.452.754 96.057.754 114.75z"
|
|
12
|
-
fill="#FFF"
|
|
13
|
-
/>
|
|
14
|
-
<path
|
|
15
|
-
d="M201.025 79.674a151.364 151.364 0 0 0-7.274-2.292 137.5 137.5 0 0 0 1.124-4.961c5.506-26.728 1.906-48.26-10.388-55.348-11.787-6.798-31.065.29-50.535 17.233a151.136 151.136 0 0 0-5.626 5.163 137.573 137.573 0 0 0-3.744-3.458c-20.405-18.118-40.858-25.752-53.139-18.643-11.776 6.817-15.264 27.06-10.307 52.39a150.91 150.91 0 0 0 1.67 7.484c-2.894.822-5.689 1.698-8.363 2.63-23.922 8.34-39.2 21.412-39.2 34.97 0 14.004 16.4 28.05 41.318 36.566a128.44 128.44 0 0 0 6.11 1.91 147.813 147.813 0 0 0-1.775 8.067c-4.726 24.89-1.035 44.653 10.71 51.428 12.131 6.995 32.491-.195 52.317-17.525 1.567-1.37 3.14-2.823 4.715-4.346a148.34 148.34 0 0 0 6.108 5.573c19.204 16.525 38.17 23.198 49.905 16.405 12.12-7.016 16.058-28.247 10.944-54.078-.39-1.973-.845-3.988-1.355-6.04 1.43-.422 2.833-.858 4.202-1.312 25.904-8.582 42.757-22.457 42.757-36.648 0-13.607-15.77-26.767-40.174-35.168z"
|
|
16
|
-
fill="#53C1DE"
|
|
17
|
-
/>
|
|
18
|
-
<path
|
|
19
|
-
d="M195.406 142.328c-1.235.409-2.503.804-3.795 1.187-2.86-9.053-6.72-18.68-11.442-28.625 4.507-9.71 8.217-19.213 10.997-28.208 2.311.67 4.555 1.375 6.717 2.12 20.91 7.197 33.664 17.84 33.664 26.04 0 8.735-13.775 20.075-36.14 27.486zm-9.28 18.389c2.261 11.422 2.584 21.749 1.086 29.822-1.346 7.254-4.052 12.09-7.398 14.027-7.121 4.122-22.35-1.236-38.772-15.368-1.883-1.62-3.78-3.35-5.682-5.18 6.367-6.964 12.73-15.06 18.94-24.05 10.924-.969 21.244-2.554 30.603-4.717.46 1.86.87 3.683 1.223 5.466zm-93.85 43.137c-6.957 2.457-12.498 2.527-15.847.596-7.128-4.11-10.09-19.98-6.049-41.265a138.507 138.507 0 0 1 1.65-7.502c9.255 2.047 19.5 3.52 30.45 4.408 6.251 8.797 12.798 16.883 19.396 23.964a118.863 118.863 0 0 1-4.305 3.964c-8.767 7.664-17.552 13.1-25.294 15.835zm-32.593-61.58c-11.018-3.766-20.117-8.66-26.354-14-5.604-4.8-8.434-9.565-8.434-13.432 0-8.227 12.267-18.722 32.726-25.855a139.276 139.276 0 0 1 7.777-2.447c2.828 9.197 6.537 18.813 11.013 28.537-4.534 9.869-8.296 19.638-11.15 28.943a118.908 118.908 0 0 1-5.578-1.746zm10.926-74.37c-4.247-21.703-1.427-38.074 5.67-42.182 7.56-4.376 24.275 1.864 41.893 17.507 1.126 1 2.257 2.047 3.39 3.13-6.564 7.049-13.051 15.074-19.248 23.82-10.627.985-20.8 2.567-30.152 4.686a141.525 141.525 0 0 1-1.553-6.962zm97.467 24.067a306.982 306.982 0 0 0-6.871-11.3c7.21.91 14.117 2.12 20.603 3.601-1.947 6.241-4.374 12.767-7.232 19.457a336.42 336.42 0 0 0-6.5-11.758zm-39.747-38.714c4.452 4.823 8.911 10.209 13.297 16.052a284.245 284.245 0 0 0-26.706-.006c4.39-5.789 8.887-11.167 13.409-16.046zm-40.002 38.78a285.24 285.24 0 0 0-6.378 11.685c-2.811-6.667-5.216-13.222-7.18-19.552 6.447-1.443 13.322-2.622 20.485-3.517a283.79 283.79 0 0 0-6.927 11.384zm7.133 57.683c-7.4-.826-14.379-1.945-20.824-3.348 1.995-6.442 4.453-13.138 7.324-19.948a283.494 283.494 0 0 0 6.406 11.692 285.27 285.27 0 0 0 7.094 11.604zm33.136 27.389c-4.575-4.937-9.138-10.397-13.595-16.27 4.326.17 8.737.256 13.22.256 4.606 0 9.159-.103 13.64-.303-4.4 5.98-8.843 11.448-13.265 16.317zm46.072-51.032c3.02 6.884 5.566 13.544 7.588 19.877-6.552 1.495-13.625 2.699-21.078 3.593a337.537 337.537 0 0 0 6.937-11.498 306.632 306.632 0 0 0 6.553-11.972zm-14.915 7.15a316.478 316.478 0 0 1-10.84 17.49c-6.704.479-13.632.726-20.692.726-7.031 0-13.871-.219-20.458-.646A273.798 273.798 0 0 1 96.72 133.28a271.334 271.334 0 0 1-9.64-18.206 273.864 273.864 0 0 1 9.611-18.216v.002a271.252 271.252 0 0 1 10.956-17.442c6.72-.508 13.61-.774 20.575-.774 6.996 0 13.895.268 20.613.78a290.704 290.704 0 0 1 10.887 17.383 316.418 316.418 0 0 1 9.741 18.13 290.806 290.806 0 0 1-9.709 18.29zm19.913-107.792c7.566 4.364 10.509 21.961 5.755 45.038a127.525 127.525 0 0 1-1.016 4.492c-9.374-2.163-19.554-3.773-30.212-4.773-6.209-8.841-12.642-16.88-19.1-23.838a141.92 141.92 0 0 1 5.196-4.766c16.682-14.518 32.273-20.25 39.377-16.153z"
|
|
20
|
-
fill="#FFF"
|
|
21
|
-
/>
|
|
22
|
-
<path
|
|
23
|
-
d="M128.221 94.665c11.144 0 20.177 9.034 20.177 20.177 0 11.144-9.033 20.178-20.177 20.178-11.143 0-20.177-9.034-20.177-20.178 0-11.143 9.034-20.177 20.177-20.177"
|
|
24
|
-
fill="#53C1DE"
|
|
25
|
-
/>
|
|
26
|
-
</svg>
|
|
27
|
-
)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import {CSSProperties} from 'react'
|
|
3
|
-
import {RxJSLogo} from './RxJs'
|
|
4
|
-
import styled from 'styled-components'
|
|
5
|
-
import {ReactLogo} from './React'
|
|
6
|
-
|
|
7
|
-
const StyledRxJSLogo = styled(RxJSLogo)`
|
|
8
|
-
width: ${props => props.width};
|
|
9
|
-
opacity: 0.7;
|
|
10
|
-
position: absolute;
|
|
11
|
-
`
|
|
12
|
-
const StyledReactLogo = styled(ReactLogo)`
|
|
13
|
-
width: ${props => props.width};
|
|
14
|
-
opacity: 0.7;
|
|
15
|
-
position: absolute;
|
|
16
|
-
`
|
|
17
|
-
|
|
18
|
-
export function ReactRxLogo(props: {
|
|
19
|
-
className?: string
|
|
20
|
-
style?: CSSProperties
|
|
21
|
-
size: string
|
|
22
|
-
}) {
|
|
23
|
-
return (
|
|
24
|
-
<div
|
|
25
|
-
className={props.className}
|
|
26
|
-
style={{
|
|
27
|
-
display: 'inline-block',
|
|
28
|
-
verticalAlign: 'middle',
|
|
29
|
-
position: 'relative',
|
|
30
|
-
width: props.size,
|
|
31
|
-
height: props.size,
|
|
32
|
-
...props.style
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
<StyledReactLogo width={props.size} height={props.size} />
|
|
36
|
-
<StyledRxJSLogo width={props.size} height={props.size} />
|
|
37
|
-
</div>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
export const RxJSLogo = (props: React.ComponentProps<'svg'>) => (
|
|
4
|
-
<svg
|
|
5
|
-
{...props}
|
|
6
|
-
viewBox="12.1 8.4 262.8 272.2"
|
|
7
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
-
>
|
|
9
|
-
<linearGradient
|
|
10
|
-
id="a"
|
|
11
|
-
gradientUnits="userSpaceOnUse"
|
|
12
|
-
x1="53.496"
|
|
13
|
-
x2="177.932"
|
|
14
|
-
y1="247.701"
|
|
15
|
-
y2="115.323"
|
|
16
|
-
>
|
|
17
|
-
<stop offset="0" stopColor="#e01d84" />
|
|
18
|
-
<stop offset=".401" stopColor="#df1d85" />
|
|
19
|
-
<stop offset=".77" stopColor="#932c87" />
|
|
20
|
-
<stop offset="1" stopColor="#5d2f88" />
|
|
21
|
-
</linearGradient>
|
|
22
|
-
<radialGradient
|
|
23
|
-
id="b"
|
|
24
|
-
cx="190.456"
|
|
25
|
-
cy="80.2"
|
|
26
|
-
gradientTransform="matrix(1 .00239 -.002 .8362 .16 12.685)"
|
|
27
|
-
gradientUnits="userSpaceOnUse"
|
|
28
|
-
r="121.582"
|
|
29
|
-
>
|
|
30
|
-
<stop offset="0" stopColor="#e01d84" />
|
|
31
|
-
<stop offset=".139" stopColor="#de1e85" />
|
|
32
|
-
<stop offset=".285" stopColor="#d62085" />
|
|
33
|
-
<stop offset=".434" stopColor="#c92386" />
|
|
34
|
-
<stop offset=".586" stopColor="#b72786" />
|
|
35
|
-
<stop offset=".739" stopColor="#9d2b87" />
|
|
36
|
-
<stop offset=".891" stopColor="#7c2e88" />
|
|
37
|
-
<stop offset="1" stopColor="#5d2f88" />
|
|
38
|
-
</radialGradient>
|
|
39
|
-
<linearGradient
|
|
40
|
-
id="c"
|
|
41
|
-
gradientUnits="userSpaceOnUse"
|
|
42
|
-
x1="83.212"
|
|
43
|
-
x2="137.371"
|
|
44
|
-
y1="62.336"
|
|
45
|
-
y2="62.336"
|
|
46
|
-
>
|
|
47
|
-
<stop offset="0" stopColor="#e01d84" />
|
|
48
|
-
<stop offset=".238" stopColor="#da1e85" />
|
|
49
|
-
<stop offset=".658" stopColor="#c72085" />
|
|
50
|
-
<stop offset=".999" stopColor="#b52284" />
|
|
51
|
-
</linearGradient>
|
|
52
|
-
<path
|
|
53
|
-
d="M29.6 175.3c-5.2-16.2-6.7-33.3-3.7-50.9 1.3-7.3 3.3-14.3 5.5-21.4 0 0 13.8-45.3 60.5-66 0 0 16.1-8.5 40.3-9.1 0 0-3.3-3.2-5.4-4.6-11.4-7.6-28.4-10.1-38.7.6-3.1 3.2-5.7 6.7-8.6 9.9-3.3 3.6-7.3 6.6-11.9 8.3-4 1.5-8 1.2-12.1 1.9-4.2.7-8.5 2.2-11.9 4.9-3.7 3-5.2 7-5.6 11.6-.4 3.6-.3 7.3-.5 10.9C37 82 33.6 85 26 90.9c-3.2 2.4-5.9 5.6-7.9 9-6 10.6 3.6 21.6 4.1 32.3.1 2.2-.1 4.4-.9 6.5-.8 2.3-2.4 3.8-3.7 5.7-1.8 2.5-3 5.5-2.5 8.6s2.1 6 3.6 8.7c2.9 4.8 6.5 9.1 10.3 13.2.2 0 .4.2.6.4"
|
|
54
|
-
fill="#e32286"
|
|
55
|
-
/>
|
|
56
|
-
<path
|
|
57
|
-
d="M220.4 213.7c23-10 32.8-27.3 32.8-27.3 21.5-29.3 14.2-60.2 14.2-60.2-13.7 29.8-26.2 38-26.2 38 33.7-51.3.2-82.3.2-82.3 13.7 29.2-4.5 64.8-4.5 64.8-15.3 32.2-37 43.7-37 43.7 24.2 4.5 42-11.8 42-11.8-34.7 37.5-72.3 35.7-72.3 35.7 15.8 17.7 39.5 16.2 39.5 16.2-31 7.3-60.1-3-84-22.9-4.5-3.7-8.8-7.7-12.8-12 0 0-3.6-3.8-4.3-4.8l-.1-.1c-.5 18.5 18.8 35.7 18.8 35.7-24.2-10-35.3-31.7-35.3-31.7s-16.3-27.8-4.5-59.5 47.5-38.5 47.5-38.5c29.5 14.3 54.5 18.8 54.5 18.8 52.7 8.8 49.7-17 49.7-17 .5-22.2-33-45.8-33-45.8C145.9 8.4 91.9 37 91.9 37c-46.7 20.7-60.5 66-60.5 66-2.2 7.1-4.2 14.1-5.5 21.4-5.1 29.7 2.6 57.8 19.3 82.8 26 38.8 68.2 52.2 68.2 52.2 62.5 21.2 105.2-10 105.2-10 39.3-27 47.2-58.2 47.2-58.2-31.7 24.8-45.4 22.5-45.4 22.5zM171.6 67.8c3 0 5.4 2.4 5.4 5.4s-2.4 5.4-5.4 5.4-5.4-2.4-5.4-5.4 2.4-5.4 5.4-5.4z"
|
|
58
|
-
fill="url(#a)"
|
|
59
|
-
/>
|
|
60
|
-
<path
|
|
61
|
-
d="M238.5 98.4c.5-22.2-33-45.8-33-45.8C145.8 8.4 91.8 37 91.8 37c-46.7 20.7-60.5 66-60.5 66-2.7 7.7-5.1 19.5-5.1 19.5-2.9 14.8-1.6 28.5-1.6 28.5 1.2 13.1 4.1 21.9 4.1 21.9 3 9.4 4.4 12.3 4.4 12.3-.1-.3-.6-2.5-.6-2.5s-4.2-20.2-.3-39.6c0 0 3.4-20.2 17.2-35.8 0 0 22.4-31.9 64.1-19.4 0 0 9 3.2 12.1 4.8 3.1 1.5 8.5 3.8 8.5 3.8 29.5 14.3 54.5 18.8 54.5 18.8 52.9 8.9 49.9-16.9 49.9-16.9zm-66.9-19.7c-3 0-5.4-2.4-5.4-5.4s2.4-5.4 5.4-5.4 5.4 2.4 5.4 5.4-2.4 5.4-5.4 5.4z"
|
|
62
|
-
fill="url(#b)"
|
|
63
|
-
/>
|
|
64
|
-
<path
|
|
65
|
-
d="M137.4 58.2l-34.1-10.6c-.2 0-1.2-.5-3 0 0 0-20.1 5.1-16.6 16.1 0 0 2.1 6.9 7.8 13.6l37.5-1.8z"
|
|
66
|
-
fill="url(#c)"
|
|
67
|
-
/>
|
|
68
|
-
</svg>
|
|
69
|
-
)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
|
|
3
|
-
const CHECKER_SIZE = 60
|
|
4
|
-
const CHECKER_FG = '#252525'
|
|
5
|
-
const CHECKER_BG = '#222'
|
|
6
|
-
|
|
7
|
-
export const Checkerboard = styled.div`
|
|
8
|
-
display: flex;
|
|
9
|
-
/*align-items: center;*/
|
|
10
|
-
justify-content: center;
|
|
11
|
-
color: #fff;
|
|
12
|
-
height: calc(100% - 1.95em);
|
|
13
|
-
width: 100%;
|
|
14
|
-
background-color: ${CHECKER_FG};
|
|
15
|
-
background-image: linear-gradient(45deg, ${CHECKER_BG} 25%, transparent 25%),
|
|
16
|
-
linear-gradient(-45deg, ${CHECKER_BG} 25%, transparent 25%),
|
|
17
|
-
linear-gradient(45deg, transparent 75%, ${CHECKER_BG} 75%),
|
|
18
|
-
linear-gradient(-45deg, transparent 75%, ${CHECKER_BG} 75%);
|
|
19
|
-
background-size: 20px 20px;
|
|
20
|
-
background-position: 0 0, 0 10px, 10px -10px, -10px 0;
|
|
21
|
-
|
|
22
|
-
background-size: ${CHECKER_SIZE}px ${CHECKER_SIZE}px;
|
|
23
|
-
background-position: 0 0, 0 ${CHECKER_SIZE / 2}px,
|
|
24
|
-
${CHECKER_SIZE / 2}px -${CHECKER_SIZE / 2}px, -${CHECKER_SIZE / 2}px 0;
|
|
25
|
-
`
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
import * as globalScope from '../../examples/_utils/globalScope'
|
|
4
|
-
import {Checkerboard} from './Checkerboard'
|
|
5
|
-
import {ShowError} from './ShowError'
|
|
6
|
-
import {CodeMirror} from './CodeMirror'
|
|
7
|
-
import {compile} from './compile/babel'
|
|
8
|
-
import {evalReactDomRender} from './eval/evalReactDomRender'
|
|
9
|
-
import {Prelude} from './Prelude'
|
|
10
|
-
import {EvalCode} from './EvalCode'
|
|
11
|
-
import './codemirror-lib'
|
|
12
|
-
import styled from 'styled-components'
|
|
13
|
-
|
|
14
|
-
const fs = require('fs')
|
|
15
|
-
|
|
16
|
-
interface Scope {
|
|
17
|
-
[variableName: string]: any
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface Props {
|
|
21
|
-
source: string
|
|
22
|
-
scope?: Scope
|
|
23
|
-
filename: string
|
|
24
|
-
prelude?: string
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const tryCompile = (code: string, filename: string) => {
|
|
28
|
-
try {
|
|
29
|
-
return [null, compile(code, {filename})?.code || '']
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return [error]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const evalRender = (code: string, scope: Scope = {}) => {
|
|
36
|
-
return evalReactDomRender(code, {
|
|
37
|
-
...scope,
|
|
38
|
-
...globalScope
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const COMMON_PRELUDE = `import {rxComponent, observeEvent, observeContext, observeState, forwardRef} from 'react-rx'\n${
|
|
43
|
-
fs
|
|
44
|
-
.readFileSync(`${__dirname}/../../examples/_utils/globalScope.ts`, 'utf-8')
|
|
45
|
-
.split('//@endimport')[0]
|
|
46
|
-
}`
|
|
47
|
-
|
|
48
|
-
const stripImports = (str: string) => {
|
|
49
|
-
return str
|
|
50
|
-
.split('//@endimport')
|
|
51
|
-
.slice(-1)[0]
|
|
52
|
-
.trim()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const CODEMIRROR_MODE = {
|
|
56
|
-
name: 'jsx',
|
|
57
|
-
base: {name: 'javascript', typescript: true}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const CODEMIRROR_OPTIONS = {
|
|
61
|
-
theme: 'custom',
|
|
62
|
-
smartIndent: false,
|
|
63
|
-
tabSize: 2,
|
|
64
|
-
mode: CODEMIRROR_MODE
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const StyledWrapper = styled.div`
|
|
68
|
-
@media (max-width: 979px) {
|
|
69
|
-
display: block;
|
|
70
|
-
}
|
|
71
|
-
@media (min-width: 1280px) {
|
|
72
|
-
display: flex;
|
|
73
|
-
align-items: stretch;
|
|
74
|
-
flex-direction: row;
|
|
75
|
-
}
|
|
76
|
-
`
|
|
77
|
-
const Header = styled.div`
|
|
78
|
-
color: #d8d8d8;
|
|
79
|
-
font-size: 0.9em;
|
|
80
|
-
text-transform: uppercase;
|
|
81
|
-
padding: 0.5em 1.5em;
|
|
82
|
-
`
|
|
83
|
-
const BORDER_RADIUS = 0.5
|
|
84
|
-
const Column = styled.div<{type: 'editor' | 'result'}>`
|
|
85
|
-
@media (min-width: 1280px) {
|
|
86
|
-
border-radius: ${props =>
|
|
87
|
-
props.type === 'editor'
|
|
88
|
-
? `${BORDER_RADIUS}em 0 0 ${BORDER_RADIUS}em`
|
|
89
|
-
: `0 ${BORDER_RADIUS}em ${BORDER_RADIUS}em 0`};
|
|
90
|
-
padding: ${props =>
|
|
91
|
-
props.type === 'editor' ? '0 1px 0.5em 0' : '0 0 0.5em 1px'};
|
|
92
|
-
}
|
|
93
|
-
@media (max-width: 1279px) {
|
|
94
|
-
border-radius: ${props =>
|
|
95
|
-
props.type === 'editor'
|
|
96
|
-
? `${BORDER_RADIUS}em ${BORDER_RADIUS}em 0 0`
|
|
97
|
-
: `0 0 ${BORDER_RADIUS}em ${BORDER_RADIUS}em`};
|
|
98
|
-
padding: ${props => (props.type === 'editor' ? '0' : '0 0 0.5em 0')};
|
|
99
|
-
}
|
|
100
|
-
flex: 0 0 ${props => (props.type === 'editor' ? 60 : 40)}%;
|
|
101
|
-
background: #282c34;
|
|
102
|
-
`
|
|
103
|
-
|
|
104
|
-
export function CodeBlock(props: Props) {
|
|
105
|
-
const source = stripImports(props.source)
|
|
106
|
-
const [code, setCode] = React.useState(source.trim())
|
|
107
|
-
|
|
108
|
-
const [compileError, transformed] = tryCompile(code, props.filename)
|
|
109
|
-
return (
|
|
110
|
-
<StyledWrapper>
|
|
111
|
-
<Column type="editor">
|
|
112
|
-
<Header>Live editor</Header>
|
|
113
|
-
<Prelude
|
|
114
|
-
mode={CODEMIRROR_MODE}
|
|
115
|
-
value={`${COMMON_PRELUDE}${props.prelude ? props.prelude : ''}`}
|
|
116
|
-
/>
|
|
117
|
-
<CodeMirror
|
|
118
|
-
value={code}
|
|
119
|
-
options={CODEMIRROR_OPTIONS}
|
|
120
|
-
onBeforeChange={(editor, data, value) => {
|
|
121
|
-
setCode(value)
|
|
122
|
-
}}
|
|
123
|
-
/>
|
|
124
|
-
</Column>
|
|
125
|
-
<Column type="result">
|
|
126
|
-
<Header>Result</Header>
|
|
127
|
-
<Checkerboard>
|
|
128
|
-
<div style={{padding: '2em'}}>
|
|
129
|
-
{compileError ? (
|
|
130
|
-
<ShowError title="Compile error">
|
|
131
|
-
{compileError.message}
|
|
132
|
-
</ShowError>
|
|
133
|
-
) : (
|
|
134
|
-
<EvalCode
|
|
135
|
-
code={transformed}
|
|
136
|
-
evalWith={src => evalRender(src, props.scope)}
|
|
137
|
-
renderError={error => (
|
|
138
|
-
<ShowError title="Runtime error">{error.message}</ShowError>
|
|
139
|
-
)}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
</Checkerboard>
|
|
144
|
-
</Column>
|
|
145
|
-
</StyledWrapper>
|
|
146
|
-
)
|
|
147
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
import {Controlled} from 'react-codemirror2'
|
|
3
|
-
|
|
4
|
-
const SCROLLBAR_BG_COLOR = '#1f222a'
|
|
5
|
-
const SCROLLBAR_THUMB_COLOR = '#575757'
|
|
6
|
-
|
|
7
|
-
export const CodeMirror = styled(Controlled)`
|
|
8
|
-
font-size: 0.8em;
|
|
9
|
-
background-color: #282c34;
|
|
10
|
-
|
|
11
|
-
& ::-webkit-scrollbar {
|
|
12
|
-
width: 11px;
|
|
13
|
-
}
|
|
14
|
-
& {
|
|
15
|
-
scrollbar-width: thin;
|
|
16
|
-
scrollbar-color: ${SCROLLBAR_THUMB_COLOR} ${SCROLLBAR_BG_COLOR};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
& ::-webkit-scrollbar-track {
|
|
20
|
-
background: ${SCROLLBAR_BG_COLOR};
|
|
21
|
-
}
|
|
22
|
-
& ::-webkit-scrollbar-thumb {
|
|
23
|
-
background-color: ${SCROLLBAR_THUMB_COLOR} ;
|
|
24
|
-
border-radius: 6px;
|
|
25
|
-
border: 3px solid ${SCROLLBAR_BG_COLOR};
|
|
26
|
-
}
|
|
27
|
-
.CodeMirror-scroll {
|
|
28
|
-
max-height: calc(100vh - 24em);
|
|
29
|
-
}
|
|
30
|
-
.CodeMirror {
|
|
31
|
-
padding: 0.6rem;
|
|
32
|
-
height: auto;
|
|
33
|
-
font-family: source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace;
|
|
34
|
-
-webkit-font-smoothing: antialiased;
|
|
35
|
-
line-height: 1.4em;
|
|
36
|
-
}
|
|
37
|
-
}`
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {rxComponent} from 'react-rx'
|
|
2
|
-
import {map, switchMap, toArray} from 'rxjs/operators'
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import styled from 'styled-components'
|
|
5
|
-
import {runMode} from './runMode'
|
|
6
|
-
|
|
7
|
-
export interface CodeMirrorModeProps {
|
|
8
|
-
mode: null | {name: string; base?: any}
|
|
9
|
-
highlighted?: number[]
|
|
10
|
-
children: string
|
|
11
|
-
className?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const CodeMirrorMode = rxComponent<CodeMirrorModeProps>(
|
|
15
|
-
(props$) => {
|
|
16
|
-
return props$.pipe(
|
|
17
|
-
switchMap((props) =>
|
|
18
|
-
runMode(props.children, props.mode).pipe(
|
|
19
|
-
toArray(),
|
|
20
|
-
map((lines, i) => (
|
|
21
|
-
<Code
|
|
22
|
-
key={`line-${i}`}
|
|
23
|
-
className={`cm-s-custom${
|
|
24
|
-
props.className ? ` ${props.className}` : ''
|
|
25
|
-
}`}
|
|
26
|
-
>
|
|
27
|
-
{lines.map((line, lineNo) => (
|
|
28
|
-
<div
|
|
29
|
-
key={`line-${i}-${lineNo}`}
|
|
30
|
-
className={`cm-line${
|
|
31
|
-
(props.highlighted || []).includes(lineNo + 1)
|
|
32
|
-
? ' CodeMirror-selected'
|
|
33
|
-
: ''
|
|
34
|
-
}`}
|
|
35
|
-
>
|
|
36
|
-
{line.map((token, i) =>
|
|
37
|
-
token.style ? (
|
|
38
|
-
<span key={i} className={`cm-${token.style}`}>
|
|
39
|
-
{token.token}
|
|
40
|
-
</span>
|
|
41
|
-
) : (
|
|
42
|
-
token.token
|
|
43
|
-
)
|
|
44
|
-
)}
|
|
45
|
-
</div>
|
|
46
|
-
))}
|
|
47
|
-
</Code>
|
|
48
|
-
))
|
|
49
|
-
)
|
|
50
|
-
)
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
const Code = styled.div`
|
|
56
|
-
font-size: 0.8em;
|
|
57
|
-
|
|
58
|
-
background-color: rgb(40, 44, 52);
|
|
59
|
-
color: #fff;
|
|
60
|
-
margin: 0;
|
|
61
|
-
white-space: pre;
|
|
62
|
-
overflow: auto;
|
|
63
|
-
padding: 0.9rem;
|
|
64
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, Courier New, monospace;
|
|
65
|
-
-webkit-font-smoothing: antialiased;
|
|
66
|
-
line-height: 1.4em;
|
|
67
|
-
`
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
interface EvalErrorBoundaryProps {
|
|
4
|
-
code: string
|
|
5
|
-
renderError: (error: Error) => React.ReactNode
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface EvalErrorBoundaryState {
|
|
9
|
-
error: Error | null
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
class EvalErrorBoundary extends React.Component<
|
|
13
|
-
EvalErrorBoundaryProps,
|
|
14
|
-
EvalErrorBoundaryState
|
|
15
|
-
> {
|
|
16
|
-
state: EvalErrorBoundaryState = {error: null}
|
|
17
|
-
|
|
18
|
-
static getDerivedStateFromError(error: Error) {
|
|
19
|
-
return {error}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
componentDidUpdate(
|
|
23
|
-
prevProps: Readonly<EvalErrorBoundaryProps>,
|
|
24
|
-
prevState: Readonly<EvalErrorBoundaryState>
|
|
25
|
-
) {
|
|
26
|
-
if (prevProps.code !== this.props.code) {
|
|
27
|
-
this.setState({error: null})
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
const {error} = this.state
|
|
33
|
-
return error ? this.props.renderError(error) : this.props.children
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type Runner = (code: string) => React.ReactNode
|
|
38
|
-
|
|
39
|
-
const Eval = (props: {with: Runner; code: string}) => (
|
|
40
|
-
<>{props.with(props.code)}</>
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
interface Props {
|
|
44
|
-
code: string
|
|
45
|
-
renderError: (error: Error) => React.ReactNode
|
|
46
|
-
evalWith: Runner
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function EvalCode(props: Props) {
|
|
50
|
-
return (
|
|
51
|
-
<EvalErrorBoundary code={props.code} renderError={props.renderError}>
|
|
52
|
-
<Eval with={props.evalWith} code={props.code} />
|
|
53
|
-
</EvalErrorBoundary>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
3
|
-
import {CodeMirrorMode} from './CodeMirrorMode'
|
|
4
|
-
|
|
5
|
-
const Details = styled.details`
|
|
6
|
-
text-align: right;
|
|
7
|
-
white-space: pre;
|
|
8
|
-
background-color: #1f222a;
|
|
9
|
-
line-height: 1.4em;
|
|
10
|
-
border: 0;
|
|
11
|
-
box-sizing: border-box;
|
|
12
|
-
`
|
|
13
|
-
|
|
14
|
-
const Summary = styled.summary`
|
|
15
|
-
background-color: #242831;
|
|
16
|
-
display: inline-block;
|
|
17
|
-
color: #65737e;
|
|
18
|
-
font-size: 0.8em;
|
|
19
|
-
border-radius: 2px 2px 0 0;
|
|
20
|
-
margin: 1px 0 0 0;
|
|
21
|
-
text-transform: uppercase;
|
|
22
|
-
padding: 0.4em 0.9em;
|
|
23
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, Courier New, monospace;
|
|
24
|
-
-webkit-font-smoothing: antialiased;
|
|
25
|
-
outline: none;
|
|
26
|
-
`
|
|
27
|
-
|
|
28
|
-
const StyledCodeMirrorMode = styled(CodeMirrorMode)`
|
|
29
|
-
opacity: 0.7;
|
|
30
|
-
text-align: left;
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
interface Props {
|
|
34
|
-
mode: any
|
|
35
|
-
value: string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const Prelude = (props: Props) => {
|
|
39
|
-
const [isOpen, setOpen] = React.useState(false)
|
|
40
|
-
return (
|
|
41
|
-
<Details>
|
|
42
|
-
<Summary onClick={() => setOpen(current => !current)}>
|
|
43
|
-
{isOpen ? 'hide prelude' : 'show prelude'}
|
|
44
|
-
</Summary>
|
|
45
|
-
<StyledCodeMirrorMode mode={props.mode}>
|
|
46
|
-
{props.value}
|
|
47
|
-
</StyledCodeMirrorMode>
|
|
48
|
-
</Details>
|
|
49
|
-
)
|
|
50
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
title: string
|
|
6
|
-
children: React.ReactNode
|
|
7
|
-
className?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const Pre = styled.pre`
|
|
11
|
-
color: rgb(255, 100, 100);
|
|
12
|
-
`
|
|
13
|
-
|
|
14
|
-
const Heading = styled.h2`
|
|
15
|
-
padding: 3px:
|
|
16
|
-
color: #fff
|
|
17
|
-
padding: 8px;
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
export function ShowError(props: Props) {
|
|
21
|
-
return (
|
|
22
|
-
<div className={props.className}>
|
|
23
|
-
<Heading>{props.title}</Heading>
|
|
24
|
-
<Pre>{props.children}</Pre>
|
|
25
|
-
</div>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as codemirror from 'codemirror'
|
|
2
|
-
import 'codemirror/mode/javascript/javascript'
|
|
3
|
-
import 'codemirror/mode/jsx/jsx'
|
|
4
|
-
import 'codemirror/addon/selection/active-line'
|
|
5
|
-
import 'codemirror/addon/edit/matchbrackets'
|
|
6
|
-
import 'codemirror/addon/edit/matchtags'
|
|
7
|
-
|
|
8
|
-
export default codemirror
|