@awesomephant/reactcake 1.2.0 → 1.3.0
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/CHANGELOG.md +2 -2
- package/lib/Html/index.tsx +8 -2
- package/lib/ReactCake/index.tsx +22 -8
- package/lib/ScaledSvg/index.tsx +3 -0
- package/lib/Svg/index.tsx +3 -0
- package/lib/index.ts +2 -0
- package/lib/types.ts +23 -10
- package/package.json +1 -1
- package/site/astro.config.mjs +41 -20
- package/site/package.json +2 -0
- package/site/src/assets/ABCArealMonoVariable.woff2 +0 -0
- package/site/src/components/PropList.astro +59 -17
- package/site/src/components/TSDComment.astro +32 -0
- package/site/src/content/installation.md +5 -5
- package/site/src/layouts/Base.astro +86 -75
- package/site/src/layouts/code.scss +13 -21
- package/site/src/pages/index.astro +126 -97
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# [1.
|
|
1
|
+
# [1.3.0](https://github.com/awesomephant/reactcake/compare/v1.2.0...v1.3.0) (2026-11-15)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* iterate LayoutProps ([e6ea26a](https://github.com/awesomephant/reactcake/commit/e6ea26ad9f583846f20925ada21b5b7504f83d1d))
|
package/lib/Html/index.tsx
CHANGED
|
@@ -3,6 +3,10 @@ import { useReactCake } from "../ReactCake";
|
|
|
3
3
|
import { LayoutProps } from "../types";
|
|
4
4
|
|
|
5
5
|
interface HtmlProps extends LayoutProps {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the HTML `role` attribute
|
|
8
|
+
*/
|
|
9
|
+
role?: string;
|
|
6
10
|
children?: ReactNode;
|
|
7
11
|
}
|
|
8
12
|
|
|
@@ -13,15 +17,17 @@ const Html = ({
|
|
|
13
17
|
labelledBy,
|
|
14
18
|
describedBy,
|
|
15
19
|
children,
|
|
20
|
+
role = "figure",
|
|
16
21
|
}: HtmlProps) => {
|
|
17
22
|
const { padding } = useReactCake();
|
|
18
23
|
|
|
19
24
|
return (
|
|
20
25
|
<div
|
|
21
26
|
className="reactcake-html"
|
|
22
|
-
aria-label={
|
|
27
|
+
aria-label={label}
|
|
28
|
+
aria-labelledby={labelledBy}
|
|
23
29
|
aria-describedby={describedBy}
|
|
24
|
-
role={
|
|
30
|
+
role={role}
|
|
25
31
|
style={{
|
|
26
32
|
position: "absolute",
|
|
27
33
|
top: `${padding.top}px`,
|
package/lib/ReactCake/index.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { createContext, useContext, type CSSProperties, type ReactNode } from "r
|
|
|
2
2
|
import { extent } from "d3-array";
|
|
3
3
|
|
|
4
4
|
import { useDimensions } from "../hooks/useDimensions";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ScaleLike, ContextValue, DomainLike, Accessor } from "../types";
|
|
6
6
|
|
|
7
7
|
const ReactCakeContext = createContext<ContextValue>(null);
|
|
8
8
|
|
|
@@ -11,17 +11,27 @@ type RangeLike = [number, number];
|
|
|
11
11
|
interface ReactCakeProps {
|
|
12
12
|
data: object[];
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* The key in each row of data that corresponds to the x-field
|
|
15
15
|
*/
|
|
16
16
|
x?: Accessor;
|
|
17
17
|
x2?: Accessor;
|
|
18
18
|
y?: Accessor;
|
|
19
19
|
z?: Accessor;
|
|
20
20
|
flatData?: object[];
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Sets the chart area padding in pixels following the {@link https://gist.github.com/mbostock/3019563 | D3 margin convention}. All values are optional.
|
|
23
|
+
*/
|
|
24
|
+
padding?: {
|
|
25
|
+
top?: number;
|
|
26
|
+
left?: number;
|
|
27
|
+
right?: number;
|
|
28
|
+
bottom?: number;
|
|
29
|
+
};
|
|
22
30
|
xScale?: ScaleLike;
|
|
23
31
|
xRange?: RangeLike;
|
|
32
|
+
x2Range?: RangeLike;
|
|
24
33
|
xDomain?: DomainLike;
|
|
34
|
+
x2Domain?: DomainLike;
|
|
25
35
|
x2Scale?: ScaleLike;
|
|
26
36
|
yScale?: ScaleLike;
|
|
27
37
|
yRange?: RangeLike;
|
|
@@ -29,15 +39,19 @@ interface ReactCakeProps {
|
|
|
29
39
|
zScale?: ScaleLike;
|
|
30
40
|
zRange?: RangeLike;
|
|
31
41
|
zDomain?: DomainLike;
|
|
42
|
+
/**
|
|
43
|
+
* CSS property/value pairs applied to the container element.
|
|
44
|
+
*/
|
|
32
45
|
style?: CSSProperties;
|
|
46
|
+
/**
|
|
47
|
+
* Sets ranges to `[0, 100]` for SSR
|
|
48
|
+
*/
|
|
33
49
|
percentRange?: boolean;
|
|
34
50
|
children?: ReactNode;
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param param0
|
|
40
|
-
* @returns
|
|
54
|
+
* Top-level container element for your chart.
|
|
41
55
|
*/
|
|
42
56
|
const ReactCake = ({
|
|
43
57
|
data = [],
|
|
@@ -88,10 +102,10 @@ const ReactCake = ({
|
|
|
88
102
|
? Array.from(new Set(data.map((d) => _z(d))))
|
|
89
103
|
: extent(flatData || data, _z);
|
|
90
104
|
|
|
91
|
-
const _xScale = xScale?.range([0, width]).domain(xDomain || extentX);
|
|
105
|
+
const _xScale = xScale?.range(xRange || [0, width]).domain(xDomain || extentX);
|
|
92
106
|
|
|
93
107
|
const _yScale = yScale
|
|
94
|
-
?.range([0, height])
|
|
108
|
+
?.range(yRange || [0, height])
|
|
95
109
|
.domain([
|
|
96
110
|
yDomain[0] !== null ? yDomain[0] : extentY[0],
|
|
97
111
|
yDomain[1] !== null ? yDomain[1] : extentY[1],
|
package/lib/ScaledSvg/index.tsx
CHANGED
package/lib/Svg/index.tsx
CHANGED
package/lib/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Html, type HtmlProps } from "./Html/index.tsx";
|
|
|
2
2
|
import { Svg, type SvgProps } from "./Svg";
|
|
3
3
|
import { ScaledSvg, type ScaledSvgProps } from "./ScaledSvg";
|
|
4
4
|
import { ReactCake, useReactCake, type ReactCakeProps } from "./ReactCake/index.tsx";
|
|
5
|
+
import { type Accessor } from "./types.ts";
|
|
5
6
|
|
|
6
7
|
export {
|
|
7
8
|
Html,
|
|
@@ -13,4 +14,5 @@ export {
|
|
|
13
14
|
type ScaledSvgProps,
|
|
14
15
|
type SvgProps,
|
|
15
16
|
type ReactCakeProps,
|
|
17
|
+
type Accessor,
|
|
16
18
|
};
|
package/lib/types.ts
CHANGED
|
@@ -9,13 +9,6 @@ export type DomainLike =
|
|
|
9
9
|
| ((domain: Array<any>) => Array<any>)
|
|
10
10
|
| undefined;
|
|
11
11
|
|
|
12
|
-
export type Padding = {
|
|
13
|
-
top?: number;
|
|
14
|
-
left?: number;
|
|
15
|
-
right?: number;
|
|
16
|
-
bottom?: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
12
|
export interface ScaleLike<T = DatumValue> {
|
|
20
13
|
(value: unknown): number;
|
|
21
14
|
domain: (domain: DomainLike) => ScaleLike<T>;
|
|
@@ -41,19 +34,39 @@ export interface ContextValue {
|
|
|
41
34
|
xGet?: (d: unknown) => number;
|
|
42
35
|
yGet?: (d: unknown) => number;
|
|
43
36
|
zGet?: (d: unknown) => number | string;
|
|
44
|
-
padding:
|
|
37
|
+
padding: {
|
|
38
|
+
top?: number;
|
|
39
|
+
left?: number;
|
|
40
|
+
right?: number;
|
|
41
|
+
bottom?: number;
|
|
42
|
+
};
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
export interface LayoutProps {
|
|
48
46
|
/**
|
|
49
|
-
* Sets the CSS overflow property
|
|
47
|
+
* Sets the CSS `overflow` property.
|
|
48
|
+
* @defaultValue "visible"
|
|
50
49
|
*/
|
|
51
50
|
overflow?: "hidden" | "visible";
|
|
51
|
+
/**
|
|
52
|
+
* Sets the `aria-label` attribute
|
|
53
|
+
*/
|
|
52
54
|
label?: string;
|
|
53
55
|
/**
|
|
54
|
-
* Sets the aria-labelledby attribute
|
|
56
|
+
* Sets the `aria-labelledby` attribute
|
|
55
57
|
*/
|
|
56
58
|
labelledBy?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Sets the `aria-describedby` attribute
|
|
61
|
+
*/
|
|
57
62
|
describedBy?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the CSS `z-index` property
|
|
65
|
+
*/
|
|
58
66
|
zIndex?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the CSS `pointer-events` property.
|
|
69
|
+
* @defaultValue true
|
|
70
|
+
*/
|
|
71
|
+
pointerEvents?: boolean;
|
|
59
72
|
}
|
package/package.json
CHANGED
package/site/astro.config.mjs
CHANGED
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { defineConfig, fontProviders } from
|
|
3
|
-
import {
|
|
2
|
+
import { defineConfig, fontProviders } from "astro/config";
|
|
3
|
+
import {
|
|
4
|
+
transformerRenderIndentGuides,
|
|
5
|
+
transformerRenderLineNumber,
|
|
6
|
+
} from "@shikijs/transformers";
|
|
4
7
|
|
|
5
|
-
import mdx from
|
|
8
|
+
import mdx from "@astrojs/mdx";
|
|
6
9
|
|
|
7
|
-
import react from
|
|
10
|
+
import react from "@astrojs/react";
|
|
8
11
|
|
|
9
12
|
export default defineConfig({
|
|
10
|
-
fonts: [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
fonts: [
|
|
14
|
+
{
|
|
15
|
+
provider: fontProviders.local(),
|
|
16
|
+
name: "Areal",
|
|
17
|
+
cssVariable: "--font-areal",
|
|
18
|
+
options: {
|
|
19
|
+
variants: [
|
|
20
|
+
{
|
|
21
|
+
weight: "100 900",
|
|
22
|
+
style: "normal",
|
|
23
|
+
src: ["./src/assets/ABCArealVariable.woff2"],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
provider: fontProviders.local(),
|
|
30
|
+
name: "Areal Mono",
|
|
31
|
+
cssVariable: "--font-areal-mono",
|
|
32
|
+
options: {
|
|
33
|
+
variants: [
|
|
34
|
+
{
|
|
35
|
+
weight: "100 900",
|
|
36
|
+
style: "normal",
|
|
37
|
+
src: ["./src/assets/ABCArealMonoVariable.woff2"],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
22
43
|
markdown: {
|
|
23
44
|
shikiConfig: {
|
|
24
|
-
theme:
|
|
45
|
+
theme: "css-variables",
|
|
25
46
|
defaultColor: false,
|
|
26
47
|
},
|
|
27
48
|
syntaxHighlight: {
|
|
28
|
-
type:
|
|
29
|
-
|
|
49
|
+
type: "shiki",
|
|
50
|
+
},
|
|
30
51
|
},
|
|
31
52
|
|
|
32
|
-
integrations: [mdx(), react()]
|
|
53
|
+
integrations: [mdx(), react()],
|
|
33
54
|
});
|
package/site/package.json
CHANGED
|
Binary file
|
|
@@ -1,26 +1,60 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getCollection } from "astro:content";
|
|
3
|
+
import TsdComment from "./TSDComment.astro";
|
|
3
4
|
|
|
4
|
-
const {data} = Astro.props;
|
|
5
|
-
const typedoc = await getCollection(
|
|
5
|
+
const { data } = Astro.props;
|
|
6
|
+
const typedoc = await getCollection("typedoc");
|
|
6
7
|
|
|
7
8
|
const expandReferenceType = (name: string, data) => {
|
|
8
|
-
const ref = data.find(d => d.data.name === name)
|
|
9
|
+
const ref = data.find((d) => d.data.name === name);
|
|
9
10
|
return ref ? ref.data.children : null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const expanded = data[0].parameters ? data[0].parameters.map(d => {
|
|
13
|
-
return d.type.type === "reference"? expandReferenceType(d.type.name, typedoc): d.type
|
|
14
|
-
}).flat(): []
|
|
11
|
+
};
|
|
15
12
|
|
|
13
|
+
const expanded = data[0].parameters
|
|
14
|
+
? data[0].parameters
|
|
15
|
+
.map((d) => {
|
|
16
|
+
return d.type.type === "reference"
|
|
17
|
+
? expandReferenceType(d.type.name, typedoc)
|
|
18
|
+
: d.type;
|
|
19
|
+
})
|
|
20
|
+
.flat()
|
|
21
|
+
: [];
|
|
16
22
|
---
|
|
17
23
|
|
|
18
24
|
<ul>
|
|
19
|
-
{expanded.map(d =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
{expanded.map((d) => (
|
|
26
|
+
<>
|
|
27
|
+
<li>
|
|
28
|
+
<span>
|
|
29
|
+
{d?.name}
|
|
30
|
+
{!d?.flags.isOptional && <strong class="required">required</strong>}
|
|
31
|
+
</span>
|
|
32
|
+
<span>
|
|
33
|
+
<code class="value">
|
|
34
|
+
{d?.type.type === "union" ? (
|
|
35
|
+
`${d.type.types.map((t) => `"${t.value}"`).join(" | ")}`
|
|
36
|
+
) : d?.type.type === "array" ? (
|
|
37
|
+
<>{d.type.elementType.name}[]</>
|
|
38
|
+
) : d?.type.type === "reflection" ? (
|
|
39
|
+
<pre>{JSON.stringify(
|
|
40
|
+
Object.fromEntries(
|
|
41
|
+
d.type.declaration.children.map((c) => [
|
|
42
|
+
c.name,
|
|
43
|
+
c.type.name,
|
|
44
|
+
]),
|
|
45
|
+
),
|
|
46
|
+
null,
|
|
47
|
+
" ",
|
|
48
|
+
).replaceAll('"', "")}</pre>
|
|
49
|
+
) : (
|
|
50
|
+
<>{d?.type?.name}</>
|
|
51
|
+
)}
|
|
52
|
+
</code>
|
|
53
|
+
</span>
|
|
54
|
+
{d.comment && <TsdComment comment={d.comment} />}
|
|
55
|
+
</li>
|
|
56
|
+
</>
|
|
57
|
+
))}
|
|
24
58
|
</ul>
|
|
25
59
|
|
|
26
60
|
<style lang="scss">
|
|
@@ -36,20 +70,28 @@ const expanded = data[0].parameters ? data[0].parameters.map(d => {
|
|
|
36
70
|
li {
|
|
37
71
|
display: grid;
|
|
38
72
|
grid-template-columns: subgrid;
|
|
39
|
-
grid-column: 1 / 4;
|
|
40
73
|
border-bottom: 1px dotted currentColor;
|
|
74
|
+
grid-column: 1 / 4;
|
|
75
|
+
align-items: baseline;
|
|
41
76
|
&:last-child {
|
|
42
77
|
border-bottom: 0;
|
|
43
78
|
}
|
|
44
79
|
}
|
|
45
80
|
.required {
|
|
46
|
-
margin-left: .5ch;
|
|
81
|
+
margin-left: 0.5ch;
|
|
47
82
|
background: #f2d9d9;
|
|
48
83
|
font-family: monospace;
|
|
49
|
-
padding: .1em .3em;
|
|
84
|
+
padding: 0.1em 0.3em;
|
|
50
85
|
padding-bottom: 0;
|
|
51
|
-
font-size: .9em;
|
|
86
|
+
font-size: 0.9em;
|
|
52
87
|
font-weight: normal;
|
|
53
88
|
text-transform: uppercase;
|
|
54
89
|
}
|
|
90
|
+
|
|
91
|
+
.value {
|
|
92
|
+
display: block;
|
|
93
|
+
hyphens: none;
|
|
94
|
+
max-width: 32ch;
|
|
95
|
+
overflow-wrap: break-word;
|
|
96
|
+
}
|
|
55
97
|
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
const { comment } = Astro.props;
|
|
3
|
+
|
|
4
|
+
const defaultValue = comment.blockTags?.find((c) => c.tag === "@defaultValue");
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<span>
|
|
8
|
+
{comment.summary.map((part) =>
|
|
9
|
+
part.kind === "text" ? (
|
|
10
|
+
<>{part.text}</>
|
|
11
|
+
) : part.kind === "code" ? (
|
|
12
|
+
<code>{part.text.replaceAll("`", "")}</code>
|
|
13
|
+
) : part.tag === "@link" ? (
|
|
14
|
+
<a href={part.target}>{part.text}</a>
|
|
15
|
+
) : (
|
|
16
|
+
<></>
|
|
17
|
+
),
|
|
18
|
+
)}
|
|
19
|
+
{defaultValue && (
|
|
20
|
+
<>
|
|
21
|
+
{" "}
|
|
22
|
+
Defaults to{" "}
|
|
23
|
+
<code>
|
|
24
|
+
{defaultValue.content[0].text
|
|
25
|
+
.replaceAll("```", "")
|
|
26
|
+
.replace("ts", "")
|
|
27
|
+
.trim()}
|
|
28
|
+
</code>
|
|
29
|
+
.
|
|
30
|
+
</>
|
|
31
|
+
)}
|
|
32
|
+
</span>
|
|
@@ -8,15 +8,15 @@ npm install --save @awesomephant/reactcake
|
|
|
8
8
|
|
|
9
9
|
```tsx
|
|
10
10
|
import { ReactCake, Html, Svg } from "@awesomephant/reactcake";
|
|
11
|
-
import { scaleLinear, scaleBand } from "d3-scale"
|
|
11
|
+
import { scaleLinear, scaleBand } from "d3-scale";
|
|
12
12
|
|
|
13
13
|
// Chart components live in your project
|
|
14
14
|
import { xScale, yScale, Bars } from "./lib";
|
|
15
15
|
|
|
16
16
|
const data = [
|
|
17
|
-
{year: 2024, value: 32},
|
|
18
|
-
{year: 2025, value: 15},
|
|
19
|
-
{year: 2026, value: 52}
|
|
17
|
+
{ year: 2024, value: 32 },
|
|
18
|
+
{ year: 2025, value: 15 },
|
|
19
|
+
{ year: 2026, value: 52 },
|
|
20
20
|
];
|
|
21
21
|
|
|
22
22
|
// Use any d3 scale
|
|
@@ -31,7 +31,7 @@ return (
|
|
|
31
31
|
<AxisY />
|
|
32
32
|
</Html>
|
|
33
33
|
<Svg>
|
|
34
|
-
<Bars/>
|
|
34
|
+
<Bars />
|
|
35
35
|
</Svg>
|
|
36
36
|
</ReactCake>
|
|
37
37
|
);
|
|
@@ -1,98 +1,109 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { Font } from "astro:assets";
|
|
3
|
-
import "./code.scss"
|
|
3
|
+
import "./code.scss";
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!doctype html>
|
|
7
7
|
<html lang="en">
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
<head>
|
|
9
|
+
<meta charset="utf-8" />
|
|
10
|
+
<meta name="viewport" content="width=device-width" />
|
|
11
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
12
|
+
<meta name="generator" content={Astro.generator} />
|
|
13
|
+
<title>ReactCake</title>
|
|
14
|
+
<Font cssVariable="--font-areal" />
|
|
15
|
+
<Font cssVariable="--font-areal-mono" />
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<slot />
|
|
19
|
+
</body>
|
|
19
20
|
</html>
|
|
20
21
|
|
|
21
22
|
<style is:global>
|
|
22
23
|
* {
|
|
23
24
|
box-sizing: border-box;
|
|
25
|
+
font-size: inherit;
|
|
24
26
|
margin: 0;
|
|
25
27
|
padding: 0;
|
|
26
|
-
font-size: inherit;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
a, a:visited {
|
|
47
|
-
color: var(--blue-50);
|
|
48
|
-
background: #f0f0f0;
|
|
49
|
-
text-decoration: none;
|
|
50
|
-
border-bottom: 1px dotted currentColor;
|
|
51
|
-
}
|
|
30
|
+
body {
|
|
31
|
+
margin: 0;
|
|
32
|
+
width: 100%;
|
|
33
|
+
padding: 0.5rem;
|
|
34
|
+
font-family: var(--font-areal), sans-serif;
|
|
35
|
+
--blue-70: hsl(20, 80%, 20%);
|
|
36
|
+
--blue-50: hsl(20, 80%, 26%);
|
|
37
|
+
--blue-30: hsl(20, 80%, 76%);
|
|
38
|
+
--blue-20: hsl(20, 80%, 92%);
|
|
39
|
+
--blue-10: hsl(20, 80%, 97%);
|
|
40
|
+
--ms--1: 0.8rem padding: 1rem;
|
|
41
|
+
background: #d8d2f6;
|
|
42
|
+
line-height: 1.25;
|
|
43
|
+
color: var(--blue-50);
|
|
44
|
+
}
|
|
52
45
|
|
|
46
|
+
a,
|
|
47
|
+
a:visited {
|
|
48
|
+
color: var(--blue-50);
|
|
49
|
+
background: #f0f0f0;
|
|
50
|
+
text-decoration: none;
|
|
51
|
+
border-bottom: 1px dotted currentColor;
|
|
52
|
+
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
code {
|
|
55
|
+
font-family: var(--font-areal-mono);
|
|
56
|
+
font-size: 0.825rem;
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
transform-origin: left;
|
|
63
|
-
}
|
|
59
|
+
p,
|
|
60
|
+
li {
|
|
61
|
+
letter-spacing: 0.002em;
|
|
62
|
+
}
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
&:first-child {
|
|
72
|
-
margin-top: 0;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
h3 {
|
|
76
|
-
margin-bottom: 0.1rem;
|
|
77
|
-
font-weight: 600;
|
|
78
|
-
font-size: 1.2em;
|
|
79
|
-
}
|
|
80
|
-
h4 {
|
|
81
|
-
font-weight: 400;
|
|
82
|
-
font-size: 1rem;
|
|
83
|
-
opacity: .7;
|
|
84
|
-
margin-bottom: 0.1rem;
|
|
85
|
-
}
|
|
64
|
+
h1 {
|
|
65
|
+
font-weight: 900;
|
|
66
|
+
font-size: 2.75em;
|
|
67
|
+
transform: scaleX(0.8);
|
|
68
|
+
transform-origin: left;
|
|
69
|
+
}
|
|
86
70
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
71
|
+
h2 {
|
|
72
|
+
transform: scaleX(0.8) skew(-10deg);
|
|
73
|
+
transform-origin: left;
|
|
74
|
+
font-size: 1.85rem;
|
|
75
|
+
margin-top: 1rem;
|
|
76
|
+
margin-bottom: 0.25rem;
|
|
77
|
+
&:first-child {
|
|
78
|
+
margin-top: 0;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
h3 {
|
|
82
|
+
margin-bottom: 0.1rem;
|
|
83
|
+
font-weight: 600;
|
|
84
|
+
font-size: 1.2em;
|
|
85
|
+
}
|
|
86
|
+
h4 {
|
|
87
|
+
font-weight: 400;
|
|
88
|
+
font-size: 1.1rem;
|
|
89
|
+
margin-bottom: 0.25rem;
|
|
90
|
+
code {
|
|
91
|
+
font-size: 0.85em;
|
|
92
|
+
font-weight: 800;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
93
95
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
p,
|
|
97
|
+
ul,
|
|
98
|
+
ol {
|
|
99
|
+
margin-bottom: 0.75em;
|
|
100
|
+
&:last-child {
|
|
101
|
+
margin-bottom: 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
97
104
|
|
|
105
|
+
ul,
|
|
106
|
+
ol {
|
|
107
|
+
margin-left: 1em;
|
|
108
|
+
}
|
|
98
109
|
</style>
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
.astro-code {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
2
|
+
--astro-code-background: white;
|
|
3
|
+
--astro-code-token-comment: #666;
|
|
4
|
+
font-family: var(--font-areal-mono);
|
|
5
|
+
border: 1px solid currentColor;
|
|
6
|
+
margin: 1em 0;
|
|
7
|
+
margin-top: 0.5em;
|
|
8
|
+
padding: 0.5em;
|
|
9
|
+
line-height: 0.95;
|
|
10
|
+
&:last-child {
|
|
11
|
+
margin-bottom: 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
16
14
|
|
|
17
15
|
pre.astro-code .indent {
|
|
18
16
|
display: inline-block;
|
|
@@ -26,15 +24,9 @@ pre.astro-code .indent:empty {
|
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
pre.astro-code .indent::before {
|
|
29
|
-
content:
|
|
27
|
+
content: "";
|
|
30
28
|
position: absolute;
|
|
31
29
|
opacity: 0.5;
|
|
32
30
|
width: 1px;
|
|
33
31
|
height: 100%;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
pre.astro-code .line-number {
|
|
37
|
-
user-select: none;
|
|
38
|
-
color: rgba(black, .5);
|
|
39
|
-
margin-right: 3ch;
|
|
40
|
-
}
|
|
@@ -1,108 +1,137 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { getCollection } from
|
|
2
|
+
import { getCollection } from "astro:content";
|
|
3
3
|
|
|
4
|
-
import Base from
|
|
5
|
-
import {Content as Installation} from "../content/installation.md"
|
|
6
|
-
import {Content as Background} from "../content/background.md"
|
|
7
|
-
import Example from "../components/Example.astro"
|
|
8
|
-
import PropList from "../components/PropList.astro"
|
|
9
|
-
import ColumnChart from "../examples/ColumnChart.tsx"
|
|
4
|
+
import Base from "../layouts/Base.astro";
|
|
5
|
+
import { Content as Installation } from "../content/installation.md";
|
|
6
|
+
import { Content as Background } from "../content/background.md";
|
|
7
|
+
import Example from "../components/Example.astro";
|
|
8
|
+
import PropList from "../components/PropList.astro";
|
|
9
|
+
import ColumnChart from "../examples/ColumnChart.tsx";
|
|
10
10
|
|
|
11
|
-
const typedoc = await getCollection(
|
|
11
|
+
const typedoc = await getCollection("typedoc");
|
|
12
12
|
|
|
13
|
+
const components = ["Reactcake", "Html", "Svg", "ScaledSvg"];
|
|
13
14
|
---
|
|
14
15
|
|
|
15
16
|
<Base>
|
|
16
|
-
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
</
|
|
66
|
-
|
|
17
|
+
<article class="home">
|
|
18
|
+
<header>
|
|
19
|
+
<div>
|
|
20
|
+
<h1>ReactCake</h1>
|
|
21
|
+
<p>
|
|
22
|
+
A headless chart framework for React inspired by{" "}
|
|
23
|
+
<a href="https://layercake.graphics/">Layercake</a>
|
|
24
|
+
</p>
|
|
25
|
+
<ul>
|
|
26
|
+
<li>
|
|
27
|
+
<a href="https://github.com/awesomephant/reactcake">Github</a>
|
|
28
|
+
</li>
|
|
29
|
+
<li>
|
|
30
|
+
<a href="https://www.npmjs.com/package/@awesomephant/reactcake">
|
|
31
|
+
npm
|
|
32
|
+
</a>
|
|
33
|
+
</li>
|
|
34
|
+
</ul>
|
|
35
|
+
</div>
|
|
36
|
+
<Example height="12rem">
|
|
37
|
+
<ColumnChart />
|
|
38
|
+
</Example>
|
|
39
|
+
</header>
|
|
40
|
+
|
|
41
|
+
<section class="installation">
|
|
42
|
+
<h2>Quickstart</h2>
|
|
43
|
+
<Installation />
|
|
44
|
+
</section>
|
|
45
|
+
|
|
46
|
+
<section class="docs">
|
|
47
|
+
<h2>Docs</h2>
|
|
48
|
+
<h3>Components</h3>
|
|
49
|
+
{typedoc
|
|
50
|
+
.filter((d) => d.data.kind === 64 && !d.data.name.startsWith("use"))
|
|
51
|
+
.sort(
|
|
52
|
+
(a, b) =>
|
|
53
|
+
components.indexOf(a.data.name) - components.indexOf(b.data.name),
|
|
54
|
+
)
|
|
55
|
+
.map((d) => {
|
|
56
|
+
return (
|
|
57
|
+
<>
|
|
58
|
+
<h4>
|
|
59
|
+
<code>
|
|
60
|
+
{`<`}
|
|
61
|
+
{d.data.name}
|
|
62
|
+
{`/>`}
|
|
63
|
+
</code>
|
|
64
|
+
</h4>
|
|
65
|
+
{d.data.signatures[0].comment && (
|
|
66
|
+
<p>{d.data.signatures[0].comment.summary[0].text}</p>
|
|
67
|
+
)}
|
|
68
|
+
<PropList data={d.data.signatures} />
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
})}
|
|
72
|
+
<h3>Hooks</h3>
|
|
73
|
+
{typedoc
|
|
74
|
+
.filter((d) => d.data.kind === 64 && d.data.name.startsWith("use"))
|
|
75
|
+
.map((d) => {
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
<h3>
|
|
79
|
+
<code>
|
|
80
|
+
{d.data.name}
|
|
81
|
+
{`()`}
|
|
82
|
+
</code>
|
|
83
|
+
</h3>
|
|
84
|
+
{d.data.signatures[0].comment && (
|
|
85
|
+
<p>{d.data.signatures[0].comment.summary[0].text}</p>
|
|
86
|
+
)}
|
|
87
|
+
<PropList data={d.data.signatures} />
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
})}
|
|
91
|
+
<h3>Utils</h3>
|
|
92
|
+
</section>
|
|
93
|
+
|
|
94
|
+
<section class="background">
|
|
95
|
+
<Background />
|
|
96
|
+
</section>
|
|
97
|
+
</article>
|
|
67
98
|
</Base>
|
|
68
99
|
|
|
69
100
|
<style lang="scss">
|
|
70
|
-
.home {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
101
|
+
.home {
|
|
102
|
+
display: grid;
|
|
103
|
+
grid-template-columns: repeat(12, 1fr);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
header,
|
|
107
|
+
section {
|
|
108
|
+
padding: 1rem;
|
|
109
|
+
border: 1px solid var(--blue-50);
|
|
110
|
+
background-color: white;
|
|
111
|
+
margin-bottom: -1px;
|
|
112
|
+
margin-right: -1px;
|
|
113
|
+
}
|
|
114
|
+
header {
|
|
115
|
+
border-top: 1px solid var(--blue-50);
|
|
116
|
+
border-left: 1px solid var(--blue-50);
|
|
117
|
+
grid-column: span 2;
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-flow: column;
|
|
120
|
+
justify-content: space-between;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.installation {
|
|
124
|
+
border-top: 1px solid var(--blue-50);
|
|
125
|
+
grid-column: 3 / 8;
|
|
126
|
+
}
|
|
127
|
+
.docs {
|
|
128
|
+
border-top: 1px solid var(--blue-50);
|
|
129
|
+
grid-column: 8 / 13;
|
|
130
|
+
grid-row: span 3;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.background {
|
|
134
|
+
grid-column: 3 / 8;
|
|
135
|
+
border-left: 1px solid var(--blue-50);
|
|
136
|
+
}
|
|
108
137
|
</style>
|