0.0.48-alpha • Published 1 year ago
css-to-vanilla-extract v0.0.48-alpha
Generate vanilla-extract typescript file from the CSS (SCSS/SASS) file.
The following APIs are covered.
Motivation
- Generate style definitions received from designers without any errors.
- Cost-effective migration of existing projects using css modules.
Install
npm i -D css-to-vanilla-extract
Usage
Once installed, you can run it to convert css (scss/sass) files to vanilla-extract ts files. For example:
npx css-to-vanilla-extract sample/test.css
Output:sample/test.css.ts
Sample
Input
.foo {
background-color: blue;
}
@media (min-width: 1200px) {
input {
font-size: 5rem;
}
.foo {
font-size: 5rem;
color: red;
}
.bar {
font-size: 10rem;
}
}
@font-face {
font-family: "Roboto";
src: url("https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap");
}
@keyframes slidein {
from {
transform: translateX(0%);
}
to {
transform: translateX(100%);
}
}
.fizz .buzz {
background-color: blue;
}
.fizz .buzz {
font-size: 5rem;
}
Output
import {
globalFontFace,
globalKeyframes,
globalStyle,
style,
} from "@vanilla-extract/css";
globalFontFace("Roboto", {
src: "url(https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap)",
});
globalKeyframes("slidein", {
from: {
transform: "translateX(0%)",
},
to: {
transform: "translateX(100%)",
},
});
export const fizz = style({});
export const bar = style({
"@media": {
"(min-width: 1200px)": {
fontSize: "10rem",
},
},
});
export const buzz = style({
selectors: {
[`${fizz} &`]: {
backgroundColor: "blue",
fontSize: "5rem",
},
},
});
export const foo = style({
backgroundColor: "blue",
"@media": {
"(min-width: 1200px)": {
color: "red",
fontSize: "5rem",
},
},
});
globalStyle("input", {
"@media": {
"(min-width: 1200px)": {
fontSize: "5rem",
},
},
});
Principles of conduct
Please see the principles of conduct when building a site.
License
This library is licensed under the MIT license.
0.0.48-alpha
1 year ago
0.0.47-alpha
1 year ago
0.0.46-alphaa
2 years ago
0.0.41-alpha
2 years ago
0.0.42-alpha
2 years ago
0.0.43-alpha
2 years ago
0.0.45-alphaa
2 years ago
0.0.44-alpha
2 years ago
0.0.39-alpha
2 years ago
0.0.38-alpha
2 years ago
0.0.32-alpha
2 years ago
0.0.37-alpha
2 years ago
0.0.33-alpha
2 years ago
0.0.34-alpha
2 years ago
0.0.30-alpha
2 years ago
0.0.29-alpha
2 years ago
0.0.27-alpha
2 years ago
0.0.26-alpha
2 years ago
0.0.25-alpha
2 years ago
0.0.24-alpha
2 years ago
0.0.23-alpha
2 years ago
0.0.22-alpha
2 years ago
0.0.21-alpha
2 years ago