Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
phonzammi committed Nov 14, 2024
1 parent d955a5c commit ee63b61
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 42 deletions.
39 changes: 9 additions & 30 deletions packages/vike-react-chakra/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<!-- WARNING: keep links absolute in this file so they work on NPM too -->

[<img src="https://vike.dev/vike-readme.svg" align="right" height="90">](https://vike.dev)
[![npm version](https://img.shields.io/npm/v/vike-react-chakra)](https://www.npmjs.com/package/vike-react-chakra)

# `vike-react-chakra`

[Installation](#installation)
[Basic usage](#basic-usage)
[`+chakra` Setting](#chakra-setting)
[See also](#see-also)

<br/>

## Installation

1. npm install @chakra-ui/react @emotion/react vike-react-chakra
1. `npm install vike-react-chakra @chakra-ui/react @emotion/react`
2. Extend `+config.js`:
```js
// pages/+config.js
Expand All @@ -31,9 +26,8 @@
> [!NOTE]
> The `vike-react-chakra` extension requires [`vike-react`](https://vike.dev/vike-react).
<br/>

## Basic usage
3. That's it! You can now use Chakra UI components in any of your components.
```jsx
import { HStack, Button } from '@chakra-ui/react'

Expand All @@ -47,22 +41,14 @@ const Demo = () => {
}
```

> [!NOTE]
> Chakra UI provides a cli tool to add snippets.
> Snippets are pre-built components that you can use to build your UI faster.
> Using the `@chakra-ui/cli` you can add snippets to your project.
```
npx @chakra-ui/cli snippet add
```

<br/>

## `+chakra` Setting
`vike-react-chakra` provides a custom setting, `+chakra`, for configuring custom theme system, custom locale to adds `LocaleProvider` and can be used to disable Chakra UI for specific pages.

`vike-react-chakra` provides a configuration `+chakra` for setting a custom theme system and custom locale.
```js
// pages/+chakra.js
import React, { ReactNode } from 'react'

import { createSystem, defaultConfig, defineConfig } from '@chakra-ui/react'

const customConfig = defineConfig({
Expand All @@ -78,20 +64,13 @@ const system = createSystem(defaultConfig, customConfig)

export const chakra = {
system,
locale: "ar-BH"
locale: "fr-FR"
}
```

To disable Chakra UI for specific page:
You can remove Chakra UI [for some of your pages](https://vike.dev/config#inheritance):
```js
// pages/about/+chakra.js
export const chakra = null
```

<br/>

## See also

- [Chakra UI Components](https://www.chakra-ui.com/docs/components/concepts/overview)
- [Chakra UI Styling](https://www.chakra-ui.com/docs/styling/overview)
- [Chakra UI Theming](https://www.chakra-ui.com/docs/theming/overview)
export const chakra = null
```
2 changes: 1 addition & 1 deletion packages/vike-react-chakra/integration/+config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { config as default }

import { LocaleProviderProps, SystemContext } from '@chakra-ui/react'
import type { LocaleProviderProps, SystemContext } from '@chakra-ui/react'
import type { Config } from 'vike/types'

const config = {
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-react-chakra/integration/Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { Wrapper }

import React, { ReactNode } from 'react'
import React, { type ReactNode } from 'react'
import { ChakraProvider, LocaleProvider, defaultSystem } from '@chakra-ui/react'
import { usePageContext } from 'vike-react/usePageContext'

Expand Down
4 changes: 1 addition & 3 deletions packages/vike-react-chakra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
"vike-react": ">=0.4.13"
},
"devDependencies": {
"@brillout/release-me": "0.3.8",
"@brillout/release-me": "^0.3.8",
"@chakra-ui/react": "^3.0.2",
"@emotion/react": "^11.13.3",
"@types/node": "^20.11.17",
"@types/react": "^18.2.55",
"jsdom": "^24.0.0",
"react": "^18.3.1",
"rimraf": "^5.0.5",
"typescript": "^5.5.3",
Expand Down
8 changes: 1 addition & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee63b61

Please sign in to comment.