@salty-css/react 0.0.1-alpha.221 → 0.0.1-alpha.223

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 (2) hide show
  1. package/README.md +44 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [Get started](#get-started) | [API](#api) | [Website](https://salty-css.dev/) | [GitHub](https://github.com/margarita-form/salty-css) | [NPM](https://www.npmjs.com/package/@salty-css/core)
2
+
1
3
  ![Salty CSS Banner](https://salty-css.dev/assets/banners/dvd.svg)
2
4
 
3
5
  # Salty CSS - CSS-in-JS library that is kinda sweet
@@ -32,7 +34,7 @@ Fastest way to get started with any framework is `npx salty-css init [directory]
32
34
  2. Salty CSS components created with styled function can extend non Salty CSS components (`export const CustomLink = styled(NextJSLink, { ... });`) but those components must take in `className` prop for styles to apply.
33
35
  3. Among common types like `string` and `number`, CSS-in-JS properties in Salty CSS do support `functions` and `promises` as values (`styled('span', { base: { color: async () => 'red' } });`) but running asynchronous tasks or importing heavy 3rd party libraries into `*.css.ts` or `*.css.tsx` files can cause longer build times.
34
36
 
35
- ## Functions
37
+ ## API
36
38
 
37
39
  ### Styling
38
40
 
@@ -57,13 +59,13 @@ Fastest way to get started with any framework is `npx salty-css init [directory]
57
59
  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
60
 
59
61
  ```ts
60
- // components/my-component.css.ts
62
+ // /components/my-component.css.ts
61
63
  import { styled } from '@salty-css/react/styled';
62
64
 
63
65
  // 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
66
  export const Component = styled('div', {
65
- className: 'wrapper', // Define custom class name that will be included for this component
66
- element: 'section', // Define the html element that will be rendered for this component, overrides the first 'div' argument
67
+ className: 'wrapper', // Define optional custom class name that will be included for this component
68
+ element: 'section', // Override the html element that will be rendered for this component
67
69
  base: {
68
70
  // 👉 Add your CSS-in-JS base styles here! 👈
69
71
  },
@@ -83,23 +85,43 @@ export const Component = styled('div', {
83
85
  });
84
86
  ```
85
87
 
88
+ Example usage:
89
+
90
+ ```tsx
91
+ import { Component } from './my-component.css';
92
+
93
+ export const Page = () => {
94
+ return <Component>Hello world</Component>;
95
+ };
96
+ ```
97
+
86
98
  ## Class name function
87
99
 
88
100
  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
101
 
90
102
  ```ts
91
- // styles/my-class.css.ts
103
+ // /components/my-class.css.ts
92
104
  import { className } from '@salty-css/react/class-name';
93
105
 
94
106
  // Define a CSS class with className function. First and only argument is the object containing the styles and other options
95
107
  export const myClass = className({
96
- className: 'wrapper', // Define custom class name that will be included to the scope
108
+ className: 'wrapper', // Define optional custom class name that will be included to the scope
97
109
  base: {
98
110
  // 👉 Add your CSS-in-JS base styles here! 👈
99
111
  },
100
112
  });
101
113
  ```
102
114
 
115
+ Example usage:
116
+
117
+ ```tsx
118
+ import { myClass } from './my-class.css';
119
+
120
+ export const Page = () => {
121
+ return <div className={myClass}>Hello world</div>;
122
+ };
123
+ ```
124
+
103
125
  ## Global styles
104
126
 
105
127
  ```ts
@@ -178,7 +200,7 @@ export default defineVariables({
178
200
  },
179
201
 
180
202
  /*
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">).
203
+ 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
204
  */
183
205
  conditional: {
184
206
  theme: {
@@ -195,6 +217,21 @@ export default defineVariables({
195
217
  });
196
218
  ```
197
219
 
220
+ Example usage:
221
+
222
+ ```ts
223
+ styled('span', {
224
+ base: {
225
+ // Use of static font family variable
226
+ fontFamily: '{colors.fontFamily.heading}',
227
+ // Use of responsive font size variable
228
+ fontSize: '{fontSize.heading.regular}',
229
+ // Use of conditional theme text color variable
230
+ color: '{theme.textColor}',
231
+ },
232
+ });
233
+ ```
234
+
198
235
  ## Media queries
199
236
 
200
237
  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.221",
3
+ "version": "0.0.1-alpha.223",
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.221",
65
+ "@salty-css/core": "^0.0.1-alpha.223",
66
66
  "clsx": ">=2.x",
67
67
  "react": ">=19.x || >=18.3.x"
68
68
  }