effcss 3.0.0 → 3.0.2

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,23 @@ 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
+ - [Vue](https://stackblitz.com/edit/effcss-3-vue-vitejs?file=index.html)
42
+ - [Vue SSR](https://stackblitz.com/edit/effcss-3-vue-ssr-vitejs?file=index.html)
43
+
44
+ ## V2 examples
40
45
 
41
46
  - [React](https://stackblitz.com/edit/vitejs-react-effcss?file=index.html)
42
47
  - [React SSR](https://stackblitz.com/edit/vitejs-react-ssr-effcss?file=index.html)
@@ -49,9 +54,6 @@ Docs and examples will be available soon.
49
54
  - [Lit](https://stackblitz.com/edit/vitejs-lit-effcss?file=index.html)
50
55
  - [Angular](https://stackblitz.com/edit/angular-effcss?file=src%2Findex.html)
51
56
  - [HTML only](https://stackblitz.com/edit/static-effcss?file=index.html)
52
-
53
- ## Try EffCSS v2 with
54
-
55
57
  - [Storybook](https://stackblitz.com/edit/storybook-react-effcss?file=src%2Findex.ts)
56
58
  - [Vitest benchmarking](https://stackblitz.com/edit/vitest-bench-effcss?file=tests%2FPublic.bench.ts)
57
59
 
@@ -89,20 +91,20 @@ First, define and add `Style provider` to your HTML:
89
91
  </html>
90
92
  ```
91
93
 
92
- Second, use `Style consumer` to operate styles in your JS:
94
+ Second, use `Style consumer` to operate styles in your code:
93
95
 
94
96
  **main.js**
95
97
 
96
98
  ```jsx
97
- import { createConsumer } from 'effcss/consumer';
99
+ import { createConsumer } from "effcss/consumer";
98
100
 
99
101
  const consumer = createConsumer();
100
102
 
101
- const root = createRoot(document.getElementById('root'));
103
+ const root = createRoot(document.getElementById("root"));
102
104
  root.render(<App css={consumer} />);
103
105
  ```
104
106
 
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:
107
+ Each CSS stylesheet corresponds to a single `Stylesheet maker`. `Stylesheet maker` is a pure JS function that should return object with style rules:
106
108
 
107
109
  **App.js**
108
110
 
@@ -118,28 +120,32 @@ export interface ICardMaker {
118
120
  */
119
121
  card: {
120
122
  /**
121
- * Block modifiers
123
+ * Card modifiers
122
124
  */
123
125
  '': {
124
126
  /**
125
- * Card border radius boolean modifier
127
+ * Card border radius
126
128
  */
127
129
  rounded: '';
128
130
  /**
129
- * Card height modifier
131
+ * Card height
130
132
  */
131
133
  h: 'full' | 'half';
132
134
  };
133
135
  /**
134
- * Card footer element
136
+ * Card logo
137
+ */
138
+ logo: {},
139
+ /**
140
+ * Card footer
135
141
  */
136
142
  footer: {
137
143
  /**
138
- * Footer visibility boolean modifier
144
+ * Footer visibility
139
145
  */
140
146
  visible: '';
141
147
  /**
142
- * Footer size modifier
148
+ * Footer size
143
149
  */
144
150
  sz: 's' | 'm' | 'l';
145
151
  };
@@ -171,18 +177,12 @@ const myStyleSheetMaker: TStyleSheetMaker = ({ bem, pseudo, at: { kf }, merge })
171
177
  transform: 'rotate(360deg)',
172
178
  },
173
179
  },
174
- '.card-logo': cardLogoStyles,
175
- // block
176
180
  [bem<ICardMaker>('card')]: { ... },
177
- // block boolean attribute
181
+ [bem<ICardMaker>('card.logo')]: cardLogoStyles,
178
182
  [bem<ICardMaker>('card..rounded')]: { ... },
179
- // block attribute with value
180
183
  [bem<ICardMaker>('card..h.full')]: { ... },
181
- // element
182
184
  [bem<ICardMaker>('card.footer')]: { ... },
183
- // element boolean attribute
184
185
  [bem<ICardMaker>('card.footer.visible')]: { ... },
185
- // element attribute with value
186
186
  [bem<ICardMaker>('card.footer.sz.m')]: { ... },
187
187
  };
188
188
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * EffCSS v3.0.0
2
+ * EffCSS v3.0.2
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.2
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.2
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<TStrOrNum, 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
  };
@@ -61,6 +61,7 @@ type TStringBEM<T> = TBlocks<T> | TMods<T> | TElems<T>;
61
61
  type TBEM<T> = TDeepPartial<T> | TStringBEM<T> | TStringBEM<T>[];
62
62
  type TResolveSelector = <T extends object>(params: TBEM<T>) => string;
63
63
  type TResolveAttr = <T extends object>(params: TBEM<T>) => TStrDict;
64
+ type TParts = (string | number)[];
64
65
  type TScope = {
65
66
  /**
66
67
  * BEM selector resolver
@@ -73,15 +74,15 @@ type TScope = {
73
74
  /**
74
75
  * Name resolver
75
76
  */
76
- name: (...parts: (string | number)[] | string[]) => string;
77
+ name: (...parts: TParts) => string;
77
78
  /**
78
79
  * Var name
79
80
  */
80
- varName: (...parts: (string | number)[] | string[]) => string;
81
+ varName: (...parts: TParts) => string;
81
82
  /**
82
83
  * Var expression
83
84
  */
84
- varExp: (...parts: (string | number)[]) => string;
85
+ varExp: (...parts: TParts) => string;
85
86
  };
86
87
  /**
87
88
  * Style scope resolver
@@ -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.2",
4
4
  "description": "Self-confident CSS-in-JS",
5
5
  "type": "module",
6
6
  "scripts": {