Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Jun 4, 2024
1 parent 296df22 commit edd5ad7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ MistCSS is a new, better and faster way to write visual components. ~~CSS-in-JS~

All major frameworks are supported.

## Write your component in CSS only
## 1. Write your component in CSS only

This CSS is the only code you'll write for your component.
`./src/Button.mist.css`

```css title="Button.mist.css"
```css
@scope (button.custom-button) {
:scope {
background: black;
color: white;

/* Define component's props directly in your CSS 👇 */
/* 👇 Define component's props directly in your CSS */
&[data-variant="primary"] {
background: blue;
}
Expand All @@ -30,13 +30,27 @@ This CSS is the only code you'll write for your component.
}
```

## Get a type-safe component without writing TypeScript
## 2. Run MistCSS codegen

```jsx title="App.tsx"
```shell
mistcss ./src --target=react --watch
# It will create ./src/Button.mist.tsx
```

## 3. Get a type-safe component without writing TypeScript

`./src/App.tsx`

```jsx
import { CustomButton } from './Button.mist'

export const App = () => (
<CustomButton variant="primary">Save</CustomButton>
<>
<CustomButton variant="primary">Save</CustomButton>

{/* TypeScript will catch the error */}
<CustomButton variant="tertiary">Cancel</CustomButton>
</>
)
```

Expand Down

0 comments on commit edd5ad7

Please sign in to comment.