clampography 2.0.0-beta.13 → 2.0.0-beta.14

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.13",
3
+ "version": "2.0.0-beta.14",
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/index.js CHANGED
@@ -99,23 +99,28 @@ export default plugin.withOptions(
99
99
  }
100
100
  }
101
101
 
102
- // 5. Generate CSS
102
+ // 5. Generate CSS (daisyUI v5 approach)
103
103
  const themeStyles = {};
104
104
 
105
- // A. Default theme (:root)
105
+ // A. Default theme - uses :where() for lower specificity
106
106
  if (defaultThemeName && builtInThemes[defaultThemeName]) {
107
- themeStyles[rootSelector] = builtInThemes[defaultThemeName];
107
+ const defaultSelector =
108
+ `:where(${rootSelector}),[data-theme="${defaultThemeName}"]`;
109
+ themeStyles[defaultSelector] = builtInThemes[defaultThemeName];
108
110
  }
109
111
 
110
- // B. Theme for prefers-color-scheme: dark
112
+ // B. Theme for prefers-color-scheme: dark - only applies to root selector
111
113
  if (prefersDarkTheme && builtInThemes[prefersDarkTheme]) {
112
114
  themeStyles["@media (prefers-color-scheme: dark)"] = {
113
115
  [rootSelector]: builtInThemes[prefersDarkTheme],
114
116
  };
115
117
  }
116
118
 
117
- // C. Scoped styles [data-theme="..."]
119
+ // C. All themes available via [data-theme] attribute
118
120
  themesToInclude.forEach((themeName) => {
121
+ // Skip if already added as default (to avoid duplication)
122
+ if (themeName === defaultThemeName) return;
123
+
119
124
  themeStyles[`[data-theme="${themeName}"]`] = builtInThemes[themeName];
120
125
  });
121
126
 
@@ -91,18 +91,21 @@ export default plugin.withOptions((options = {}) => {
91
91
  // Add the CSS property 'color-scheme' for browser UI adaptation (scrollbars, etc.)
92
92
  themeColors["color-scheme"] = colorScheme;
93
93
 
94
- // 4. Generate Styles
94
+ // 4. Generate Styles (daisyUI v5 approach)
95
95
  const styles = {};
96
96
 
97
- // A. Define the theme as a named data-theme
98
- styles[`[data-theme="${themeName}"]`] = themeColors;
97
+ // Build selector based on flags
98
+ let selector = `[data-theme="${themeName}"]`;
99
99
 
100
- // B. If default, apply to root
100
+ // If default, prepend :where(root) with lower specificity
101
101
  if (isDefault) {
102
- styles[rootSelector] = themeColors;
102
+ selector = `:where(${rootSelector}),${selector}`;
103
103
  }
104
104
 
105
- // C. If prefers-dark, apply to media query
105
+ // Apply theme to the constructed selector
106
+ styles[selector] = themeColors;
107
+
108
+ // If prefers-dark, apply only to root selector in media query
106
109
  if (isPrefersDark) {
107
110
  styles["@media (prefers-color-scheme: dark)"] = {
108
111
  [rootSelector]: themeColors,