@just-web/css 0.1.0 → 0.2.0

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.
Files changed (35) hide show
  1. package/esm/css-properties/css-properties.d.ts +27 -0
  2. package/esm/css-properties/css-properties.d.ts.map +1 -0
  3. package/esm/css-properties/css-properties.js +20 -0
  4. package/esm/css-properties/css-properties.js.map +1 -0
  5. package/esm/index.d.ts +4 -3
  6. package/esm/index.d.ts.map +1 -1
  7. package/esm/index.js +4 -3
  8. package/esm/index.js.map +1 -1
  9. package/esm/props/class-name.d.ts.map +1 -0
  10. package/esm/props/class-name.js.map +1 -0
  11. package/esm/{style.d.ts → props/style.d.ts} +1 -1
  12. package/esm/props/style.d.ts.map +1 -0
  13. package/esm/props/style.js.map +1 -0
  14. package/esm/utils/get-css-prop-values.d.ts +17 -0
  15. package/esm/utils/get-css-prop-values.d.ts.map +1 -0
  16. package/esm/utils/get-css-prop-values.js +8 -0
  17. package/esm/utils/get-css-prop-values.js.map +1 -0
  18. package/package.json +5 -3
  19. package/src/css-properties/css-properties.ts +30 -0
  20. package/src/index.ts +4 -3
  21. package/src/{style.ts → props/style.ts} +1 -1
  22. package/src/utils/get-css-prop-values.ts +29 -0
  23. package/esm/class-name.d.ts.map +0 -1
  24. package/esm/class-name.js.map +0 -1
  25. package/esm/css-properties.d.ts +0 -10
  26. package/esm/css-properties.d.ts.map +0 -1
  27. package/esm/css-properties.js +0 -2
  28. package/esm/css-properties.js.map +0 -1
  29. package/esm/style.d.ts.map +0 -1
  30. package/esm/style.js.map +0 -1
  31. package/src/css-properties.ts +0 -10
  32. /package/esm/{class-name.d.ts → props/class-name.d.ts} +0 -0
  33. /package/esm/{class-name.js → props/class-name.js} +0 -0
  34. /package/esm/{style.js → props/style.js} +0 -0
  35. /package/src/{class-name.ts → props/class-name.ts} +0 -0
