@salty-css/next 0.0.1-alpha.37

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 ADDED
@@ -0,0 +1,158 @@
1
+ # Salty CSS - Kinda sweet but yet spicy CSS-in-JS library
2
+
3
+ In the world of frontend dev is there anything saltier than CSS? Salty CSS is built to provide better developer experience for developers looking for performant and feature rich CSS-in-JS solutions.
4
+
5
+ ## Features
6
+
7
+ - Build time compilation to achieve awesome runtime performance and minimal size
8
+ - Next.js, React Server Components, Vite and Webpack support
9
+ - Type safety with out of the box TypeScript and ESLint plugin
10
+ - Advanced CSS variables configuration to allow smooth token usage
11
+ - Style templates to create reusable styles easily
12
+
13
+ ## Get started
14
+
15
+ ### TL;DR
16
+
17
+ - Initialize: `npx salty-css init [directory]`
18
+ - Create component: `npx salty-css generate [filePath]`
19
+ - Build: `npx salty-css build [directory]`
20
+
21
+ ### Quick way of using `salty-css` CLI
22
+
23
+ #### Initialize Salty CSS for a project
24
+
25
+ In your existing repository run `npx salty-css init [directory]` which installs required salty-css packages to the current directory and creates project files to the provided directory. Directory can be left blank if you want files to be created to the current directory. Init will also create `.saltyrc` which contains some metadata for future CLI commands.
26
+
27
+ #### Create components
28
+
29
+ Components can be created with `npx salty-css generate [filePath]` which then creates a new Salty CSS component file to the specified path. Additional options like `--dir, --tag, --name and --className` are also supported. Read more about them with `npx salty-css generate --help`
30
+
31
+ #### Build / Compile Salty CSS
32
+
33
+ If you want to manually build your project that can be done by running `npx salty-css build [directory]`. Directory is not required as CLI can use default directory defined in `.saltyrc`. Note that build generates css files but Vite / Webpack plugin is still required for full support.
34
+
35
+ #### Update Salty CSS packages
36
+
37
+ To ease the pain of package updates all Salty CSS packages can be updated with `npx salty-css update`
38
+
39
+ ### Manual work
40
+
41
+ #### React
42
+
43
+ 1. Install related dependencies: `npm i @salty-css/core @salty-css/react`
44
+ 2. Create `salty.config.ts` to your app directory
45
+
46
+ #### Vite
47
+
48
+ 1. First check the instructions for React
49
+ 2. For Vite support install `npm i -D @salty-css/vite`
50
+ 3. In `vite.config.ts` add import for salty plugin `import { saltyPlugin } from '@salty-css/vite';` and then add `saltyPlugin(__dirname)` to your vite configuration plugins
51
+ 4. Make sure that `salty.config.ts` and `vite.config.ts` are in the same folder!
52
+
53
+ ### Create components
54
+
55
+ 1. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
56
+
57
+ ## Code examples
58
+
59
+ ### Basic usage example with Button
60
+
61
+ **Salty config**
62
+
63
+ ```tsx
64
+ import { defineConfig } from '@salty-css/core/config';
65
+
66
+ export const config = defineConfig({
67
+ variables: {
68
+ colors: {
69
+ brand: '#111',
70
+ highlight: 'yellow',
71
+ },
72
+ },
73
+ global: {
74
+ html: {
75
+ backgroundColor: '#f8f8f8',
76
+ },
77
+ },
78
+ });
79
+ ```
80
+
81
+ **Your React component file**
82
+
83
+ ```tsx
84
+ import { Wrapper } from '../components/wrapper/wrapper.css';
85
+ import { Button } from '../components/button/button.css';
86
+
87
+ export const IndexPage = () => {
88
+ return (
89
+ <Wrapper>
90
+ <Button variant="solid" onClick={() => alert('It is a button.')}>
91
+ Outlined
92
+ </Button>
93
+ </Wrapper>
94
+ );
95
+ };
96
+ ```
97
+
98
+ **Wrapper** (`components/wrapper/wrapper.css.ts`)
99
+
100
+ ```tsx
101
+ import { styled } from '@salty-css/react/styled';
102
+
103
+ export const Wrapper = styled('div', {
104
+ base: {
105
+ display: 'block',
106
+ padding: '2vw',
107
+ },
108
+ });
109
+ ```
110
+
111
+ **Button** (`components/button/button.css.ts`)
112
+
113
+ ```tsx
114
+ import { styled } from '@salty-css/react/styled';
115
+
116
+ export const Button = styled('button', {
117
+ base: {
118
+ display: 'block',
119
+ padding: `0.6em 1.2em`,
120
+ border: '1px solid currentColor',
121
+ background: 'transparent',
122
+ color: 'currentColor/40',
123
+ cursor: 'pointer',
124
+ transition: '200ms',
125
+ textDecoration: 'none',
126
+ '&:hover': {
127
+ background: 'black',
128
+ borderColor: 'black',
129
+ color: 'white',
130
+ },
131
+ '&:disabled': {
132
+ opacity: 0.25,
133
+ pointerEvents: 'none',
134
+ },
135
+ },
136
+ variants: {
137
+ variant: {
138
+ outlined: {
139
+ // same as default styles
140
+ },
141
+ solid: {
142
+ '&:not(:hover)': {
143
+ background: 'black',
144
+ borderColor: 'black',
145
+ color: 'white',
146
+ },
147
+ '&:hover': {
148
+ background: 'transparent',
149
+ borderColor: 'currentColor',
150
+ color: 'currentColor',
151
+ },
152
+ },
153
+ },
154
+ },
155
+ });
156
+ ```
157
+
158
+ More examples coming soon
package/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@salty-css/webpack"),s=a=>{const{webpack:t,...u}=a;return{...u,webpack(e,r){const{dir:i,isServer:l}=r;return c.saltyPlugin(e,i,l),t&&t(e,r),e}}};exports.default=s;exports.withSaltyCss=s;
package/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ type NextWebpackFNLike = (config: any, options: any) => any;
2
+ interface NextConfigLike {
3
+ webpack?: null | undefined | NextWebpackFNLike;
4
+ }
5
+ export declare const withSaltyCss: <T extends NextConfigLike>(nextConfig: T) => T;
6
+ export default withSaltyCss;
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import { saltyPlugin as n } from "@salty-css/webpack";
2
+ const p = (s) => {
3
+ const { webpack: t, ...a } = s;
4
+ return {
5
+ ...a,
6
+ webpack(r, e) {
7
+ const { dir: c, isServer: i } = e;
8
+ return n(r, c, i), t && t(r, e), r;
9
+ }
10
+ };
11
+ };
12
+ export {
13
+ p as default,
14
+ p as withSaltyCss
15
+ };
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@salty-css/next",
3
+ "version": "0.0.1-alpha.37",
4
+ "main": "./dist/index.js",
5
+ "module": "./dist/index.mjs",
6
+ "typings": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "license": "MIT",
9
+ "private": false,
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "homepage": "https://github.com/margarita-form/salty-css",
14
+ "bugs": {
15
+ "url": "https://github.com/margarita-form/salty-css/issues"
16
+ },
17
+ "files": [
18
+ "**/*",
19
+ "!**/*.tsbuildinfo"
20
+ ],
21
+ "nx": {
22
+ "sourceRoot": "libs/next/src",
23
+ "name": "next"
24
+ },
25
+ "exports": {
26
+ ".": {
27
+ "import": "./index.js",
28
+ "require": "./index.cjs"
29
+ }
30
+ },
31
+ "dependencies": {
32
+ "@salty-css/core": "^0.0.1-alpha.37",
33
+ "@salty-css/webpack": "^0.0.1-alpha.37"
34
+ }
35
+ }