effcss 3.0.0 → 3.0.1

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/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  </div>
17
17
 
18
- EffCSS is a self-confident CSS-in-JS library based only on the browser APIs.
18
+ EffCSS is a self-confident CSS-in-JS library based only on the browser APIs. Use the full power of JS & TS when creating styles!
19
19
 
20
20
  ## Some features
21
21
 
@@ -25,18 +25,21 @@ EffCSS is a self-confident CSS-in-JS library based only on the browser APIs.
25
25
  - built-in BEM support
26
26
  - server-side rendering compatible
27
27
 
28
- ## EffCSS v3
29
-
30
- EffCSS v3 is already here! The new version simplifies the API - if you know JS and CSS, you are already know it.
31
- Docs and examples will be available soon.
32
-
33
28
  ## Links
34
29
 
35
- - [Docs for EffCSS v2](https://effcss.surge.sh)
30
+ - [Docs](https://effcss.surge.sh)
36
31
  - [Repository](https://gitverse.ru/msabitov/effcss)
37
32
  - [Github mirror](https://github.com/msabitov/effcss)
38
33
 
39
- ## EffCSS v2 examples
34
+ ## V3 examples
35
+
36
+ - [Vanilla TS](https://stackblitz.com/edit/effcss-3-ts-vitejs?file=index.html)
37
+ - [React](https://stackblitz.com/edit/effcss-3-react-vitejs?file=index.html)
38
+ - [React SSR](https://stackblitz.com/edit/effcss-3-react-ssr-vitejs?file=index.html)
39
+ - [Svelte](https://stackblitz.com/edit/effcss-3-svelte-vitejs?file=index.html)
40
+ - [Svelte SSR](https://stackblitz.com/edit/effcss-3-svelte-ssr-vitejs?file=index.html)
41
+
42
+ ## V2 examples
40
43
 
41
44
  - [React](https://stackblitz.com/edit/vitejs-react-effcss?file=index.html)
42
45
  - [React SSR](https://stackblitz.com/edit/vitejs-react-ssr-effcss?file=index.html)
@@ -49,9 +52,6 @@ Docs and examples will be available soon.
49
52
  - [Lit](https://stackblitz.com/edit/vitejs-lit-effcss?file=index.html)
50
53
  - [Angular](https://stackblitz.com/edit/angular-effcss?file=src%2Findex.html)
51
54
  - [HTML only](https://stackblitz.com/edit/static-effcss?file=index.html)
52
-
53
- ## Try EffCSS v2 with
54
-
55
55
  - [Storybook](https://stackblitz.com/edit/storybook-react-effcss?file=src%2Findex.ts)
56
56
  - [Vitest benchmarking](https://stackblitz.com/edit/vitest-bench-effcss?file=tests%2FPublic.bench.ts)
57
57
 
@@ -89,20 +89,20 @@ First, define and add `Style provider` to your HTML:
89
89
  </html>
90
90
  ```
91
91
 
92
- Second, use `Style consumer` to operate styles in your JS:
92
+ Second, use `Style consumer` to operate styles in your code:
93
93
 
94
94
  **main.js**
95
95
 
96
96
  ```jsx
97
- import { createConsumer } from 'effcss/consumer';
97
+ import { createConsumer } from "effcss/consumer";
98
98
 
99
99
  const consumer = createConsumer();
100
100
 
101
- const root = createRoot(document.getElementById('root'));
101
+ const root = createRoot(document.getElementById("root"));
102
102
  root.render(<App css={consumer} />);
103
103
  ```
104
104
 
105
- Each CSS stylesheet corresponds to a single `StyleSheet maker`. `Stylesheet maker` is a pure JS function that gets an object with utilities as arguments and should return object with style rules:
105
+ Each CSS stylesheet corresponds to a single `Stylesheet maker`. `Stylesheet maker` is a pure JS function that should return object with style rules:
106
106
 
107
107
  **App.js**
108
108
 
@@ -118,28 +118,32 @@ export interface ICardMaker {
118
118
  */
119
119
  card: {
120
120
  /**
121
- * Block modifiers
121
+ * Card modifiers
122
122
  */
123
123
  '': {
124
124
  /**
125
- * Card border radius boolean modifier
125
+ * Card border radius
126
126
  */
127
127
  rounded: '';
128
128
  /**
129
- * Card height modifier
129
+ * Card height
130
130
  */
131
131
  h: 'full' | 'half';
132
132
  };
133
133
  /**
134
- * Card footer element
134
+ * Card logo
135
+ */
136
+ logo: {},
137
+ /**
138
+ * Card footer
135
139
  */
136
140
  footer: {
137
141
  /**
138
- * Footer visibility boolean modifier
142
+ * Footer visibility
139
143
  */
140
144
  visible: '';
141
145
  /**
142
- * Footer size modifier
146
+ * Footer size
143
147
  */
144
148
  sz: 's' | 'm' | 'l';
145
149
  };
@@ -171,18 +175,12 @@ const myStyleSheetMaker: TStyleSheetMaker = ({ bem, pseudo, at: { kf }, merge })
171
175
  transform: 'rotate(360deg)',
172
176
  },
173
177
  },
174
- '.card-logo': cardLogoStyles,
175
- // block
176
178
  [bem<ICardMaker>('card')]: { ... },
177
- // block boolean attribute
179
+ [bem<ICardMaker>('card.logo')]: cardLogoStyles,
178
180
  [bem<ICardMaker>('card..rounded')]: { ... },
179
- // block attribute with value
180
181
  [bem<ICardMaker>('card..h.full')]: { ... },
181
- // element
182
182
  [bem<ICardMaker>('card.footer')]: { ... },
183
- // element boolean attribute
184
183
  [bem<ICardMaker>('card.footer.visible')]: { ... },
185
- // element attribute with value
186
184
  [bem<ICardMaker>('card.footer.sz.m')]: { ... },
187
185
  };
188
186
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * EffCSS v3.0.0
2
+ * EffCSS v3.0.1
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
5
  * @license Apache 2.0
package/dist/consumer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * EffCSS v3.0.0
2
+ * EffCSS v3.0.1
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
5
  * @license Apache 2.0
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * EffCSS v3.0.0
2
+ * EffCSS v3.0.1
3
3
  * {@link https://gitverse.ru/msabitov/effcss}
4
4
  * Copyright (c) Marat Sabitov
5
5
  * @license Apache 2.0
@@ -5,7 +5,7 @@ export declare const getBaseHandlers: () => {
5
5
  comma: TJoinArr;
6
6
  space: TJoinArr;
7
7
  range: (size: number, handler: (k: number) => object) => object;
8
- each: <V>(rules: Record<string, V> | V[], handler: (k: string | number, v: V) => object) => object;
8
+ each: <V extends Record<string | number, any>>(rules: V, handler: (k: V extends ArrayLike<any> ? string : keyof V, v: V extends ArrayLike<any> ? NoInfer<V[number]> : NoInfer<V[keyof V]>) => object) => object;
9
9
  merge: (target: Record<string, any>, ...sources: Record<string, any>[]) => Record<string, any>;
10
10
  when: (condition: boolean | undefined, rules: object, otherwise?: object) => object;
11
11
  };
@@ -86,7 +86,7 @@ export declare const baseHandlers: {
86
86
  comma: (...val: (string | number)[]) => string;
87
87
  space: (...val: (string | number)[]) => string;
88
88
  range: (size: number, handler: (k: number) => object) => object;
89
- each: <V>(rules: Record<string, V> | V[], handler: (k: string | number, v: V) => object) => object;
89
+ each: <V extends Record<string | number, any>>(rules: V, handler: (k: V extends ArrayLike<any> ? string : keyof V, v: V extends ArrayLike<any> ? NoInfer<V[number]> : NoInfer<V[keyof V]>) => object) => object;
90
90
  merge: (target: Record<string, any>, ...sources: Record<string, any>[]) => Record<string, any>;
91
91
  when: (condition: boolean | undefined, rules: object, otherwise?: object) => object;
92
92
  };
@@ -46,7 +46,7 @@ export interface IStyleProvider {
46
46
  */
47
47
  set settings(val: Partial<TProviderSettings>);
48
48
  /**
49
- * Use stylesheet
49
+ * Use stylesheet maker
50
50
  * @param maker - stylesheet maker
51
51
  * @returns {@link TResolveAttr | attribute resolver}
52
52
  */
@@ -75,7 +75,7 @@ export interface IStyleProvider {
75
75
  css(maker: TStyleSheetMaker, key: string): string;
76
76
  /**
77
77
  * Resolve target key
78
- * @param param - style target
78
+ * @param target - style target
79
79
  */
80
80
  key(target: TStyleTarget): string | undefined;
81
81
  /**
@@ -84,13 +84,13 @@ export interface IStyleProvider {
84
84
  */
85
85
  status(key: TStyleTarget): boolean;
86
86
  /**
87
- * Switch stylesheet/stylesheets on
88
- * @param target - target stylesheet maker or key
87
+ * Switch stylesheets on
88
+ * @param targets - target stylesheet maker or key
89
89
  */
90
90
  on(...targets: TStyleTarget[]): boolean | undefined;
91
91
  /**
92
- * Switch stylesheet/stylesheets off
93
- * @param target - target stylesheet maker or key
92
+ * Switch stylesheets off
93
+ * @param targets - target stylesheet maker or key
94
94
  */
95
95
  off(...targets: TStyleTarget[]): boolean | undefined;
96
96
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effcss",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Self-confident CSS-in-JS",
5
5
  "type": "module",
6
6
  "scripts": {