@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 CHANGED
@@ -1,6 +1,6 @@
1
- # [1.2.0](https://github.com/awesomephant/reactcake/compare/v1.1.2...v1.2.0) (2026-11-15)
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
- * Add zIndex prop ([9d57d3f](https://github.com/awesomephant/reactcake/commit/9d57d3ff786a969f9224a90a527e38993dec7899))
6
+ * iterate LayoutProps ([e6ea26a](https://github.com/awesomephant/reactcake/commit/e6ea26ad9f583846f20925ada21b5b7504f83d1d))
@@ -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={labelledBy}
27
+ aria-label={label}
28
+ aria-labelledby={labelledBy}
23
29
  aria-describedby={describedBy}
24
- role={label ? "figure" : "none"}
30
+ role={role}
25
31
  style={{
26
32
  position: "absolute",
27
33
  top: `${padding.top}px`,
@@ -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 { Padding, ScaleLike, ContextValue, DomainLike, Accessor } from "../types";
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
- * x accs comment
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
- padding?: Padding;
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
- * This is a comment
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],
@@ -3,6 +3,9 @@ import { useReactCake } from "../ReactCake";
3
3
  import { LayoutProps } from "../types";
4
4
 
5
5
  interface ScaledSvgProps extends LayoutProps {
6
+ /**
7
+ * Sets the contents of the <title> tag
8
+ */
6
9
  title?: string;
7
10
  children?: ReactNode;
8
11
  }
package/lib/Svg/index.tsx CHANGED
@@ -3,6 +3,9 @@ import { useReactCake } from "../ReactCake";
3
3
  import { LayoutProps } from "../types";
4
4
 
5
5
  interface SvgProps extends LayoutProps {
6
+ /**
7
+ * Sets the contents of the `<title>` tag
8
+ */
6
9
  title?: string;
7
10
  children?: ReactNode;
8
11
  }
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: 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomephant/reactcake",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A headless chart framework for React inspired by Layercake",
5
5
  "keywords": [
6
6
  "react",
@@ -1,33 +1,54 @@
1
1
  // @ts-check
2
- import { defineConfig, fontProviders } from 'astro/config';
3
- import {transformerRenderIndentGuides, transformerRenderLineNumber} from "@shikijs/transformers"
2
+ import { defineConfig, fontProviders } from "astro/config";
3
+ import {
4
+ transformerRenderIndentGuides,
5
+ transformerRenderLineNumber,
6
+ } from "@shikijs/transformers";
4
7
 
5
- import mdx from '@astrojs/mdx';
8
+ import mdx from "@astrojs/mdx";
6
9
 
7
- import react from '@astrojs/react';
10
+ import react from "@astrojs/react";
8
11
 
9
12
  export default defineConfig({
10
- fonts: [{
11
- provider: fontProviders.local(),
12
- name: "Areal",
13
- cssVariable: "--font-areal",
14
- options: {
15
- variants: [{
16
- weight: "100 900",
17
- style: "normal",
18
- src:["./src/assets/ABCArealVariable.woff2"]
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: 'css-variables',
45
+ theme: "css-variables",
25
46
  defaultColor: false,
26
47
  },
27
48
  syntaxHighlight: {
28
- type: 'shiki',
29
- },
49
+ type: "shiki",
50
+ },
30
51
  },
31
52
 
32
- integrations: [mdx(), react()]
53
+ integrations: [mdx(), react()],
33
54
  });
package/site/package.json CHANGED
@@ -29,6 +29,8 @@
29
29
  "@types/react": "^19.3.0",
30
30
  "@types/react-dom": "^19.3.0",
31
31
  "npm-run-all": "^4.1.5",
32
+ "prettier": "^3.10.1",
33
+ "prettier-plugin-astro": "^1.1.2",
32
34
  "sass-embedded": "^1.108.2",
33
35
  "typedoc": "^0.28.20"
34
36
  }
@@ -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('typedoc');
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
- <li><span>{d?.name}{!d?.flags.isOptional && <strong class="required">required</strong>}</span><span><code>{d?.type.type === "union"? `${d.type.types.map(t => `"${t.value}"`).join(" | ")}` : d?.type.type ==="array"?<code>{d.type.elementType.name}[]</code> : d?.type?.name}</code></span>{d.comment && <span>{d.comment.summary[0].text}</span>}</li>
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
- <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
- </head>
16
- <body>
17
- <slot />
18
- </body>
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
- body {
30
- margin: 0;
31
- width: 100%;
32
- padding: .5rem;
33
- font-family: var(--font-areal), sans-serif;
34
- --blue-70: hsl(20, 80%, 20%);
35
- --blue-50: hsl(20, 80%, 26%);
36
- --blue-30: hsl(20, 80%, 76%);
37
- --blue-20: hsl(20, 80%, 92%);
38
- --blue-10: hsl(20, 80%, 97%);
39
- --ms--1: .8rem
40
- padding: 1rem;
41
- background: #d8d2f6;
42
- line-height: 1.25;
43
- color: var(--blue-50);
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
- p, li {
55
- letter-spacing: .002em;
56
- }
54
+ code {
55
+ font-family: var(--font-areal-mono);
56
+ font-size: 0.825rem;
57
+ }
57
58
 
58
- h1 {
59
- font-weight: 900;
60
- font-size: 2.75em;
61
- transform: scaleX(.8);
62
- transform-origin: left;
63
- }
59
+ p,
60
+ li {
61
+ letter-spacing: 0.002em;
62
+ }
64
63
 
65
- h2 {
66
- transform: scaleX(.8);
67
- transform-origin: left;
68
- font-size: 1.75rem;
69
- margin-top: 1rem;
70
- margin-bottom: .25rem;
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
- p, ul, ol {
88
- margin-bottom: .75em;
89
- &:last-child {
90
- margin-bottom: 0;
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
- ul, ol {
95
- margin-left: 1em;
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
- --astro-code-background: white;
3
- --astro-code-token-comment: #666;
4
- border: 1px solid currentColor;
5
- margin: 1em 0;
6
- margin-top: .5em;
7
- padding: .5em;
8
- font-size: 12px;
9
- line-height: 1.1;
10
- font-family: monospace;
11
- &:last-child {
12
- margin-bottom: 0;
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 'astro:content';
2
+ import { getCollection } from "astro:content";
3
3
 
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"
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('typedoc');
11
+ const typedoc = await getCollection("typedoc");
12
12
 
13
+ const components = ["Reactcake", "Html", "Svg", "ScaledSvg"];
13
14
  ---
14
15
 
15
16
  <Base>
16
-
17
- <article class="home">
18
-
19
- <header>
20
- <div>
21
- <h1>ReactCake</h1>
22
- <p>A headless chart framework for React inspired by <a href="https://layercake.graphics/">Layercake</a></p>
23
- <ul>
24
- <li><a href="https://github.com/awesomephant/reactcake">Github</a></li>
25
- <li><a href="https://www.npmjs.com/package/@awesomephant/reactcake">npm</a></li>
26
- </ul>
27
- </div>
28
- <Example height="12rem" >
29
- <ColumnChart/>
30
- </Example>
31
- </header>
32
-
33
- <section class="installation">
34
- <h2>Quickstart</h2>
35
- <Installation/>
36
- </section>
37
-
38
- <section class="docs">
39
- <h2>Docs</h2>
40
- <h3>Components</h3>
41
- {typedoc.filter(d => d.data.kind === 64 && !d.data.name.startsWith("use")).map(d => {
42
- return (
43
- <>
44
- <h3><code>{`<`}{d.data.name}{`/>`}</code></h3>
45
- {d.data.signatures[0].comment && <p>{d.data.signatures[0].comment.summary[0].text}</p>}
46
- <PropList data={d.data.signatures}/>
47
- </>)
48
- })}
49
- <h3>Hooks</h3>
50
- {typedoc.filter(d => d.data.kind === 64 && d.data.name.startsWith("use")).map(d => {
51
- return (
52
- <>
53
- <h3><code>{d.data.name}{`()`}</code></h3>
54
- {d.data.signatures[0].comment && <p>{d.data.signatures[0].comment.summary[0].text}</p>}
55
- <PropList data={d.data.signatures}/>
56
- </>)
57
- })}
58
- <h3>Utils</h3>
59
-
60
- </section>
61
-
62
- <section class="background">
63
- <Background/>
64
- </section>
65
- </article>
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
- display: grid;
72
- grid-template-columns: repeat(12, 1fr);
73
- hyphens: auto;
74
- }
75
-
76
- header, section {
77
- padding: 1rem;
78
- border: 1px solid var(--blue-50);
79
- background-color: white;
80
- margin-bottom: -1px;
81
- margin-right: -1px;
82
-
83
- }
84
- header {
85
- border-top: 1px solid var(--blue-50);
86
- border-left: 1px solid var(--blue-50);
87
- grid-column: span 2;
88
- display: flex;
89
- flex-flow: column;
90
- justify-content: space-between;
91
- }
92
-
93
- .installation {
94
- border-top: 1px solid var(--blue-50);
95
- grid-column: 3 / 8;
96
- }
97
- .docs {
98
- border-top: 1px solid var(--blue-50);
99
- grid-column: 8 / 13;
100
- grid-row: span 3;
101
- }
102
-
103
- .background {
104
- grid-column: 3 / 8;
105
- border-left: 1px solid var(--blue-50);
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>