Skip to content

Commit

Permalink
[🔖]: v2.0.0-rc.1 (#9)
Browse files Browse the repository at this point in the history
* Update documentation

* Update version
  • Loading branch information
mimshins authored Apr 15, 2024
1 parent f5ca1f6 commit faaa126
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ pnpm add react-design-tokens

The library exposes two APIs, `create` and `defaultCSSVariableGenerator`:

### 1. `create(variants, config?): { useTokens, VariantSelector, generateCSSVariablesAsInlineStyle }`
### 1. `create`

```ts
declare const create: (variants, config?) => {
VariantSelector,
useTokens,
generateCSSVariablesAsInlineStyle,
}
```
This is the main API exposed by the library. It will take your variants map and an optional config options to create your theming client.
Expand Down Expand Up @@ -57,15 +65,25 @@ A React hook to use in a component that is descendant of `<VariantSelector>` wra
A helper function to generate CSS variables in valid CSS syntax (`--variable=value`). It is helpful when you want to manually control the population of the CSS variables (e.g. Put initial tokens on html tag with `<html style={generateCSSVariablesAsInlineStyle('dark')} />`)
### 2. `defaultCSSVariableGenerator(context): { variableName: string; variableValue: string } | null`
### 2. `defaultCSSVariableGenerator`
```ts
declare const defaultCSSVariableGenerator: (context: {
tokenFamilyKey: string;
tokenKey: string;
tokenPath: string;
tokenValue: unknown;
}) => {
variableName: string;
variableValue: string;
} | null;
```

The default CSS variable generate function. The generated variables obey the following rules:
- Values that are not of type `string` or `number` will be omitted (returns `null`).
- Values of type `number` will be converted into `{tokenValue}px`.
- The generated variable format: `{ variableName: 'PATH-TO-TOKEN', variableValue: 'tokenValue' }`

The `context` consists of:

#### `context.tokenFamilyKey`:

The key of a root token family.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-design-tokens",
"version": "2.0.0-rc.0",
"version": "2.0.0-rc.1",
"description": "An optimized and creative theming solution that generates CSS variables based on the tokens provided.",
"license": "MIT",
"type": "module",
Expand Down

0 comments on commit faaa126

Please sign in to comment.