andywer / andywer/ideabox

ReactCSSDOM

Aperta
#15 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Nessun dato sulla lingua
Stelle
1
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Extend `react-dom` to provide a generic, fully featured, declarative styling API that is as easy to use as inline styles, but comes with the power of CSS classes:

```jsx
import React from 'react'

const MyButton = ({ children, primary }) => {
return (
{children}
)
}
export default MyButton
```

To render your app:

```jsx
import * as ReactCSSDOM from 'react-css-dom' // instead of react-dom
import MyButton from './Button'

ReactCSSDOM.render(
Click me,
document.getElementById('demo')
)
```

Server-side rendering should also be really simple. Something like that:

```jsx
import * as ReactCSSDOM from 'react-css-dom' // instead of react-dom
import MyButton from './Button'

const stylesheet = ReactCSSDOM.createStylesheet()
const rendered = ReactCSSDOM.renderToString(Click me, stylesheet)

const html = `


${stylesheet.toStyleTag()}


${rendered}

`
```

## Benefits

- Great for component libraries, since it requires no dependencies to be added to the library
- Thus helps keeping the bundle small
- Dead-simple to set up, even for SSR
- Generic, universal styling API

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.