Skip to content

Commit c757cd8

Browse files
committed
chore: Finalized changesets and made a script gen:docs for autogenerating examples.
1 parent ef07903 commit c757cd8

File tree

12 files changed

+85
-12
lines changed

12 files changed

+85
-12
lines changed

.changeset/chilly-pugs-repair.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'bagon-hooks': patch
3+
---
4+
5+
feat: Added use-in-viewport.

.changeset/nasty-rings-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'bagon-hooks': patch
3+
---
4+
5+
feat: Added use-input-state.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'bagon-hooks': patch
3+
---
4+
5+
feat: Added use-intersection.

.changeset/sixty-ways-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'bagon-hooks': patch
3+
---
4+
5+
feat: Added use-disclosure.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'bagon-hooks': patch
3+
---
4+
5+
feat: Added use-document-visibility.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
### Patch Changes
1414

1515
- docs: Finished many examples for each hooks + code examples.
16-
- feat: Added use-resize-observer.
16+
- feat: Added use-resize-observer & use-element-size.
1717
- feat: Added use-favicon.
1818
- feat: Added use-network.
1919
- feat: Added use-mounted.
2020
- feat: Added use-local-storage.
2121
- fix: get-os to work in onMount (for SSR).
2222
- feat: Added use-toggle.
23+
- feat: Added use-idle.
2324

2425
## 0.0.1
2526

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
```tsx
2+
import { useDisclosure } from 'bagon-hooks';
3+
4+
import { Show } from 'solid-js';
5+
26
export function UseDisclosureExample() {
7+
const [opened, handlers] = useDisclosure(false);
8+
39
return (
4-
<div class="flex h-full w-full items-center justify-center gap-x-1 rounded-md border p-3 py-10 text-center text-sm"></div>
10+
<div class="flex h-full w-full items-center justify-center gap-x-1 rounded-md border p-3 py-10 text-center text-sm">
11+
<button onClick={handlers.open} class="rounded bg-blue-500 px-4 py-2 text-white">
12+
Open Dialog
13+
</button>
14+
15+
<Show when={opened()}>
16+
<div class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50">
17+
<div class="rounded-lg bg-white p-6 shadow-lg">
18+
<h2 class="mb-4 text-lg font-bold">Dialog Title</h2>
19+
<p class="mb-4">This is an example dialog using useDisclosure</p>
20+
<button onClick={handlers.close} class="rounded bg-gray-500 px-4 py-2 text-white">
21+
Close
22+
</button>
23+
</div>
24+
</div>
25+
</Show>
26+
</div>
527
);
628
}
729
```
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
1-
import { ExampleBase } from '../example-base';
2-
import Code from './use-disclosure.code.mdx';
1+
import { useDisclosure } from 'src';
32

3+
import { Show } from 'solid-js';
44
import { useMDXComponents } from 'solid-jsx';
5+
import { ExampleBase } from '../example-base';
6+
import Code from './use-disclosure.code.mdx';
57

68
export function UseDisclosureExample() {
9+
const [opened, handlers] = useDisclosure(false);
10+
711
// @ts-ignore
812
const components: any = useMDXComponents();
9-
1013
return (
1114
<ExampleBase
1215
title="useDisclosure"
13-
description="A hook to manage state for dialogs, modals, etc."
16+
description="A simple hook to manage state for dialogs, modals, accordions, etc. Anything that needs to open/close/toggle."
1417
code={<Code components={components} />}
1518
>
16-
<div class="flex h-full w-full items-center justify-center gap-x-1 rounded-md border p-3 py-10 text-center text-sm"></div>
19+
<div class="flex h-full w-full items-center justify-center gap-x-1 rounded-md border p-3 py-10 text-center text-sm">
20+
<button onClick={handlers.open} class="rounded bg-blue-500 px-4 py-2 text-white">
21+
Open Dialog
22+
</button>
23+
24+
<Show when={opened()}>
25+
<div class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50">
26+
<div class="rounded-lg bg-white p-6 shadow-lg">
27+
<h2 class="mb-4 text-lg font-bold">Dialog Title</h2>
28+
<p class="mb-4">This is an example dialog using useDisclosure</p>
29+
<button onClick={handlers.close} class="rounded bg-gray-500 px-4 py-2 text-white">
30+
Close
31+
</button>
32+
</div>
33+
</div>
34+
</Show>
35+
</div>
1736
</ExampleBase>
1837
);
1938
}

dev/constants/hooks-count.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const HOOKS_COUNT = 36;

dev/pages/index/+Page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { UseOsExample } from 'dev/components/examples/use-os/use-os.example';
3737
import { UseResizeObserverExample } from 'dev/components/examples/use-resize-observer/use-resize-observer.example';
3838
import { UseToggleExample } from 'dev/components/examples/use-toggle/use-toggle.example';
3939
import { Kbd } from 'dev/components/kbd';
40+
import { HOOKS_COUNT } from 'dev/constants/hooks-count';
4041
import { IconCheck, IconCopy, IconGithub, IconLogo } from 'dev/icons';
4142
import { createMemo, createSignal, For, Show } from 'solid-js';
4243
import { createStore } from 'solid-js/store';
@@ -270,9 +271,9 @@ export default function HomePage() {
270271
</span>
271272
</div>
272273

273-
<p class="text-center text-neutral-50">
274-
A collection of zero-dependency hooks for SolidJS forked directly from Mantine Hooks, with
275-
some improvements.
274+
<p class="mx-auto max-w-lg text-center text-neutral-50">
275+
A collection of <span class="font-semibold">{HOOKS_COUNT}+</span> zero-dependency hooks
276+
for SolidJS forked directly from Mantine Hooks, with some improvements.
276277
</p>
277278

278279
<div class="class mx-auto flex items-center gap-x-4 rounded-md border border-neutral-950 bg-neutral-800 p-4 text-muted">

0 commit comments

Comments
 (0)