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.
Files changed (142) hide show
  1. package/blocks/Arbitrary/Arbitrary.d.ts +11 -0
  2. package/blocks/Arbitrary/context.d.ts +7 -0
  3. package/blocks/Arbitrary/docs/index.mdx +36 -0
  4. package/blocks/Arbitrary/index.d.ts +2 -0
  5. package/blocks/Arbitrary/index.js +117 -0
  6. package/blocks/Arbitrary/samples/basic.d.ts +5 -0
  7. package/blocks/Arbitrary/styles.css +6 -0
  8. package/blocks/Code/Code.d.ts +35 -0
  9. package/blocks/Code/docs/api.mdx +76 -0
  10. package/blocks/Code/docs/index.mdx +39 -0
  11. package/blocks/Code/index.d.ts +1 -0
  12. package/blocks/Code/index.js +154 -0
  13. package/blocks/Code/samples/basic.d.ts +5 -0
  14. package/blocks/Code/samples/toggle.d.ts +2 -0
  15. package/blocks/Code/styles.css +14 -0
  16. package/blocks/Code/theme.d.ts +2 -0
  17. package/blocks/ColorBar/ColorBar.d.ts +18 -0
  18. package/blocks/ColorBar/docs/api.mdx +76 -0
  19. package/blocks/ColorBar/docs/index.mdx +128 -0
  20. package/blocks/ColorBar/index.d.ts +1 -0
  21. package/blocks/ColorBar/index.js +90 -0
  22. package/blocks/ColorBar/samples/basic.d.ts +2 -0
  23. package/blocks/ColorBar/styles.css +5 -0
  24. package/blocks/ColorBook/ColorBook.d.ts +16 -0
  25. package/blocks/ColorBook/docs/api.mdx +76 -0
  26. package/blocks/ColorBook/docs/index.mdx +12 -0
  27. package/blocks/ColorBook/index.d.ts +1 -0
  28. package/blocks/ColorBook/index.js +77 -0
  29. package/blocks/ColorBook/samples/basic.d.ts +2 -0
  30. package/blocks/ColorBook/styles.css +6 -0
  31. package/blocks/Cover/Cover.d.ts +20 -0
  32. package/blocks/Cover/docs/api.mdx +76 -0
  33. package/blocks/Cover/docs/index.mdx +20 -0
  34. package/blocks/Cover/index.d.ts +1 -0
  35. package/blocks/Cover/index.js +64 -0
  36. package/blocks/Cover/samples/basic.d.ts +2 -0
  37. package/blocks/Exhibit/Exhibit.d.ts +19 -0
  38. package/blocks/Exhibit/docs/api.mdx +76 -0
  39. package/blocks/Exhibit/docs/index.mdx +56 -0
  40. package/blocks/Exhibit/index.d.ts +1 -0
  41. package/blocks/Exhibit/index.js +83 -0
  42. package/blocks/Exhibit/samples/basic.d.ts +2 -0
  43. package/blocks/Exhibit/styles.css +3 -0
  44. package/blocks/Font/Font.d.ts +15 -0
  45. package/blocks/Font/docs/api.mdx +76 -0
  46. package/blocks/Font/docs/index.mdx +23 -0
  47. package/blocks/Font/index.d.ts +1 -0
  48. package/blocks/Font/index.js +131 -0
  49. package/blocks/Font/samples/basic.d.ts +5 -0
  50. package/blocks/Font/samples/system.d.ts +2 -0
  51. package/blocks/Font/styles.css +9 -0
  52. package/blocks/Grid/Grid.d.ts +9 -0
  53. package/blocks/Grid/docs/api.mdx +76 -0
  54. package/blocks/Grid/docs/index.mdx +82 -0
  55. package/blocks/Grid/index.d.ts +1 -0
  56. package/blocks/Grid/index.js +53 -0
  57. package/blocks/Grid/samples/basic.d.ts +2 -0
  58. package/blocks/Grid/styles.css +1 -0
  59. package/blocks/Icon/Icon.d.ts +11 -0
  60. package/blocks/Icon/docs/api.mdx +76 -0
  61. package/blocks/Icon/docs/index.mdx +218 -0
  62. package/blocks/Icon/index.d.ts +1 -0
  63. package/blocks/Icon/index.js +155 -0
  64. package/blocks/Icon/internal/Canvas.d.ts +9 -0
  65. package/blocks/Icon/internal/index.d.ts +1 -0
  66. package/blocks/Icon/samples/basic.d.ts +2 -0
  67. package/blocks/Icon/styles.css +5 -0
  68. package/blocks/Icon/types.d.ts +10 -0
  69. package/blocks/Message/Message.d.ts +10 -0
  70. package/blocks/Message/docs/api.mdx +76 -0
  71. package/blocks/Message/docs/index.mdx +63 -0
  72. package/blocks/Message/index.d.ts +1 -0
  73. package/blocks/Message/index.js +72 -0
  74. package/blocks/Message/samples/basic.d.ts +5 -0
  75. package/blocks/Message/styles.css +6 -0
  76. package/blocks/Swatch/Swatch.d.ts +33 -0
  77. package/blocks/Swatch/docs/api.mdx +76 -0
  78. package/blocks/Swatch/docs/index.mdx +39 -0
  79. package/blocks/Swatch/index.d.ts +1 -0
  80. package/blocks/Swatch/index.js +84 -0
  81. package/blocks/Swatch/samples/basic.d.ts +2 -0
  82. package/blocks/Swatch/styles.css +4 -0
  83. package/blocks/Viewport/Viewport.d.ts +17 -0
  84. package/blocks/Viewport/docs/api.mdx +76 -0
  85. package/blocks/Viewport/docs/index.mdx +34 -0
  86. package/blocks/Viewport/index.d.ts +1 -0
  87. package/blocks/Viewport/index.js +322 -0
  88. package/blocks/Viewport/internal/Caption.d.ts +8 -0
  89. package/blocks/Viewport/internal/Handle.d.ts +10 -0
  90. package/blocks/Viewport/internal/Ruler.d.ts +7 -0
  91. package/blocks/Viewport/internal/index.d.ts +3 -0
  92. package/blocks/Viewport/samples/basic.d.ts +2 -0
  93. package/blocks/Viewport/styles.css +14 -0
  94. package/blocks/WebLink/WebLink.d.ts +10 -0
  95. package/blocks/WebLink/docs/api.mdx +76 -0
  96. package/blocks/WebLink/docs/index.mdx +13 -0
  97. package/blocks/WebLink/index.d.ts +1 -0
  98. package/blocks/WebLink/index.js +97 -0
  99. package/blocks/WebLink/samples/basic.d.ts +5 -0
  100. package/blocks/WebLink/styles.css +8 -0
  101. package/blocks/index.d.ts +13 -0
  102. package/blocks/index.js +13 -0
  103. package/blocks/styles.css +81 -0
  104. package/bus/index.d.ts +12 -0
  105. package/bus/index.js +22 -0
  106. package/bus/messages.d.ts +15 -0
  107. package/context/index.d.ts +20 -0
  108. package/context/index.js +15 -0
  109. package/core/components/Footer/Footer.d.ts +16 -0
  110. package/core/components/Footer/docs/api.mdx +76 -0
  111. package/core/components/Footer/docs/index.mdx +27 -0
  112. package/core/components/Footer/index.d.ts +1 -0
  113. package/core/components/Footer/samples/basic.d.ts +5 -0
  114. package/core/components/NavigationFooter/NavigationFooter.d.ts +19 -0
  115. package/core/components/NavigationFooter/docs/api.mdx +76 -0
  116. package/core/components/NavigationFooter/docs/index.mdx +10 -0
  117. package/core/components/NavigationFooter/index.d.ts +1 -0
  118. package/core/components/NavigationFooter/samples/basic.d.ts +5 -0
  119. package/core/components/Page/Page.d.ts +60 -0
  120. package/core/components/Page/components.d.ts +46 -0
  121. package/core/components/Page/docs/api.mdx +76 -0
  122. package/core/components/Page/docs/index.mdx +37 -0
  123. package/core/components/Page/index.d.ts +2 -0
  124. package/core/components/Page/internal/Section.d.ts +7 -0
  125. package/core/components/Page/internal/Sidebar.d.ts +15 -0
  126. package/core/components/Page/internal/index.d.ts +2 -0
  127. package/core/components/Page/samples/basic.d.ts +2 -0
  128. package/core/components/Page/samples/layout.d.ts +2 -0
  129. package/core/components/Page/types.d.ts +5 -0
  130. package/core/index.d.ts +22 -0
  131. package/core/index.js +708 -0
  132. package/core/layout.d.ts +4 -0
  133. package/core/styles.css +47 -0
  134. package/core/theme/colors.d.ts +36 -0
  135. package/core/theme/index.d.ts +1 -0
  136. package/hooks/index.d.ts +1 -0
  137. package/hooks/index.js +72 -0
  138. package/hooks/useResizeObserver/index.d.ts +56 -0
  139. package/package.json +27 -0
  140. package/std/base58/index.d.ts +2 -0
  141. package/std/base58/index.js +71 -0
  142. package/styles.css +128 -0
