Skip to content

Commit 779528f

Browse files
authored
V3 (#192)
Co-authored-by: Alex Nicholson <alex.n@clove.kitchen>
1 parent 927070b commit 779528f

176 files changed

Lines changed: 7191 additions & 34341 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/run-tests.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@ name: Run Tests
22
on:
33
pull_request:
44
types: [opened, synchronize]
5-
paths:
6-
- packages/**
75
push:
8-
paths:
9-
- packages/**
6+
branches: ["main"]
107
jobs:
118
run-tests:
129
runs-on: ubuntu-latest
@@ -32,5 +29,11 @@ jobs:
3229
- name: Install dependencies
3330
run: pnpm i
3431

32+
- name: Lint
33+
run: pnpm lint
34+
35+
- name: Typecheck
36+
run: pnpm check
37+
3538
- name: Run tests
3639
run: pnpm test

.gitignore

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
node_modules
22
.idea
3-
dist/
3+
.claude
44

5-
.yarn/*
6-
!.yarn/patches
7-
!.yarn/plugins
8-
!.yarn/releases
9-
!.yarn/sdks
10-
!.yarn/versions
5+
dist/
116

127
.docusaurus
8+

.yarn/releases/yarn-4.6.0.cjs

Lines changed: 0 additions & 934 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,46 @@
44
[![Types](https://img.shields.io/npm/types/react-dialog-async.svg)](https://www.npmjs.com/package/react-dialog-async)
55
[![Downloads](https://img.shields.io/npm/dt/react-dialog-async.svg)](https://www.npmjs.com/package/react-dialog-async)
66

7-
React Dialog Async provides a simple hook-based API for managing dialog state in React apps.
8-
9-
* ✅ CSS Framework agnostic - works with any component library or CSS setup
10-
* ✅ Lightweight with zero dependencies
11-
* ✅ Written in Typescript
12-
* ✅ Supports both React and React Native
7+
React Dialog Async provides a hook-based API for managing dialog state in React apps, with a focus on performance and developer ergonomics.
138

149
[✨ Read the docs here ✨](https://react-dialog-async.a16n.dev)
1510

16-
# Quick Start
17-
This example demonstrates how to create a simple dialog that asks the user a question and logs their response to the console:
18-
```js
19-
// 1. Wrap your app with DialogProvider
20-
<DialogProvider>
21-
<App />
22-
</DialogProvider>
11+
# Installation
2312

24-
// 2. Create a dialog component
25-
const QuestionDialog = ({ data, open, handleClose }) => {
26-
if (!open) return null; // Don't render if the dialog is closed
13+
Install the package into your project:
14+
```bash
15+
pnpm add react-dialog-async
16+
```
2717

28-
return (
29-
<div className={'dialog'}>
30-
<p>{data.question}</p>
31-
<button onClick={() => handleClose("No")}>No</button>
32-
<button onClick={() => handleClose("Yes")}>Yes</button>
33-
</div>
34-
)
35-
};
36-
37-
// 3. Use the useDialog hook to show the dialog
38-
const App = () => {
39-
const questionDialog = useDialog(QuestionDialog);
40-
41-
const handleClick = async () => {
42-
const response = await questionDialog.open({
43-
// pass data to the dialog
44-
question: "Do you like apples?"
45-
});
46-
47-
console.log(response) // Will be either "Yes" or "No"
48-
};
18+
## Why use React Dialog Async?
19+
20+
Here's an example of how you might use it to show a confirmation dialog in response to a user action:
21+
22+
```tsx
23+
import { useDialog } from 'react-dialog-async';
24+
25+
const DeleteItemButton = () => {
26+
const dialog = useDialog(ConfirmationDialog);
27+
28+
const handleDelete = async () => {
29+
const result = await dialog.open({
30+
message: "Are you sure you want to delete this item?"
31+
});
32+
33+
if(result?.confirmed) {
34+
deleteItem();
35+
}
36+
}
4937

5038
return (
51-
<button onClick={handleClick}>
52-
Ask me a question
53-
</button>
39+
<Button onClick={handleDelete}>
40+
Delete item
41+
</Button>
5442
);
55-
};
43+
}
5644
```
5745

46+
5847
# Contributing
5948
Contributions are more than welcome!
6049

docs/README.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import { importX } from 'eslint-plugin-import-x';
4+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
5+
6+
export default tseslint.config(
7+
{
8+
settings: {
9+
'import-x/resolver-next': [
10+
createTypeScriptImportResolver({
11+
project: 'packages/*/tsconfig.json',
12+
}),
13+
],
14+
},
15+
},
16+
{ ignores: ['**/dist/**', '**/node_modules/**'] },
17+
{
18+
files: [''],
19+
plugins: { js },
20+
},
21+
importX.flatConfigs.recommended,
22+
tseslint.configs.recommended,
23+
{
24+
rules: {
25+
'@typescript-eslint/no-explicit-any': 'off',
26+
'import-x/order': 'error',
27+
},
28+
},
29+
);

examples/README.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

examples/material-ui/package.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)