Skip to content

Commit 7f4b743

Browse files
authored
Merge pull request #344 from csandman/feat/demo
2 parents e40333b + e896665 commit 7f4b743

25 files changed

+7072
-113
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ tmp/
66
# Codemod generated files
77
codemod/**/*.js
88
codemod/**/*.d.ts
9+
10+
# Demo files
11+
demo/**/*

.github/workflows/package-size-report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
uses: actions/setup-node@v4
1616
with:
1717
node-version: 20
18+
cache: "npm"
1819

1920
- name: Package size report
2021
uses: pkg-size/action@v1

.github/workflows/pkg-pr.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish Pull Requests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- run: corepack enable
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: "npm"
22+
23+
- name: Install dependencies
24+
run: npm install
25+
26+
- name: Build
27+
run: npm run build
28+
29+
- run: npx pkg-pr-new publish --compact --template './demo'

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing
2+
3+
Thanks for your interest in `chakra-react-select`! All forms of contribution are
4+
welcome, from issue reports to PRs and documentation / write-ups.
5+
6+
Before you open a PR:
7+
8+
- In development, run `npm run install:all` to setup the dependencies for the
9+
core package and the demo.
10+
- Run `npm run dev` to build (and watch) the package source, as well as run the
11+
demo project which can be viewed at http://localhost:5152.
12+
- Please ensure all the examples work correctly after your change.
13+
- Also run `npm run lint` to ensure that the change meets the projects code
14+
style setup.
15+
- Make sure there's an issue open for any work you take on and intend to submit
16+
as a pull request - it helps core members review your concept and direction
17+
early and is a good way to discuss what you're planning to do.
18+
- If you open an issue and are interested in working on a fix, please let us
19+
know. We'll help you get started, rather than inadvertently doubling up on
20+
your hard work.
21+
- All new features and changes need documentation. If you don't have time to
22+
write any, leave a note in your PR.

README.md

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
# chakra-react-select v5
1212

