Skip to content

Commit 65fcb77

Browse files
committed
add docs, improve cli
1 parent 9603ec5 commit 65fcb77

17 files changed

Lines changed: 2470 additions & 288 deletions

.github/workflows/deploy.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Sample workflow for building and deploying a VitePress site to GitHub Pages
2+
#
3+
name: Deploy VitePress site to Pages
4+
5+
on:
6+
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
7+
# using the `master` branch as the default branch.
8+
push:
9+
branches: [main]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
21+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
22+
concurrency:
23+
group: pages
24+
cancel-in-progress: false
25+
26+
jobs:
27+
# Build job
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0 # Not needed if lastUpdated is not enabled
35+
# - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
36+
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
37+
- name: Setup Node
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 20
41+
cache: npm # or pnpm / yarn
42+
- name: Setup Pages
43+
uses: actions/configure-pages@v4
44+
- name: Install dependencies
45+
run: npm ci # or pnpm install / yarn install / bun install
46+
- name: Build with VitePress
47+
run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
48+
- name: Upload artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: docs/.vitepress/dist
52+
53+
# Deployment job
54+
deploy:
55+
environment:
56+
name: github-pages
57+
url: ${{ steps.deployment.outputs.page_url }}
58+
needs: build
59+
runs-on: ubuntu-latest
60+
name: Deploy
61+
steps:
62+
- name: Deploy to GitHub Pages
63+
id: deployment
64+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
lib
2+
lib
3+
docs/.vitepress/cache

README.md

Lines changed: 17 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -2,168 +2,37 @@
22