@@ -0,0 +1,27 @@
1
+ import type { Properties } from 'csstype';
2
+ /**
3
+ * Extends CSS properties to include custom properties.
4
+ * Allows for string or number values for standard properties,
5
+ * and string values for custom properties with '--' prefix.
6
+ */
7
+ export interface CSSProperties extends Properties<string | number> {
8
+ [k: `--${string}`]: string;
9
+ }
10
+ /**
11
+ * Defines CSS properties including custom properties.
12
+ * This function is used to properly type CSS properties when defining styles,
13
+ * especially when using CSS custom properties (variables).
14
+ *
15
+ * @param style - CSS properties object that can include both standard and custom properties
16
+ * @returns The same style object with proper typing
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * defineCSSProperties({
21
+ * color: 'red',
22
+ * '--custom-color': '#ff0000'
23
+ * })
24
+ * ```
25
+ */
26
+ export declare function defineCSSProperties(style: CSSProperties): any;
27
+ //# sourceMappingURL=css-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-properties.d.ts","sourceRoot":"","sources":["../../src/css-properties/css-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;IACjE,CAAC,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GACvC,GAAG,CACnB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Defines CSS properties including custom properties.
3
+ * This function is used to properly type CSS properties when defining styles,
4
+ * especially when using CSS custom properties (variables).
5
+ *
6
+ * @param style - CSS properties object that can include both standard and custom properties
7
+ * @returns The same style object with proper typing
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * defineCSSProperties({
12
+ * color: 'red',
13
+ * '--custom-color': '#ff0000'
14
+ * })
15
+ * ```
16
+ */
17
+ export function defineCSSProperties(style) {
18
+ return style;
19
+ }
20
+ //# sourceMappingURL=css-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css-properties.js","sourceRoot":"","sources":["../../src/css-properties/css-properties.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAoB;IACvD,OAAO,KAAY,CAAA;AACpB,CAAC"}
package/esm/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- export * from './class-name.ts';
2
- export * from './css-properties.ts';
3
- export * from './style.ts';
1
+ export * from './css-properties/css-properties.ts';
2
+ export * from './props/class-name.ts';
3
+ export * from './props/style.ts';
4
4
  export * from './theme/class-name.ts';
5
5
  export * from './theme/data-attribute.ts';
6
6
  export * from './utils/attribute.ts';
7
7
  export * from './utils/data-attribute.ts';
8
+ export * from './utils/get-css-prop-values.ts';
8
9
  export * from './utils/prefers-color-scheme.ts';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
package/esm/index.js CHANGED
@@ -1,9 +1,10 @@
1
- export * from "./class-name.js";
2
- export * from "./css-properties.js";
3
- export * from "./style.js";
1
+ export * from "./css-properties/css-properties.js";
2
+ export * from "./props/class-name.js";
3
+ export * from "./props/style.js";
4
4
  export * from "./theme/class-name.js";
5
5
  export * from "./theme/data-attribute.js";
6
6
  export * from "./utils/attribute.js";
7
7
  export * from "./utils/data-attribute.js";
8
+ export * from "./utils/get-css-prop-values.js";
8
9
  export * from "./utils/prefers-color-scheme.js";
9
10
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-name.d.ts","sourceRoot":"","sources":["../../src/props/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-name.js","sourceRoot":"","sources":["../../src/props/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,4 +1,4 @@
1
- import type { CSSProperties } from './css-properties.ts';
1
+ import type { CSSProperties } from '../css-properties/css-properties.ts';
2
2
  /**
3
3
  * Interface for component props that include a style property.
4
4
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/props/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAExE;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACjC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/props/style.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { CreateTuple } from 'type-plus';
2
+ /**
3
+ * Retrieves CSS custom property values from the specified element.
4
+ *
5
+ * @param element - The HTML element to get property values from
6
+ * @param props - CSS custom property names to retrieve, must be in the format `--property-name`
7
+ * @returns Array of property values corresponding to the requested custom properties
8
+ */
9
+ export declare function getCSSPropValues<Props extends Array<`--${string}`>>(element: HTMLElement, ...props: Props): CreateTuple<Props['length'], string>;
10
+ /**
11
+ * Retrieves CSS custom property values from `document.body`.
12
+ *
13
+ * @param props - CSS custom property names to retrieve, must be in the format `--property-name`
14
+ * @returns Array of property values corresponding to the requested custom properties
15
+ */
16
+ export declare function getCSSPropValues<Props extends Array<`--${string}`>>(...props: Props): CreateTuple<Props['length'], string>;
17
+ //# sourceMappingURL=get-css-prop-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-css-prop-values.d.ts","sourceRoot":"","sources":["../../src/utils/get-css-prop-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC,EAClE,OAAO,EAAE,WAAW,EACpB,GAAG,KAAK,EAAE,KAAK,GACb,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAA;AACvC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,SAAS,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC,EAClE,GAAG,KAAK,EAAE,KAAK,GACb,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ export function getCSSPropValues(element, ...props) {
2
+ if (typeof element === 'string') {
3
+ return getCSSPropValues(globalThis.document.body, element, ...props);
4
+ }
5
+ const style = globalThis.getComputedStyle(element);
6
+ return props.map((v) => style.getPropertyValue(v));
7
+ }
8
+ //# sourceMappingURL=get-css-prop-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-css-prop-values.js","sourceRoot":"","sources":["../../src/utils/get-css-prop-values.ts"],"names":[],"mappings":"AAsBA,MAAM,UAAU,gBAAgB,CAAqC,OAAgB,EAAE,GAAG,KAAY;IACrG,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAwB,EAAE,GAAG,KAAK,CAAC,CAAA;IACtF,CAAC;IACD,MAAM,KAAK,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAsB,CAAC,CAAA;IACjE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAQ,CAAA;AAC1D,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@just-web/css",
3
- "version": "0.1.0",
4
- "description": "",
3
+ "version": "0.2.0",
4
+ "description": "CSS types and utilities",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -21,7 +21,7 @@
21
21
  "type-plus": "8.0.0-beta.7"
22
22
  },
23
23
  "devDependencies": {
24
- "@repobuddy/storybook": "^0.9.1",
24
+ "@repobuddy/storybook": "^0.9.4",
25
25
  "@repobuddy/vitest": "^1.2.2",
26
26
  "@storybook/addon-essentials": "^8.6.12",
27
27
  "@storybook/addon-storysource": "^8.6.12",
@@ -33,6 +33,7 @@
33
33
  "@storybook/react-vite": "^8.6.12",
34
34
  "@storybook/test": "^8.6.12",
35
35
  "@storybook/theming": "^8.6.12",
36
+ "@tailwindcss/cli": "^4.1.6",
36
37
  "@tailwindcss/vite": "^4.1.6",
37
38
  "@vitest/browser": "^3.1.3",
38
39
  "@vitest/coverage-v8": "^3.1.3",
@@ -59,6 +60,7 @@
59
60
  "build:esm": "tsc -p tsconfig.esm.json",
60
61
  "clean": "rimraf .turbo esm *.tsbuildinfo",
61
62
  "cov": "vitest run --coverage",
63
+ "inspect:css": "tailwindcss -i ./src/tailwind.css -o ./styles.css",
62
64
  "nuke": "rimraf node_modules",
63
65
  "sb": "storybook dev -p 6206",
64
66
  "test": "vitest run",
@@ -0,0 +1,30 @@
1
+ import type { Properties } from 'csstype'
2
+
3
+ /**
4
+ * Extends CSS properties to include custom properties.
5
+ * Allows for string or number values for standard properties,
6
+ * and string values for custom properties with '--' prefix.
7
+ */
8
+ export interface CSSProperties extends Properties<string | number> {
9
+ [k: `--${string}`]: string
10
+ }
11
+
12
+ /**
13
+ * Defines CSS properties including custom properties.
14
+ * This function is used to properly type CSS properties when defining styles,
15
+ * especially when using CSS custom properties (variables).
16
+ *
17
+ * @param style - CSS properties object that can include both standard and custom properties
18
+ * @returns The same style object with proper typing
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * defineCSSProperties({
23
+ * color: 'red',
24
+ * '--custom-color': '#ff0000'
25
+ * })
26
+ * ```
27
+ */
28
+ export function defineCSSProperties(style: CSSProperties) {
29
+ return style as any
30
+ }
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
- export * from './class-name.ts'
2
- export * from './css-properties.ts'
3
- export * from './style.ts'
1
+ export * from './css-properties/css-properties.ts'
2
+ export * from './props/class-name.ts'
3
+ export * from './props/style.ts'
4
4
  export * from './theme/class-name.ts'