13+
This component is a wrapper for the popular react component
14+
[React Select](https://react-select.com/home) made using the UI library
15+
[Chakra UI](https://v2.chakra-ui.com/).
16+
17+
> [!IMPORTANT]
18+
>
1319
> This version of `chakra-react-select` is updated for
1420
> [Chakra UI v2](https://v2.chakra-ui.com/getting-started/migration) which works
1521
> exclusively with React v18. `chakra-react-select` v3, which is compatible with
@@ -31,10 +37,6 @@
3137
[![](https://img.shields.io/badge/Code_Style-prettier-c596c7.svg?logo=prettier "Code Style: Prettier")](https://github.com/prettier/prettier)
3238
[![](https://badgen.net/github/license/csandman/chakra-react-select "MIT License")](LICENSE.md)
3339

34-
This component is a wrapper for the popular react component
35-
[react-select](https://react-select.com/home) made using the UI library
36-
[Chakra UI](https://v2.chakra-ui.com/).
37-
3840
| Light Mode | Dark Mode |
3941
| :-------------------------------------------------: | :-----------------------------------------------: |
4042
| ![Light Mode Demo](./.github/images/demo-light.png) | ![Dark Mode Demo](./.github/images/demo-dark.png) |
@@ -43,11 +45,13 @@ Check out the demo here:
4345

4446
[![SB-TS]](https://stackblitz.com/edit/vitejs-vite-lzaqwr?file=src%2Fapp.tsx)
4547

46-
**NOTE:** Before leaving an issue on this project, remember that this is just a
47-
_wrapper_ for `react-select`, not a standalone package. A large percentage of
48-
the questions people have end up being about how `react-select` itself works, so
49-
please read through their documentation to familiarize yourself with it!
50-
https://react-select.com/home
48+
> [!NOTE]
49+
>
50+
> Before leaving an issue on this project, remember that this is just a
51+
> _wrapper_ for `react-select`, not a standalone package. A large percentage of
52+
> the questions people have end up being about how `react-select` itself works,
53+
> so please read through their documentation to familiarize yourself with it!
54+
> https://react-select.com/home
5155
5256
## Contents
5357

@@ -94,11 +98,13 @@ npm i @chakra-ui/react @emotion/react@^11.8.1 @emotion/styled@^11 framer-motion@
9498
yarn add @chakra-ui/react @emotion/react@^11.8.1 @emotion/styled@^11 framer-motion@^6
9599
```
96100

97-
**NOTE:** As of
98-
[`v3.3.3`](https://github.com/csandman/chakra-react-select/releases/tag/v3.3.3),
99-
your project will need to have a minimum of `@emotion/[email protected]` installed to
100-
avoid having multiple copies of `@emotion/react` installed. For more info, see
101-
[PR #115](https://github.com/csandman/chakra-react-select/pull/115).
101+
> [!NOTE]
102+
>
103+
> As of
104+
> [`v3.3.3`](https://github.com/csandman/chakra-react-select/releases/tag/v3.3.3),
105+
> your project will need to have a minimum of `@emotion/[email protected]` installed
106+
> to avoid having multiple copies of `@emotion/react` installed. For more info,
107+
> see [PR #115](https://github.com/csandman/chakra-react-select/pull/115).
102108
103109
After Chakra UI is set up,
104110
[install this package from NPM](https://www.npmjs.com/package/chakra-react-select):
@@ -172,6 +178,8 @@ return (
172178

173179
#### `tagColorScheme`
174180

181+
> [!NOTE]
182+
>
175183
> Renamed from `colorScheme` in
176184
> [`v5.0.0`](https://github.com/csandman/chakra-react-select/releases/tag/v5.0.0)
177185
@@ -346,16 +354,19 @@ highlight color, you can pass the `selectedOptionColorScheme` prop to change it.
346354
This prop will accept any named color from your theme's color palette, and it
347355
will use the `500` value in light mode or the `300` value in dark mode.
348356

349-
> **NOTE:** This prop can only be used for named colors from your theme, not
350-
> arbitrary hex/rgb colors. If you would like to use a specific color for the
351-
> background that's not a part of your theme, use the
352-
> [`chakraStyles`](#chakrastyles) prop to customize it (see
357+
> [!NOTE]
358+
>
359+
> This prop can only be used for named colors from your theme, not arbitrary
360+
> hex/rgb colors. If you would like to use a specific color for the background
361+
> that's not a part of your theme, use the [`chakraStyles`](#chakrastyles) prop
362+
> to customize it (see
353363
> [#99](https://github.com/csandman/chakra-react-select/discussions/99) for an
354364
> example).
355365
>
356-
> Prior to `v4.6.0` this prop was named `selectedOptionColor`, and it was
357-
> renamed to prevent confusion about its purpose. `selectedOptionColor` is still
358-
> available but will be removed in the next major version.
366+
> Prior to
367+
> [`v4.6.0`](https://github.com/csandman/chakra-react-select/releases/tag/v4.6.0)
368+
> this prop was named `selectedOptionColor`, and it was renamed to prevent
369+
> confusion about its purpose.
359370
360371
```tsx
361372
return (
@@ -420,9 +431,10 @@ elements.
420431

421432
#### `useBasicStyles` (removed)
422433

423-
This prop was removed in `v5.0.0`, as these styles are now the default styles
424-
applied to the component. If you'd like to keep the legacy styles, here are some
425-
examples (for each
434+
This prop was removed in
435+
[`v5.0.0`](https://github.com/csandman/chakra-react-select/releases/tag/v5.0.0),
436+
as these styles are now the default styles applied to the component. If you'd
437+
like to keep the legacy styles, here are some examples (for each
426438
[`variant`](#variant--options-outline--filled--flushed--unstyled--default-outline))
427439
of how you could accomplish that with the [`chakraStyles`](#chakrastyles) prop:
428440

@@ -683,8 +695,10 @@ or are themselves those components. As this package pulls directly from your
683695
Chakra theme, any changes you make to those components' themes will propagate to
684696
the components in this package.
685697

686-
> **NOTE:** Some of the theme styles are manually overridden when this package
687-
> implements them. This is necessary for implementing styles for
698+
> [!NOTE]
699+
>
700+
> Some of the theme styles are manually overridden when this package implements
701+
> them. This is necessary for implementing styles for
688702
> [`size`](#size--options-responsivevaluesm--md--lg--default-md) variants in
689703
> components that do not natively have them in Chakra's default theme. This
690704
> mostly concerns components that make up the `Menu`, but there are a few other
@@ -714,9 +728,11 @@ Here is a list of all components that will be affected by changes to your theme:
714728
In addition to specific component styles, any changes you make to your global
715729
color scheme will also be reflected in these custom components.
716730

717-
> **NOTE:** Only make changes to your global component themes if you want them
718-
> to appear in all instances of that component. Otherwise, just change the
719-
> individual components' styles using the `chakraStyles` prop.
731+
> [!NOTE]
732+
>
733+
> Only make changes to your global component themes if you want them to appear
734+
> in all instances of that component. Otherwise, just change the individual
735+
> components' styles using the `chakraStyles` prop.
720736
721737
### `className`
722738

@@ -1101,9 +1117,10 @@ const GooglePlacesAutocomplete = () => {
11011117
export default GooglePlacesAutocomplete;
11021118
```
11031119

1104-
> **NOTE:** An API key would be needed to create a CodeSandbox example for this
1105-
> so you will have to implement it in your own project if you'd like to test it
1106-
> out.
1120+
> [!NOTE]
1121+
>
1122+
> An API key would be needed to create a CodeSandbox example for this so you
1123+
> will have to implement it in your own project if you'd like to test it out.
11071124
11081125
## Usage with React Form Libraries
11091126

@@ -1133,7 +1150,9 @@ component or [`useController`](https://react-hook-form.com/api/usecontroller)
11331150
hook in order to keep the value(s) tracked in `react-hook-form`'s state. Here
11341151
are some examples using each:
11351152

1136-
> **NOTE:** These examples still need to be updated to the newest version of
1153+
> [!NOTE]
1154+
>
1155+
> These examples still need to be updated to the newest version of
11371156
> `chakra-react-select` at some point, but they should still give you a good
11381157
> idea of how to implement what you want.
11391158
@@ -1238,8 +1257,8 @@ issue using one of these templates:
12381257
### StackBlitz
12391258

12401259
Recently, CodeSandbox severely limited their free tier, so this project has
1241-
started to move away from it. Here are a couple StackBlitz templates you can use
1242-
as an alternative.
1260+
started to move away from it. Here are a couple
1261+
[StackBlitz](https://stackblitz.com/) templates you can use as an alternative.
12431262

12441263
- Vanilla JS Starter:
12451264
https://stackblitz.com/edit/vitejs-vite-fatlrb?file=src%2Fapp.jsx

demo/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

demo/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Chakra React Select Demo
2+
3+
This is a demo application for testing out
4+
[`chakra-react-select`](../README.md).

demo/eslint.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import js from "@eslint/js";
2+
import prettier from "eslint-config-prettier";
3+
import react from "eslint-plugin-react";
4+
import reactHooks from "eslint-plugin-react-hooks";
5+
import reactRefresh from "eslint-plugin-react-refresh";
6+
import globals from "globals";
7+
import tseslint from "typescript-eslint";
8+
9+
const eslintConfig = tseslint.config(
10+
{ ignores: ["dist"] },
11+
{
12+
settings: { react: { version: "18.3" } },
13+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
14+
files: ["**/*.{ts,tsx}"],
15+
languageOptions: {
16+
ecmaVersion: 2020,
17+
globals: globals.browser,
18+
},
19+
plugins: {
20+
react,
21+
"react-hooks": reactHooks,
22+
"react-refresh": reactRefresh,
23+
},
24+
rules: {
25+
...react.configs.recommended.rules,
26+
...react.configs["jsx-runtime"].rules,
27+
...reactHooks.configs.recommended.rules,
28+
"react-refresh/only-export-components": [
29+
"warn",
30+
{ allowConstantExport: true },
31+
],
32+
"react/no-unescaped-entities": "off",
33+
},
34+
},
35+
prettier
36+
);
37+
38+
export default eslintConfig;

demo/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Chakra React Select Demo</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)