@salty-css/eslint-plugin-core 0.1.0-feat-define-font.0 → 0.1.0-feat-define-import.0

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 +33 -72
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -57,7 +57,7 @@ To get help with problems, [Join Salty CSS Discord server](https://discord.gg/R6
57
57
  - [defineVariables](#variables) - create CSS variables (tokens) that can be used in any styling function
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
- - [defineFont](#custom-fonts) - register custom fonts via `@font-face` (or a remote stylesheet) and expose them as a CSS variable
60
+ - [defineImport](#importing-additional-css) - pull in external CSS files (relative, public, node_modules, or URL)
61
61
  - [keyframes](#keyframes-animations) - create CSS keyframes animation that can be used and imported in any styling function
62
62
 
63
63
  ### Styling helpers & utility
@@ -320,86 +320,47 @@ Example usage:
320
320
  styled('div', { base: { textStyle: 'headline.large', card: '20px' } });
321
321
  ```
322
322
 
323
- ## Custom fonts
323
+ ## Importing additional CSS
324
324
 
325
- Register custom fonts that will be emitted as `@font-face` declarations and exposed as a CSS variable. Mirrors the developer experience of Next.js / Astro font loaders, but generated at build time alongside the rest of your Salty CSS output.
326
-
327
- The returned object stringifies to its `font-family` value and exposes helpers for explicit usage:
328
-
329
- - `Font.variable` → CSS variable name (e.g. `--font-inter`)
330
- - `Font.fontFamily` → final `font-family` string with fallbacks
331
- - `Font.className` → class that sets the variable + applies the font on a subtree
332
- - `Font.style` → object you can spread on a React `style` prop
325
+ 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.
333
326
 
334
327
  ```ts
335
- // /styles/fonts.css.ts
336
- import { defineFont } from '@salty-css/core/factories';
337
-
338
- // 1. Local or self-hosted @font-face sources.
339
- // URLs are passed through as-is (use a public-folder path or a CDN URL).
340
- export const Inter = defineFont({
341
- name: 'Inter', // CSS font-family value
342
- variable: '--font-inter', // Optional — accepts 'font-inter' too; if omitted we derive `--font-<name>-<hash>` from the inputs
343
- display: 'swap', // Optional default applied to variants without their own `display`
344
- fallback: ['system-ui', 'sans-serif'], // Optional family fallbacks appended after `name`
345
- variants: [
346
- {
347
- weight: 400,
348
- style: 'normal',
349
- // Shorthand: pass a string and the `format()` descriptor is auto-detected
350
- // from the file extension (woff2, woff, ttf, otf, eot, svg, ttc).
351
- src: '/fonts/inter-400.woff2',
352
- },
353
- {
354
- weight: 700,
355
- style: 'normal',
356
- // Multiple sources can be a string array — first entry is preferred;
357
- // the browser picks the first format it supports.
358
- src: ['/fonts/inter-700.woff2', '/fonts/inter-700.ttf'],
359
- },
360
- {
361
- weight: 400,
362
- style: 'italic',
363
- // Use the `{ url, format }` object form when the URL has no recognisable
364
- // extension (signed CDN URLs, query-only endpoints, etc.). You can also
365
- // mix strings and objects in the same array.
366
- src: ['/fonts/inter-400-italic.woff2', { url: 'https://cdn.example.com/inter-italic', format: 'woff' }],
367
- },
368
- ],
369
- });
370
-
371
- // 2. Remote stylesheet (Google Fonts, etc.). Emits `@import url(...)` and still
372
- // registers the CSS variable so usage stays the same as the @font-face flow.
373
- export const InterCdn = defineFont({
374
- name: 'Inter',
375
- variable: '--font-inter',
376
- import: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap',
377
- });
328
+ // /styles/imports.css.ts
329
+ import { defineImport } from '@salty-css/core/factories';
330
+
331
+ export default defineImport(
332
+ // Relative to this file
333
+ './reset.css',
334
+ // From node_modules (bare specifier — same as Vite / native CSS @import)
335
+ 'modern-normalize/modern-normalize.css',
336
+ // From node_modules (~ prefix same resolver, webpack-style)
337
+ '~normalize.css/normalize.css',
338
+ // From your app's public/ folder (served at the host root)
339
+ '/fonts/inter.css',
340
+ // External URL
341
+ 'https://fonts.googleapis.com/css2?family=Inter&display=swap',
342
+ // Object form attach media or supports() conditions
343
+ { url: './print.css', media: 'print' },
344
+ { url: './p3.css', supports: 'color(display-p3 1 1 1)' }
345
+ );
378
346
  ```
379
347
 
380
- Example usage:
348
+ Path resolution:
381
349
 
382
- ```tsx
383
- import { Inter } from './fonts.css';
384
- import { styled } from '@salty-css/react/styled';
350
+ | Pattern | Behaviour |
351
+ | --------------------------- | ---------------------------------------------------------------------------------------- |
352
+ | `http://`, `https://`, `//` | Emitted verbatim |
353
+ | Starts with `/` | Public-folder URL — emitted verbatim, the browser resolves it against your host |
354
+ | Starts with `./` or `../` | Resolved at build time relative to the file that called `defineImport` |
355
+ | `~package/file.css` | Stripped of the leading `~`, then resolved from `node_modules` and copied into the build |
356
+ | `package/file.css` (bare) | Same `node_modules` resolution as the `~` form |
385
357
 
386
- // Apply the font globally by attaching its className high up in the tree.
387
- // This sets `--font-inter` on the subtree and applies `font-family: var(--font-inter)`.
388
- export const App = ({ children }) => <div className={Inter.className}>{children}</div>;
358
+ 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`.
389
359
 
390
- // `Inter` stringifies to its font-family value (with fallbacks), so it can be used directly.
391
- export const Heading = styled('h1', {
392
- base: {
393
- fontFamily: `${Inter}`,
394
- },
395
- });
360
+ The full layer order in the generated `index.css` is:
396
361
 
397
- // Or reference the CSS variable explicitly.
398
- export const Body = styled('p', {
399
- base: {
400
- fontFamily: `var(${Inter.variable})`,
401
- },
402
- });
362
+ ```css
363
+ @layer imports, reset, global, templates, l0, l1, l2, l3, l4, l5, l6, l7, l8;
403
364
  ```
404
365
 
405
366
  ## Keyframes animations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/eslint-plugin-core",
3
- "version": "0.1.0-feat-define-font.0",
3
+ "version": "0.1.0-feat-define-import.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@salty-css/core": "^0.1.0-feat-define-font.0",
37
+ "@salty-css/core": "^0.1.0-feat-define-import.0",
38
38
  "eslint": ">=9.x || >=8.x || >=7.x"
39
39
  }
40
40
  }