lapikit 0.7.1 → 0.7.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.
@@ -1,5 +1,6 @@
1
1
  import { DEV } from 'esm-env';
2
2
  import { makeComponentProps } from '../html-mapped';
3
+ import { colorStyle } from './color.js';
3
4
  const endsWithSeparator = /[^a-zA-Z0-9]$/;
4
5
  const startsWithSeparator = /^[^a-zA-Z0-9]/;
5
6
  const whitespace = /\s/;
@@ -224,15 +225,21 @@ export function useElevation(elevation) {
224
225
  * ({ active: isActive } -> active). The s-class_xxx directives (class:xxx on a kit tag) keep their
225
226
  * rule: class:gap={4} -> gap-4.
226
227
  *
227
- * @param baseClass - The class of the component ('kit-btn-v2'), '' for none.
228
- * @param props - The class, s-class, style and s-style props of the component.
228
+ * @param baseClass - The class of the component ('kit-btn'), '' for none.
229
+ * The color prop gives the --{baseClass}-color / --{baseClass}-on-color variables, read by the
230
+ * color mixin; they come before the style, so the style attribute still wins.
231
+ * With { base, active }, active picks the color of the active state.
232
+ *
233
+ * @param props - The class, s-class, style, s-style, color and active props of the component.
229
234
  * @param rest - The rest of the props: the s-class_xxx / s-style_xxx directives are taken out of it.
230
235
  */
231
- export function useComponentAttrs(baseClass, { className, sClass, styleAttr, sStyle }, rest) {
236
+ export function useComponentAttrs(baseClass, { className, sClass, styleAttr, sStyle, color, active }, rest) {
232
237
  const { classProps, styleProps, restProps } = makeComponentProps(rest);
233
238
  return {
234
239
  class: [baseClass, sClass, directiveClasses(classProps), className],
235
- style: useStyles({ styleAttr, sStyle, styleProps }),
240
+ style: [colorStyle(baseClass, color, active), useStyles({ styleAttr, sStyle, styleProps })]
241
+ .filter(Boolean)
242
+ .join('; '),
236
243
  rest: restProps
237
244
  };
238
245
  }
@@ -1,2 +1,3 @@
1
1
  export * from './components.js';
2
2
  export * from './outside.js';
3
+ export * from './color.js';
@@ -1,2 +1,3 @@
1
1
  export * from './components.js';
2
2
  export * from './outside.js';
3
+ export * from './color.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lapikit",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"