clampography 2.0.0-beta.1 → 2.0.0-beta.3

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.1",
3
+ "version": "2.0.0-beta.3",
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
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Base typography and reset styles converted from base.css
2
+ * Base typography and layout styles (structure only, no colors).
3
+ * Converted from base.css.
3
4
  */
4
5
  export default {
5
- // Global CSS Variables
6
+ // Global CSS Variables (Spacing & Fonts)
6
7
  "@layer base": {
7
8
  ":root": {
8
9
  "--spacing-sm": "clamp(0.75rem, 0.5625rem + 0.9375vw, 1.25rem)",
@@ -17,7 +18,7 @@ export default {
17
18
  },
18
19
  },
19
20
 
20
- // Typography & Resets
21
+ // Body Structure
21
22
  "body": {
22
23
  "font-family": "var(--font-family-base)",
23
24
  "font-size": "clamp(1rem, 0.95rem + 0.25vw, 1.125rem)",
@@ -28,6 +29,7 @@ export default {
28
29
  "text-wrap": "pretty",
29
30
  },
30
31
 
32
+ // Headings Structure
31
33
  ":where(h1, h2, h3, h4, h5, h6)": {
32
34
  "font-weight": "700",
33
35
  "scroll-margin-top": "var(--scroll-offset)",
@@ -54,6 +56,7 @@ export default {
54
56
  "margin-bottom": "var(--spacing-xs)",
55
57
  },
56
58
 
59
+ // Links
57
60
  "a": {
58
61
  "text-decoration-line": "underline",
59
62
  "text-decoration-thickness": "0.0625em",
@@ -66,6 +69,7 @@ export default {
66
69
  "text-decoration": "none",
67
70
  },
68
71
 
72
+ // Lists & Menus
69
73
  "menu": {
70
74
  "list-style": "none",
71
75
  "margin-bottom": "var(--spacing-md)",
@@ -98,6 +102,7 @@ export default {
98
102
  "margin-top": "0",
99
103
  },
100
104
 
105
+ // Inline elements
101
106
  ":where(strong, b)": {
102
107
  "font-weight": "700",
103
108
  },
@@ -179,6 +184,7 @@ export default {
179
184
  "font-variant-numeric": "tabular-nums",
180
185
  },
181
186
 
187
+ // Blockquotes
182
188
  "blockquote": {
183
189
  "margin-top": "0",
184
190
  "margin-bottom": "0",
@@ -195,6 +201,7 @@ export default {
195
201
  "font-style": "inherit",
196
202
  },
197
203
 
204
+ // Lists
198
205
  ":where(ul, ol)": {
199
206
  "list-style": "none",
200
207
  "margin-bottom": "0",
@@ -222,7 +229,6 @@ export default {
222
229
  "top": "calc(0.875em - 0.1875em)",
223
230
  "width": "0.375em",
224
231
  "height": "0.375em",
225
- "background-color": "currentColor",
226
232
  "border-radius": "50%",
227
233
  },
228
234
 
@@ -243,7 +249,6 @@ export default {
243
249
  "width": "1.75em",
244
250
  "text-align": "right",
245
251
  "font-weight": "600",
246
- "color": "currentColor",
247
252
  },
248
253
 
249
254
  ":where(ul, ol) :where(ul, ol)": {
@@ -281,6 +286,7 @@ export default {
281
286
  "margin-bottom": "0",
282
287
  },
283
288
 
289
+ // Pre / Code
284
290
  "pre": {
285
291
  "margin-top": "var(--spacing-md)",
286
292
  "margin-bottom": "var(--spacing-md)",
@@ -293,10 +299,10 @@ export default {
293
299
  "pre code": {
294
300
  "font-size": "inherit",
295
301
  "padding": "0",
296
- "background": "none",
297
302
  "border-radius": "0",
298
303
  },
299
304
 
305
+ // Fieldset & Form
300
306
  "fieldset": {
301
307
  "margin-top": "var(--spacing-md)",
302
308
  "margin-bottom": "var(--spacing-md)",
@@ -319,6 +325,7 @@ export default {
319
325
  "vertical-align": "middle",
320
326
  },
321
327
 
328
+ // Media
322
329
  ":where(img, video)": {
323
330
  "max-width": "100%",
324
331
  "height": "auto",
@@ -337,6 +344,7 @@ export default {
337
344
  "line-height": "1.5",
338
345
  },
339
346
 
347
+ // Tables
340
348
  "table": {
341
349
  "width": "100%",
342
350
  "margin-top": "0",
@@ -371,12 +379,14 @@ export default {
371
379
  "border-top-width": "2px",
372
380
  },
373
381
 
382
+ // Horizontal Rule
374
383
  "hr": {
375
384
  "margin-top": "var(--spacing-xl)",
376
385
  "margin-bottom": "var(--spacing-xl)",
377
386
  "border": "0",
378
387
  },
379
388
 
389
+ // Interactive
380
390
  ":where(:focus, :focus-visible)": {
381
391
  "outline-offset": "2px",
382
392
  },
@@ -400,6 +410,7 @@ export default {
400
410
  "line-height": "inherit",
401
411
  },
402
412
 
413
+ // Resets
403
414
  "ul": {
404
415
  "margin-top": "0",
405
416
  "margin-bottom": "0",
@@ -414,11 +425,6 @@ export default {
414
425
  },
415
426
 
416
427
  "@media print": {
417
- "body": {
418
- "font-size": "12pt",
419
- "line-height": "1.5",
420
- "color": "#000",
421
- },
422
428
  "table": {
423
429
  "break-inside": "avoid",
424
430
  },
package/src/extra.js CHANGED
@@ -1,34 +1,138 @@
1
+ /**
2
+ * Extra opinionated styles and coloring.
3
+ * Applies colors to the structural base elements.
4
+ */
1
5
  export default {
6
+ // --- Basic Coloring (Applying theme variables) ---
7
+
8
+ "body": {
9
+ "background-color": "var(--clampography-background)",
10
+ "color": "var(--clampography-text)",
11
+ },
12
+
13
+ ":where(h1, h2, h3, h4, h5, h6)": {
14
+ "color": "var(--clampography-heading)",
15
+ },
16
+
17
+ "a": {
18
+ "color": "var(--clampography-link)",
19
+ },
20
+
21
+ // Lists
22
+ "ul > li::before": {
23
+ "background-color": "var(--clampography-primary)", // Bullet points
24
+ },
25
+
26
+ "ol > li::before": {
27
+ "color": "var(--clampography-secondary)", // Numbers
28
+ },
29
+
30
+ // Inline Code
31
+ ":where(code, kbd, samp)": {
32
+ "background-color": "var(--clampography-surface)",
33
+ "color": "var(--clampography-heading)",
34
+ "border": "1px solid var(--clampography-border)",
35
+ "border-radius": "0.25rem",
36
+ },
37
+
38
+ // Preformatted Code Blocks
39
+ "pre": {
40
+ "background-color": "var(--clampography-surface)",
41
+ "border": "1px solid var(--clampography-border)",
42
+ "border-radius": "0.375rem",
43
+ "padding": "1rem",
44
+ },
45
+
46
+ // Tables
47
+ "th": {
48
+ "color": "var(--clampography-heading)",
49
+ },
50
+
51
+ "th, td": {
52
+ "border-bottom": "1px solid var(--clampography-border)",
53
+ },
54
+
55
+ "thead th": {
56
+ "border-bottom-width": "2px",
57
+ },
58
+
59
+ // Captions & Muted text
60
+ "caption, figcaption, .muted": {
61
+ "color": "var(--clampography-muted)",
62
+ },
63
+
64
+ // Horizontal Rule (Thematic)
2
65
  "hr": {
3
66
  "height": "1px",
4
67
  "border-width": "0",
5
- "margin-top": "3rem", /* my-12 (12 * 0.25rem) */
6
- "margin-bottom": "3rem", /* my-12 */
7
- "background-color": "var(--clampography-secondary)",
68
+ "margin-top": "3rem",
69
+ "margin-bottom": "3rem",
70
+ "background-color": "var(--clampography-border)",
8
71
  },
9
72
 
73
+ // --- Opinionated Extras ---
74
+
75
+ // Styled Blockquote
10
76
  "blockquote": {
11
77
  "border-left-width": "4px",
12
- "border-color": "var(--clampography-primary)",
13
- "padding-left": "1rem", /* pl-4 */
14
- "padding-top": "0.5rem", /* py-2 */
15
- "padding-bottom": "0.5rem", /* py-2 */
16
- "padding-right": "0.5rem", /* pr-2 */
78
+ "border-left-color": "var(--clampography-primary)",
79
+ "background-color": "var(--clampography-surface)",
80
+ "padding": "1rem",
81
+ "border-radius": "0.25rem",
82
+ "font-style": "italic",
83
+ "color": "var(--clampography-heading)",
17
84
  },
18
85
 
86
+ // Styled Links (Enhanced)
19
87
  "a": {
20
- "color": "var(--clampography-link)",
21
- "font-weight": "700", /* font-bold */
22
- "letter-spacing": "0.025em", /* tracking-wide */
88
+ "font-weight": "700",
89
+ "letter-spacing": "0.025em",
23
90
  "text-decoration-line": "underline",
24
- "text-decoration-thickness": "2px", /* decoration-2 */
25
- "text-underline-offset": "4px", /* underline-offset-4 */
91
+ "text-decoration-thickness": "2px",
92
+ "text-underline-offset": "4px",
26
93
  "transition-property": "color, text-decoration-color",
27
- "transition-duration": "150ms", /* duration-150 */
94
+ "transition-duration": "150ms",
28
95
  },
29
96
 
30
97
  "a:hover": {
31
- // Używamy zmiennej zdefiniowanej w themes.js (bez prefixu --color-)
32
98
  "text-decoration-color": "var(--clampography-primary)",
33
99
  },
100
+
101
+ // Mark
102
+ "mark": {
103
+ "background-color": "var(--clampography-primary)",
104
+ "color": "var(--clampography-background)",
105
+ },
106
+
107
+ // Deleted Text
108
+ "del": {
109
+ "text-decoration-color": "var(--clampography-secondary)",
110
+ "text-decoration-thickness": "2px",
111
+ },
112
+
113
+ // Fieldset
114
+ "fieldset": {
115
+ "border": "1px solid var(--clampography-border)",
116
+ "border-radius": "0.375rem",
117
+ },
118
+
119
+ "legend": {
120
+ "color": "var(--clampography-heading)",
121
+ },
122
+
123
+ // Details
124
+ "details": {
125
+ "border": "1px solid var(--clampography-border)",
126
+ "border-radius": "0.375rem",
127
+ "padding": "0.5rem",
128
+ },
129
+
130
+ "summary": {
131
+ "color": "var(--clampography-heading)",
132
+ },
133
+
134
+ "details[open] > summary": {
135
+ "border-bottom": "1px solid var(--clampography-border)",
136
+ "padding-bottom": "0.5rem",
137
+ },
34
138
  };
@@ -1,66 +1,76 @@
1
1
  import plugin from "tailwindcss/plugin";
2
-
3
- // List of required color keys for validation (optional but good practice)
4
- const REQUIRED_KEYS = [
5
- "--clampography-background",
6
- "--clampography-text",
7
- "--clampography-link",
8
- "--clampography-primary",
9
- "--clampography-secondary",
10
- ];
2
+ import { themes as builtInThemes } from "./themes.js";
11
3
 
12
4
  export default plugin.withOptions((options = {}) => {
13
5
  return ({ addBase }) => {
14
6
  // 1. Extract metadata
15
7
  const themeName = options.name;
16
8
  const isDefault = options.default ?? false;
17
- const isPrefersDark = options.prefersdark ?? false; // lowercase because CSS might force it
9
+ const isPrefersDark = options.prefersdark ?? false;
18
10
  const rootSelector = options.root ?? ":root";
11
+ // Nowa opcja: color-scheme (defaults to 'light' if not specified)
12
+ const colorScheme = options["color-scheme"] ?? "light";
19
13
 
20
14
  if (!themeName) {
21
15
  console.warn("Clampography: Theme definition missing 'name' property.");
22
16
  return;
23
17
  }
24
18
 
25
- // 2. Extract colors from options
26
- // We iterate over the options object and pick anything that looks like our CSS variable
27
- // or simply take all known keys.
28
- const themeColors = {};
19
+ // 2. Prepare Base Colors (Fallback)
20
+ // We fetch the full palette of the requested color scheme (light/dark)
21
+ // to fill in any missing gaps in the user's definition.
22
+ const fallbackTheme = builtInThemes[colorScheme] || builtInThemes["light"];
29
23
 
30
- // You can also support short aliases here if you want (e.g., 'primary' -> '--clampography-primary')
31
- // For now, let's assume user passes full variable names or mapped keys.
24
+ // 3. Extract & Merge Colors
25
+ const themeColors = {};
32
26
 
33
- // Helper to map simplified keys to full CSS vars (optional convenience)
27
+ // Mapping of simplified keys to full CSS variable names
34
28
  const keyMap = {
35
29
  "background": "--clampography-background",
30
+ "surface": "--clampography-surface",
31
+ "border": "--clampography-border",
32
+ "heading": "--clampography-heading",
36
33
  "text": "--clampography-text",
34
+ "muted": "--clampography-muted",
37
35
  "link": "--clampography-link",
38
36
  "primary": "--clampography-primary",
39
37
  "secondary": "--clampography-secondary",
40
38
  };
41
39
 
40
+ // First, populate with fallback colors
41
+ Object.keys(fallbackTheme).forEach((key) => {
42
+ themeColors[key] = fallbackTheme[key];
43
+ });
44
+
45
+ // Then override with user provided values
42
46
  Object.keys(options).forEach((key) => {
43
- // Check if it's one of our mapped short keys
47
+ // Ignore metadata keys
48
+ if (
49
+ ["name", "default", "prefersdark", "root", "color-scheme"].includes(key)
50
+ ) return;
51
+
44
52
  if (keyMap[key]) {
45
53
  themeColors[keyMap[key]] = options[key];
46
- } // Or if it is already a custom property key (starts with --)
47
- else if (key.startsWith("--")) {
54
+ } else if (key.startsWith("--")) {
48
55
  themeColors[key] = options[key];
49
56
  }
50
57
  });
51
58
 
52
- // 3. Generate Styles
59
+ // Add the CSS property 'color-scheme' for browser UI adaptation (scrollbars, etc.)
60
+ themeColors["color-scheme"] = colorScheme;
61
+
62
+ // 4. Generate Styles
53
63
  const styles = {};
54
64
 
55
- // A. Define the theme as a named data-theme (always available)
65
+ // A. Define the theme as a named data-theme
56
66
  styles[`[data-theme="${themeName}"]`] = themeColors;
57
67
 
58
- // B. If marked as default, apply to :root
68
+ // B. If default, apply to root
59
69
  if (isDefault) {
60
70
  styles[rootSelector] = themeColors;
61
71
  }
62
72
 
63
- // C. If marked as prefers-dark, apply to media query
73
+ // C. If prefers-dark, apply to media query
64
74
  if (isPrefersDark) {
65
75
  styles["@media (prefers-color-scheme: dark)"] = {
66
76
  [rootSelector]: themeColors,
package/src/themes.js CHANGED
@@ -1,28 +1,48 @@
1
1
  export const themes = {
2
2
  light: {
3
+ "color-scheme": "light",
3
4
  "--clampography-background": "#ffffff",
4
- "--clampography-text": "#1f2937",
5
+ "--clampography-surface": "#f3f4f6",
6
+ "--clampography-border": "#e5e7eb",
7
+ "--clampography-heading": "#111827",
8
+ "--clampography-text": "#374151",
9
+ "--clampography-muted": "#6b7280",
5
10
  "--clampography-link": "#2563eb",
6
11
  "--clampography-primary": "#3b82f6",
7
12
  "--clampography-secondary": "#9333ea",
8
13
  },
9
14
  dark: {
15
+ "color-scheme": "dark",
10
16
  "--clampography-background": "#0f172a",
11
- "--clampography-text": "#f3f4f6",
17
+ "--clampography-surface": "#1e293b",
18
+ "--clampography-border": "#334155",
19
+ "--clampography-heading": "#f8fafc",
20
+ "--clampography-text": "#cbd5e1",
21
+ "--clampography-muted": "#94a3b8",
12
22
  "--clampography-link": "#60a5fa",
13
23
  "--clampography-primary": "#3b82f6",
14
24
  "--clampography-secondary": "#a855f7",
15
25
  },
16
26
  retro: {
27
+ "color-scheme": "light",
17
28
  "--clampography-background": "#ece3ca",
18
- "--clampography-text": "#2c2420",
29
+ "--clampography-surface": "#e0d6b6",
30
+ "--clampography-border": "#cbbd99",
31
+ "--clampography-heading": "#2c2420",
32
+ "--clampography-text": "#4a3b32",
33
+ "--clampography-muted": "#756354",
19
34
  "--clampography-link": "#d97757",
20
35
  "--clampography-primary": "#e45f2b",
21
36
  "--clampography-secondary": "#f6c342",
22
37
  },
23
38
  cyberpunk: {
39
+ "color-scheme": "dark",
24
40
  "--clampography-background": "#000b1e",
41
+ "--clampography-surface": "#051630",
42
+ "--clampography-border": "#0f3661",
43
+ "--clampography-heading": "#ffffff",
25
44
  "--clampography-text": "#00f0ff",
45
+ "--clampography-muted": "#008f99",
26
46
  "--clampography-link": "#ff0099",
27
47
  "--clampography-primary": "#fcee0a",
28
48
  "--clampography-secondary": "#05ffa1",