clampography 2.0.0-beta.11 → 2.0.0-beta.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clampography",
3
- "version": "2.0.0-beta.11",
3
+ "version": "2.0.0-beta.13",
4
4
  "description": "Fluid typography system based on CSS clamp() with optional themes and extra styles. A feature-rich alternative to Tailwind CSS Typography plugin.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/base.js CHANGED
@@ -83,8 +83,6 @@ export default {
83
83
  // LINKS - Clickable Text (Structural Indicators)
84
84
  a: {
85
85
  "text-decoration-line": "underline",
86
- "text-decoration-thickness": "0.0625em",
87
- "text-underline-offset": "0.15em",
88
86
  cursor: "pointer",
89
87
  },
90
88
 
package/src/extra.js CHANGED
@@ -1,37 +1,44 @@
1
- /**
2
- * Extra opinionated styles and coloring.
3
- * Applies colors to the structural base elements.
4
- */
5
-
6
1
  export default {
7
2
  // --- Basic Coloring (Applying theme variables) ---
8
3
  "body": {
9
- "background-color": "oklch(var(--clampography-background))",
10
- "color": "oklch(var(--clampography-text))",
4
+ "background-color": "var(--clampography-background)",
5
+ "color": "var(--clampography-text)",
11
6
  },
12
7
 
13
8
  ":where(h1, h2, h3, h4, h5, h6)": {
14
- "color": "oklch(var(--clampography-heading))",
9
+ "color": "var(--clampography-heading)",
15
10
  },
16
11
 
12
+ // Styled Links (Enhanced)
17
13
  "a": {
18
- "color": "oklch(var(--clampography-link))",
14
+ "color": "var(--clampography-link)",
15
+ "font-weight": "600",
16
+ "letter-spacing": "0.025em",
17
+ "text-decoration-line": "underline",
18
+ "text-decoration-thickness": "2px",
19
+ "text-underline-offset": "4px",
20
+ "transition-property": "color, text-decoration-color",
21
+ "transition-duration": "150ms",
22
+ },
23
+
24
+ "a:hover": {
25
+ "text-decoration-color": "var(--clampography-link)",
19
26
  },
20
27
 
21
28
  // Lists
22
29
  "ul > li::before": {
23
- "background-color": "oklch(var(--clampography-primary))", // Bullet points
30
+ "background-color": "var(--clampography-primary)", // Bullet points
24
31
  },
25
32
 
26
33
  "ol > li::before": {
27
- "color": "oklch(var(--clampography-secondary))", // Numbers
34
+ "color": "var(--clampography-secondary)", // Numbers
28
35
  },
29
36
 
30
37
  // Inline Code
31
38
  ":where(code, kbd, samp)": {
32
- "background-color": "oklch(var(--clampography-surface))",
33
- "color": "oklch(var(--clampography-heading))",
34
- "border": "1px solid oklch(var(--clampography-border))",
39
+ "background-color": "var(--clampography-surface)",
40
+ "color": "var(--clampography-heading)",
41
+ "border": "1px solid var(--clampography-border)",
35
42
  "border-radius": "0.25rem",
36
43
  "padding": "0.125rem var(--spacing-xs)",
37
44
  },
@@ -43,8 +50,8 @@ export default {
43
50
 
44
51
  // Preformatted Code Blocks
45
52
  "pre": {
46
- "background-color": "oklch(var(--clampography-surface))",
47
- "border": "1px solid oklch(var(--clampography-border))",
53
+ "background-color": "var(--clampography-surface)",
54
+ "border": "1px solid var(--clampography-border)",
48
55
  "border-radius": "0.375rem",
49
56
  "padding": "1rem",
50
57
  },
@@ -52,15 +59,15 @@ export default {
52
59
  // Tables
53
60
  "table": {
54
61
  "padding": "var(--spacing-sm)",
55
- "border": "1px solid oklch(var(--clampography-border))",
62
+ "border": "1px solid var(--clampography-border)",
56
63
  },
57
64
 
58
65
  "th": {
59
- "color": "oklch(var(--clampography-heading))",
66
+ "color": "var(--clampography-heading)",
60
67
  },
61
68
 
62
69
  "th, td": {
63
- "border": "1px solid oklch(var(--clampography-border))",
70
+ "border": "1px solid var(--clampography-border)",
64
71
  },
65
72
 
66
73
  "thead th": {
@@ -69,12 +76,12 @@ export default {
69
76
 
70
77
  // Zebra striping for table rows
71
78
  "tbody tr:nth-child(even)": {
72
- "background-color": "oklch(var(--clampography-surface))",
79
+ "background-color": "var(--clampography-surface)",
73
80
  },
74
81
 
75
82
  // Captions & Muted text
76
83
  "caption, figcaption, .muted": {
77
- "color": "oklch(var(--clampography-muted))",
84
+ "color": "var(--clampography-muted)",
78
85
  },
79
86
 
80
87
  // Horizontal Rule (Thematic)
@@ -83,88 +90,73 @@ export default {
83
90
  "border-width": "0",
84
91
  "margin-top": "3rem",
85
92
  "margin-bottom": "3rem",
86
- "background-color": "oklch(var(--clampography-border))",
93
+ "background-color": "var(--clampography-border)",
87
94
  },
88
95
 
89
- // --- Opinionated Extras ---
90
-
91
96
  // Styled Blockquote
92
97
  "blockquote": {
93
98
  "border-left-width": "4px",
94
- "border-left-color": "oklch(var(--clampography-primary))",
95
- "background-color": "oklch(var(--clampography-surface))",
99
+ "border-left-color": "var(--clampography-primary)",
100
+ "background-color": "var(--clampography-surface)",
96
101
  "padding": "1rem",
97
102
  "border-radius": "0.25rem",
98
103
  "font-style": "italic",
99
- "color": "oklch(var(--clampography-heading))",
100
- },
101
-
102
- // Styled Links (Enhanced)
103
- "a": {
104
- "font-weight": "700",
105
- "letter-spacing": "0.025em",
106
- "text-decoration-line": "underline",
107
- "text-decoration-thickness": "2px",
108
- "text-underline-offset": "4px",
109
- "transition-property": "color, text-decoration-color",
110
- "transition-duration": "150ms",
111
- },
112
-
113
- "a:hover": {
114
- "text-decoration-color": "oklch(var(--clampography-primary))",
104
+ "color": "var(--clampography-heading)",
115
105
  },
116
106
 
117
107
  // Mark
118
108
  "mark": {
119
- "background-color": "oklch(var(--clampography-primary))",
120
- "color": "oklch(var(--clampography-background))",
109
+ "background-color": "var(--clampography-primary)",
110
+ "color": "var(--clampography-background)",
121
111
  "padding": "0.125rem var(--spacing-xs)",
122
112
  "border-radius": "0.25rem",
123
113
  },
124
114
 
125
115
  // Deleted Text
126
116
  "del": {
127
- "text-decoration-color": "oklch(var(--clampography-secondary))",
117
+ "text-decoration-color": "var(--clampography-secondary)",
128
118
  "text-decoration-thickness": "2px",
129
119
  },
130
120
 
131
121
  // Buttons - All types
122
+ // WILL BE REMOVED FROM THIS FILE
132
123
  ":where(button, [type='button'], [type='reset'], [type='submit'])": {
133
124
  "padding": "var(--spacing-xs) var(--spacing-sm)",
134
- "border": "1px solid oklch(var(--clampography-border))",
125
+ "border": "1px solid var(--clampography-border)",
135
126
  "border-radius": "0.375rem", // ← Rounded corners
136
127
  },
137
128
 
138
129
  // Inputs - All types
130
+ // WILL BE REMOVED FROM THIS FILE
139
131
  ":where(input:not([type='checkbox'], [type='radio']), textarea, select)": {
140
132
  "padding": "var(--spacing-xs) var(--spacing-sm)",
141
- "border": "1px solid oklch(var(--clampography-border))",
133
+ "border": "1px solid var(--clampography-border)",
142
134
  "border-radius": "0.375rem", // ← Rounded corners
143
135
  },
144
136
 
145
137
  // Fieldset
146
138
  "fieldset": {
147
- "border": "1px solid oklch(var(--clampography-border))",
139
+ "border": "1px solid var(--clampography-border)",
148
140
  "border-radius": "0.375rem",
149
141
  },
150
142
 
151
143
  "legend": {
152
- "color": "oklch(var(--clampography-heading))",
144
+ "color": "var(--clampography-heading)",
153
145
  },
154
146
 
155
147
  // Details
156
148
  "details": {
157
- "border": "1px solid oklch(var(--clampography-border))",
149
+ "border": "1px solid var(--clampography-border)",
158
150
  "border-radius": "0.375rem",
159
151
  "padding": "0.5rem",
160
152
  },
161
153
 
162
154
  "summary": {
163
- "color": "oklch(var(--clampography-heading))",
155
+ "color": "var(--clampography-heading)",
164
156
  },
165
157
 
166
158
  "details[open] > summary": {
167
- "border-bottom": "1px solid oklch(var(--clampography-border))",
159
+ "border-bottom": "1px solid var(--clampography-border)",
168
160
  "padding-bottom": "0.5rem",
169
161
  },
170
162
  };
package/src/index.js CHANGED
@@ -33,6 +33,7 @@ export default plugin.withOptions(
33
33
  let defaultThemeName = null;
34
34
  let prefersDarkTheme = false;
35
35
  let rootSelector = options.root ?? ":root";
36
+ let isAllThemes = false; // Track if user specified "all"
36
37
 
37
38
  // Normalize input to an array of strings
38
39
  let rawThemeList = [];
@@ -40,6 +41,7 @@ export default plugin.withOptions(
40
41
  if (typeof configThemes === "string") {
41
42
  if (["all", "true", "yes"].includes(configThemes.trim())) {
42
43
  // Special case: themes: all
44
+ isAllThemes = true;
43
45
  rawThemeList = Object.keys(builtInThemes);
44
46
  } else if (["false", "none", "no"].includes(configThemes.trim())) {
45
47
  // Explicitly disabled themes
@@ -85,7 +87,19 @@ export default plugin.withOptions(
85
87
  themesToInclude.length === 0 && !defaultThemeName && !prefersDarkTheme
86
88
  ) return;
87
89
 
88
- // 4. Generate CSS
90
+ // 4. Auto-configure defaults for "themes: all"
91
+ // If user didn't specify --default or --prefersdark flags,
92
+ // automatically set light as default and dark for prefers-color-scheme
93
+ if (isAllThemes) {
94
+ if (!defaultThemeName && themesToInclude.includes("light")) {
95
+ defaultThemeName = "light";
96
+ }
97
+ if (!prefersDarkTheme && themesToInclude.includes("dark")) {
98
+ prefersDarkTheme = "dark";
99
+ }
100
+ }
101
+
102
+ // 5. Generate CSS
89
103
  const themeStyles = {};
90
104
 
91
105
  // A. Default theme (:root)
@@ -114,19 +128,19 @@ export default plugin.withOptions(
114
128
  theme: {
115
129
  extend: {
116
130
  colors: {
117
- background: "oklch(var(--clampography-background) / <alpha-value>)",
118
- border: "oklch(var(--clampography-border) / <alpha-value>)",
119
- error: "oklch(var(--clampography-error) / <alpha-value>)",
120
- heading: "oklch(var(--clampography-heading) / <alpha-value>)",
121
- info: "oklch(var(--clampography-info) / <alpha-value>)",
122
- link: "oklch(var(--clampography-link) / <alpha-value>)",
123
- muted: "oklch(var(--clampography-muted) / <alpha-value>)",
124
- primary: "oklch(var(--clampography-primary) / <alpha-value>)",
125
- secondary: "oklch(var(--clampography-secondary) / <alpha-value>)",
126
- success: "oklch(var(--clampography-success) / <alpha-value>)",
127
- surface: "oklch(var(--clampography-surface) / <alpha-value>)",
128
- text: "oklch(var(--clampography-text) / <alpha-value>)",
129
- warning: "oklch(var(--clampography-warning) / <alpha-value>)",
131
+ background: "var(--clampography-background)",
132
+ border: "var(--clampography-border)",
133
+ error: "var(--clampography-error)",
134
+ heading: "var(--clampography-heading)",
135
+ info: "var(--clampography-info)",
136
+ link: "var(--clampography-link)",
137
+ muted: "var(--clampography-muted)",
138
+ primary: "var(--clampography-primary)",
139
+ secondary: "var(--clampography-secondary)",
140
+ success: "var(--clampography-success)",
141
+ surface: "var(--clampography-surface)",
142
+ text: "var(--clampography-text)",
143
+ warning: "var(--clampography-warning)",
130
144
  },
131
145
  },
132
146
  },
@@ -53,10 +53,38 @@ export default plugin.withOptions((options = {}) => {
53
53
  ["name", "default", "prefersdark", "root", "color-scheme"].includes(key)
54
54
  ) return;
55
55
 
56
+ const value = options[key];
57
+
56
58
  if (keyMap[key]) {
57
- themeColors[keyMap[key]] = options[key];
59
+ // Validate color format for better DX
60
+ if (value && typeof value === "string") {
61
+ // Check if value starts with oklch() or is a valid CSS color
62
+ const isOklch = value.trim().startsWith("oklch(");
63
+ const isHex = /^#[0-9A-Fa-f]{3,8}$/.test(value.trim());
64
+ const isRgb = value.trim().startsWith("rgb(") ||
65
+ value.trim().startsWith("rgba(");
66
+
67
+ if (!isOklch && !isHex && !isRgb) {
68
+ console.warn(
69
+ `Clampography (${themeName}): Color "${key}" has value "${value}" which may not be a valid color format. ` +
70
+ `For best compatibility with opacity modifiers (e.g., bg-${key}/20), use full OKLCH format: ` +
71
+ `oklch(70% 0.2 180) or oklch(0.7 0.2 180)`,
72
+ );
73
+ }
74
+
75
+ if (isHex || isRgb) {
76
+ console.info(
77
+ `Clampography (${themeName}): Color "${key}" uses ${
78
+ isHex ? "HEX" : "RGB"
79
+ } format. ` +
80
+ `Consider using OKLCH format for better color space support and smoother gradients.`,
81
+ );
82
+ }
83
+ }
84
+
85
+ themeColors[keyMap[key]] = value;
58
86
  } else if (key.startsWith("--")) {
59
- themeColors[key] = options[key];
87
+ themeColors[key] = value;
60
88
  }
61
89
  });
62
90
 
package/src/themes.js CHANGED
@@ -1,67 +1,67 @@
1
1
  export const themes = {
2
2
  light: {
3
3
  "color-scheme": "light",
4
- "--clampography-background": "100% 0 0",
5
- "--clampography-border": "92% 0.003 264",
6
- "--clampography-error": "63% 0.22 27",
7
- "--clampography-heading": "15% 0.02 264",
8
- "--clampography-info": "63% 0.258 262",
9
- "--clampography-link": "43% 0.19 264",
10
- "--clampography-muted": "52% 0.014 258",
11
- "--clampography-primary": "63% 0.258 262",
12
- "--clampography-secondary": "55% 0.28 300",
13
- "--clampography-success": "65% 0.17 165",
14
- "--clampography-surface": "96% 0.003 264",
15
- "--clampography-text": "31% 0.02 257",
16
- "--clampography-warning": "72% 0.17 65",
4
+ "--clampography-background": "oklch(100% 0 0)",
5
+ "--clampography-border": "oklch(92% 0.003 264)",
6
+ "--clampography-error": "oklch(63% 0.22 27)",
7
+ "--clampography-heading": "oklch(15% 0.02 264)",
8
+ "--clampography-info": "oklch(63% 0.258 262)",
9
+ "--clampography-link": "oklch(43% 0.19 264)",
10
+ "--clampography-muted": "oklch(52% 0.014 258)",
11
+ "--clampography-primary": "oklch(63% 0.258 262)",
12
+ "--clampography-secondary": "oklch(55% 0.28 300)",
13
+ "--clampography-success": "oklch(65% 0.17 165)",
14
+ "--clampography-surface": "oklch(96% 0.003 264)",
15
+ "--clampography-text": "oklch(31% 0.02 257)",
16
+ "--clampography-warning": "oklch(72% 0.17 65)",
17
17
  },
18
18
  dark: {
19
19
  "color-scheme": "dark",
20
- "--clampography-background": "10% 0 0",
21
- "--clampography-border": "31% 0.03 254",
22
- "--clampography-error": "63% 0.22 27",
23
- "--clampography-heading": "98% 0.003 264",
24
- "--clampography-info": "72% 0.17 254",
25
- "--clampography-link": "72% 0.17 254",
26
- "--clampography-muted": "68% 0.024 254",
27
- "--clampography-primary": "63% 0.258 262",
28
- "--clampography-secondary": "63% 0.25 300",
29
- "--clampography-success": "65% 0.17 165",
30
- "--clampography-surface": "12% 0 0",
31
- "--clampography-text": "95% 0 0",
32
- "--clampography-warning": "72% 0.17 65",
20
+ "--clampography-background": "oklch(10% 0 0)",
21
+ "--clampography-border": "oklch(31% 0.03 254)",
22
+ "--clampography-error": "oklch(63% 0.22 27)",
23
+ "--clampography-heading": "oklch(98% 0.003 264)",
24
+ "--clampography-info": "oklch(72% 0.17 254)",
25
+ "--clampography-link": "oklch(72% 0.17 254)",
26
+ "--clampography-muted": "oklch(68% 0.024 254)",
27
+ "--clampography-primary": "oklch(63% 0.258 262)",
28
+ "--clampography-secondary": "oklch(63% 0.25 300)",
29
+ "--clampography-success": "oklch(65% 0.17 165)",
30
+ "--clampography-surface": "oklch(12% 0 0)",
31
+ "--clampography-text": "oklch(95% 0 0)",
32
+ "--clampography-warning": "oklch(72% 0.17 65)",
33
33
  },
34
34
  retro: {
35
35
  "color-scheme": "light",
36
- "--clampography-background": "91% 0.03 85",
37
- "--clampography-border": "78% 0.05 85",
38
- "--clampography-error": "52% 0.15 35",
39
- "--clampography-heading": "18% 0.02 35",
40
- "--clampography-info": "60% 0.06 230",
41
- "--clampography-link": "63% 0.13 40",
42
- "--clampography-muted": "44% 0.03 45",
43
- "--clampography-primary": "60% 0.19 35",
44
- "--clampography-secondary": "80% 0.14 85",
45
- "--clampography-success": "62% 0.10 130",
46
- "--clampography-surface": "87% 0.04 85",
47
- "--clampography-text": "28% 0.03 40",
48
- "--clampography-warning": "80% 0.14 85",
36
+ "--clampography-background": "oklch(91% 0.03 85)",
37
+ "--clampography-border": "oklch(78% 0.05 85)",
38
+ "--clampography-error": "oklch(52% 0.15 35)",
39
+ "--clampography-heading": "oklch(18% 0.02 35)",
40
+ "--clampography-info": "oklch(60% 0.06 230)",
41
+ "--clampography-link": "oklch(63% 0.13 40)",
42
+ "--clampography-muted": "oklch(44% 0.03 45)",
43
+ "--clampography-primary": "oklch(60% 0.19 35)",
44
+ "--clampography-secondary": "oklch(80% 0.14 85)",
45
+ "--clampography-success": "oklch(62% 0.10 130)",
46
+ "--clampography-surface": "oklch(87% 0.04 85)",
47
+ "--clampography-text": "oklch(28% 0.03 40)",
48
+ "--clampography-warning": "oklch(80% 0.14 85)",
49
49
  },
50
50
  cyberpunk: {
51
51
  "color-scheme": "dark",
52
- "--clampography-background": "8% 0.04 264",
53
- "--clampography-border": "27% 0.09 254",
54
- "--clampography-error": "60% 0.29 340",
55
- "--clampography-heading": "100% 0 0",
56
- "--clampography-info": "88% 0.16 195",
57
- "--clampography-link": "60% 0.29 340",
58
- "--clampography-muted": "55% 0.07 200",
59
- "--clampography-primary": "93% 0.22 105",
60
- "--clampography-secondary": "87% 0.20 165",
61
- "--clampography-success": "87% 0.20 165",
62
- "--clampography-surface": "12% 0.05 264",
63
- "--clampography-text": "88% 0.16 195",
64
- "--clampography-warning": "93% 0.22 105",
52
+ "--clampography-background": "oklch(8% 0.04 264)",
53
+ "--clampography-border": "oklch(27% 0.09 254)",
54
+ "--clampography-error": "oklch(60% 0.29 340)",
55
+ "--clampography-heading": "oklch(100% 0 0)",
56
+ "--clampography-info": "oklch(88% 0.16 195)",
57
+ "--clampography-link": "oklch(60% 0.29 340)",
58
+ "--clampography-muted": "oklch(55% 0.07 200)",
59
+ "--clampography-primary": "oklch(93% 0.22 105)",
60
+ "--clampography-secondary": "oklch(87% 0.20 165)",
61
+ "--clampography-success": "oklch(87% 0.20 165)",
62
+ "--clampography-surface": "oklch(12% 0.05 264)",
63
+ "--clampography-text": "oklch(88% 0.16 195)",
64
+ "--clampography-warning": "oklch(93% 0.22 105)",
65
65
  },
66
66
  };
67
67