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,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":"variant","type":{"optional":true,"name":"\"info\" | \"warning\" | \"alert\"","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,63 @@
1
+ import { Exhibit } from "../../Exhibit";
2
+ import { Grid } from "../../Grid";
3
+ import { Swatch } from "../../Swatch";
4
+ import { Code } from "../../Code";
5
+
6
+ # Message
7
+
8
+ <Exhibit bleed="var(--timvir-page-margin)">
9
+ <Sample variant="basic" />
10
+ </Exhibit>
11
+
12
+ <Code language="jsx">
13
+ <Sample variant="basic" as="source" />
14
+ </Code>
15
+
16
+ ## Variants
17
+
18
+ <Grid>
19
+ <Exhibit bleed={8} caption="info">
20
+ <Sample variant="basic" props={{ variant: "info" }} />
21
+ </Exhibit>
22
+ <Exhibit bleed={8} caption="warning">
23
+ <Sample variant="basic" props={{ variant: "warning" }} />
24
+ </Exhibit>
25
+ <Exhibit bleed={8} caption="alert">
26
+ <Sample variant="basic" props={{ variant: "alert" }} />
27
+ </Exhibit>
28
+ </Grid>
29
+
30
+ ## Content
31
+
32
+ Make the title bold and place it before the message, or use a level 3 heading. You can use arbitrary markdown inside the message.
33
+
34
+ <Grid>
35
+ <Exhibit bleed={8} caption="Inline title">
36
+ <Sample variant="basic">
37
+
38
+
39
+ **Short Messages** should place the title in front of the message and make it stand out.
40
+
41
+ </Sample>
42
+ </Exhibit>
43
+
44
+
45
+ <Exhibit bleed={8} caption="Title as a separate block elment">
46
+ <Sample variant="basic">
47
+
48
+
49
+ ### Longer Messages
50
+
51
+ Longer messages should make the title a separate block element. This body uses [links](#) and _italic_ text.
52
+
53
+ And multiple paragraphs. And even a component:
54
+
55
+ <Swatch value="#FF00FF" />
56
+
57
+ </Sample>
58
+ </Exhibit>
59
+ </Grid>
60
+
61
+ ## References
62
+
63
+ - [ATLASSIAN Design: Messages](https://www.atlassian.design/server/components/messages/)
@@ -0,0 +1 @@
1
+ export { default as Message } from "./Message";
@@ -0,0 +1,72 @@
1
+ import * as React from 'react';
2
+ import * as Icons from 'react-feather';
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 = "div";
35
+
36
+ function Message(props, ref) {
37
+ const {
38
+ variant,
39
+ className,
40
+ children,
41
+ ...rest
42
+ } = props;
43
+ return /*#__PURE__*/React.createElement(Root, {
44
+ ref: ref,
45
+ className: cx(className, "r1ssql2z", variant !== undefined && variantStyles[variant]),
46
+ ...rest
47
+ }, variant && /*#__PURE__*/React.createElement("div", {
48
+ className: icon
49
+ }, {
50
+ info: /*#__PURE__*/React.createElement(Icons.ChevronsRight, {
51
+ size: "1.5em"
52
+ }),
53
+ warning: /*#__PURE__*/React.createElement(Icons.AlertCircle, {
54
+ size: "1.5em"
55
+ }),
56
+ alert: /*#__PURE__*/React.createElement(Icons.XOctagon, {
57
+ size: "1.5em"
58
+ })
59
+ }[variant]), /*#__PURE__*/React.createElement("div", {
60
+ className: "dhvu07f"
61
+ }, children));
62
+ }
63
+
64
+ var Message$1 = /*#__PURE__*/React.forwardRef(Message);
65
+ const icon = "i1dz18jz";
66
+ const variantStyles = {
67
+ info: "i41wipx",
68
+ warning: "wi7iy6",
69
+ alert: "a1d5oxsn"
70
+ };
71
+
72
+ export { Message$1 as Message };
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { Message } from "..";
3
+ declare type Props = Partial<React.ComponentPropsWithoutRef<typeof Message>>;
4
+ export default function Sample(props: Props): JSX.Element;
5
+ export {};
@@ -0,0 +1,6 @@
1
+ .r1ssql2z{position:relative;background:var(--c-p-0);color:black;border-radius:3px;padding:16px 24px 16px 24px;box-shadow:inset 0 0 0 1px rgba(16,22,26,0.2);display:flex;align-items:flex-start;line-height:1.5;}
2
+ .dhvu07f > *:first-child{margin-top:0;}.dhvu07f > *:last-child{margin-bottom:0;}.dhvu07f > h3:before{display:none;}
3
+ .i1dz18jz{position:relative;top:3px;margin:-2px 12px 0 -4px;}.i1dz18jz > svg{display:block;}
4
+ .i41wipx{background:#f0f2fc;color:black;}.i41wipx .i1dz18jz{color:#2a47d5;}
5
+ .wi7iy6{background:#fcf9f0;color:black;}.wi7iy6 .i1dz18jz{color:#a68521;}
6
+ .a1d5oxsn{background:#fcf0f0;color:black;}.a1d5oxsn .i1dz18jz{color:#da4444;}
@@ -0,0 +1,33 @@
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
+ * The CSS Color value of the swatch. Any CSS color definition is accepted.
9
+ *
10
+ * @example "#FFFFFF"
11
+ */
12
+ value: string;
13
+ /**
14
+ * Color of the text that is rendered on top of the swatch. Should be chosen
15
+ * such that it provides enough contrast. If not provided then the normal text
16
+ * color from the page will be inherited.
17
+ */
18
+ contrastValue?: string;
19
+ /**
20
+ * Name of the swatch.
21
+ */
22
+ name?: string;
23
+ /**
24
+ * Use this as a short reference where or how the color was derived. If it is an
25
+ * primordial color (not derived from any color palette or other algorithm), then
26
+ * leave it empty.
27
+ *
28
+ * @example "Blue 500"
29
+ */
30
+ ancestry?: string;
31
+ }
32
+ declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
33
+ 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":"value","type":{"optional":false,"name":"string","module":""},"example":"\"#FFFFFF\"","comment":{"shortText":"The CSS Color value of the swatch. Any CSS color definition is accepted."}},{"name":"contrastValue","type":{"optional":true,"name":"string","module":""},"comment":{"shortText":"Color of the text that is rendered on top of the swatch. Should be chosen\nsuch that it provides enough contrast. If not provided then the normal text\ncolor from the page will be inherited."}},{"name":"name","type":{"optional":true,"name":"string","module":""},"comment":{"shortText":"Name of the swatch."}},{"name":"ancestry","type":{"optional":true,"name":"string","module":""},"example":"\"Blue 500\"","comment":{"shortText":"Use this as a short reference where or how the color was derived. If it is an\nprimordial color (not derived from any color palette or other algorithm), then\nleave it empty."}}]}} />
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 { Swatch } from "..";
2
+ import { Exhibit } from "../../Exhibit";
3
+ import { Grid } from "../../Grid";
4
+
5
+ # Swatch
6
+
7
+ <Exhibit caption="Plain color" style={{ marginBottom: 24 }}>
8
+ <Swatch value="#FF00FF" />
9
+ </Exhibit>
10
+
11
+ <Exhibit caption="Give the color a meaningful name" style={{ marginBottom: 24 }}>
12
+ <Swatch value="#FF00FF" name="Primary" />
13
+ </Exhibit>
14
+
15
+ <Exhibit caption="Add a note about its ancenstry (how or where from it was derived)" style={{ marginBottom: 24 }}>
16
+ <Swatch value="#FF00FF" name="Primary" ancestry="Red 700" />
17
+ </Exhibit>
18
+
19
+ ## In a Grid
20
+
21
+ <Grid style={{ gridGap: 6 }}>
22
+ <Swatch value="#0E5A8A" contrastValue="#FFFFFF" name="@blue1" />
23
+ <Swatch value="#106BA3" contrastValue="#FFFFFF" name="@blue2" />
24
+ <Swatch value="#137CBD" contrastValue="#FFFFFF" name="@blue3" />
25
+ <Swatch value="#2B95D6" contrastValue="#000000" name="@blue4" />
26
+ <Swatch value="#48AFF0" contrastValue="#000000" name="@blue5" />
27
+ </Grid>
28
+
29
+ ## Another example
30
+
31
+ <div style={{display: "grid", gridGap: 6 }}>
32
+ <Swatch value="#F58221" name="Access" ancestry="Orange 300" />
33
+ <Swatch value="#D9418D" name="Use" ancestry="Red 500" />
34
+ <Swatch value="#B87AF2" name="Innovation" ancestry="Violett 500" />
35
+ <Swatch value="#4188D9" name="Jobs" ancestry="Blue 500" />
36
+ <Swatch value="#4AE6CC" name="Society" ancestry="…" />
37
+ <Swatch value="#1FD35B" name="Trust" ancestry="Green 400" />
38
+ <Swatch value="#C4D534" name="Market Openness" ancestry="…" />
39
+ </div>
@@ -0,0 +1 @@
1
+ export { default as Swatch } from "./Swatch";
@@ -0,0 +1,84 @@
1
+ import { useBlock } from 'timvir/core';
2
+ import * as React from 'react';
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 = "div";
35
+
36
+ function Swatch(props, ref) {
37
+ const block = useBlock(props);
38
+ const {
39
+ value,
40
+ contrastValue,
41
+ name,
42
+ ancestry,
43
+ onClick,
44
+ onMouseLeave,
45
+ className,
46
+ ...rest
47
+ } = block.props;
48
+ const [label, setLabel] = React.useState(name);
49
+ React.useEffect(() => {
50
+ setLabel(name);
51
+ }, [name]);
52
+ return /*#__PURE__*/React.createElement(Root, {
53
+ role: "button",
54
+ ref: ref,
55
+ ...rest,
56
+ style: {
57
+ height: ancestry ? 48 : 36
58
+ },
59
+ className: cx(className, "r19bcggb"),
60
+ onClick: ev => {
61
+ navigator.clipboard.writeText(value);
62
+ setLabel("Copied to clipboard");
63
+ onClick === null || onClick === void 0 ? void 0 : onClick(ev);
64
+ },
65
+ onMouseLeave: ev => {
66
+ setLabel(name);
67
+ onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(ev);
68
+ }
69
+ }, /*#__PURE__*/React.createElement("div", {
70
+ className: "dhgsgky",
71
+ style: {
72
+ background: value,
73
+ color: contrastValue
74
+ }
75
+ }, /*#__PURE__*/React.createElement("div", {
76
+ className: "dobecwk"
77
+ }, label && /*#__PURE__*/React.createElement("div", null, label), label === name && /*#__PURE__*/React.createElement("div", null, value)), ancestry && /*#__PURE__*/React.createElement("div", {
78
+ className: "dho7t08"
79
+ }, ancestry)));
80
+ }
81
+
82
+ var Swatch$1 = /*#__PURE__*/React.forwardRef(Swatch);
83
+
84
+ export { Swatch$1 as Swatch };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export default function Sample(): JSX.Element;
@@ -0,0 +1,4 @@
1
+ .r19bcggb{position:relative;}.r19bcggb > div{border-radius:2px;}.r19bcggb:hover > div{top:-4px;right:-4px;bottom:-4px;left:-4px;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);padding:0px 16px;z-index:2;}.r19bcggb:active > div{top:-2px;right:-2px;bottom:-2px;left:-2px;box-shadow:inset 0 0 0 1px rgba(16,22,26,0.2),0 1px 1px rgba(16,22,26,0.2);padding:0px 14px;z-index:2;}
2
+ .dhgsgky{display:flex;flex-direction:column;justify-content:center;position:absolute;top:0;right:0;bottom:0;left:0;transition:all 0.16s;padding:0px 12px;cursor:pointer;}
3
+ .dobecwk{display:flex;justify-content:space-between;align-items:center;line-height:1;}
4
+ .dho7t08{padding-top:6px;opacity:0.5;font-size:0.8em;line-height:1;}
@@ -0,0 +1,17 @@
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
+ * URL that should be loaded in the viewport. Can be absolute or relative.
9
+ */
10
+ src: string;
11
+ /**
12
+ * TODO: Document
13
+ */
14
+ code?: string;
15
+ }
16
+ declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
17
+ 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":"src","type":{"optional":false,"name":"string","module":""},"comment":{"shortText":"URL that should be loaded in the viewport. Can be absolute or relative."}},{"name":"code","type":{"optional":true,"name":"string","module":""},"comment":{"shortText":"TODO: Document"}}]}} />
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,34 @@
1
+ import { Viewport } from "..";
2
+
3
+ # Viewport
4
+
5
+ The `<Viewport>` component is a full-width component which is a lightly interactive wrapper around an `<iframe>`.
6
+ The viewport can be resized to simulate different device widths. The height of the iframe will automatically adjust
7
+ to the iframe content.
8
+
9
+ The component does not provide the full functionality of the browsers responsive device mode simulation. In particular,
10
+ it can't simulate network / CPU throttling, nor can it change the user agent. It's purpose is to provide a simple
11
+ interface to test your components at different viewport widths.
12
+
13
+ Since `<Viewport>` uses an `<iframe>`, you must provide a page which can be loaded into it. If you used the timvir
14
+ cli to scaffold your component, you already have one such sample (in `src/components/…/samples/basic.tsx`). Make that
15
+ sample available via a Next.js page and load it into the `<Viewport>`.
16
+
17
+ See also [Concepts: Component Sample](/concepts/component-sample).
18
+
19
+ <Viewport src="/docs/components/Grid/samples/basic" />
20
+
21
+ ## Loading Behaviour
22
+
23
+ The `<Viewport>` displays a gray, animated background while the iframe is loading.
24
+
25
+ <Viewport src="/api/slow" />
26
+
27
+ ## Unsupported content
28
+
29
+ When the Viewport points to something else than a HTML document (eg. an image), it'll
30
+ stay the default height, but display the contents nonetheless.
31
+
32
+ TODO: display a nice error message describing the problem.
33
+
34
+ <Viewport src="/assets/image.jpg" />
@@ -0,0 +1 @@
1
+ export { default as Viewport } from "./Viewport";