timvir 0.1.42
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/blocks/Arbitrary/Arbitrary.d.ts +11 -0
- package/blocks/Arbitrary/context.d.ts +7 -0
- package/blocks/Arbitrary/docs/index.mdx +36 -0
- package/blocks/Arbitrary/index.d.ts +2 -0
- package/blocks/Arbitrary/index.js +117 -0
- package/blocks/Arbitrary/samples/basic.d.ts +5 -0
- package/blocks/Arbitrary/styles.css +6 -0
- package/blocks/Code/Code.d.ts +35 -0
- package/blocks/Code/docs/api.mdx +76 -0
- package/blocks/Code/docs/index.mdx +39 -0
- package/blocks/Code/index.d.ts +1 -0
- package/blocks/Code/index.js +154 -0
- package/blocks/Code/samples/basic.d.ts +5 -0
- package/blocks/Code/samples/toggle.d.ts +2 -0
- package/blocks/Code/styles.css +14 -0
- package/blocks/Code/theme.d.ts +2 -0
- package/blocks/ColorBar/ColorBar.d.ts +18 -0
- package/blocks/ColorBar/docs/api.mdx +76 -0
- package/blocks/ColorBar/docs/index.mdx +128 -0
- package/blocks/ColorBar/index.d.ts +1 -0
- package/blocks/ColorBar/index.js +90 -0
- package/blocks/ColorBar/samples/basic.d.ts +2 -0
- package/blocks/ColorBar/styles.css +5 -0
- package/blocks/ColorBook/ColorBook.d.ts +16 -0
- package/blocks/ColorBook/docs/api.mdx +76 -0
- package/blocks/ColorBook/docs/index.mdx +12 -0
- package/blocks/ColorBook/index.d.ts +1 -0
- package/blocks/ColorBook/index.js +77 -0
- package/blocks/ColorBook/samples/basic.d.ts +2 -0
- package/blocks/ColorBook/styles.css +6 -0
- package/blocks/Cover/Cover.d.ts +20 -0
- package/blocks/Cover/docs/api.mdx +76 -0
- package/blocks/Cover/docs/index.mdx +20 -0
- package/blocks/Cover/index.d.ts +1 -0
- package/blocks/Cover/index.js +64 -0
- package/blocks/Cover/samples/basic.d.ts +2 -0
- package/blocks/Exhibit/Exhibit.d.ts +19 -0
- package/blocks/Exhibit/docs/api.mdx +76 -0
- package/blocks/Exhibit/docs/index.mdx +56 -0
- package/blocks/Exhibit/index.d.ts +1 -0
- package/blocks/Exhibit/index.js +83 -0
- package/blocks/Exhibit/samples/basic.d.ts +2 -0
- package/blocks/Exhibit/styles.css +3 -0
- package/blocks/Font/Font.d.ts +15 -0
- package/blocks/Font/docs/api.mdx +76 -0
- package/blocks/Font/docs/index.mdx +23 -0
- package/blocks/Font/index.d.ts +1 -0
- package/blocks/Font/index.js +131 -0
- package/blocks/Font/samples/basic.d.ts +5 -0
- package/blocks/Font/samples/system.d.ts +2 -0
- package/blocks/Font/styles.css +9 -0
- package/blocks/Grid/Grid.d.ts +9 -0
- package/blocks/Grid/docs/api.mdx +76 -0
- package/blocks/Grid/docs/index.mdx +82 -0
- package/blocks/Grid/index.d.ts +1 -0
- package/blocks/Grid/index.js +53 -0
- package/blocks/Grid/samples/basic.d.ts +2 -0
- package/blocks/Grid/styles.css +1 -0
- package/blocks/Icon/Icon.d.ts +11 -0
- package/blocks/Icon/docs/api.mdx +76 -0
- package/blocks/Icon/docs/index.mdx +218 -0
- package/blocks/Icon/index.d.ts +1 -0
- package/blocks/Icon/index.js +155 -0
- package/blocks/Icon/internal/Canvas.d.ts +9 -0
- package/blocks/Icon/internal/index.d.ts +1 -0
- package/blocks/Icon/samples/basic.d.ts +2 -0
- package/blocks/Icon/styles.css +5 -0
- package/blocks/Icon/types.d.ts +10 -0
- package/blocks/Message/Message.d.ts +10 -0
- package/blocks/Message/docs/api.mdx +76 -0
- package/blocks/Message/docs/index.mdx +63 -0
- package/blocks/Message/index.d.ts +1 -0
- package/blocks/Message/index.js +72 -0
- package/blocks/Message/samples/basic.d.ts +5 -0
- package/blocks/Message/styles.css +6 -0
- package/blocks/Swatch/Swatch.d.ts +33 -0
- package/blocks/Swatch/docs/api.mdx +76 -0
- package/blocks/Swatch/docs/index.mdx +39 -0
- package/blocks/Swatch/index.d.ts +1 -0
- package/blocks/Swatch/index.js +84 -0
- package/blocks/Swatch/samples/basic.d.ts +2 -0
- package/blocks/Swatch/styles.css +4 -0
- package/blocks/Viewport/Viewport.d.ts +17 -0
- package/blocks/Viewport/docs/api.mdx +76 -0
- package/blocks/Viewport/docs/index.mdx +34 -0
- package/blocks/Viewport/index.d.ts +1 -0
- package/blocks/Viewport/index.js +322 -0
- package/blocks/Viewport/internal/Caption.d.ts +8 -0
- package/blocks/Viewport/internal/Handle.d.ts +10 -0
- package/blocks/Viewport/internal/Ruler.d.ts +7 -0
- package/blocks/Viewport/internal/index.d.ts +3 -0
- package/blocks/Viewport/samples/basic.d.ts +2 -0
- package/blocks/Viewport/styles.css +14 -0
- package/blocks/WebLink/WebLink.d.ts +10 -0
- package/blocks/WebLink/docs/api.mdx +76 -0
- package/blocks/WebLink/docs/index.mdx +13 -0
- package/blocks/WebLink/index.d.ts +1 -0
- package/blocks/WebLink/index.js +97 -0
- package/blocks/WebLink/samples/basic.d.ts +5 -0
- package/blocks/WebLink/styles.css +8 -0
- package/blocks/index.d.ts +13 -0
- package/blocks/index.js +13 -0
- package/blocks/styles.css +81 -0
- package/bus/index.d.ts +12 -0
- package/bus/index.js +22 -0
- package/bus/messages.d.ts +15 -0
- package/context/index.d.ts +20 -0
- package/context/index.js +15 -0
- package/core/components/Footer/Footer.d.ts +16 -0
- package/core/components/Footer/docs/api.mdx +76 -0
- package/core/components/Footer/docs/index.mdx +27 -0
- package/core/components/Footer/index.d.ts +1 -0
- package/core/components/Footer/samples/basic.d.ts +5 -0
- package/core/components/NavigationFooter/NavigationFooter.d.ts +19 -0
- package/core/components/NavigationFooter/docs/api.mdx +76 -0
- package/core/components/NavigationFooter/docs/index.mdx +10 -0
- package/core/components/NavigationFooter/index.d.ts +1 -0
- package/core/components/NavigationFooter/samples/basic.d.ts +5 -0
- package/core/components/Page/Page.d.ts +60 -0
- package/core/components/Page/components.d.ts +46 -0
- package/core/components/Page/docs/api.mdx +76 -0
- package/core/components/Page/docs/index.mdx +37 -0
- package/core/components/Page/index.d.ts +2 -0
- package/core/components/Page/internal/Section.d.ts +7 -0
- package/core/components/Page/internal/Sidebar.d.ts +15 -0
- package/core/components/Page/internal/index.d.ts +2 -0
- package/core/components/Page/samples/basic.d.ts +2 -0
- package/core/components/Page/samples/layout.d.ts +2 -0
- package/core/components/Page/types.d.ts +5 -0
- package/core/index.d.ts +22 -0
- package/core/index.js +708 -0
- package/core/layout.d.ts +4 -0
- package/core/styles.css +47 -0
- package/core/theme/colors.d.ts +36 -0
- package/core/theme/index.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +72 -0
- package/hooks/useResizeObserver/index.d.ts +56 -0
- package/package.json +27 -0
- package/std/base58/index.d.ts +2 -0
- package/std/base58/index.js +71 -0
- package/styles.css +128 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exhibit } from "timvir/blocks";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* The underlying DOM element which is rendered by this component.
|
|
5
|
+
*/
|
|
6
|
+
declare const Root = "div";
|
|
7
|
+
interface Props extends React.ComponentPropsWithRef<typeof Root> {
|
|
8
|
+
ExhibitProps?: React.ComponentPropsWithRef<typeof Exhibit>;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "key" | "dir" | "onError" | "hidden" | "color" | "style" | "translate" | "prefix" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "draggable" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "ExhibitProps"> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Arbitrary } from "..";
|
|
2
|
+
import { Exhibit } from "timvir/blocks";
|
|
3
|
+
|
|
4
|
+
# Arbitrary
|
|
5
|
+
|
|
6
|
+
The `<Arbitrary>` component manages a React context that contains a seed. This seed is displayed
|
|
7
|
+
in an input field where users can copy it from.
|
|
8
|
+
|
|
9
|
+
The component renders its children in an `<Exhibit>`. The children can make use of the seed in the
|
|
10
|
+
React context to render themselves in a predictable way.
|
|
11
|
+
|
|
12
|
+
<Sample variant="basic" />
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
Given a component-under-test:
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import { useContext } from "timvir/blocks/Arbitrary"
|
|
20
|
+
|
|
21
|
+
function Component() {
|
|
22
|
+
const { seed } = useContext();
|
|
23
|
+
return <div>{seed}</div>;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
We can take it and display it inside an `<Arbitrary>` in a timvir doc page:
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
import { Arbitrary } from "timvir/blocks"
|
|
31
|
+
import { Component } from ".."
|
|
32
|
+
|
|
33
|
+
<Arbitrary>
|
|
34
|
+
<Component />
|
|
35
|
+
</Arbitrary>
|
|
36
|
+
```
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Exhibit } from 'timvir/blocks';
|
|
2
|
+
import { useBlock } from 'timvir/core';
|
|
3
|
+
import * as base58 from 'timvir/std/base58';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useImmer } from 'use-immer';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Takes a list of class names and filters for truthy ones, joining them into a single class name for convenience.
|
|
9
|
+
* eg.
|
|
10
|
+
* ```js
|
|
11
|
+
* cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
|
|
12
|
+
* ```
|
|
13
|
+
* If arguments provided are objects, these objects are merged together, and the values are taken as class names:
|
|
14
|
+
*
|
|
15
|
+
* ```js
|
|
16
|
+
* cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @returns the combined, space separated class names that can be applied directly to the class attribute
|
|
20
|
+
*/
|
|
21
|
+
const cx = function cx() {
|
|
22
|
+
const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
|
|
23
|
+
|
|
24
|
+
const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
|
|
25
|
+
// key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
|
|
26
|
+
// deduplicate the values based on their properties. The object's values are
|
|
27
|
+
// the class names
|
|
28
|
+
|
|
29
|
+
const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
|
|
30
|
+
return [...styleCollectionResult, ...classNamesResult].join(' ');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const Context = /*#__PURE__*/React.createContext({
|
|
34
|
+
seed: 0
|
|
35
|
+
});
|
|
36
|
+
const useContext = () => React.useContext(Context);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The underlying DOM element which is rendered by this component.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
const Root = "div";
|
|
43
|
+
|
|
44
|
+
function Arbitrary(props, ref) {
|
|
45
|
+
const block = useBlock(props);
|
|
46
|
+
const {
|
|
47
|
+
ExhibitProps,
|
|
48
|
+
className,
|
|
49
|
+
children,
|
|
50
|
+
...rest
|
|
51
|
+
} = block.props;
|
|
52
|
+
const [value, mutate] = useImmer({
|
|
53
|
+
seed: 0
|
|
54
|
+
});
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
mutate(draft => {
|
|
57
|
+
draft.seed = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
58
|
+
});
|
|
59
|
+
}, [mutate]);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (props.id) {
|
|
62
|
+
block.bus.next({
|
|
63
|
+
type: "SIGNAL",
|
|
64
|
+
path: `/dev/timvir/block/${props.id}`,
|
|
65
|
+
interface: "dev.timvir.block.Arbitrary",
|
|
66
|
+
member: "seed",
|
|
67
|
+
body: value.seed
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [block.bus, value.seed]);
|
|
71
|
+
return /*#__PURE__*/React.createElement(Context.Provider, {
|
|
72
|
+
value: value
|
|
73
|
+
}, /*#__PURE__*/React.createElement(Root, {
|
|
74
|
+
ref: ref,
|
|
75
|
+
className: cx(classes.root, className),
|
|
76
|
+
...rest
|
|
77
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: classes.controls
|
|
79
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
80
|
+
className: classes.textField
|
|
81
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
82
|
+
className: classes.startAdornment
|
|
83
|
+
}, "Seed:"), /*#__PURE__*/React.createElement("input", {
|
|
84
|
+
className: classes.input,
|
|
85
|
+
placeholder: "Seed",
|
|
86
|
+
value: base58.encode(new TextEncoder().encode(`${value.seed}`)),
|
|
87
|
+
onPaste: ev => {
|
|
88
|
+
const v = ev.clipboardData.getData("text/plain");
|
|
89
|
+
mutate(draft => {
|
|
90
|
+
draft.seed = +base58.decode(v);
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
onFocus: ev => {
|
|
94
|
+
ev.currentTarget.select();
|
|
95
|
+
}
|
|
96
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
97
|
+
className: classes.button,
|
|
98
|
+
onClick: () => {
|
|
99
|
+
mutate(draft => {
|
|
100
|
+
draft.seed = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}, "Refresh")), /*#__PURE__*/React.createElement(Exhibit, { ...ExhibitProps
|
|
104
|
+
}, children)));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var Arbitrary$1 = /*#__PURE__*/React.forwardRef(Arbitrary);
|
|
108
|
+
const classes = {
|
|
109
|
+
root: "r1ev38xg",
|
|
110
|
+
controls: "c8hz158",
|
|
111
|
+
textField: "t1663phv",
|
|
112
|
+
startAdornment: "s1k50njo",
|
|
113
|
+
input: "i1dajnne",
|
|
114
|
+
button: "b128wsn"
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export { Arbitrary$1 as Arbitrary, useContext };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
.r1ev38xg{margin:1em 0;}
|
|
2
|
+
.c8hz158{display:grid;grid-gap:8px;grid-template-columns:1fr 100px;margin-bottom:8px;}
|
|
3
|
+
.t1663phv{display:flex;align-items:center;padding:0 0 0 10px;height:36px;position:relative;}.t1663phv::after{display:block;position:absolute;content:"";inset:0;pointer-events:none;border:1px solid var(--timvir-secondary-text-color);border-radius:2px;}.t1663phv:hover::after{border-color:var(--timvir-accent-color);}.t1663phv:focus-within::after{border-color:var(--timvir-accent-color);}
|
|
4
|
+
.s1k50njo{display:inline-block;color:var(--timvir-secondary-text-color);margin-right:6px;}
|
|
5
|
+
.i1dajnne{border:none;outline:none;font:inherit;background:transparent;align-self:stretch;padding:0;height:34px;width:100%;color:inherit;}
|
|
6
|
+
.b128wsn{border:none;outline:none;height:36px;background:var(--timvir-accent-color);font:inherit;border-radius:2px;cursor:pointer;transition:background 0.2s;}.b128wsn:hover{background:var(--c-p-3);}.b128wsn:active{background:var(--c-p-4);}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is documentation for the Code component.
|
|
3
|
+
*/
|
|
4
|
+
import { Language } from "prism-react-renderer";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
/**
|
|
7
|
+
* The underlying DOM element which is rendered by this component.
|
|
8
|
+
*/
|
|
9
|
+
declare const Root = "div";
|
|
10
|
+
interface Props extends React.ComponentPropsWithoutRef<typeof Root> {
|
|
11
|
+
/**
|
|
12
|
+
* The code that should be highlighted.
|
|
13
|
+
*/
|
|
14
|
+
children: string;
|
|
15
|
+
/**
|
|
16
|
+
* Language in which the code is.
|
|
17
|
+
*
|
|
18
|
+
* @default "markup"
|
|
19
|
+
*/
|
|
20
|
+
language?: Language;
|
|
21
|
+
/**
|
|
22
|
+
* When set, the code block spans the full width. Note that the text itself
|
|
23
|
+
* is still aligned with the main column. Use this when you expect the text
|
|
24
|
+
* to be wider than the center column.
|
|
25
|
+
*/
|
|
26
|
+
fullWidth?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The numbering starts at 1, ie. `highlightedLines={[1, 2]}` will highlight
|
|
29
|
+
* the first two lines.
|
|
30
|
+
*/
|
|
31
|
+
highlightedLines?: Array<number>;
|
|
32
|
+
caption?: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
35
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
<div style={ { display: "grid", gridTemplateColumns: "min-content 1fr" } }>
|
|
4
|
+
<div style={ { fontWeight: "bold", marginRight: 16 } }>Root:</div>
|
|
5
|
+
<div>{`<div>`}</div>
|
|
6
|
+
<div style={ { fontWeight: "bold", marginRight: 16 } }>Ref:</div>
|
|
7
|
+
<div>Forward <span style={ { color: "rgb(153, 153, 153)" } }>(HTMLDivElement)</span></div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
<Props {...{"fields":[{"name":"children","type":{"optional":false,"name":"string","module":""},"comment":{"shortText":"The code that should be highlighted."}},{"name":"language","type":{"optional":true,"name":"Language","module":""},"def":"\"markup\"","comment":{"shortText":"Language in which the code is."}},{"name":"fullWidth","type":{"optional":true,"name":"boolean","module":""},"comment":{"shortText":"When set, the code block spans the full width. Note that the text itself\nis still aligned with the main column. Use this when you expect the text\nto be wider than the center column."}},{"name":"highlightedLines","type":{"optional":true,"name":"number[]","module":""},"comment":{"shortText":"The numbering starts at 1, ie. `highlightedLines={[1, 2]}` will highlight\nthe first two lines."}}]}} />
|
|
13
|
+
|
|
14
|
+
export const required = (
|
|
15
|
+
<svg
|
|
16
|
+
x="0px"
|
|
17
|
+
y="0px"
|
|
18
|
+
width="10px"
|
|
19
|
+
height="10px"
|
|
20
|
+
viewBox="0 0 16 16"
|
|
21
|
+
style={ { position: "relative", top: 0, display: "inline-block", marginRight: 8 } }
|
|
22
|
+
>
|
|
23
|
+
<g transform="translate(0, 0)">
|
|
24
|
+
<circle cx="8" cy="8" r="8" fill="#444444"></circle>
|
|
25
|
+
</g>
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const optional = (
|
|
30
|
+
<svg
|
|
31
|
+
x="0px"
|
|
32
|
+
y="0px"
|
|
33
|
+
width="10px"
|
|
34
|
+
height="10px"
|
|
35
|
+
viewBox="0 0 16 16"
|
|
36
|
+
style={ { position: "relative", top: 0, display: "inline-block", marginRight: 8 } }
|
|
37
|
+
>
|
|
38
|
+
<g transform="translate(0, 0)">
|
|
39
|
+
<circle
|
|
40
|
+
cx="8"
|
|
41
|
+
cy="8"
|
|
42
|
+
r="7.5"
|
|
43
|
+
fill="none"
|
|
44
|
+
stroke="#444444"
|
|
45
|
+
strokeLinecap="round"
|
|
46
|
+
strokeLinejoin="round"
|
|
47
|
+
data-cap="butt"
|
|
48
|
+
></circle>
|
|
49
|
+
</g>
|
|
50
|
+
</svg>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export const Props = ({ fields }) => (
|
|
54
|
+
<div style={ { marginTop: 16, display: "grid", gridGap: 24 } }>
|
|
55
|
+
{fields.map(({ name, type, def, example, comment }) => (
|
|
56
|
+
<div key={name}>
|
|
57
|
+
<div style={ { marginLeft: -18 } }>
|
|
58
|
+
{type.optional ? optional : required}
|
|
59
|
+
<span style={ { fontWeight: "bold" } }>{name}</span>{`: `}
|
|
60
|
+
<span>{type.name}</span>
|
|
61
|
+
{def && (
|
|
62
|
+
<>
|
|
63
|
+
{` = `}<span style={ { fontWeight: "bold" } }>{def}</span>
|
|
64
|
+
</>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
<div>{comment.shortText}</div>
|
|
68
|
+
{example && (
|
|
69
|
+
<div style={ { marginLeft: 0, marginTop: 8, color: "rgb(153, 153, 153)", fontSize: "0.8rem" } }>
|
|
70
|
+
Example: <span style={ { fontWeight: "bold" } }>{example}</span>
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Code } from "..";
|
|
2
|
+
import { Exhibit } from "../../Exhibit";
|
|
3
|
+
|
|
4
|
+
# Code
|
|
5
|
+
|
|
6
|
+
The `<Code>` component provides syntax highlighting for code blocks.
|
|
7
|
+
|
|
8
|
+
The component supports many different languages such as
|
|
9
|
+
<Sample variant="toggle" language="javascript">JavaScript</Sample>,
|
|
10
|
+
<Sample variant="toggle" language="markdown">Markdown</Sample>,
|
|
11
|
+
<Sample variant="toggle" language="html">HTML</Sample>,
|
|
12
|
+
<Sample variant="toggle" language="css">CSS</Sample> and many more.
|
|
13
|
+
|
|
14
|
+
<Code
|
|
15
|
+
id="code"
|
|
16
|
+
language="tsx"
|
|
17
|
+
highlightedLines={[2, 7]}
|
|
18
|
+
caption="The highlighted lines show how to import and use the <Code> block."
|
|
19
|
+
>
|
|
20
|
+
<Sample variant="basic" as="source" />
|
|
21
|
+
</Code>
|
|
22
|
+
|
|
23
|
+
The default language is "markdown", but you can specify any of the languages
|
|
24
|
+
which are supported by [prism-react-renderer](https://github.com/FormidableLabs/prism-react-renderer).
|
|
25
|
+
|
|
26
|
+
<Code language="javascript" caption="The Hitchhiker's Guide to the Galaxy">
|
|
27
|
+
{'const answer = 42;'}
|
|
28
|
+
</Code>
|
|
29
|
+
|
|
30
|
+
## Full-width
|
|
31
|
+
|
|
32
|
+
Full-width code blocks provide more space for the code. They are not constrained to the center column.
|
|
33
|
+
|
|
34
|
+
<Code language="javascript" fullWidth>
|
|
35
|
+
{`(defun csg-intersection-intersect-all (obj-a obj-b)
|
|
36
|
+
(lambda (ray)
|
|
37
|
+
(flet ((inside-p (obj) (lambda (d) (inside-p obj (ray-point ray d)))))
|
|
38
|
+
(merge 'fvector (remove-if-not (inside-p obj-b) (intersect-all obj-a ray)) (remove-if-not (inside-p obj-a) (intersect-all obj-b ray)) #'<))))`}
|
|
39
|
+
</Code>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Code } from "./Code";
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as Page from 'timvir/core';
|
|
2
|
+
import { useBlock } from 'timvir/core';
|
|
3
|
+
import Highlight, { defaultProps } from 'prism-react-renderer';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import * as Icons from 'react-feather';
|
|
6
|
+
import { useImmer } from 'use-immer';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Takes a list of class names and filters for truthy ones, joining them into a single class name for convenience.
|
|
10
|
+
* eg.
|
|
11
|
+
* ```js
|
|
12
|
+
* cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
|
|
13
|
+
* ```
|
|
14
|
+
* If arguments provided are objects, these objects are merged together, and the values are taken as class names:
|
|
15
|
+
*
|
|
16
|
+
* ```js
|
|
17
|
+
* cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @returns the combined, space separated class names that can be applied directly to the class attribute
|
|
21
|
+
*/
|
|
22
|
+
const cx = function cx() {
|
|
23
|
+
const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
|
|
24
|
+
|
|
25
|
+
const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
|
|
26
|
+
// key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
|
|
27
|
+
// deduplicate the values based on their properties. The object's values are
|
|
28
|
+
// the class names
|
|
29
|
+
|
|
30
|
+
const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
|
|
31
|
+
return [...styleCollectionResult, ...classNamesResult].join(' ');
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var theme = "tac6gx6";
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* This is documentation for the Code component.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* The underlying DOM element which is rendered by this component.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
const Root = "div";
|
|
44
|
+
const nullTheme = {
|
|
45
|
+
plain: {},
|
|
46
|
+
styles: []
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function Code(props, ref) {
|
|
50
|
+
const block = useBlock(props);
|
|
51
|
+
const {
|
|
52
|
+
children,
|
|
53
|
+
language,
|
|
54
|
+
fullWidth,
|
|
55
|
+
highlightedLines,
|
|
56
|
+
caption,
|
|
57
|
+
...rest
|
|
58
|
+
} = block.props;
|
|
59
|
+
|
|
60
|
+
const isHighlightedLine = (() => {
|
|
61
|
+
return line => highlightedLines === null || highlightedLines === void 0 ? void 0 : highlightedLines.includes(line);
|
|
62
|
+
})();
|
|
63
|
+
|
|
64
|
+
const [state, mutate] = useImmer({
|
|
65
|
+
mouseOver: false,
|
|
66
|
+
copiedToClipboard: false
|
|
67
|
+
});
|
|
68
|
+
return /*#__PURE__*/React.createElement(Root, {
|
|
69
|
+
ref: ref,
|
|
70
|
+
className: cx(classes.root, fullWidth && Page.fullWidth),
|
|
71
|
+
...rest
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Highlight, { ...defaultProps,
|
|
73
|
+
code: children.trim(),
|
|
74
|
+
language: language !== null && language !== void 0 ? language : "markup",
|
|
75
|
+
theme: nullTheme
|
|
76
|
+
}, ({
|
|
77
|
+
className,
|
|
78
|
+
style,
|
|
79
|
+
tokens,
|
|
80
|
+
getLineProps,
|
|
81
|
+
getTokenProps
|
|
82
|
+
}) => /*#__PURE__*/React.createElement("pre", {
|
|
83
|
+
className: cx(className, theme, classes.code, fullWidth && classes.fullWidth),
|
|
84
|
+
style: style
|
|
85
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
className: "d1513p2s",
|
|
87
|
+
onMouseEnter: () => {
|
|
88
|
+
mutate(draft => {
|
|
89
|
+
draft.mouseOver = true;
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
onMouseLeave: () => {
|
|
93
|
+
mutate(draft => {
|
|
94
|
+
draft.mouseOver = false;
|
|
95
|
+
draft.copiedToClipboard = false;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
99
|
+
onClick: () => {
|
|
100
|
+
navigator.clipboard.writeText(children);
|
|
101
|
+
mutate(draft => {
|
|
102
|
+
draft.copiedToClipboard = true;
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
className: cx("b157mkz", state.mouseOver && "b10oxtfo")
|
|
106
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
107
|
+
width: 48,
|
|
108
|
+
height: 48,
|
|
109
|
+
viewBox: "0 0 48 48",
|
|
110
|
+
className: "s1hdfi6o"
|
|
111
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
112
|
+
d: "M0 0 H48 V48 Z"
|
|
113
|
+
})), state.copiedToClipboard ? /*#__PURE__*/React.createElement(Icons.Clipboard, {
|
|
114
|
+
size: "16px"
|
|
115
|
+
}) : /*#__PURE__*/React.createElement(Icons.Copy, {
|
|
116
|
+
size: "16px"
|
|
117
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: cx(fullWidth ? "d17pltln" : "d793q8f")
|
|
119
|
+
}, tokens.map((line, i) => {
|
|
120
|
+
const {
|
|
121
|
+
className,
|
|
122
|
+
...lineProps
|
|
123
|
+
} = getLineProps({
|
|
124
|
+
line,
|
|
125
|
+
key: i
|
|
126
|
+
});
|
|
127
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
key: i,
|
|
129
|
+
...lineProps,
|
|
130
|
+
className: cx(className, classes.line, isHighlightedLine(i + 1) && classes.highlightedLine)
|
|
131
|
+
}, line.map((token, key) => /*#__PURE__*/React.createElement("span", {
|
|
132
|
+
key: key,
|
|
133
|
+
...getTokenProps({
|
|
134
|
+
token,
|
|
135
|
+
key
|
|
136
|
+
})
|
|
137
|
+
})));
|
|
138
|
+
}))))), caption && /*#__PURE__*/React.createElement("div", {
|
|
139
|
+
className: classes.caption
|
|
140
|
+
}, caption));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
var Code$1 = /*#__PURE__*/React.forwardRef(Code);
|
|
144
|
+
const classes = {
|
|
145
|
+
root: "r9v2r0l",
|
|
146
|
+
code: "cs7tint",
|
|
147
|
+
fullWidth: "fjvaz2s",
|
|
148
|
+
line: "lchll0h",
|
|
149
|
+
highlightedLine: "h1xcko1i",
|
|
150
|
+
lineNumber: "ll2b9hx",
|
|
151
|
+
caption: "c5vr6r2"
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export { Code$1 as Code };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.d1513p2s{display:grid;grid-template-columns:1fr;padding-block:16px;}
|
|
2
|
+
.b157mkz{--size:48px;z-index:1;position:absolute;top:0;right:0;width:var(--size);height:var(--size);display:flex;align-items:flex-start;justify-content:flex-end;outline:none;border:none;padding:6px;background:transparent;transition:all 0.2s;cursor:pointer;pointer-events:none;opacity:0;}.b157mkz:hover{color:white;}.b157mkz:hover svg:first-child{transform:translate(0,0);}.b157mkz:active svg:first-child{transform:translate(2px,-2px);}
|
|
3
|
+
.b10oxtfo{pointer-events:all;opacity:1;}
|
|
4
|
+
.s1hdfi6o{position:absolute;z-index:-1;top:0;right:0;transition:all 0.2s;transform:translate(48px,-48px);}.s1hdfi6o path{fill:var(--c-p-4);}
|
|
5
|
+
.d17pltln{padding:16px 24px 16px 0;}
|
|
6
|
+
|
|
7
|
+
.r9v2r0l{margin:1.5rem 0 3rem;}
|
|
8
|
+
.cs7tint{overflow-x:auto;contain:content;font-size:0.9em;border-radius:5px;--timvir-b-Code-bleed:var(--timvir-page-margin,24px);--timvir-b-Code-inlinePadding:max(var(--timvir-b-Code-bleed),24px);padding:0;margin:0 calc(-1 * var(--timvir-b-Code-bleed));box-shadow:inset 0 0 0 1px rgb(16 22 26 / 20%),0 1px 4px rgb(16 22 26 / 10%);transition:box-shadow 0.3s;}.cs7tint:hover{box-shadow:inset 0 0 0 1px rgb(16 22 26 / 30%),0 1px 4px rgb(16 22 26 / 10%),0 8px 24px rgb(16 22 26 / 10%);}:root[data-timvir-theme="dark"] .cs7tint{box-shadow:inset 0 0 0 1px rgb(216 222 226 / 10%),0 1px 4px rgb(216 222 226 / 5%), 0 2px 8px rgb(216 222 226 / 2%);}:root[data-timvir-theme="dark"] .cs7tint:hover{box-shadow:inset 0 0 0 1px rgb(216 222 226 / 10%),0 1px 3px rgb(216 222 226 / 7%), 0 2px 16px rgb(216 222 226 / 5%);}
|
|
9
|
+
.fjvaz2s{display:grid;border-radius:0;box-shadow:none;margin-inline:0;grid-auto-rows:min-content;grid-template-columns:[le] 0 [lc] 1fr [rc] 0 [re];grid-column-gap:16px;}.fjvaz2s:hover{box-shadow:none;}@media (min-width:60rem){.fjvaz2s{grid-template-columns:[le] 1fr [lc] minmax(0,48rem) [rc] 1fr [re];grid-column-gap:24px;}}.fjvaz2s > *{grid-column:lc / re;}
|
|
10
|
+
.lchll0h{padding-inline:var(--timvir-b-Code-inlinePadding);margin-inline:1px;}
|
|
11
|
+
.h1xcko1i{background-color:#ffe10044;}:root[data-timvir-theme="dark"] .h1xcko1i{background-color:rgba(174,124,20,0.15);}
|
|
12
|
+
.ll2b9hx{display:inline-block;width:var(--timvir-b-Code-bleed);color:var(--timvir-secondary-text-color);text-align:right;padding-inline:4px;}
|
|
13
|
+
.c5vr6r2{font-size:0.75rem;color:var(--timvir-secondary-text-color);margin-top:2px;}
|
|
14
|
+
.tac6gx6{color:#393a34;background-color:#f6f8fa;}.tac6gx6 :is(.comment,.prolog,.doctype,.cdata){color:#999988;font-style:italic;}.tac6gx6 :is(.namespace){opacity:0.7;}.tac6gx6 :is(.string,.attr-value){color:#e3116c;}.tac6gx6 :is(.punctuation,.operator){color:#6cb6ff;}.tac6gx6 :is(.function,.delete,.tag){color:#d73a49;}.tac6gx6 :is(.tag,.selector,.keyword){color:#00009f;}.tac6gx6 :is(.function-variable){color:#6f42c1;}.tac6gx6 :is(.atrule,.keyword,.attr-name,.selector){color:#00a4db;}.tac6gx6 :is(.entity,.url,.symbol,.number,.boolean,.variable,.constant,.property,.regex,.inserted){color:#36acaa;}:root[data-timvir-theme="dark"] .tac6gx6{color:#adbac7;background-color:#2d333b;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.comment,.prolog,.doctype,.cdata){color:#999988;font-style:italic;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.namespace){opacity:0.7;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.string,.attr-value){color:#96d0ff;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.punctuation,.operator){color:#6cb6ff;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.function,.delete,.tag){color:#d73a49;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.tag,.selector,.keyword){color:#8ddb8c;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.function-variable){color:#6f42c1;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.atrule,.keyword,.attr-name,.selector){color:#f47067;}:root[data-timvir-theme="dark"] .tac6gx6 :is(.entity,.url,.symbol,.number,.boolean,.variable,.constant,.property,.regex,.inserted){color:#dcbdfb;}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The underlying DOM element which is rendered by this component.
|
|
4
|
+
*/
|
|
5
|
+
declare const Root = "div";
|
|
6
|
+
interface Props extends React.ComponentPropsWithoutRef<typeof Root> {
|
|
7
|
+
/**
|
|
8
|
+
* Array of CSS Color values.
|
|
9
|
+
*/
|
|
10
|
+
values: Array<string | {
|
|
11
|
+
value: string;
|
|
12
|
+
contrastValue?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
ancestry?: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
<div style={ { display: "grid", gridTemplateColumns: "min-content 1fr" } }>
|
|
4
|
+
<div style={ { fontWeight: "bold", marginRight: 16 } }>Root:</div>
|
|
5
|
+
<div>{`<div>`}</div>
|
|
6
|
+
<div style={ { fontWeight: "bold", marginRight: 16 } }>Ref:</div>
|
|
7
|
+
<div>Forward <span style={ { color: "rgb(153, 153, 153)" } }>(HTMLDivElement)</span></div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
<Props {...{"fields":[{"name":"values","type":{"optional":false,"name":"string[]","module":""},"comment":{"shortText":"Array of CSS Color values."}}]}} />
|
|
13
|
+
|
|
14
|
+
export const required = (
|
|
15
|
+
<svg
|
|
16
|
+
x="0px"
|
|
17
|
+
y="0px"
|
|
18
|
+
width="10px"
|
|
19
|
+
height="10px"
|
|
20
|
+
viewBox="0 0 16 16"
|
|
21
|
+
style={ { position: "relative", top: 0, display: "inline-block", marginRight: 8 } }
|
|
22
|
+
>
|
|
23
|
+
<g transform="translate(0, 0)">
|
|
24
|
+
<circle cx="8" cy="8" r="8" fill="#444444"></circle>
|
|
25
|
+
</g>
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const optional = (
|
|
30
|
+
<svg
|
|
31
|
+
x="0px"
|
|
32
|
+
y="0px"
|
|
33
|
+
width="10px"
|
|
34
|
+
height="10px"
|
|
35
|
+
viewBox="0 0 16 16"
|
|
36
|
+
style={ { position: "relative", top: 0, display: "inline-block", marginRight: 8 } }
|
|
37
|
+
>
|
|
38
|
+
<g transform="translate(0, 0)">
|
|
39
|
+
<circle
|
|
40
|
+
cx="8"
|
|
41
|
+
cy="8"
|
|
42
|
+
r="7.5"
|
|
43
|
+
fill="none"
|
|
44
|
+
stroke="#444444"
|
|
45
|
+
strokeLinecap="round"
|
|
46
|
+
strokeLinejoin="round"
|
|
47
|
+
data-cap="butt"
|
|
48
|
+
></circle>
|
|
49
|
+
</g>
|
|
50
|
+
</svg>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export const Props = ({ fields }) => (
|
|
54
|
+
<div style={ { marginTop: 16, display: "grid", gridGap: 24 } }>
|
|
55
|
+
{fields.map(({ name, type, def, example, comment }) => (
|
|
56
|
+
<div key={name}>
|
|
57
|
+
<div style={ { marginLeft: -18 } }>
|
|
58
|
+
{type.optional ? optional : required}
|
|
59
|
+
<span style={ { fontWeight: "bold" } }>{name}</span>{`: `}
|
|
60
|
+
<span>{type.name}</span>
|
|
61
|
+
{def && (
|
|
62
|
+
<>
|
|
63
|
+
{` = `}<span style={ { fontWeight: "bold" } }>{def}</span>
|
|
64
|
+
</>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
<div>{comment.shortText}</div>
|
|
68
|
+
{example && (
|
|
69
|
+
<div style={ { marginLeft: 0, marginTop: 8, color: "rgb(153, 153, 153)", fontSize: "0.8rem" } }>
|
|
70
|
+
Example: <span style={ { fontWeight: "bold" } }>{example}</span>
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
))}
|
|
75
|
+
</div>
|
|
76
|
+
)
|