Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/modular custom parser #480

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ It's a pun on the tagline.

# Talks and Podcasts

* [React Round Up](https://reactroundup.com/wrangle-your-css-in-js-for-peanuts-using-goober-ft-cristian-bote-rru-177) 👉 https://reactroundup.com/wrangle-your-css-in-js-for-peanuts-using-goober-ft-cristian-bote-rru-177
* ReactDay Berlin 2019 👉 https://www.youtube.com/watch?v=k4-AVy3acqk
* [PodRocket](https://podrocket.logrocket.com/) by [LogRocket](https://logrocket.com/) 👉 https://podrocket.logrocket.com/goober
* [ngParty](https://www.ngparty.cz/) 👉 https://www.youtube.com/watch?v=XKFvOBDPeB0
- [React Round Up](https://reactroundup.com/wrangle-your-css-in-js-for-peanuts-using-goober-ft-cristian-bote-rru-177) 👉 https://reactroundup.com/wrangle-your-css-in-js-for-peanuts-using-goober-ft-cristian-bote-rru-177
- ReactDay Berlin 2019 👉 https://www.youtube.com/watch?v=k4-AVy3acqk
- [PodRocket](https://podrocket.logrocket.com/) by [LogRocket](https://logrocket.com/) 👉 https://podrocket.logrocket.com/goober
- [ngParty](https://www.ngparty.cz/) 👉 https://www.youtube.com/watch?v=XKFvOBDPeB0

# Table of contents

Expand Down Expand Up @@ -285,7 +285,7 @@ const Title = styled('h1', React.forwardRef)`
`;
```

### `setup(pragma: Function, prefixer?: Function, theme?: Function, forwardProps?: Function)`
### `setup(pragma: Function, parser?: Object, theme?: Function, forwardProps?: Function, parser?: Function)`

The call to `setup()` should occur only once. It should be called in the entry file of your project.

Expand All @@ -298,17 +298,26 @@ import { setup } from 'goober';
setup(React.createElement);
```

#### With prefixer
#### With parser

```js
import React from 'react';
import { setup } from 'goober';

const customPrefixer = (key, value) => `${key}: ${value};\n`;

setup(React.createElement, customPrefixer);
setup(React.createElement, { pre: customPrefixer });
```

There are four parser functions you can override to customize how goober handles styles:

- `at`: Handles @ rules.
- `obj`: Handles objects.
- `str`: Handles strings.
- `pre`: Allows for adding a custom prefix function easily within the default `str` parser function.

You can reference the [default parser functions](https://github.com/cristianbote/goober/blob/master/src/core/parse.js) as a starting point.

#### With theme

```js
Expand Down Expand Up @@ -768,7 +777,7 @@ import { setup } from 'goober';
import { prefix } from 'goober/prefixer';

// Bootstrap goober
setup(React.createElement, prefix);
setup(React.createElement, { pre: prefix });
```

And voilà! It is done!
Expand Down
Loading