33
[![Node.js CI](https://github.com/typicode/mistcss/actions/workflows/node.js.yml/badge.svg)](https://github.com/typicode/mistcss/actions/workflows/node.js.yml)
44

5-
> Write atomic React components using only CSS! (JS-from-CSS™)
5+
> Write React components using CSS only
66
7-
## Why?
7+
MistCSS is a new, better and faster way to write visual components. ~~CSS-in-JS~~? Nope! JS-from-CSS 👍
88

9-
- CSS is a beautiful language 💖, getting better every year 🚀.
10-
- Easily distinguish between pure visual/atomic components and more complex ones by their extension (`*.mist.css`).
11-
- Write less and focus on style to avoid context-switching with JS, reducing bugs.
12-
- Gain automatic type safety for your React components; MistCSS compiles to TSX.
13-
- Enjoy a zero-runtime experience.
14-
- Works with Next, Remix, Astro, ... any modern React framework.
9+
View the [site](https://typicode.github.io/mistcss) to learn more.
1510

16-
## Install
17-
18-
```shell
19-
npm install mistcss --save-dev
20-
```
21-
22-
## Usage
23-
24-
### 1. Create your first CSS component
25-
26-
Assuming your React components are in `src/components`, let's create a basic Button component using CSS.
27-
28-
`src/components/Button.mist.css`
11+
Supports Next.js, Remix and TailwindCSS. More to come.
2912

3013
```css
31-
@scope (.btn) {
32-
button:scope {
33-
/* Default style */
34-
font-size: 1rem;
35-
border-radius: 0.25rem;
36-
37-
&[data-size='lg'] {
38-
font-size: 1.5rem;
39-
}
40-
41-
&[data-size='sm'] {
42-
font-size: 0.75rem;
43-
}
14+
@scope (.paragraph) {
15+
p {
16+
color: black;
4417

45-
&[data-danger] {
46-
background-color: red;
47-
color: white;
18+
[data-error] {
19+
color: red;
4820
}
4921
}
5022
}
5123
```
5224

53-
Note: the class in `@scope` needs to be unique across your project. Plans are in place to automate this check.
54-
55-
### 2. Compile to a React component
56-
57-
```shell
58-
mistcss src/components/Button.mist.css
59-
# Creates Button.mist.css.tsx
60-
```
61-
62-
Now, you can import your React component.
63-
64-
```tsx
65-
import { Button } from '.components/Button.mist.css'
66-
67-
export default function App() {
68-
return (
69-
<main>
70-
<Button size="lg" danger>
71-
OMG 😱 JS from CSS
72-
</Button>
73-
74-
{/* 💥 TypeScript will catch the error here */}
75-
<Button size="lgg">Submit</Button>
76-
</main>
77-
)
78-
}
79-
```
80-
81-
### 3. Integrate it into your workflow
82-
83-
Edit `package.json`:
84-
85-
```json
86-
{
87-
"scripts": {
88-
"mistcss-dev": "mistcss ./src --watch",
89-
"mistcss-build": "mistcss ./src"
90-
}
91-
}
92-
```
93-
94-
Use tools like [concurrently](https://github.com/open-cli-tools/concurrently) to run it alongside your other scripts in development.
95-
96-
### 4. TailwindCSS (optional)
97-
98-
If you're using NextJS, you may need to add [support for nested declarations](https://tailwindcss.com/docs/using-with-preprocessors#nesting).
25+
```jsx
26+
import { Paragraph } from 'Paragraph.mist.css'
9927

100-
Use Tailwind's `@apply` directive to style your CSS component. For example:
101-
102-
```css
103-
&[data-danger] {
104-
@apply bg-red-700 text-white;
105-
}
106-
```
107-
108-
### 5. Ignoring generated files
109-
110-
Edit `.gitignore`:
111-
112-
```gitignore
113-
*.mist.css.tsx # Ignore compiled files
114-
```
115-
116-
Edit `.prettierignore`:
117-
118-
```gitignore
119-
*.mist.css.tsx # Ignore compiled files
120-
```
121-
122-
Edit `eslint.config.js`:
123-
124-
```js
125-
{
126-
ignores: ['**/*.mist.css.tsx']
127-
}
128-
```
129-
130-
Edit `.vscode/settings.json`:
131-
132-
```json
133-
{
134-
"files.exclude": {
135-
"**/*.mist.css.tsx": true
136-
}
137-
}
138-
```
139-
140-
## The power of CSS
141-
142-
Since MistCSS uses pure CSS, you can use **all** CSS features:
143-
144-
- Container queries `@container`, ...
145-
- CSS variables `--primary-color`, ...
146-
- Media queries `@media (prefers-color-scheme: dark)`, ...
147-
- And more...
148-
149-
This approach allows you to stay focused on styling without the mental switch to JS.
150-
151-
## Origin of the name
152-
153-
```
154-
The C in CSS stands for cascade 🌊
155-
Atomized water forms mist 🌫️
156-
MistCSS creates pure CSS atomic components 🌬️
28+
<Paragraph>I'm React component written in CSS only</Paragraph>
29+
<Paragraph error>I can accept props</Paragraph>
15730
```
15831
159-
## Roadmap
32+
## Documentation
16033
161-
MistCSS is a new project, so expect **breaking changes** until `v1.0`.
34+
https://typicode.github.io/mistcss
16235
163-
If you like this idea and want to help, please consider having your company [sponsor](https://github.com/typicode/mistcss) it 🙇. This project is not backed by a large company.
36+
## Why the name?
16437
165-
- [x] Release 🥳
166-
- [x] Add TailwindCSS support
167-
- [ ] Add Vite support
168-
- [ ] CLI and compiler improvements
169-
- [ ] v1.0
38+
C in CSS stands for cascade 🌊 → atomized water forms mist 🌫️ → MistCSS creates pure CSS atomic components 🌬️

docs/.vitepress/config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: 'MistCSS',
6+
description: 'Write atomic React components using only CSS',
7+
head: [
8+
[
9+
'link',
10+
{
11+
rel: 'icon',
12+
href: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="85">🌬️</text></svg>',
13+
},
14+
],
15+
],
16+
base: '/mistcss/',
17+
themeConfig: {
18+
// https://vitepress.dev/reference/default-theme-config
19+
logo: '/logo.svg',
20+
nav: [
21+
{ text: 'Guide', link: '/getting-started' },
22+
{ text: 'Sponsor', link: 'https://github.com/sponsors/typicode' },
23+
],
24+
25+
sidebar: [
26+
{ text: 'Getting Started', link: '/getting-started' },
27+
{ text: 'Integrate to your Workflow', link: '/workflow' },
28+
{ text: 'Roadmap', link: '/roadmap' },
29+
],
30+
31+
socialLinks: [
32+
{ icon: 'github', link: 'https://github.com/typicode/mistcss' },
33+
{ icon: 'twitter', link: 'https://twitter.com/typicode' },
34+
],
35+
},
36+
})

docs/App.tsx.png

37.2 KB
Loading

docs/App.tsx_dark.svg

Lines changed: 145 additions & 0 deletions
Loading

docs/App.tsx_light.svg

Lines changed: 105 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)