From 3c94101b92d143f4714feb805024280476cb8d5b Mon Sep 17 00:00:00 2001 From: Rachel Marconi Date: Thu, 8 Aug 2024 17:42:40 -0400 Subject: [PATCH] add layercake components, stories and docs --- .storybook/preview.js | 1 + CHANGELOG.md | 1 + src/lib/Layercake/AxisX.docs.md | 13 +++ src/lib/Layercake/AxisX.stories.svelte | 84 +++++++++++++++++ src/lib/Layercake/AxisX.svelte | 120 +++++++++++++++++++++++++ src/lib/Layercake/AxisY.docs.md | 13 +++ src/lib/Layercake/AxisY.stories.svelte | 97 ++++++++++++++++++++ src/lib/Layercake/AxisY.svelte | 107 ++++++++++++++++++++++ src/lib/Layercake/data.json | 8 ++ src/lib/index.js | 2 + 10 files changed, 446 insertions(+) create mode 100644 src/lib/Layercake/AxisX.docs.md create mode 100644 src/lib/Layercake/AxisX.stories.svelte create mode 100644 src/lib/Layercake/AxisX.svelte create mode 100644 src/lib/Layercake/AxisY.docs.md create mode 100644 src/lib/Layercake/AxisY.stories.svelte create mode 100644 src/lib/Layercake/AxisY.svelte create mode 100644 src/lib/Layercake/data.json diff --git a/.storybook/preview.js b/.storybook/preview.js index 0ec5f26..0a749ee 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -23,6 +23,7 @@ const preview = { ["Theme", "Fonts"], "Examples", "Components", + "Layercake", "Layout", "Logos", "Maps", diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cf4a34..cfdbf0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Patch: Update method of declaring Storybook component descriptions and add import instructions to components - Patch: Remove description field from top level `meta` object in component `.stories.svelte` files (do not render) - Feature: CLI command to generate new component boilerplate (`npm run create-component`) +- Feature: Add Layercake AxisX and AxisY components and docs ## v0.10.2 diff --git a/src/lib/Layercake/AxisX.docs.md b/src/lib/Layercake/AxisX.docs.md new file mode 100644 index 0000000..b9cd5fd --- /dev/null +++ b/src/lib/Layercake/AxisX.docs.md @@ -0,0 +1,13 @@ +Layercake components can be useful for out-of-the-box Svelte charts. Often, however, they are not built according to Urban style. This AxisX component takes those available in Layercake and updates them to use Urban font family, colors, and sizes. + +Furthermore, while Layercake components are often externally updated, this axis here is set in time at a stage where they will not break our builds. Any updates to merge in newer Layercake code will happen not project to project but here, at source, when decided necessary. Therefore, this axis will always work with expected parameters. + + +## Usage + +Layercake axes must be built inside a Layercake component and context, and, further, within an Svg component. Both can be imported from the layercake package. The Layercake object must be passed flat array (not object) data and domain before anything can be initialized and rendered, and these are used across all components used to craft a chart. + + +```js +import { AxisX } from "@urbaninstitute/dataviz-components"; +``` diff --git a/src/lib/Layercake/AxisX.stories.svelte b/src/lib/Layercake/AxisX.stories.svelte new file mode 100644 index 0000000..d64cfbd --- /dev/null +++ b/src/lib/Layercake/AxisX.stories.svelte @@ -0,0 +1,84 @@ + + + + + + + diff --git a/src/lib/Layercake/AxisX.svelte b/src/lib/Layercake/AxisX.svelte new file mode 100644 index 0000000..99932ba --- /dev/null +++ b/src/lib/Layercake/AxisX.svelte @@ -0,0 +1,120 @@ + + + + + {#each tickVals as tick, i (tick)} + + {#if gridlines !== false} + + {/if} + {#if tickMarks === true} + + {/if} + {formatTick(tick)} + + {/each} + {#if baseline === true} + + {/if} + {#if axisLabel} + {axisLabel} + {/if} + + + \ No newline at end of file diff --git a/src/lib/Layercake/AxisY.docs.md b/src/lib/Layercake/AxisY.docs.md new file mode 100644 index 0000000..a7a56db --- /dev/null +++ b/src/lib/Layercake/AxisY.docs.md @@ -0,0 +1,13 @@ +Layercake components can be useful for out-of-the-box Svelte charts. Often, however, they are not built according to Urban style. This AxisY component takes those available in Layercake and updates them to use Urban font family, colors, and sizes. + +Furthermore, while Layercake components are often externally updated, this axis here is set in time at a stage where they will not break our builds. Any updates to merge in newer Layercake code will happen not project to project but here, at source, when decided necessary. Therefore, this axis will always work with expected parameters. + + +## Usage + +Layercake axes must be built inside a Layercake component and context, and, further, within an Svg component. Both can be imported from the layercake package. The Layercake object must be passed flat array (not object) data and domain before anything can be initialized and rendered, and these are used across all components used to craft a chart. + + +```js +import { AxisY } from "@urbaninstitute/dataviz-components"; +``` diff --git a/src/lib/Layercake/AxisY.stories.svelte b/src/lib/Layercake/AxisY.stories.svelte new file mode 100644 index 0000000..d932c30 --- /dev/null +++ b/src/lib/Layercake/AxisY.stories.svelte @@ -0,0 +1,97 @@ + + + + + + + diff --git a/src/lib/Layercake/AxisY.svelte b/src/lib/Layercake/AxisY.svelte new file mode 100644 index 0000000..cf7f05c --- /dev/null +++ b/src/lib/Layercake/AxisY.svelte @@ -0,0 +1,107 @@ + + + + + {#each tickVals as tick (tick)} + + {#if gridlines !== false} + + {/if} + {#if tickMarks === true} + + {/if} + {formatTick(tick)} + + {/each} + {#if axisLabel} + {axisLabel} + {/if} + + + \ No newline at end of file diff --git a/src/lib/Layercake/data.json b/src/lib/Layercake/data.json new file mode 100644 index 0000000..55e6a46 --- /dev/null +++ b/src/lib/Layercake/data.json @@ -0,0 +1,8 @@ +[ +["year","value"], +[1979, 2], +[1980, 3], +[1981, 5], +[1982, 8], +[1983, 18] +] \ No newline at end of file diff --git a/src/lib/index.js b/src/lib/index.js index e03e915..f35f7b1 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -27,3 +27,5 @@ export { default as Headline } from "./Headline/Headline.svelte"; export { default as PymChild } from "./Pym/PymChild.svelte"; export { default as LoadingWrapper } from "./LoadingWrapper/LoadingWrapper.svelte"; export { default as Tooltip } from "./Tooltip/Tooltip.svelte"; +export { default as AxisY } from "./Layercake/AxisY.svelte"; +export { default as AxisX } from "./Layercake/AxisX.svelte"; \ No newline at end of file