@salty-css/react 0.1.0-alpha.26 → 0.1.0-alpha.27
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 +44 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ To get help with problems, [Join Salty CSS Discord server](https://discord.gg/R6
|
|
|
58
58
|
- [defineMediaQuery](#media-queries) - create CSS media queries and use them in any styling function
|
|
59
59
|
- [defineTemplates](#templates) - create reusable templates that can be applied when same styles are used over and over again
|
|
60
60
|
- [defineFont](#custom-fonts) - register custom fonts via `@font-face` (or a remote stylesheet) and expose them as a CSS variable
|
|
61
|
+
- [defineImport](#importing-additional-css) - pull in external CSS files (relative, public, node_modules, or URL)
|
|
61
62
|
- [keyframes](#keyframes-animations) - create CSS keyframes animation that can be used and imported in any styling function
|
|
62
63
|
|
|
63
64
|
### Styling helpers & utility
|
|
@@ -402,6 +403,49 @@ export const Body = styled('p', {
|
|
|
402
403
|
});
|
|
403
404
|
```
|
|
404
405
|
|
|
406
|
+
## Importing additional CSS
|
|
407
|
+
|
|
408
|
+
Use `defineImport` to pull in CSS that lives outside of Salty's authoring API — a reset stylesheet from npm, a Google Fonts URL, an asset in your app's `public/` folder, or a sibling `.css` file. The compiler turns each spec into an `@import` rule in the generated `saltygen/index.css`, so the imported stylesheets travel with the rest of your build.
|
|
409
|
+
|
|
410
|
+
```ts
|
|
411
|
+
// /styles/imports.css.ts
|
|
412
|
+
import { defineImport } from '@salty-css/core/factories';
|
|
413
|
+
|
|
414
|
+
export default defineImport(
|
|
415
|
+
// Relative to this file
|
|
416
|
+
'./reset.css',
|
|
417
|
+
// From node_modules (bare specifier — same as Vite / native CSS @import)
|
|
418
|
+
'modern-normalize/modern-normalize.css',
|
|
419
|
+
// From node_modules (~ prefix — same resolver, webpack-style)
|
|
420
|
+
'~normalize.css/normalize.css',
|
|
421
|
+
// From your app's public/ folder (served at the host root)
|
|
422
|
+
'/fonts/inter.css',
|
|
423
|
+
// External URL
|
|
424
|
+
'https://fonts.googleapis.com/css2?family=Inter&display=swap',
|
|
425
|
+
// Object form — attach media or supports() conditions
|
|
426
|
+
{ url: './print.css', media: 'print' },
|
|
427
|
+
{ url: './p3.css', supports: 'color(display-p3 1 1 1)' }
|
|
428
|
+
);
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Path resolution:
|
|
432
|
+
|
|
433
|
+
| Pattern | Behaviour |
|
|
434
|
+
| --------------------------- | ---------------------------------------------------------------------------------------- |
|
|
435
|
+
| `http://`, `https://`, `//` | Emitted verbatim |
|
|
436
|
+
| Starts with `/` | Public-folder URL — emitted verbatim, the browser resolves it against your host |
|
|
437
|
+
| Starts with `./` or `../` | Resolved at build time relative to the file that called `defineImport` |
|
|
438
|
+
| `~package/file.css` | Stripped of the leading `~`, then resolved from `node_modules` and copied into the build |
|
|
439
|
+
| `package/file.css` (bare) | Same `node_modules` resolution as the `~` form |
|
|
440
|
+
|
|
441
|
+
All imports are placed inside a new `imports` cascade layer that sits **before** `reset`, `global`, `templates`, and your component styles. This means your own styles always win over third-party CSS you pull in — which is what most teams expect when they drop in something like `modern-normalize`.
|
|
442
|
+
|
|
443
|
+
The full layer order in the generated `index.css` is:
|
|
444
|
+
|
|
445
|
+
```css
|
|
446
|
+
@layer imports, reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
|
447
|
+
```
|
|
448
|
+
|
|
405
449
|
## Keyframes animations
|
|
406
450
|
|
|
407
451
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salty-css/react",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.27",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@salty-css/core": "^0.1.0-alpha.
|
|
81
|
+
"@salty-css/core": "^0.1.0-alpha.27",
|
|
82
82
|
"clsx": ">=2.x",
|
|
83
83
|
"react": ">=19.x || >=18.3.x"
|
|
84
84
|
},
|