@@ -0,0 +1,322 @@
1
+ import { useBlock, fullWidth } from 'timvir/core';
2
+ import { useResizeObserverEntry, useResizeObserver } from 'timvir/hooks';
3
+ import * as React from 'react';
4
+ import { useMDXComponents } from '@mdx-js/react';
5
+ import { Code } from 'timvir/blocks';
6
+ import * as Icons from 'react-feather';
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
+ function Caption(props) {
35
+ const components = {
36
+ a: "a",
37
+ ...useMDXComponents()
38
+ };
39
+ const {
40
+ src,
41
+ code
42
+ } = props;
43
+ const [codeRef, setCodeRef] = React.useState(null);
44
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("figcaption", {
45
+ className: "fgdj0yb"
46
+ }, /*#__PURE__*/React.createElement("div", null, "Source:", " ", /*#__PURE__*/React.createElement(components.a, {
47
+ href: src,
48
+ target: "_blank"
49
+ }, src)), code && /*#__PURE__*/React.createElement("div", {
50
+ className: "d1rc4zjh",
51
+ onClick: () => {
52
+ if (codeRef) {
53
+ const infoParent = codeRef.parentElement;
54
+
55
+ if (infoParent.style.height === "0px") {
56
+ infoParent.style.height = `${codeRef.getBoundingClientRect().height}px`;
57
+ infoParent.style.opacity = "1";
58
+ } else {
59
+ infoParent.style.height = "0px";
60
+ infoParent.style.opacity = "0";
61
+ }
62
+ }
63
+ }
64
+ }, /*#__PURE__*/React.createElement(Icons.Code, {
65
+ size: "1.6em"
66
+ }))), code && /*#__PURE__*/React.createElement("div", {
67
+ className: cx("d1enfo6"),
68
+ style: {
69
+ height: 0,
70
+ opacity: 0
71
+ }
72
+ }, /*#__PURE__*/React.createElement("div", {
73
+ ref: setCodeRef,
74
+ className: cx("d1watfn6")
75
+ }, /*#__PURE__*/React.createElement(Code, {
76
+ language: "jsx"
77
+ }, code))));
78
+ }
79
+
80
+ var Caption$1 = /*#__PURE__*/React.memo(Caption);
81
+
82
+ function Handle(props) {
83
+ const {
84
+ gridColumn,
85
+ lock,
86
+ edge,
87
+ iframeRef
88
+ } = props;
89
+ return /*#__PURE__*/React.createElement("div", {
90
+ className: "d1mmz2b6",
91
+ onMouseDown: () => {
92
+ lock.current = edge;
93
+
94
+ if (iframeRef.current) {
95
+ iframeRef.current.style.userSelect = "none";
96
+ iframeRef.current.style.pointerEvents = "none";
97
+ }
98
+ },
99
+ style: {
100
+ gridColumn
101
+ }
102
+ }, /*#__PURE__*/React.createElement("svg", {
103
+ width: "56",
104
+ height: "56",
105
+ viewBox: "0 0 56 56"
106
+ }, /*#__PURE__*/React.createElement("path", {
107
+ fill: "currentColor",
108
+ d: "M27 18h2v20h-2V18zm-6 0h2v20h-2V18zm12 0h2v20h-2V18z"
109
+ })));
110
+ }
111
+
112
+ var Handle$1 = /*#__PURE__*/React.memo(Handle);
113
+
114
+ const height = 16;
115
+
116
+ function Ruler(props) {
117
+ const {
118
+ containerWidth = 0,
119
+ viewportWidth = 0
120
+ } = props;
121
+ return /*#__PURE__*/React.createElement("svg", {
122
+ viewBox: `-${containerWidth / 2} ${-height / 2} ${containerWidth} ${height}`,
123
+ className: "ssl4j8q"
124
+ }, /*#__PURE__*/React.createElement("rect", {
125
+ x: -containerWidth / 2,
126
+ y: -height / 2,
127
+ width: containerWidth,
128
+ height: height,
129
+ fill: "rgba(0, 0, 0, .1)"
130
+ }), /*#__PURE__*/React.createElement("line", {
131
+ x1: -viewportWidth / 2,
132
+ x2: -viewportWidth / 2,
133
+ y1: -height / 2,
134
+ y2: height / 2,
135
+ strokeWidth: 2,
136
+ stroke: "var(--c-p-4)"
137
+ }), /*#__PURE__*/React.createElement("line", {
138
+ x1: viewportWidth / 2,
139
+ x2: viewportWidth / 2,
140
+ y1: -height / 2,
141
+ y2: height / 2,
142
+ strokeWidth: 2,
143
+ stroke: "var(--c-p-4)"
144
+ }));
145
+ }
146
+
147
+ /**
148
+ * The underlying DOM element which is rendered by this component.
149
+ */
150
+
151
+ const Root = "div";
152
+
153
+ function Viewport(props, ref) {
154
+ var _iframeRef$current, _iframeRef$current$co;
155
+
156
+ const block = useBlock(props);
157
+ const {
158
+ src,
159
+ code,
160
+ className,
161
+ ...rest
162
+ } = block.props;
163
+ /*
164
+ * The container measures the width of the main column. It is used to initialize
165
+ * the default width.
166
+ */
167
+
168
+ const [containerRef, containerROE] = useResizeObserverEntry();
169
+ /*
170
+ * The SVG spans across the full width. It is used to restrict the max width.
171
+ */
172
+
173
+ const [svgRef, svgROE] = useResizeObserverEntry();
174
+ const [height, setHeight] = React.useState(undefined);
175
+ const [maxHeight, setMaxHeight] = React.useState(undefined);
176
+ const [width, setWidth] = React.useState(undefined);
177
+ React.useEffect(() => {
178
+ if (width === undefined && svgROE) {
179
+ setWidth(svgROE.contentRect.width);
180
+ } else if (svgROE) {
181
+ const max = svgROE.contentRect.width - 2 * (56 + 8 + 8);
182
+
183
+ if (width !== undefined && width > max) {
184
+ setWidth(max);
185
+ }
186
+ }
187
+ }, [containerROE, svgROE, setWidth, width]);
188
+ const lock = React.useRef("");
189
+ const iframeRef = React.useRef(null);
190
+ React.useEffect(() => {
191
+ const onMouseMove = ev => {
192
+ if (lock.current && svgROE) {
193
+ ev.preventDefault();
194
+ const max = svgROE.contentRect.width - 2 * (56 + 8 + 8);
195
+ setWidth(width => {
196
+ var _left$right$lock$curr;
197
+
198
+ return Math.min(max, Math.max(320, (width !== null && width !== void 0 ? width : 0) + 2 * ev.movementX * ((_left$right$lock$curr = {
199
+ left: -1,
200
+ right: 1
201
+ }[lock.current]) !== null && _left$right$lock$curr !== void 0 ? _left$right$lock$curr : 1)));
202
+ });
203
+ }
204
+ };
205
+
206
+ const onMouseUp = () => {
207
+ lock.current = "";
208
+ iframeRef.current.style.userSelect = "";
209
+ iframeRef.current.style.pointerEvents = "";
210
+ setHeight(height => {
211
+ setMaxHeight(height);
212
+ return height;
213
+ });
214
+ };
215
+
216
+ window.addEventListener("mousemove", onMouseMove);
217
+ window.addEventListener("mouseup", onMouseUp);
218
+ return () => {
219
+ window.removeEventListener("mousemove", onMouseMove);
220
+ window.removeEventListener("mouseup", onMouseUp);
221
+ };
222
+ }, [svgROE]);
223
+ const iframeRO = useResizeObserver(entries => {
224
+ if (height !== undefined) {
225
+ const height = entries[entries.length - 1].contentRect.height;
226
+ setHeight(height);
227
+ setMaxHeight(Math.max(height, maxHeight !== null && maxHeight !== void 0 ? maxHeight : 0));
228
+ }
229
+ });
230
+ /*
231
+ * The <html> element of the iframe document is the one which we observe and
232
+ * measure. We do not use <body> because that may have margins around which would
233
+ * throw off our height observations.
234
+ *
235
+ * We hope that nobody intentionally adds margins around the <html> element. By default
236
+ * it doesn't have.
237
+ */
238
+
239
+ const html = (_iframeRef$current = iframeRef.current) === null || _iframeRef$current === void 0 ? void 0 : (_iframeRef$current$co = _iframeRef$current.contentDocument) === null || _iframeRef$current$co === void 0 ? void 0 : _iframeRef$current$co.querySelector("html");
240
+ React.useEffect(() => {
241
+ if (html) {
242
+ iframeRO.observe(html);
243
+ }
244
+ });
245
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
246
+ ref: containerRef
247
+ }), /*#__PURE__*/React.createElement(Root, {
248
+ ref: ref,
249
+ ...rest,
250
+ className: cx(className, fullWidth, "r1ouu0bc")
251
+ }, /*#__PURE__*/React.createElement("div", {
252
+ ref: svgRef,
253
+ className: "d1uj09ka"
254
+ }, /*#__PURE__*/React.createElement(Ruler, {
255
+ containerWidth: svgROE === null || svgROE === void 0 ? void 0 : svgROE.contentRect.width,
256
+ viewportWidth: width
257
+ }), /*#__PURE__*/React.createElement("div", {
258
+ className: "d2uawyc"
259
+ }, width, "px")), /*#__PURE__*/React.createElement("div", {
260
+ className: "d8ms9m9"
261
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
262
+ className: "d17q9rbm"
263
+ }, /*#__PURE__*/React.createElement("div", {
264
+ className: cx("daubpa6", height === undefined && "d1d22s19"),
265
+ style: {
266
+ width,
267
+ height
268
+ }
269
+ }, /*#__PURE__*/React.createElement("iframe", {
270
+ ref: iframeRef,
271
+ frameBorder: "0",
272
+ src: src,
273
+ onLoad: () => {
274
+ var _iframeRef$current2, _iframeRef$current2$c;
275
+
276
+ /*
277
+ * Once the iframe has loaded, initialize the height/maxHeight.
278
+ * The <html> element may not exist though (eg. the page failed
279
+ * to load, or it's not a HTML page).
280
+ */
281
+ const html = (_iframeRef$current2 = iframeRef.current) === null || _iframeRef$current2 === void 0 ? void 0 : (_iframeRef$current2$c = _iframeRef$current2.contentDocument) === null || _iframeRef$current2$c === void 0 ? void 0 : _iframeRef$current2$c.querySelector("html");
282
+
283
+ if (html) {
284
+ const {
285
+ height
286
+ } = html.getBoundingClientRect();
287
+ setHeight(height);
288
+ setMaxHeight(height);
289
+ }
290
+ },
291
+ className: "i11uos8q",
292
+ style: {
293
+ opacity: height === undefined ? 0 : 1,
294
+ pointerEvents: height === undefined ? "none" : undefined
295
+ }
296
+ })), /*#__PURE__*/React.createElement(Handle$1, {
297
+ gridColumn: "1",
298
+ lock: lock,
299
+ edge: "left",
300
+ iframeRef: iframeRef
301
+ }), /*#__PURE__*/React.createElement(Handle$1, {
302
+ gridColumn: "3",
303
+ lock: lock,
304
+ edge: "right",
305
+ iframeRef: iframeRef
306
+ })))), /*#__PURE__*/React.createElement(Ruler, {
307
+ containerWidth: svgROE === null || svgROE === void 0 ? void 0 : svgROE.contentRect.width,
308
+ viewportWidth: width
309
+ })), /*#__PURE__*/React.createElement(Caption$1, {
310
+ src: src,
311
+ code: code
312
+ }), /*#__PURE__*/React.createElement("div", {
313
+ style: {
314
+ height: (maxHeight !== null && maxHeight !== void 0 ? maxHeight : 0) - (height !== null && height !== void 0 ? height : 0),
315
+ transition: "height 0.16s"
316
+ }
317
+ }));
318
+ }
319
+
320
+ var Viewport$1 = /*#__PURE__*/React.forwardRef(Viewport);
321
+
322
+ export { Viewport$1 as Viewport };
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ interface Props {
3
+ src: string;
4
+ code?: string;
5
+ }
6
+ declare function Caption(props: Props): JSX.Element;
7
+ declare const _default: React.MemoExoticComponent<typeof Caption>;
8
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ interface Props {
3
+ gridColumn: string;
4
+ lock: React.MutableRefObject<string>;
5
+ edge: "left" | "right";
6
+ iframeRef: React.RefObject<HTMLIFrameElement>;
7
+ }
8
+ declare function Handle(props: Props): JSX.Element;
9
+ declare const _default: React.MemoExoticComponent<typeof Handle>;
10
+ export default _default;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface Props {
3
+ containerWidth?: number;
4
+ viewportWidth?: number;
5
+ }
6
+ declare function Ruler(props: Props): JSX.Element;
7
+ export default Ruler;
@@ -0,0 +1,3 @@
1
+ export { default as Caption } from "./Caption";
2
+ export { default as Handle } from "./Handle";
3
+ export { default as Ruler } from "./Ruler";
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function Sample(): JSX.Element;
@@ -0,0 +1,14 @@
1
+ .r1ouu0bc{contain:layout;}
2
+ .d1uj09ka{position:relative;}
3
+ .d2uawyc{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);}
4
+ .d8ms9m9{display:flex;align-items:stretch;justify-content:center;}
5
+ .d17q9rbm{border-radius:3px;display:grid;grid-template-columns:56px auto 56px;grid-template-rows:0 auto 0;grid-column-gap:8px;}
6
+ .daubpa6{grid-column:2 / span 1;grid-row:2 / span 1;position:relative;flex:1;height:100px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAAAAACoWZBhAAAAF0lEQVQI12P4BAI/QICBFCaYBPNJYQIAkUZftTbC4sIAAAAASUVORK5CYII=);transition:height 0.16s;overflow:hidden;}
7
+ .d1d22s19{animation-duration:2s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:shimmer-d1d22s19;animation-timing-function:linear;background-size:150vw 100px;background-image:linear-gradient(to right,#fafafa 0%,#f4f4f4 25%,#fafafa 40%);box-shadow:inset 0 0 0 1px rgba(16,22,26,0.2);border-radius:1px;}@keyframes shimmer-d1d22s19{0%{background-position:-60vw 0;}40%{background-position:85vw 0;}100%{background-position:85vw 0;}}
8
+ .i11uos8q{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:opacity 0.2s;}
9
+ .fgdj0yb{font-size:0.75rem;color:var(--timvir-secondary-text-color);white-space:nowrap;display:flex;justify-content:space-between;align-items:center;}
10
+ .d1rc4zjh{cursor:pointer;}.d1rc4zjh:hover{color:var(--c-p-4);opacity:1;}.d1rc4zjh > svg{display:block;}
11
+ .d1enfo6{overflow:hidden;transition:height 0.2s,opacity 0.2s 0.1s;}
12
+ .d1watfn6{margin-top:12px;}
13
+ .d1mmz2b6{grid-row:1 / span 3;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0.5;color:var(--timvir-text-color);border-radius:2px;transition:all 0.2s cubic-bezier(0.4,1,0.75,0.9);}.d1mmz2b6:hover{opacity:1;box-shadow:0 0 0 1px rgba(16,22,26,0.1),0 2px 4px rgba(16,22,26,0.2),0 8px 24px rgba(16,22,26,0.2);}.d1mmz2b6:active{box-shadow:0 0 0 1px rgba(16,22,26,0.1),0 0 0 rgba(16,22,26,0),0 1px 1px rgba(16,22,26,0.2);}
14
+ .ssl4j8q{width:100%;display:block;height:16px;margin:8px 0;}
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ /**
3
+ * The underlying DOM element which is rendered by this component.
4
+ */
5
+ declare const Root = "a";
6
+ interface Props extends React.ComponentPropsWithoutRef<typeof Root> {
7
+ url: string;
8
+ }
9
+ declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLAnchorElement>>;
10
+ 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":"url","type":{"optional":false,"name":"string","module":""},"comment":{"shortText":""}}]}} />
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,13 @@
1
+ import { WebLink } from "..";
2
+
3
+ # WebLink
4
+
5
+ `<WebLink>` is a link to an website, displayed as rich media (title, description, and opengraph image).
6
+
7
+ ## Examples
8
+
9
+ <WebLink url="https://twitter.com" style={{ marginBottom: 16 }} />
10
+ <WebLink url="https://figma.com" style={{ marginBottom: 16 }} />
11
+ <WebLink url="https://www.framer.com/motion/" style={{ marginBottom: 16 }} />
12
+ <WebLink url="https://formatjs.io" style={{ marginBottom: 16 }} />
13
+ <WebLink url="https://www.typescriptlang.org" style={{ marginBottom: 16 }} />
@@ -0,0 +1 @@
1
+ export { default as WebLink } from "./WebLink";
@@ -0,0 +1,97 @@
1
+ import * as React from 'react';
2
+ import { useContext } from 'timvir/core';
3
+
4
+ /**
5
+ * Takes a list of class names and filters for truthy ones, joining them into a single class name for convenience.
6
+ * eg.
7
+ * ```js
8
+ * cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
9
+ * ```
10
+ * If arguments provided are objects, these objects are merged together, and the values are taken as class names:
11
+ *
12
+ * ```js
13
+ * cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
14
+ * ```
15
+ *
16
+ * @returns the combined, space separated class names that can be applied directly to the class attribute
17
+ */
18
+ const cx = function cx() {
19
+ 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
20
+
21
+ const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
22
+ // key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
23
+ // deduplicate the values based on their properties. The object's values are
24
+ // the class names
25
+
26
+ const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
27
+ return [...styleCollectionResult, ...classNamesResult].join(' ');
28
+ };
29
+
30
+ /**
31
+ * The underlying DOM element which is rendered by this component.
32
+ */
33
+
34
+ const Root = "a";
35
+
36
+ function WebLink(props, ref) {
37
+ var _useContext$blocks$We, _useContext$blocks, _metadata$open_graph, _metadata$open_graph$, _metadata$open_graph$2, _ref, _metadata$open_graph$3, _metadata$open_graph2, _metadata$open_graph$4, _metadata$open_graph3;
38
+
39
+ const {
40
+ url,
41
+ className,
42
+ ...rest
43
+ } = props;
44
+ const [metadata, setMetadata] = React.useState(undefined);
45
+ const {
46
+ unfurl = defaultUnfurl
47
+ } = (_useContext$blocks$We = (_useContext$blocks = useContext().blocks) === null || _useContext$blocks === void 0 ? void 0 : _useContext$blocks.WebLink) !== null && _useContext$blocks$We !== void 0 ? _useContext$blocks$We : {};
48
+ React.useEffect(() => {
49
+ unfurl(url).then(setMetadata);
50
+ }, [url, setMetadata]);
51
+ const image = metadata === null || metadata === void 0 ? void 0 : (_metadata$open_graph = metadata.open_graph) === null || _metadata$open_graph === void 0 ? void 0 : (_metadata$open_graph$ = _metadata$open_graph.images) === null || _metadata$open_graph$ === void 0 ? void 0 : (_metadata$open_graph$2 = _metadata$open_graph$[0]) === null || _metadata$open_graph$2 === void 0 ? void 0 : _metadata$open_graph$2.url;
52
+ return /*#__PURE__*/React.createElement(Root, {
53
+ ref: ref,
54
+ href: url,
55
+ target: "_blank",
56
+ rel: "noopener noreferrer",
57
+ className: cx(className, classes.root),
58
+ ...rest
59
+ }, /*#__PURE__*/React.createElement("div", {
60
+ className: classes.text
61
+ }, /*#__PURE__*/React.createElement("div", {
62
+ className: classes.title
63
+ }, (_ref = (_metadata$open_graph$3 = metadata === null || metadata === void 0 ? void 0 : (_metadata$open_graph2 = metadata.open_graph) === null || _metadata$open_graph2 === void 0 ? void 0 : _metadata$open_graph2.title) !== null && _metadata$open_graph$3 !== void 0 ? _metadata$open_graph$3 : metadata === null || metadata === void 0 ? void 0 : metadata.title) !== null && _ref !== void 0 ? _ref : /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0")), /*#__PURE__*/React.createElement("div", {
64
+ className: classes.description
65
+ }, (_metadata$open_graph$4 = metadata === null || metadata === void 0 ? void 0 : (_metadata$open_graph3 = metadata.open_graph) === null || _metadata$open_graph3 === void 0 ? void 0 : _metadata$open_graph3.description) !== null && _metadata$open_graph$4 !== void 0 ? _metadata$open_graph$4 : metadata === null || metadata === void 0 ? void 0 : metadata.description), /*#__PURE__*/React.createElement("div", {
66
+ className: classes.url
67
+ }, /*#__PURE__*/React.createElement("img", {
68
+ style: {
69
+ opacity: metadata !== null && metadata !== void 0 && metadata.favicon ? 1 : 0
70
+ },
71
+ className: classes.favicon,
72
+ src: metadata === null || metadata === void 0 ? void 0 : metadata.favicon
73
+ }), /*#__PURE__*/React.createElement("div", null, metadata ? url : null))), image && /*#__PURE__*/React.createElement("div", {
74
+ className: classes.imageContainer
75
+ }, /*#__PURE__*/React.createElement("img", {
76
+ className: classes.image,
77
+ src: image
78
+ })));
79
+ }
80
+
81
+ var WebLink$1 = /*#__PURE__*/React.forwardRef(WebLink);
82
+ const classes = {
83
+ root: "r1szx90n",
84
+ text: "tywhumj",
85
+ title: "t1sni99u",
86
+ description: "d7eo497",
87
+ url: "u1rlrpoc",
88
+ favicon: "f1cqi3na",
89
+ imageContainer: "igksd61",
90
+ image: "i1gibb8w"
91
+ };
92
+
93
+ async function defaultUnfurl(url) {
94
+ return fetch(`https://timvir.vercel.app/api/unfurl?url=${encodeURIComponent(url)}`).then(res => res.json());
95
+ }
96
+
97
+ export { WebLink$1 as WebLink };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { WebLink } from "..";
3
+ declare type Props = Partial<React.ComponentPropsWithoutRef<typeof WebLink>>;
4
+ export default function Sample(props: Props): JSX.Element;
5
+ export {};
@@ -0,0 +1,8 @@
1
+ .r1szx90n{transition:all 0.16s;box-shadow:inset 0 0 0 1px rgba(16,22,26,0.2);border-radius:3px;display:flex;cursor:pointer;text-decoration:none;}.r1szx90n:hover{background:rgba(55,53,47,0.08);box-shadow:inset 0 0 0 1px rgba(16,22,26,0.2),0 2px 4px rgba(16,22,26,0.1), 0 8px 24px rgba(16,22,26,0.2);}.r1szx90n:active{background:rgba(55,53,47,0.08);box-shadow:inset 0 0 0 1px rgba(16,22,26,0.2),0 1px 1px rgba(16,22,26,0.2);}:root[data-timvir-theme="dark"] .r1szx90n{box-shadow:inset 0 0 0 1px rgba(255,255,255,0.2);}:root[data-timvir-theme="dark"] .r1szx90n:hover{background:rgba(255,255,255,0.08);}:root[data-timvir-theme="dark"] .r1szx90n:active{background:rgba(255,255,255,0.08);}
2
+ .tywhumj{flex:4 1 180px;padding:12px 14px 14px;min-width:0;}
3
+ .t1sni99u{color:var(--timvir-text-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-height:24px;margin-bottom:6px;}
4
+ .d7eo497{font-size:0.75rem;line-height:1.1rem;color:var(--timvir-secondary-text-color);height:2.2rem;overflow:hidden;}
5
+ .u1rlrpoc{margin-top:12px;display:flex;font-size:0.75rem;line-height:1rem;color:var(--timvir-text-color);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
6
+ .f1cqi3na{width:1rem;height:1rem;min-width:1rem;margin-right:6px;}
7
+ .igksd61{flex:1 1 180px;position:relative;min-width:180px;}
8
+ .i1gibb8w{display:block;object-fit:cover;border-radius:0 3px 3px 0;width:calc(100% - 2px);height:calc(100% - 2px);position:absolute;top:1px;left:1px;}
@@ -0,0 +1,13 @@
1
+ export { Arbitrary } from "timvir/blocks/Arbitrary";
2
+ export { Code } from "timvir/blocks/Code";
3
+ export { ColorBar } from "timvir/blocks/ColorBar";
4
+ export { ColorBook } from "timvir/blocks/ColorBook";
5
+ export { Cover } from "timvir/blocks/Cover";
6
+ export { Exhibit } from "timvir/blocks/Exhibit";
7
+ export { Font } from "timvir/blocks/Font";
8
+ export { Grid } from "timvir/blocks/Grid";
9
+ export { Icon } from "timvir/blocks/Icon";
10
+ export { Message } from "timvir/blocks/Message";
11
+ export { Swatch } from "timvir/blocks/Swatch";
12
+ export { Viewport } from "timvir/blocks/Viewport";
13
+ export { WebLink } from "timvir/blocks/WebLink";
@@ -0,0 +1,13 @@
1
+ export { Arbitrary } from 'timvir/blocks/Arbitrary';
2
+ export { Code } from 'timvir/blocks/Code';
3
+ export { ColorBar } from 'timvir/blocks/ColorBar';
4
+ export { ColorBook } from 'timvir/blocks/ColorBook';
5
+ export { Cover } from 'timvir/blocks/Cover';
6
+ export { Exhibit } from 'timvir/blocks/Exhibit';
7
+ export { Font } from 'timvir/blocks/Font';
8
+ export { Grid } from 'timvir/blocks/Grid';
9
+ export { Icon } from 'timvir/blocks/Icon';
10
+ export { Message } from 'timvir/blocks/Message';
11
+ export { Swatch } from 'timvir/blocks/Swatch';
12
+ export { Viewport } from 'timvir/blocks/Viewport';
13
+ export { WebLink } from 'timvir/blocks/WebLink';