Skip to content

Commit 01196e3

Browse files
committed
chore: apply lint and formatter
1 parent 511cc9e commit 01196e3

23 files changed

Lines changed: 780 additions & 310 deletions

.github/workflows/pages.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
runs-on: ubuntu-latest
5454
needs: build
5555
steps:
56-
5756
- name: Deploy to GitHub Pages
5857
id: deployment
5958
uses: actions/deploy-pages@v4

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm verify:precommit

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ tsconfig.json
1111
tsconfig.jest.json
1212
vite.config.ts
1313
.github/
14+
.husky/
1415
.vscode/
16+
.oxfmtrc.jsonc
1517
.pnpm-store/
18+
coverage/
1619

1720
# Exclude docs
1821
/docs/

.oxfmtrc.jsonc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 120,
4+
"ignorePatterns": ["dist/**", "docs/dist/**", "docs/node_modules/**", "node_modules/**", "pnpm-lock.yaml"],
5+
}

MIGRATION_TO_V2.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ npm install @reactleaf/modal@2
4242
```ts
4343
// modals/register.ts
4444
export const register = {
45-
Alert: () => import('./Alert'),
46-
Confirm: () => import('./Confirm'),
45+
Alert: () => import("./Alert"),
46+
Confirm: () => import("./Confirm"),
4747
};
4848
```
4949

@@ -58,8 +58,8 @@ export const register = {
5858
**Before (v1.x):**
5959

6060
```tsx
61-
import { ModalProvider } from '@reactleaf/modal';
62-
import register from './modals/register';
61+
import { ModalProvider } from "@reactleaf/modal";
62+
import register from "./modals/register";
6363

6464
function App() {
6565
return (
@@ -73,7 +73,7 @@ function App() {
7373
**After (v2.0):**
7474

7575
```tsx
76-
import { ModalManager, ModalProvider } from '@reactleaf/modal';
76+
import { ModalManager, ModalProvider } from "@reactleaf/modal";
7777

7878
const modal = new ModalManager();
7979

@@ -97,7 +97,7 @@ The `modal` instance passed to `ModalProvider` must be the same instance you cal
9797
**Before (v1.x):**
9898

9999
```tsx
100-
import { BasicModalProps } from '@reactleaf/modal';
100+
import { BasicModalProps } from "@reactleaf/modal";
101101

102102
interface AlertProps extends BasicModalProps {
103103
message: string;
@@ -116,7 +116,7 @@ export default function Alert({ message, close }: AlertProps) {
116116
**After (v2.0):**
117117

118118
```tsx
119-
import { useModalInstance } from '@reactleaf/modal';
119+
import { useModalInstance } from "@reactleaf/modal";
120120

121121
interface AlertProps {
122122
message: string;
@@ -126,9 +126,9 @@ const Alert = ({ message }: AlertProps) => {
126126
const { closeSelf, visible } = useModalInstance();
127127

128128
return (
129-
<div className={visible ? 'visible' : undefined}>
129+
<div className={visible ? "visible" : undefined}>
130130
<p>{message}</p>
131-
<button onClick={() => closeSelf('confirmed')}>OK</button>
131+
<button onClick={() => closeSelf("confirmed")}>OK</button>
132132
</div>
133133
);
134134
};
@@ -145,27 +145,27 @@ export default Alert;
145145
**Before (v1.x):**
146146

147147
```tsx
148-
import { useModal } from '@reactleaf/modal';
148+
import { useModal } from "@reactleaf/modal";
149149

150150
function MyComponent() {
151151
const { openModal } = useModal();
152152

153153
const handleShowAlert = () => {
154-
openModal('Alert', { message: 'Hello!' });
154+
openModal("Alert", { message: "Hello!" });
155155
};
156156
}
157157
```
158158

159159
**After (v2.0):**
160160

161161
```tsx
162-
import { ModalManager } from '@reactleaf/modal';
163-
import Alert from './modals/Alert';
162+
import { ModalManager } from "@reactleaf/modal";
163+
import Alert from "./modals/Alert";
164164

165165
const modal = new ModalManager();
166166

167167
async function handleShowAlert() {
168-
const result = await modal.open(Alert, { message: 'Hello!' });
168+
const result = await modal.open(Alert, { message: "Hello!" });
169169
console.log(result); // 'confirmed'
170170
}
171171
```
@@ -176,7 +176,7 @@ async function handleShowAlert() {
176176

177177
```tsx
178178
const confirmed = await modal.open(Confirm, {
179-
message: 'Are you sure you want to delete this item?',
179+
message: "Are you sure you want to delete this item?",
180180
});
181181

182182
if (confirmed) {
@@ -187,20 +187,16 @@ if (confirmed) {
187187
#### AbortController
188188

189189
```tsx
190-
import { MODAL_ABORTED } from '@reactleaf/modal';
190+
import { MODAL_ABORTED } from "@reactleaf/modal";
191191

192192
const controller = new AbortController();
193193

194194
setTimeout(() => controller.abort(), 5000);
195195

196-
const result = await modal.open(
197-
Alert,
198-
{ message: 'This will auto-close...' },
199-
{ abortController: controller },
200-
);
196+
const result = await modal.open(Alert, { message: "This will auto-close..." }, { abortController: controller });
201197

202198
if (result === MODAL_ABORTED) {
203-
console.log('Modal was aborted');
199+
console.log("Modal was aborted");
204200
}
205201
```
206202

@@ -228,11 +224,11 @@ Options are merged in this order:
228224
rootOptions={{ preventScroll: true }}
229225
>
230226
<App />
231-
</ModalProvider>
227+
</ModalProvider>;
232228

233229
Alert.layerOptions = { closeOnOutsideClick: false };
234230

235-
await modal.open(Alert, { message: 'Hello' }, { className: 'alert-layer' });
231+
await modal.open(Alert, { message: "Hello" }, { className: "alert-layer" });
236232
```
237233

238234
### 2. Context-based modal props
@@ -244,10 +240,10 @@ const MyModal = ({ title, message }: { title: string; message: string }) => {
244240
const { closeSelf, visible } = useModalInstance();
245241

246242
return (
247-
<div className={`modal ${visible ? 'visible' : ''}`}>
243+
<div className={`modal ${visible ? "visible" : ""}`}>
248244
<h1>{title}</h1>
249245
<p>{message}</p>
250-
<button onClick={() => closeSelf('success')}>OK</button>
246+
<button onClick={() => closeSelf("success")}>OK</button>
251247
</div>
252248
);
253249
};
@@ -281,10 +277,10 @@ const unsubscribe = modal.subscribe((stack) => {
281277

282278
```tsx
283279
// Old
284-
import { useModal } from '@reactleaf/modal';
280+
import { useModal } from "@reactleaf/modal";
285281

286282
// New
287-
import { ModalManager, ModalProvider, useModalInstance } from '@reactleaf/modal';
283+
import { ModalManager, ModalProvider, useModalInstance } from "@reactleaf/modal";
288284
```
289285

290286
### Issue 2: `BasicModalProps` errors

0 commit comments

Comments
 (0)