5
5
  export * from './theme/data-attribute.ts'
6
6
  export * from './utils/attribute.ts'
7
7
  export * from './utils/data-attribute.ts'
8
+ export * from './utils/get-css-prop-values.ts'
8
9
  export * from './utils/prefers-color-scheme.ts'
@@ -1,4 +1,4 @@
1
- import type { CSSProperties } from './css-properties.ts'
1
+ import type { CSSProperties } from '../css-properties/css-properties.ts'
2
2
 
3
3
  /**
4
4
  * Interface for component props that include a style property.
@@ -0,0 +1,29 @@
1
+ import type { CreateTuple } from 'type-plus'
2
+
3
+ /**
4
+ * Retrieves CSS custom property values from the specified element.
5
+ *
6
+ * @param element - The HTML element to get property values from
7
+ * @param props - CSS custom property names to retrieve, must be in the format `--property-name`
8
+ * @returns Array of property values corresponding to the requested custom properties
9
+ */
10
+ export function getCSSPropValues<Props extends Array<`--${string}`>>(
11
+ element: HTMLElement,
12
+ ...props: Props
13
+ ): CreateTuple<Props['length'], string>
14
+ /**
15
+ * Retrieves CSS custom property values from `document.body`.
16
+ *
17
+ * @param props - CSS custom property names to retrieve, must be in the format `--property-name`
18
+ * @returns Array of property values corresponding to the requested custom properties
19
+ */
20
+ export function getCSSPropValues<Props extends Array<`--${string}`>>(
21
+ ...props: Props
22
+ ): CreateTuple<Props['length'], string>
23
+ export function getCSSPropValues<Props extends Array<`--${string}`>>(element: unknown, ...props: Props) {
24
+ if (typeof element === 'string') {
25
+ return getCSSPropValues(globalThis.document.body, element as `--${string}`, ...props)
26
+ }
27
+ const style = globalThis.getComputedStyle(element as HTMLElement)
28
+ return props.map((v) => style.getPropertyValue(v)) as any
29
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-name.d.ts","sourceRoot":"","sources":["../src/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"class-name.js","sourceRoot":"","sources":["../src/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,10 +0,0 @@
1
- import type { Properties } from 'csstype';
2
- /**
3
- * Extends CSS properties to include custom properties.
4
- * Allows for string or number values for standard properties,
5
- * and string values for custom properties with '--' prefix.
6
- */
7
- export interface CSSProperties extends Properties<string | number> {
8
- [k: `--${string}`]: string;
9
- }
10
- //# sourceMappingURL=css-properties.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"css-properties.d.ts","sourceRoot":"","sources":["../src/css-properties.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;IACjE,CAAC,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,MAAM,CAAA;CAC1B"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=css-properties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"css-properties.js","sourceRoot":"","sources":["../src/css-properties.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACjC"}
package/esm/style.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.js","sourceRoot":"","sources":["../src/style.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- import type { Properties } from 'csstype'
2
-
3
- /**
4
- * Extends CSS properties to include custom properties.
5
- * Allows for string or number values for standard properties,
6
- * and string values for custom properties with '--' prefix.
7
- */
8
- export interface CSSProperties extends Properties<string | number> {
9
- [k: `--${string}`]: string
10
- }
File without changes
File without changes
File without changes
File without changes