@buildcanada/colours 0.1.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/README.md +64 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/barrelExporting.d.ts +2 -0
- package/dist/lib/barrelExporting.d.ts.map +1 -0
- package/dist/lib/barrelExporting.js +72 -0
- package/dist/lib/cssToTs.d.ts +2 -0
- package/dist/lib/cssToTs.d.ts.map +1 -0
- package/dist/lib/cssToTs.js +26 -0
- package/dist/lib/fs-utils.d.ts +11 -0
- package/dist/lib/fs-utils.d.ts.map +1 -0
- package/dist/lib/fs-utils.js +50 -0
- package/dist/lib/syntax-utils.d.ts +9 -0
- package/dist/lib/syntax-utils.d.ts.map +1 -0
- package/dist/lib/syntax-utils.js +44 -0
- package/dist/stories/ChartThemes.stories.d.ts +9 -0
- package/dist/stories/ChartThemes.stories.d.ts.map +1 -0
- package/dist/stories/ChartThemes.stories.js +122 -0
- package/dist/stories/ColourScales.stories.d.ts +24 -0
- package/dist/stories/ColourScales.stories.d.ts.map +1 -0
- package/dist/stories/ColourScales.stories.js +129 -0
- package/dist/styles/colours/amethyst.css +13 -0
- package/dist/styles/colours/amethyst.d.ts +14 -0
- package/dist/styles/colours/amethyst.d.ts.map +1 -0
- package/dist/styles/colours/amethyst.js +13 -0
- package/dist/styles/colours/amethyst.ts +13 -0
- package/dist/styles/colours/auburn.css +13 -0
- package/dist/styles/colours/auburn.d.ts +14 -0
- package/dist/styles/colours/auburn.d.ts.map +1 -0
- package/dist/styles/colours/auburn.js +13 -0
- package/dist/styles/colours/auburn.ts +13 -0
- package/dist/styles/colours/aurora.css +13 -0
- package/dist/styles/colours/aurora.d.ts +14 -0
- package/dist/styles/colours/aurora.d.ts.map +1 -0
- package/dist/styles/colours/aurora.js +13 -0
- package/dist/styles/colours/aurora.ts +13 -0
- package/dist/styles/colours/cerulean.css +13 -0
- package/dist/styles/colours/cerulean.d.ts +14 -0
- package/dist/styles/colours/cerulean.d.ts.map +1 -0
- package/dist/styles/colours/cerulean.js +13 -0
- package/dist/styles/colours/cerulean.ts +13 -0
- package/dist/styles/colours/charcoal.css +14 -0
- package/dist/styles/colours/charcoal.d.ts +15 -0
- package/dist/styles/colours/charcoal.d.ts.map +1 -0
- package/dist/styles/colours/charcoal.js +14 -0
- package/dist/styles/colours/charcoal.ts +14 -0
- package/dist/styles/colours/copper.css +13 -0
- package/dist/styles/colours/copper.d.ts +14 -0
- package/dist/styles/colours/copper.d.ts.map +1 -0
- package/dist/styles/colours/copper.js +13 -0
- package/dist/styles/colours/copper.ts +13 -0
- package/dist/styles/colours/emerald.css +13 -0
- package/dist/styles/colours/emerald.d.ts +14 -0
- package/dist/styles/colours/emerald.d.ts.map +1 -0
- package/dist/styles/colours/emerald.js +13 -0
- package/dist/styles/colours/emerald.ts +13 -0
- package/dist/styles/colours/index.css +19 -0
- package/dist/styles/colours/index.d.ts +15 -0
- package/dist/styles/colours/index.d.ts.map +1 -0
- package/dist/styles/colours/index.js +14 -0
- package/dist/styles/colours/index.ts +14 -0
- package/dist/styles/colours/lake.css +13 -0
- package/dist/styles/colours/lake.d.ts +14 -0
- package/dist/styles/colours/lake.d.ts.map +1 -0
- package/dist/styles/colours/lake.js +13 -0
- package/dist/styles/colours/lake.ts +13 -0
- package/dist/styles/colours/linen.css +13 -0
- package/dist/styles/colours/linen.d.ts +14 -0
- package/dist/styles/colours/linen.d.ts.map +1 -0
- package/dist/styles/colours/linen.js +13 -0
- package/dist/styles/colours/linen.ts +13 -0
- package/dist/styles/colours/maritime.css +13 -0
- package/dist/styles/colours/maritime.d.ts +14 -0
- package/dist/styles/colours/maritime.d.ts.map +1 -0
- package/dist/styles/colours/maritime.js +13 -0
- package/dist/styles/colours/maritime.ts +13 -0
- package/dist/styles/colours/nickel.css +13 -0
- package/dist/styles/colours/nickel.d.ts +14 -0
- package/dist/styles/colours/nickel.d.ts.map +1 -0
- package/dist/styles/colours/nickel.js +13 -0
- package/dist/styles/colours/nickel.ts +13 -0
- package/dist/styles/colours/pine.css +13 -0
- package/dist/styles/colours/pine.d.ts +14 -0
- package/dist/styles/colours/pine.d.ts.map +1 -0
- package/dist/styles/colours/pine.js +13 -0
- package/dist/styles/colours/pine.ts +13 -0
- package/dist/styles/colours/sienna.css +13 -0
- package/dist/styles/colours/sienna.d.ts +14 -0
- package/dist/styles/colours/sienna.d.ts.map +1 -0
- package/dist/styles/colours/sienna.js +13 -0
- package/dist/styles/colours/sienna.ts +13 -0
- package/dist/styles/colours/steel.css +13 -0
- package/dist/styles/colours/steel.d.ts +14 -0
- package/dist/styles/colours/steel.d.ts.map +1 -0
- package/dist/styles/colours/steel.js +13 -0
- package/dist/styles/colours/steel.ts +13 -0
- package/dist/styles/index.d.ts +3 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/index.js +2 -0
- package/dist/styles/index.ts +2 -0
- package/dist/styles/main.css +1 -0
- package/dist/styles/themes/charts/index.d.ts +2 -0
- package/dist/styles/themes/charts/index.d.ts.map +1 -0
- package/dist/styles/themes/charts/index.js +1 -0
- package/dist/styles/themes/charts/index.ts +1 -0
- package/dist/styles/themes/charts/twelve-tone/auburn-cool-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/auburn-cool-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/auburn-cool-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/auburn-cool-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/auburn-cool-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-auburn-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-auburn-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-auburn-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-auburn-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-auburn-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-linen-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-linen-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-linen-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-linen-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/aurora-linen-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/dust_maritime-pine.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/dust_maritime-pine.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/dust_maritime-pine.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/dust_maritime-pine.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/dust_maritime-pine.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/index.d.ts +28 -0
- package/dist/styles/themes/charts/twelve-tone/index.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/index.js +27 -0
- package/dist/styles/themes/charts/twelve-tone/index.ts +27 -0
- package/dist/styles/themes/charts/twelve-tone/lake-maritime-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-maritime-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/lake-maritime-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/lake-maritime-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-maritime-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-pine-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-pine-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/lake-pine-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/lake-pine-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-pine-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-warm-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-warm-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/lake-warm-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/lake-warm-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/lake-warm-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-auburn-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-auburn-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/linen-auburn-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/linen-auburn-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-auburn-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-aurora-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-aurora-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/linen-aurora-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/linen-aurora-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-aurora-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-cool-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-cool-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/linen-cool-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/linen-cool-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-cool-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-lake-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-lake-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/linen-lake-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/linen-lake-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-lake-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-pine-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-pine-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/linen-pine-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/linen-pine-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-pine-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-warm-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-warm-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/linen-warm-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/linen-warm-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/linen-warm-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-aurora-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-aurora-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-aurora-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-aurora-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-aurora-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-pine-blend.css +0 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-pine-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-pine-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-pine-blend.js +1 -0
- package/dist/styles/themes/charts/twelve-tone/maritime-pine-blend.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-auburn-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-auburn-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-auburn-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-auburn-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-auburn-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-cool-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-cool-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-cool-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-cool-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-cool-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-warm-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-warm-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-warm-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-warm-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/nickel-warm-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-cool-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-cool-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/pine-cool-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/pine-cool-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-cool-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-lake-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-lake-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/pine-lake-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/pine-lake-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-lake-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-maritime-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-maritime-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/pine-maritime-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/pine-maritime-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-maritime-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/pine-warm-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-cool-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-cool-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/steel-cool-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/steel-cool-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-cool-bend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-lake-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-lake-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/steel-lake-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/steel-lake-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-lake-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-pine-blend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-pine-blend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/steel-pine-blend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/steel-pine-blend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-pine-blend.ts +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-warm-bend.css +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-warm-bend.d.ts +2 -0
- package/dist/styles/themes/charts/twelve-tone/steel-warm-bend.d.ts.map +1 -0
- package/dist/styles/themes/charts/twelve-tone/steel-warm-bend.js +14 -0
- package/dist/styles/themes/charts/twelve-tone/steel-warm-bend.ts +14 -0
- package/dist/styles/themes/index.d.ts +2 -0
- package/dist/styles/themes/index.d.ts.map +1 -0
- package/dist/styles/themes/index.js +1 -0
- package/dist/styles/themes/index.ts +1 -0
- package/dist/styles/themes/main.css +43 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# colour-tokens
|
|
2
|
+
|
|
3
|
+
Canadian colour tokens for design systems. This package provides a curated collection of colour definitions in both CSS and TypeScript formats, designed for use in Canadian government and enterprise applications.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
This package contains colour tokens organized into:
|
|
8
|
+
|
|
9
|
+
- **Colours**: Individual colour scales with 50-950 shades (e.g., auburn, lake, pine, steel)
|
|
10
|
+
- **Themes**: Chart-ready colour blends for data visualization
|
|
11
|
+
|
|
12
|
+
All tokens are generated from CSS variables and compiled to TypeScript with full type definitions.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### CSS Imports
|
|
17
|
+
|
|
18
|
+
Import colour tokens directly in your CSS:
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
@import "colour-tokens/styles/colours/lake.css";
|
|
22
|
+
@import "colour-tokens/styles/themes/charts/twelve-tone/auburn-cool-bend.css";
|
|
23
|
+
|
|
24
|
+
/* Or import all colours */
|
|
25
|
+
@import "colour-tokens/styles/main.css";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### TypeScript Imports
|
|
29
|
+
|
|
30
|
+
Import colour tokens in your TypeScript/JavaScript code:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// Import individual colours
|
|
34
|
+
import { auburn, lake, pine } from "colour-tokens";
|
|
35
|
+
|
|
36
|
+
// Access colour scales
|
|
37
|
+
console.log(auburn["500"]); // "#d85b5b"
|
|
38
|
+
|
|
39
|
+
// Import chart themes
|
|
40
|
+
import { auburn_cool_bend, pine_lake_blend } from "colour-tokens/styles/themes/charts/twelve-tone";
|
|
41
|
+
|
|
42
|
+
// Import everything from styles
|
|
43
|
+
import * as styles from "colour-tokens/styles";
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Downloading
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install colour-tokens
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Contributing
|
|
53
|
+
|
|
54
|
+
1. Fork the repository
|
|
55
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
56
|
+
3. Add or modify colour definitions in `src/styles/`
|
|
57
|
+
4. Run the build script (`bun run build`) to generate TypeScript files and barrel exports
|
|
58
|
+
5. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
59
|
+
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
60
|
+
7. Open a Pull Request
|
|
61
|
+
|
|
62
|
+
## License
|
|
63
|
+
|
|
64
|
+
MIT
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":""}
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cssToTs } from "./lib/cssToTs";
|
|
2
|
+
import { barrelExporting } from "./lib/barrelExporting";
|
|
3
|
+
import { mkdir, cp } from "node:fs/promises";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
const build = async () => {
|
|
6
|
+
console.log("Converting CSS to TS...");
|
|
7
|
+
await cssToTs();
|
|
8
|
+
console.log("Generating barrel exports...");
|
|
9
|
+
await barrelExporting();
|
|
10
|
+
console.log("Copying styles to dist...");
|
|
11
|
+
await mkdir("dist", { recursive: true });
|
|
12
|
+
await cp("src/styles", "dist/styles", { recursive: true });
|
|
13
|
+
console.log("Compiling TypeScript to JavaScript...");
|
|
14
|
+
await new Promise((resolve, reject) => {
|
|
15
|
+
const tsc = spawn("npx", ["tsc", "--project", "tsconfig.build.json"], {
|
|
16
|
+
stdio: "inherit"
|
|
17
|
+
});
|
|
18
|
+
tsc.on("close", (code) => {
|
|
19
|
+
if (code === 0)
|
|
20
|
+
resolve();
|
|
21
|
+
else
|
|
22
|
+
reject(new Error(`tsc exited with code ${code}`));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
console.log("Build complete!");
|
|
26
|
+
};
|
|
27
|
+
build();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./styles";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrelExporting.d.ts","sourceRoot":"","sources":["../../src/lib/barrelExporting.ts"],"names":[],"mappings":"AAgFA,eAAO,MAAM,eAAe,qBAY3B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { walkDirectory } from "./fs-utils";
|
|
2
|
+
import { readdir, writeFile, stat } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
const getAllDirectories = async (dir) => {
|
|
5
|
+
const dirs = [];
|
|
6
|
+
async function traverse(currentDir) {
|
|
7
|
+
const entries = await readdir(currentDir, { withFileTypes: true });
|
|
8
|
+
for (const entry of entries) {
|
|
9
|
+
const fullPath = join(currentDir, entry.name);
|
|
10
|
+
if (entry.isDirectory()) {
|
|
11
|
+
dirs.push(fullPath);
|
|
12
|
+
await traverse(fullPath);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
await traverse(dir);
|
|
17
|
+
return dirs;
|
|
18
|
+
};
|
|
19
|
+
const getSiblingTsFiles = async (dir) => {
|
|
20
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
21
|
+
return entries
|
|
22
|
+
.filter((entry) => entry.isFile() &&
|
|
23
|
+
entry.name.endsWith(".ts") &&
|
|
24
|
+
entry.name !== "index.ts")
|
|
25
|
+
.map((entry) => join(dir, entry.name));
|
|
26
|
+
};
|
|
27
|
+
const getSiblingDirectories = async (dir) => {
|
|
28
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
29
|
+
return entries
|
|
30
|
+
.filter((entry) => entry.isDirectory())
|
|
31
|
+
.map((entry) => join(dir, entry.name));
|
|
32
|
+
};
|
|
33
|
+
const getDirectoryDepth = (path) => {
|
|
34
|
+
return path.split("/").length;
|
|
35
|
+
};
|
|
36
|
+
const normalizePath = (path) => {
|
|
37
|
+
return path.replace(/^\.\//, "");
|
|
38
|
+
};
|
|
39
|
+
const generateIndexFile = async (dir) => {
|
|
40
|
+
const normalizedDir = normalizePath(dir);
|
|
41
|
+
const tsFiles = await getSiblingTsFiles(dir);
|
|
42
|
+
const subDirs = await getSiblingDirectories(dir);
|
|
43
|
+
const exports = [];
|
|
44
|
+
for (const file of tsFiles) {
|
|
45
|
+
const normalizedFile = normalizePath(file);
|
|
46
|
+
const relativePath = normalizedFile.replace(normalizedDir + "/", "");
|
|
47
|
+
exports.push(`export * from './${relativePath.replace(".ts", "")}';`);
|
|
48
|
+
}
|
|
49
|
+
for (const subDir of subDirs) {
|
|
50
|
+
const indexPath = join(subDir, "index.ts");
|
|
51
|
+
try {
|
|
52
|
+
await stat(indexPath);
|
|
53
|
+
const normalizedSubDir = normalizePath(subDir);
|
|
54
|
+
const relativePath = normalizedSubDir.replace(normalizedDir + "/", "");
|
|
55
|
+
exports.push(`export * from './${relativePath}';`);
|
|
56
|
+
}
|
|
57
|
+
catch { }
|
|
58
|
+
}
|
|
59
|
+
if (exports.length === 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const content = exports.join("\n");
|
|
63
|
+
await writeFile(join(dir, "index.ts"), content);
|
|
64
|
+
};
|
|
65
|
+
export const barrelExporting = async () => {
|
|
66
|
+
const directories = await getAllDirectories("./src/styles");
|
|
67
|
+
const sortedDirs = directories.sort((a, b) => getDirectoryDepth(b) - getDirectoryDepth(a));
|
|
68
|
+
for (const dir of sortedDirs) {
|
|
69
|
+
await generateIndexFile(dir);
|
|
70
|
+
}
|
|
71
|
+
await generateIndexFile("./src/styles");
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssToTs.d.ts","sourceRoot":"","sources":["../../src/lib/cssToTs.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,OAAO,qBAkBnB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cwd } from "node:process";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { writeFile } from "node:fs/promises";
|
|
4
|
+
import { walkDirectory, getFile, getMetaData } from "./fs-utils";
|
|
5
|
+
import { linesToKV, kvToChartFile, kvToColourFile } from "./syntax-utils";
|
|
6
|
+
const getCssStylePaths = async () => {
|
|
7
|
+
const stylesPath = join(cwd(), "src", "styles");
|
|
8
|
+
const paths = await walkDirectory(stylesPath);
|
|
9
|
+
return paths.filter((path) => path.endsWith(".css"));
|
|
10
|
+
};
|
|
11
|
+
export const cssToTs = async () => {
|
|
12
|
+
const paths = await getCssStylePaths();
|
|
13
|
+
await Promise.all(paths.map(async (path) => {
|
|
14
|
+
const file = await getFile(path);
|
|
15
|
+
const kv = linesToKV(file);
|
|
16
|
+
const metaData = getMetaData(path);
|
|
17
|
+
if (path.includes("/styles/colours")) {
|
|
18
|
+
const colorFile = kvToColourFile(kv, metaData.cssName);
|
|
19
|
+
await writeFile(join(metaData.tsPath), colorFile, "utf-8");
|
|
20
|
+
}
|
|
21
|
+
if (path.includes("/styles/themes/charts")) {
|
|
22
|
+
const chartFile = kvToChartFile(kv, metaData.cssName);
|
|
23
|
+
await writeFile(join(metaData.tsPath), chartFile, "utf-8");
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function walkDirectory(target: string): Promise<string[]>;
|
|
2
|
+
export declare function getFile(target: string): Promise<string>;
|
|
3
|
+
type MetaData = {
|
|
4
|
+
cssPath: string;
|
|
5
|
+
cssName: string;
|
|
6
|
+
tsName: string;
|
|
7
|
+
tsPath: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const getMetaData: (path: string) => MetaData;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=fs-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-utils.d.ts","sourceRoot":"","sources":["../../src/lib/fs-utils.ts"],"names":[],"mappings":"AAUA,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAoBrE;AAED,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG7D;AAkBD,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,QAU1C,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readdir, readFile, writeFile, mkdir, stat, } from "node:fs/promises";
|
|
2
|
+
import { cwd } from "node:process";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
export async function walkDirectory(target) {
|
|
5
|
+
const files = [];
|
|
6
|
+
async function traverse(dir) {
|
|
7
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
8
|
+
for (const entry of entries) {
|
|
9
|
+
const fullPath = join(dir, entry.name);
|
|
10
|
+
const entryStat = await stat(fullPath);
|
|
11
|
+
if (entryStat.isDirectory()) {
|
|
12
|
+
await traverse(fullPath);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
files.push(fullPath);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
await traverse(target);
|
|
20
|
+
return files;
|
|
21
|
+
}
|
|
22
|
+
export async function getFile(target) {
|
|
23
|
+
const result = await readFile(target, "utf-8");
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
async function getFiles(targets) {
|
|
27
|
+
return await Promise.all(targets.map(async (target) => {
|
|
28
|
+
return await getFile(target);
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
const getFileName = (path) => {
|
|
32
|
+
const routeParts = path.split("/");
|
|
33
|
+
if (!routeParts)
|
|
34
|
+
throw new Error("Not a path");
|
|
35
|
+
const fileName = routeParts.pop();
|
|
36
|
+
if (!fileName)
|
|
37
|
+
throw new Error("What is the point of pop anyway");
|
|
38
|
+
return fileName;
|
|
39
|
+
};
|
|
40
|
+
export const getMetaData = (path) => {
|
|
41
|
+
const cssName = getFileName(path);
|
|
42
|
+
const tsName = [cssName.split(".")[0], ".ts"].join("");
|
|
43
|
+
const tsPath = join(dirname(path), tsName);
|
|
44
|
+
return {
|
|
45
|
+
cssPath: path,
|
|
46
|
+
cssName,
|
|
47
|
+
tsPath,
|
|
48
|
+
tsName,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type ColorKV = {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const linesToKV: (content: string) => ColorKV[];
|
|
6
|
+
export declare const kvToColourFile: (content: ColorKV[], cssName: string) => string;
|
|
7
|
+
export declare const kvToChartFile: (content: ColorKV[], cssName: string) => string;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=syntax-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax-utils.d.ts","sourceRoot":"","sources":["../../src/lib/syntax-utils.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAYF,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,cAIxC,CAAC;AAMF,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,EAAE,EAAE,SAAS,MAAM,KAAG,MAUpE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO,EAAE,EAAE,SAAS,MAAM,KAAG,MAQnE,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const splitLines = (content) => {
|
|
2
|
+
return content.split("\n");
|
|
3
|
+
};
|
|
4
|
+
const isColor = (line) => {
|
|
5
|
+
return line.includes("--color");
|
|
6
|
+
};
|
|
7
|
+
const splitKv = (line) => {
|
|
8
|
+
let [key, value] = line.split(":");
|
|
9
|
+
if (!key || !value)
|
|
10
|
+
throw new Error("line is not color, use isColor");
|
|
11
|
+
key = key.trim();
|
|
12
|
+
value = value.trim();
|
|
13
|
+
key = key.slice(8);
|
|
14
|
+
value = value.slice(0, -1);
|
|
15
|
+
return { key, value };
|
|
16
|
+
};
|
|
17
|
+
export const linesToKV = (content) => {
|
|
18
|
+
const lines = splitLines(content).filter((line) => isColor(line));
|
|
19
|
+
const kvs = lines.map(splitKv);
|
|
20
|
+
return kvs;
|
|
21
|
+
};
|
|
22
|
+
const kebabToSnake = (item) => {
|
|
23
|
+
return item.replaceAll("-", "_");
|
|
24
|
+
};
|
|
25
|
+
export const kvToColourFile = (content, cssName) => {
|
|
26
|
+
const colorName = kebabToSnake(cssName.split(".")[0]);
|
|
27
|
+
let payload = `export const ${colorName} = {\n`;
|
|
28
|
+
content.forEach((item, index) => {
|
|
29
|
+
const key = item.key.split("-")[1];
|
|
30
|
+
const separator = index === content.length - 1 ? "" : ",";
|
|
31
|
+
payload += `\t"${key}":"${item.value}"${separator}\n`;
|
|
32
|
+
});
|
|
33
|
+
payload += `};`;
|
|
34
|
+
return payload;
|
|
35
|
+
};
|
|
36
|
+
export const kvToChartFile = (content, cssName) => {
|
|
37
|
+
const colorName = kebabToSnake(cssName.split(".")[0]);
|
|
38
|
+
let payload = `export const ${colorName} = [\n`;
|
|
39
|
+
content.forEach((item) => {
|
|
40
|
+
payload += `\t"${item.value}",\n`;
|
|
41
|
+
});
|
|
42
|
+
payload += `];`;
|
|
43
|
+
return payload;
|
|
44
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
declare const meta: Meta;
|
|
3
|
+
export default meta;
|
|
4
|
+
export declare const AllThemesStory: StoryObj;
|
|
5
|
+
export declare const Comparison: StoryObj;
|
|
6
|
+
export declare const LakePineBlend: StoryObj;
|
|
7
|
+
export declare const AuburnCoolBend: StoryObj;
|
|
8
|
+
export declare const SteelLakeBlend: StoryObj;
|
|
9
|
+
//# sourceMappingURL=ChartThemes.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartThemes.stories.d.ts","sourceRoot":"","sources":["../../src/stories/ChartThemes.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAiNtD,QAAA,MAAM,IAAI,EAAE,IAKX,CAAA;AAED,eAAe,IAAI,CAAA;AAEnB,eAAO,MAAM,cAAc,EAAE,QAG5B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,QAGxB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,QAM3B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QAM5B,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,QAM5B,CAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { linen_pine_blend, lake_maritime_blend, linen_auburn_blend, linen_aurora_blend, pine_warm_bend, pine_cool_bend, nickel_warm_bend, nickel_cool_bend, maritime_aurora_blend, steel_lake_blend, linen_warm_bend, linen_cool_bend, nickel_auburn_blend, aurora_auburn_blend, dust_maritime_pine, pine_maritime_blend, lake_warm_bend, aurora_linen_blend, auburn_cool_bend, linen_lake_blend, pine_warm_blend, pine_lake_blend, steel_cool_bend, steel_warm_bend, maritime_pine_blend, steel_pine_blend, lake_pine_blend, } from "../styles/themes/charts/twelve-tone";
|
|
4
|
+
const chartThemes = {
|
|
5
|
+
"Auburn Cool Bend": auburn_cool_bend,
|
|
6
|
+
"Aurora Auburn Blend": aurora_auburn_blend,
|
|
7
|
+
"Aurora Linen Blend": aurora_linen_blend,
|
|
8
|
+
"Dust Maritime Pine": dust_maritime_pine,
|
|
9
|
+
"Lake Maritime Blend": lake_maritime_blend,
|
|
10
|
+
"Lake Pine Blend": lake_pine_blend,
|
|
11
|
+
"Lake Warm Bend": lake_warm_bend,
|
|
12
|
+
"Linen Auburn Blend": linen_auburn_blend,
|
|
13
|
+
"Linen Aurora Blend": linen_aurora_blend,
|
|
14
|
+
"Linen Cool Bend": linen_cool_bend,
|
|
15
|
+
"Linen Lake Blend": linen_lake_blend,
|
|
16
|
+
"Linen Pine Blend": linen_pine_blend,
|
|
17
|
+
"Linen Warm Bend": linen_warm_bend,
|
|
18
|
+
"Maritime Aurora Blend": maritime_aurora_blend,
|
|
19
|
+
"Maritime Pine Blend": maritime_pine_blend,
|
|
20
|
+
"Nickel Auburn Blend": nickel_auburn_blend,
|
|
21
|
+
"Nickel Cool Bend": nickel_cool_bend,
|
|
22
|
+
"Nickel Warm Bend": nickel_warm_bend,
|
|
23
|
+
"Pine Cool Bend": pine_cool_bend,
|
|
24
|
+
"Pine Lake Blend": pine_lake_blend,
|
|
25
|
+
"Pine Maritime Blend": pine_maritime_blend,
|
|
26
|
+
"Pine Warm Bend": pine_warm_bend,
|
|
27
|
+
"Pine Warm Blend 2": pine_warm_blend,
|
|
28
|
+
"Steel Cool Bend": steel_cool_bend,
|
|
29
|
+
"Steel Lake Blend": steel_lake_blend,
|
|
30
|
+
"Steel Pine Blend": steel_pine_blend,
|
|
31
|
+
"Steel Warm Bend": steel_warm_bend,
|
|
32
|
+
};
|
|
33
|
+
function getContrastColor(hexColor) {
|
|
34
|
+
const hex = hexColor.replace("#", "");
|
|
35
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
36
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
37
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
38
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
39
|
+
return luminance > 0.5 ? "#000000" : "#ffffff";
|
|
40
|
+
}
|
|
41
|
+
function ThemeSwatch({ colors, name }) {
|
|
42
|
+
return (_jsxs("div", { style: { marginBottom: "24px" }, children: [_jsx("h3", { style: {
|
|
43
|
+
margin: "0 0 8px 0",
|
|
44
|
+
fontWeight: 600,
|
|
45
|
+
fontSize: "16px",
|
|
46
|
+
}, children: name }), _jsx("div", { style: {
|
|
47
|
+
display: "flex",
|
|
48
|
+
borderRadius: "8px",
|
|
49
|
+
overflow: "hidden",
|
|
50
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
|
|
51
|
+
}, children: colors.map((color, index) => (_jsx("div", { style: {
|
|
52
|
+
backgroundColor: color,
|
|
53
|
+
width: "50px",
|
|
54
|
+
height: "50px",
|
|
55
|
+
display: "flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
color: getContrastColor(color),
|
|
59
|
+
fontSize: "10px",
|
|
60
|
+
fontFamily: "monospace",
|
|
61
|
+
}, title: color, children: index + 1 }, index))) }), _jsx("div", { style: {
|
|
62
|
+
marginTop: "8px",
|
|
63
|
+
fontSize: "12px",
|
|
64
|
+
fontFamily: "monospace",
|
|
65
|
+
color: "#666",
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexWrap: "wrap",
|
|
68
|
+
gap: "8px",
|
|
69
|
+
}, children: colors.map((color, index) => (_jsx("span", { children: color }, index))) })] }));
|
|
70
|
+
}
|
|
71
|
+
function AllThemes() {
|
|
72
|
+
return (_jsxs("div", { style: { padding: "20px" }, children: [_jsx("h2", { style: { marginBottom: "24px" }, children: "Chart Colour Themes" }), _jsx("p", { style: { marginBottom: "32px", color: "#666" }, children: "Pre-blended colour combinations optimized for data visualization. Each theme provides 12 distinct colours suitable for charts with multiple data series." }), _jsx("div", { style: {
|
|
73
|
+
display: "grid",
|
|
74
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(600px, 1fr))",
|
|
75
|
+
gap: "24px",
|
|
76
|
+
}, children: Object.entries(chartThemes).map(([name, colors]) => (_jsx(ThemeSwatch, { name: name, colors: colors }, name))) })] }));
|
|
77
|
+
}
|
|
78
|
+
function ThemeComparison() {
|
|
79
|
+
const selectedThemes = [
|
|
80
|
+
{ name: "Lake Pine Blend", colors: lake_pine_blend },
|
|
81
|
+
{ name: "Auburn Cool Bend", colors: auburn_cool_bend },
|
|
82
|
+
{ name: "Steel Lake Blend", colors: steel_lake_blend },
|
|
83
|
+
{ name: "Linen Warm Bend", colors: linen_warm_bend },
|
|
84
|
+
];
|
|
85
|
+
return (_jsxs("div", { style: { padding: "20px" }, children: [_jsx("h2", { style: { marginBottom: "24px" }, children: "Theme Comparison" }), _jsx("p", { style: { marginBottom: "32px", color: "#666" }, children: "Side-by-side comparison of popular chart themes." }), _jsx("div", { style: { display: "flex", flexDirection: "column", gap: "32px" }, children: selectedThemes.map(({ name, colors }) => (_jsxs("div", { children: [_jsx("h3", { style: { margin: "0 0 12px 0", fontWeight: 600 }, children: name }), _jsx("div", { style: { display: "flex", gap: "4px" }, children: colors.map((color, index) => (_jsx("div", { style: {
|
|
86
|
+
backgroundColor: color,
|
|
87
|
+
width: "60px",
|
|
88
|
+
height: "80px",
|
|
89
|
+
borderRadius: "4px",
|
|
90
|
+
display: "flex",
|
|
91
|
+
alignItems: "flex-end",
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
paddingBottom: "8px",
|
|
94
|
+
color: getContrastColor(color),
|
|
95
|
+
fontSize: "10px",
|
|
96
|
+
fontFamily: "monospace",
|
|
97
|
+
}, children: color }, index))) })] }, name))) })] }));
|
|
98
|
+
}
|
|
99
|
+
const meta = {
|
|
100
|
+
title: "Design System/Colours/Chart Themes",
|
|
101
|
+
parameters: {
|
|
102
|
+
layout: "fullscreen",
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
export default meta;
|
|
106
|
+
export const AllThemesStory = {
|
|
107
|
+
name: "All Themes",
|
|
108
|
+
render: () => _jsx(AllThemes, {}),
|
|
109
|
+
};
|
|
110
|
+
export const Comparison = {
|
|
111
|
+
name: "Theme Comparison",
|
|
112
|
+
render: () => _jsx(ThemeComparison, {}),
|
|
113
|
+
};
|
|
114
|
+
export const LakePineBlend = {
|
|
115
|
+
render: () => (_jsx("div", { style: { padding: "20px" }, children: _jsx(ThemeSwatch, { name: "Lake Pine Blend", colors: lake_pine_blend }) })),
|
|
116
|
+
};
|
|
117
|
+
export const AuburnCoolBend = {
|
|
118
|
+
render: () => (_jsx("div", { style: { padding: "20px" }, children: _jsx(ThemeSwatch, { name: "Auburn Cool Bend", colors: auburn_cool_bend }) })),
|
|
119
|
+
};
|
|
120
|
+
export const SteelLakeBlend = {
|
|
121
|
+
render: () => (_jsx("div", { style: { padding: "20px" }, children: _jsx(ThemeSwatch, { name: "Steel Lake Blend", colors: steel_lake_blend }) })),
|
|
122
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
type ColourScale = Record<string, string>;
|
|
3
|
+
declare const colourScales: Record<string, ColourScale>;
|
|
4
|
+
interface SingleScaleProps {
|
|
5
|
+
scaleName: keyof typeof colourScales;
|
|
6
|
+
}
|
|
7
|
+
declare const meta: Meta;
|
|
8
|
+
export default meta;
|
|
9
|
+
export declare const AllScalesStory: StoryObj;
|
|
10
|
+
export declare const Auburn: StoryObj<SingleScaleProps>;
|
|
11
|
+
export declare const Lake: StoryObj<SingleScaleProps>;
|
|
12
|
+
export declare const Pine: StoryObj<SingleScaleProps>;
|
|
13
|
+
export declare const Steel: StoryObj<SingleScaleProps>;
|
|
14
|
+
export declare const Amethyst: StoryObj<SingleScaleProps>;
|
|
15
|
+
export declare const Aurora: StoryObj<SingleScaleProps>;
|
|
16
|
+
export declare const Cerulean: StoryObj<SingleScaleProps>;
|
|
17
|
+
export declare const Charcoal: StoryObj<SingleScaleProps>;
|
|
18
|
+
export declare const Copper: StoryObj<SingleScaleProps>;
|
|
19
|
+
export declare const Emerald: StoryObj<SingleScaleProps>;
|
|
20
|
+
export declare const Linen: StoryObj<SingleScaleProps>;
|
|
21
|
+
export declare const Maritime: StoryObj<SingleScaleProps>;
|
|
22
|
+
export declare const Nickel: StoryObj<SingleScaleProps>;
|
|
23
|
+
export declare const Sienna: StoryObj<SingleScaleProps>;
|
|
24
|
+
//# sourceMappingURL=ColourScales.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColourScales.stories.d.ts","sourceRoot":"","sources":["../../src/stories/ColourScales.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAmBtD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEzC,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAe7C,CAAA;AAuGD,UAAU,gBAAgB;IACtB,SAAS,EAAE,MAAM,OAAO,YAAY,CAAA;CACvC;AAaD,QAAA,MAAM,IAAI,EAAE,IAKX,CAAA;AAED,eAAe,IAAI,CAAA;AAEnB,eAAO,MAAM,cAAc,EAAE,QAG5B,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAE7C,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,gBAAgB,CAE3C,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,gBAAgB,CAE3C,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAE/C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAE7C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAE/C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAE/C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAE7C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAE9C,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAE5C,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAE/C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAE7C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAE7C,CAAA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { amethyst, auburn, aurora, cerulean, charcoal, copper, emerald, lake, linen, maritime, nickel, pine, sienna, steel, } from "../styles/colours";
|
|
4
|
+
const colourScales = {
|
|
5
|
+
amethyst,
|
|
6
|
+
auburn,
|
|
7
|
+
aurora,
|
|
8
|
+
cerulean,
|
|
9
|
+
charcoal,
|
|
10
|
+
copper,
|
|
11
|
+
emerald,
|
|
12
|
+
lake,
|
|
13
|
+
linen,
|
|
14
|
+
maritime,
|
|
15
|
+
nickel,
|
|
16
|
+
pine,
|
|
17
|
+
sienna,
|
|
18
|
+
steel,
|
|
19
|
+
};
|
|
20
|
+
// Get shades in numeric order from an actual scale object
|
|
21
|
+
function getOrderedShades(scale) {
|
|
22
|
+
return Object.keys(scale).sort((a, b) => parseInt(a) - parseInt(b));
|
|
23
|
+
}
|
|
24
|
+
function getContrastColor(hexColor) {
|
|
25
|
+
if (!hexColor)
|
|
26
|
+
return "#000000";
|
|
27
|
+
const hex = hexColor.replace("#", "");
|
|
28
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
29
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
30
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
31
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
32
|
+
return luminance > 0.5 ? "#000000" : "#ffffff";
|
|
33
|
+
}
|
|
34
|
+
function Swatch({ shade, hex, scaleName }) {
|
|
35
|
+
if (!hex)
|
|
36
|
+
return null;
|
|
37
|
+
const textColor = getContrastColor(hex);
|
|
38
|
+
const cssVar = `--color-${scaleName}-${shade}`;
|
|
39
|
+
return (_jsxs("div", { style: {
|
|
40
|
+
backgroundColor: hex,
|
|
41
|
+
color: textColor,
|
|
42
|
+
padding: "12px 16px",
|
|
43
|
+
display: "flex",
|
|
44
|
+
justifyContent: "space-between",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
fontFamily: "monospace",
|
|
47
|
+
fontSize: "13px",
|
|
48
|
+
}, children: [_jsx("span", { style: { fontWeight: 600 }, children: shade }), _jsx("span", { children: hex })] }));
|
|
49
|
+
}
|
|
50
|
+
function ColourScaleDisplay({ name, scale }) {
|
|
51
|
+
const shades = getOrderedShades(scale);
|
|
52
|
+
return (_jsxs("div", { style: { marginBottom: "32px" }, children: [_jsx("h3", { style: {
|
|
53
|
+
margin: "0 0 8px 0",
|
|
54
|
+
textTransform: "capitalize",
|
|
55
|
+
fontWeight: 600,
|
|
56
|
+
fontSize: "18px",
|
|
57
|
+
}, children: name }), _jsx("div", { style: {
|
|
58
|
+
borderRadius: "8px",
|
|
59
|
+
overflow: "hidden",
|
|
60
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.12)",
|
|
61
|
+
}, children: shades.map((shade) => (_jsx(Swatch, { shade: shade, hex: scale[shade], scaleName: name }, shade))) })] }));
|
|
62
|
+
}
|
|
63
|
+
function AllScales() {
|
|
64
|
+
return (_jsx("div", { style: {
|
|
65
|
+
display: "grid",
|
|
66
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(280px, 1fr))",
|
|
67
|
+
gap: "24px",
|
|
68
|
+
padding: "20px",
|
|
69
|
+
}, children: Object.entries(colourScales).map(([name, scale]) => (_jsx(ColourScaleDisplay, { name: name, scale: scale }, name))) }));
|
|
70
|
+
}
|
|
71
|
+
function SingleScale({ scaleName }) {
|
|
72
|
+
const scale = colourScales[scaleName];
|
|
73
|
+
if (!scale)
|
|
74
|
+
return null;
|
|
75
|
+
return (_jsx("div", { style: { padding: "20px", maxWidth: "400px" }, children: _jsx(ColourScaleDisplay, { name: scaleName, scale: scale }) }));
|
|
76
|
+
}
|
|
77
|
+
const meta = {
|
|
78
|
+
title: "Design System/Colours/Scales",
|
|
79
|
+
parameters: {
|
|
80
|
+
layout: "fullscreen",
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
export default meta;
|
|
84
|
+
export const AllScalesStory = {
|
|
85
|
+
name: "All Scales",
|
|
86
|
+
render: () => _jsx(AllScales, {}),
|
|
87
|
+
};
|
|
88
|
+
export const Auburn = {
|
|
89
|
+
render: () => _jsx(SingleScale, { scaleName: "auburn" }),
|
|
90
|
+
};
|
|
91
|
+
export const Lake = {
|
|
92
|
+
render: () => _jsx(SingleScale, { scaleName: "lake" }),
|
|
93
|
+
};
|
|
94
|
+
export const Pine = {
|
|
95
|
+
render: () => _jsx(SingleScale, { scaleName: "pine" }),
|
|
96
|
+
};
|
|
97
|
+
export const Steel = {
|
|
98
|
+
render: () => _jsx(SingleScale, { scaleName: "steel" }),
|
|
99
|
+
};
|
|
100
|
+
export const Amethyst = {
|
|
101
|
+
render: () => _jsx(SingleScale, { scaleName: "amethyst" }),
|
|
102
|
+
};
|
|
103
|
+
export const Aurora = {
|
|
104
|
+
render: () => _jsx(SingleScale, { scaleName: "aurora" }),
|
|
105
|
+
};
|
|
106
|
+
export const Cerulean = {
|
|
107
|
+
render: () => _jsx(SingleScale, { scaleName: "cerulean" }),
|
|
108
|
+
};
|
|
109
|
+
export const Charcoal = {
|
|
110
|
+
render: () => _jsx(SingleScale, { scaleName: "charcoal" }),
|
|
111
|
+
};
|
|
112
|
+
export const Copper = {
|
|
113
|
+
render: () => _jsx(SingleScale, { scaleName: "copper" }),
|
|
114
|
+
};
|
|
115
|
+
export const Emerald = {
|
|
116
|
+
render: () => _jsx(SingleScale, { scaleName: "emerald" }),
|
|
117
|
+
};
|
|
118
|
+
export const Linen = {
|
|
119
|
+
render: () => _jsx(SingleScale, { scaleName: "linen" }),
|
|
120
|
+
};
|
|
121
|
+
export const Maritime = {
|
|
122
|
+
render: () => _jsx(SingleScale, { scaleName: "maritime" }),
|
|
123
|
+
};
|
|
124
|
+
export const Nickel = {
|
|
125
|
+
render: () => _jsx(SingleScale, { scaleName: "nickel" }),
|
|
126
|
+
};
|
|
127
|
+
export const Sienna = {
|
|
128
|
+
render: () => _jsx(SingleScale, { scaleName: "sienna" }),
|
|
129
|
+
};
|