@texturehq/edges 1.2.1 → 1.3.1

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/dist/theme.css CHANGED
@@ -13,6 +13,12 @@
13
13
  @import "./generated/tailwind-tokens-light.css";
14
14
  @import "./generated/tailwind-tokens-dark.css";
15
15
 
16
+ /* Data visualization colors loaded separately due to Tailwind 4 @theme filtering
17
+ See: https://github.com/tailwindlabs/tailwindcss/issues/XXXXX
18
+ These variables are also in tailwind-tokens-light.css but Tailwind strips them
19
+ from the @theme block, so we load them separately in a plain :root block. */
20
+ @import "./generated/viz-runtime.css";
21
+
16
22
  /* Layer 2: Animation Features
17
23
  Keyframes and animation utilities that aren't design tokens */
18
24
  @import "./styles/animations.css";
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.2.1",
3
- "generatedAt": "2025-10-06T20:37:56.814Z",
2
+ "version": "1.3.1",
3
+ "generatedAt": "2025-10-09T16:15:03.889Z",
4
4
  "categories": {
5
5
  "hooks": {
6
6
  "description": "React hooks for common functionality like debouncing, local storage, and time controls",
@@ -1776,6 +1776,26 @@
1776
1776
  "colors": {
1777
1777
  "description": "Color management utilities for theme-aware color resolution, contrast calculation, and palette generation",
1778
1778
  "utilities": [
1779
+ {
1780
+ "name": "calculateBounds",
1781
+ "type": "constant",
1782
+ "description": "Calculate min and max bounds from numeric values",
1783
+ "params": [],
1784
+ "returns": null,
1785
+ "example": null,
1786
+ "category": "colors",
1787
+ "file": "utils/colors.ts"
1788
+ },
1789
+ {
1790
+ "name": "calculateCenter",
1791
+ "type": "constant",
1792
+ "description": "Calculate center point for diverging palettes",
1793
+ "params": [],
1794
+ "returns": null,
1795
+ "example": null,
1796
+ "category": "colors",
1797
+ "file": "utils/colors.ts"
1798
+ },
1779
1799
  {
1780
1800
  "name": "clearColorCache",
1781
1801
  "type": "function",
@@ -1796,6 +1816,16 @@
1796
1816
  "category": "colors",
1797
1817
  "file": "utils/colors.ts"
1798
1818
  },
1819
+ {
1820
+ "name": "createCategoricalMapping",
1821
+ "type": "constant",
1822
+ "description": "Creates a categorical color mapping for use with vector layers or explicit mappings This is a helper for cases where categorical auto-assignment doesn't work: - Vector tile layers (data not accessible at render time) - URL-based GeoJSON layers - Custom pin layers // Vector layer with categorical coloring layer.vector({ tileset: \"mapbox://my-tileset\", sourceLayer: \"buildings\", style: { color: createCategoricalMapping(\"type\", [\"residential\", \"commercial\", \"industrial\"]) } }) // With custom colors for specific values const mapping = createCategoricalMapping(\"status\", [\"active\", \"pending\", \"inactive\"]); // Then override specific colors if needed: mapping.mapping.inactive = { hex: \"#cccccc\" };",
1823
+ "params": [],
1824
+ "returns": null,
1825
+ "example": "// Vector layer with categorical coloring\nlayer.vector({\n tileset: \"mapbox://my-tileset\",\n sourceLayer: \"buildings\",\n style: {\n color: createCategoricalMapping(\"type\", [\"residential\", \"commercial\", \"industrial\"])\n }\n})",
1826
+ "category": "colors",
1827
+ "file": "utils/colors.ts"
1828
+ },
1799
1829
  {
1800
1830
  "name": "createCategoryColorMap",
1801
1831
  "type": "constant",
@@ -1816,6 +1846,46 @@
1816
1846
  "category": "colors",
1817
1847
  "file": "utils/colors.ts"
1818
1848
  },
1849
+ {
1850
+ "name": "createDivergingMapping",
1851
+ "type": "constant",
1852
+ "description": "Creates a diverging color mapping for vector layers or manual bounds Use this helper when categorical auto-assignment doesn't work: - Vector tile layers (data not accessible at render time) - URL-based GeoJSON layers - When you want consistent colors across multiple maps // Vector layer with diverging coloring layer.vector({ tileset: \"mapbox://my-tileset\", sourceLayer: \"temperature\", style: { color: createDivergingMapping(\"temp_anomaly\", { min: -10, max: 10 }, 0, \"orangeYellowSeafoam\") } })",
1853
+ "params": [],
1854
+ "returns": null,
1855
+ "example": "// Vector layer with diverging coloring\nlayer.vector({\n tileset: \"mapbox://my-tileset\",\n sourceLayer: \"temperature\",\n style: {\n color: createDivergingMapping(\"temp_anomaly\", { min: -10, max: 10 }, 0, \"orangeYellowSeafoam\")\n }\n})",
1856
+ "category": "colors",
1857
+ "file": "utils/colors.ts"
1858
+ },
1859
+ {
1860
+ "name": "createSequentialMapping",
1861
+ "type": "constant",
1862
+ "description": "Creates a sequential color mapping for vector layers or manual bounds Use this helper when categorical auto-assignment doesn't work: - Vector tile layers (data not accessible at render time) - URL-based GeoJSON layers - When you want consistent colors across multiple maps // Vector layer with sequential coloring layer.vector({ tileset: \"mapbox://my-tileset\", sourceLayer: \"population\", style: { color: createSequentialMapping(\"density\", { min: 0, max: 100000 }, \"magma\") } })",
1863
+ "params": [],
1864
+ "returns": null,
1865
+ "example": "// Vector layer with sequential coloring\nlayer.vector({\n tileset: \"mapbox://my-tileset\",\n sourceLayer: \"population\",\n style: {\n color: createSequentialMapping(\"density\", { min: 0, max: 100000 }, \"magma\")\n }\n})",
1866
+ "category": "colors",
1867
+ "file": "utils/colors.ts"
1868
+ },
1869
+ {
1870
+ "name": "extractNumericValues",
1871
+ "type": "constant",
1872
+ "description": "Extract numeric values from GeoJSON data for sequential/diverging palettes",
1873
+ "params": [],
1874
+ "returns": null,
1875
+ "example": null,
1876
+ "category": "colors",
1877
+ "file": "utils/colors.ts"
1878
+ },
1879
+ {
1880
+ "name": "extractUniqueValues",
1881
+ "type": "constant",
1882
+ "description": "Extracts unique values for a given property from GeoJSON FeatureCollection",
1883
+ "params": [],
1884
+ "returns": null,
1885
+ "example": null,
1886
+ "category": "colors",
1887
+ "file": "utils/colors.ts"
1888
+ },
1819
1889
  {
1820
1890
  "name": "getContrastingTextColor",
1821
1891
  "type": "function",
@@ -1848,10 +1918,19 @@
1848
1918
  },
1849
1919
  {
1850
1920
  "name": "getDivergingColors",
1851
- "type": "constant",
1852
- "description": "Gets diverging colors from a specific palette",
1853
- "params": [],
1854
- "returns": null,
1921
+ "type": "function",
1922
+ "description": "Get colors for a specific diverging palette",
1923
+ "params": [
1924
+ {
1925
+ "name": "scheme",
1926
+ "type": "unknown",
1927
+ "description": "Diverging palette name (defaults to \"redYellowBlue\")"
1928
+ }
1929
+ ],
1930
+ "returns": {
1931
+ "type": "unknown",
1932
+ "description": "Array of 10 hex color strings (color 5 is the center)"
1933
+ },
1855
1934
  "example": null,
1856
1935
  "category": "colors",
1857
1936
  "file": "utils/colors.ts"
@@ -1859,7 +1938,7 @@
1859
1938
  {
1860
1939
  "name": "getResolvedColor",
1861
1940
  "type": "constant",
1862
- "description": "Resolves a CSS variable to its computed color value Supports both var(--name) format and plain --name format",
1941
+ "description": "Resolves a CSS variable to its computed color value Supports multiple formats and automatically adds the color- prefix if needed - \"brand-primary\" → resolves to --color-brand-primary - \"color-brand-primary\" → resolves to --color-brand-primary - \"--color-brand-primary\" → used as-is - \"var(--color-brand-primary)\" unwrapped and used",
1863
1942
  "params": [],
1864
1943
  "returns": null,
1865
1944
  "example": null,
@@ -1868,10 +1947,19 @@
1868
1947
  },
1869
1948
  {
1870
1949
  "name": "getSequentialColors",
1871
- "type": "constant",
1872
- "description": "Gets sequential colors from a specific palette",
1873
- "params": [],
1874
- "returns": null,
1950
+ "type": "function",
1951
+ "description": "Get colors for a specific sequential palette",
1952
+ "params": [
1953
+ {
1954
+ "name": "scheme",
1955
+ "type": "unknown",
1956
+ "description": "Sequential palette name (defaults to \"viridis\")"
1957
+ }
1958
+ ],
1959
+ "returns": {
1960
+ "type": "unknown",
1961
+ "description": "Array of 10 hex color strings"
1962
+ },
1875
1963
  "example": null,
1876
1964
  "category": "colors",
1877
1965
  "file": "utils/colors.ts"
@@ -1895,6 +1983,16 @@
1895
1983
  "example": null,
1896
1984
  "category": "colors",
1897
1985
  "file": "utils/colors.ts"
1986
+ },
1987
+ {
1988
+ "name": "mapValuesToCategoricalColors",
1989
+ "type": "constant",
1990
+ "description": "Maps unique values to categorical colors with looping",
1991
+ "params": [],
1992
+ "returns": null,
1993
+ "example": null,
1994
+ "category": "colors",
1995
+ "file": "utils/colors.ts"
1898
1996
  }
1899
1997
  ]
1900
1998
  },
@@ -1935,7 +2033,7 @@
1935
2033
  }
1936
2034
  },
1937
2035
  "summary": {
1938
- "totalUtilities": 193,
2036
+ "totalUtilities": 201,
1939
2037
  "totalCategories": 5,
1940
2038
  "categories": [
1941
2039
  {
@@ -1952,7 +2050,7 @@
1952
2050
  },
1953
2051
  {
1954
2052
  "name": "colors",
1955
- "count": 12
2053
+ "count": 20
1956
2054
  },
1957
2055
  {
1958
2056
  "name": "general",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@texturehq/edges",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "author": "Nicholas Brown <nick@texturehq.com>",
5
5
  "description": "A shared component library for Texture",
6
6
  "type": "module",
@@ -33,6 +33,7 @@ try {
33
33
  const tokenFiles = [
34
34
  "src/generated/tailwind-tokens-light.css",
35
35
  "src/generated/tailwind-tokens-dark.css",
36
+ "src/generated/viz-runtime.css",
36
37
  ];
37
38
 
38
39
  // Create generated directory in dist
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Generate viz-runtime.css from Style Dictionary output
3
+ *
4
+ * WORKAROUND: Tailwind 4's @theme directive filters out viz color variables,
5
+ * so we extract them and create a separate runtime file with plain :root and
6
+ * .theme-dark blocks.
7
+ *
8
+ * This script should run after Style Dictionary generates the token files.
9
+ */
10
+
11
+ import fs from "fs";
12
+ import path from "path";
13
+
14
+ const GENERATED_DIR = "src/generated";
15
+ const LIGHT_TOKENS = path.join(GENERATED_DIR, "tailwind-tokens-light.css");
16
+ const DARK_TOKENS = path.join(GENERATED_DIR, "tailwind-tokens-dark.css");
17
+ const OUTPUT_FILE = path.join(GENERATED_DIR, "viz-runtime.css");
18
+
19
+ /**
20
+ * Extract viz color variables from a CSS file
21
+ */
22
+ function extractVizColors(cssContent) {
23
+ const vizColorRegex = /^\s*(--color-viz-[^:]+:\s*[^;]+;)\s*$/gm;
24
+ const matches = [];
25
+ let match;
26
+
27
+ while ((match = vizColorRegex.exec(cssContent)) !== null) {
28
+ matches.push(match[1]);
29
+ }
30
+
31
+ return matches;
32
+ }
33
+
34
+ /**
35
+ * Generate the viz-runtime.css file
36
+ */
37
+ function generateVizRuntime() {
38
+ console.log("🎨 Generating viz-runtime.css...");
39
+
40
+ // Read token files
41
+ const lightContent = fs.readFileSync(LIGHT_TOKENS, "utf8");
42
+ const darkContent = fs.readFileSync(DARK_TOKENS, "utf8");
43
+
44
+ // Extract viz colors
45
+ const lightVizColors = extractVizColors(lightContent);
46
+ const darkVizColors = extractVizColors(darkContent);
47
+
48
+ if (lightVizColors.length === 0) {
49
+ console.warn("⚠️ No viz colors found in light theme tokens");
50
+ }
51
+
52
+ if (darkVizColors.length === 0) {
53
+ console.warn("⚠️ No viz colors found in dark theme tokens");
54
+ }
55
+
56
+ // Generate output
57
+ const output = `/**
58
+ * Data Visualization Color Palette - Runtime Override
59
+ *
60
+ * WORKAROUND: These variables are defined here instead of in tailwind-tokens-*.css
61
+ * because Tailwind 4's @theme directive filters them out (similar issue as data-* prefix).
62
+ *
63
+ * AUTO-GENERATED by scripts/generate-viz-runtime.js
64
+ * DO NOT EDIT MANUALLY - Edit tokens/base/data-visualization.json instead.
65
+ *
66
+ * To customize dark mode viz colors, edit the "viz" section in tokens/themes/dark.json
67
+ */
68
+
69
+ /* Light theme (default) */
70
+ :root {
71
+ ${lightVizColors.map((color) => ` ${color}`).join("\n")}
72
+ }
73
+
74
+ /* Dark theme */
75
+ .theme-dark {
76
+ ${darkVizColors.map((color) => ` ${color}`).join("\n")}
77
+ }
78
+ `;
79
+
80
+ // Write output
81
+ fs.writeFileSync(OUTPUT_FILE, output, "utf8");
82
+
83
+ console.log(`✅ Generated ${OUTPUT_FILE}`);
84
+ console.log(` - Light theme: ${lightVizColors.length} variables`);
85
+ console.log(` - Dark theme: ${darkVizColors.length} variables`);
86
+ }
87
+
88
+ // Run the script
89
+ try {
90
+ generateVizRuntime();
91
+ } catch (error) {
92
+ console.error("❌ Error generating viz-runtime.css:", error);
93
+ process.exit(1);
94
+ }
95
+