@salty-css/react 0.0.1-alpha.221 → 0.0.1-alpha.222
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 +41 -6
- package/package.json +2 -2
package/README.md
CHANGED
@@ -57,13 +57,13 @@ Fastest way to get started with any framework is `npx salty-css init [directory]
|
|
57
57
|
Styled function is the main way to use Salty CSS within React. Styled function creates a React component that then can be used anywhere in your app. All styled functions must be created in `.css.ts` or `.css.tsx` files
|
58
58
|
|
59
59
|
```ts
|
60
|
-
// components/my-component.css.ts
|
60
|
+
// /components/my-component.css.ts
|
61
61
|
import { styled } from '@salty-css/react/styled';
|
62
62
|
|
63
63
|
// Define a component with a styled function. First argument is the component name or existing component to extend and second argument is the object containing the styles and other options
|
64
64
|
export const Component = styled('div', {
|
65
|
-
className: 'wrapper', // Define custom class name that will be included for this component
|
66
|
-
element: 'section', //
|
65
|
+
className: 'wrapper', // Define optional custom class name that will be included for this component
|
66
|
+
element: 'section', // Override the html element that will be rendered for this component
|
67
67
|
base: {
|
68
68
|
// 👉 Add your CSS-in-JS base styles here! 👈
|
69
69
|
},
|
@@ -83,23 +83,43 @@ export const Component = styled('div', {
|
|
83
83
|
});
|
84
84
|
```
|
85
85
|
|
86
|
+
Example usage:
|
87
|
+
|
88
|
+
```tsx
|
89
|
+
import { Component } from './my-component.css';
|
90
|
+
|
91
|
+
export const Page = () => {
|
92
|
+
return <Component>Hello world</Component>;
|
93
|
+
};
|
94
|
+
```
|
95
|
+
|
86
96
|
## Class name function
|
87
97
|
|
88
98
|
Create CSS class names with possibility to add scope and media queries etc. Function `className` is quite similar to `styled` but does not allow extending components or classes.
|
89
99
|
|
90
100
|
```ts
|
91
|
-
//
|
101
|
+
// /components/my-class.css.ts
|
92
102
|
import { className } from '@salty-css/react/class-name';
|
93
103
|
|
94
104
|
// Define a CSS class with className function. First and only argument is the object containing the styles and other options
|
95
105
|
export const myClass = className({
|
96
|
-
className: 'wrapper', // Define custom class name that will be included to the scope
|
106
|
+
className: 'wrapper', // Define optional custom class name that will be included to the scope
|
97
107
|
base: {
|
98
108
|
// 👉 Add your CSS-in-JS base styles here! 👈
|
99
109
|
},
|
100
110
|
});
|
101
111
|
```
|
102
112
|
|
113
|
+
Example usage:
|
114
|
+
|
115
|
+
```tsx
|
116
|
+
import { myClass } from './my-class.css';
|
117
|
+
|
118
|
+
export const Page = () => {
|
119
|
+
return <div className={myClass}>Hello world</div>;
|
120
|
+
};
|
121
|
+
```
|
122
|
+
|
103
123
|
## Global styles
|
104
124
|
|
105
125
|
```ts
|
@@ -178,7 +198,7 @@ export default defineVariables({
|
|
178
198
|
},
|
179
199
|
|
180
200
|
/*
|
181
|
-
Conditional variables are used to define styles that depend on a class name (e.g. <div className="theme-dark">). or data-attribute (e.g. <div data-theme="dark">).
|
201
|
+
Conditional variables are used to define styles that depend on a class name (e.g. <div className="theme-dark">). or data-attribute (e.g. <div data-theme="dark">). Names for these variables will be "{theme.backgroundColor}" and "{theme.textColor}".
|
182
202
|
*/
|
183
203
|
conditional: {
|
184
204
|
theme: {
|
@@ -195,6 +215,21 @@ export default defineVariables({
|
|
195
215
|
});
|
196
216
|
```
|
197
217
|
|
218
|
+
Example usage:
|
219
|
+
|
220
|
+
```ts
|
221
|
+
styled('span', {
|
222
|
+
base: {
|
223
|
+
// Use of static font family variable
|
224
|
+
fontFamily: '{colors.fontFamily.heading}',
|
225
|
+
// Use of responsive font size variable
|
226
|
+
fontSize: '{fontSize.heading.regular}',
|
227
|
+
// Use of conditional theme text color variable
|
228
|
+
color: '{theme.textColor}',
|
229
|
+
},
|
230
|
+
});
|
231
|
+
```
|
232
|
+
|
198
233
|
## Media queries
|
199
234
|
|
200
235
|
Create global media queries that can be either used directly as a scope (e.g. `'@MEDIA_QUERY_NAME': { color: 'blue' }`) or imported to be used in JS.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@salty-css/react",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.222",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"module": "./dist/index.mjs",
|
6
6
|
"typings": "./dist/index.d.ts",
|
@@ -62,7 +62,7 @@
|
|
62
62
|
}
|
63
63
|
},
|
64
64
|
"dependencies": {
|
65
|
-
"@salty-css/core": "^0.0.1-alpha.
|
65
|
+
"@salty-css/core": "^0.0.1-alpha.222",
|
66
66
|
"clsx": ">=2.x",
|
67
67
|
"react": ">=19.x || >=18.3.x"
|
68
68
|
}
|