Skip to content

Commit 227e8dc

Browse files
author
Quang Phan
committed
docs(*/README): add quick start section for better impression on npm
1 parent 2bd5765 commit 227e8dc

12 files changed

Lines changed: 251 additions & 70 deletions

File tree

.changeset/tasty-numbers-peel.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@svelte-put/preprocess-auto-slug': patch
3+
'@svelte-put/clickoutside': patch
4+
'@svelte-put/dragscroll': patch
5+
'@svelte-put/intersect': patch
6+
'@svelte-put/shortcut': patch
7+
'@svelte-put/movable': patch
8+
'@svelte-put/resize': patch
9+
'@svelte-put/copy': patch
10+
'@svelte-put/toc': patch
11+
'@svelte-put/avatar': patch
12+
'@svelte-put/modal': patch
13+
---
14+
15+
add "Quick Start" section in package README

packages/actions/clickoutside/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,27 @@ Svelte action `use:clickoutside` - event for clicking outside a node
1010

1111
</div>
1212

13+
## `svelte-put`
14+
15+
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
16+
1317
## Usage & Documentation
1418

1519
[See the dedicated documentation page here][docs].
1620

17-
## `svelte-put`
21+
## Quick Start
1822

19-
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
23+
```html
24+
<script lang="ts">
25+
import { clickoutside } from '@svelte-put/clickoutside';
26+
27+
function doSomething(e: CustomEvent<MouseEvent>) {
28+
console.log(e.target);
29+
}
30+
</script>
31+
32+
<div use:clickoutside on:clickoutside="{doSomething}" />
33+
```
2034

2135
## [Changelog][github.changelog]
2236

packages/actions/copy/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,27 @@ Svelte action `use:copy` and utility for copying text to clipboard
88

99
</div>
1010

11+
## `svelte-put`
12+
13+
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
14+
1115
## Usage & Documentation
1216

1317
[See the dedicated documentation page here][docs].
1418

15-
## `svelte-put`
19+
## Quick Start
1620

17-
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
21+
```html
22+
<script lang="ts">
23+
import { copy, type CopyDetail } from '@svelte-put/copy';
24+
25+
function handleCopied(e: CustomEvent<CopyDetail>) {
26+
console.log('Text copied:', e.detail.text);
27+
}
28+
</script>
29+
30+
<button type="button" use:copy on:copied="{handleCopied}">Click to copy this</button>
31+
```
1832

1933
## [Changelog][github.changelog]
2034

packages/actions/dragscroll/README.md

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,31 @@
22

33
# `@svelte-put/dragscroll`
44

5-
[![npm.badge]][npm] [![bundlephobia.badge]][bundlephobia] [![repl.badge]][repl]
5+
[![npm.badge]][npm] [![bundlephobia.badge]][bundlephobia] [![docs.badge]][docs]
66

77
Svelte action `use:dragscroll` for pointer drag-to-scroll behavior
88

99
</div>
1010

11-
## Table of Contents
12-
13-
<details open>
14-
<summary>Show / hide</summary>
15-
16-
- [`@svelte-put/dragscroll`](#svelte-putdragscroll)
17-
- [Table of Contents](#table-of-contents)
18-
- [`svelte-put`](#svelte-put)
19-
- [Changelog](#changelog)
20-
- [Installation](#installation)
21-
- [Documentation](#documentation)
22-
23-
</details>
24-
2511
## `svelte-put`
2612

2713
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
2814

29-
## [Changelog][github.changelog]
15+
## Usage & Documentation
3016

31-
## Installation
17+
[See the dedicated documentation page here][docs].
3218

33-
```bash
34-
npm install -D @svelte-put/dragscroll
35-
```
19+
## Quick Start
3620

37-
```bash
38-
yarn add -D @svelte-put/dragscroll
39-
```
21+
```html
22+
<script>
23+
import { dragscroll } from '@svelte-put/dragscroll';
24+
</script>
4025

41-
```bash
42-
pnpm add -D @svelte-put/dragscroll
26+
<div use:dragscroll>...</div>
4327
```
4428

45-
</details>
46-
47-
## Documentation
48-
49-
For detailed documentation, see the [extracted API][github.api].
29+
## [Changelog][github.changelog]
5030

5131
<p align="center">
5232
<a href="https://www.buymeacoffee.com/vnphanquang" target="_blank">
@@ -64,13 +44,12 @@ For detailed documentation, see the [extracted API][github.api].
6444
[github.monorepo]: https://github.com/vnphanquang/svelte-put
6545
[github.changelog]: https://github.com/vnphanquang/svelte-put/blob/main/packages/actions/dragscroll/CHANGELOG.md
6646
[github.issues]: https://github.com/vnphanquang/svelte-put/issues?q=
67-
[github.api]: https://github.com/vnphanquang/svelte-put/blob/main/packages/actions/dragscroll/api/docs/index.md
6847

6948
<!-- heading badge -->
7049

7150
[npm.badge]: https://img.shields.io/npm/v/@svelte-put/dragscroll
7251
[npm]: https://www.npmjs.com/package/@svelte-put/dragscroll
7352
[bundlephobia.badge]: https://img.shields.io/bundlephobia/minzip/@svelte-put/dragscroll?label=minzipped
7453
[bundlephobia]: https://bundlephobia.com/package/@svelte-put/dragscroll
75-
[repl]: https://svelte.dev/repl/835eacce6ac44aff95a7cb0bb5ca200d
76-
[repl.badge]: https://img.shields.io/static/v1?label=&message=Svelte+REPL&logo=svelte&logoColor=fff&color=ff3e00
54+
[docs]: https://svelte-put.vnphanquang.com/docs/dragscroll
55+
[docs.badge]: https://img.shields.io/badge/-Docs%20Site-blue

packages/actions/intersect/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,29 @@ Svelte action `use:intersect` - wrapper for [IntersectionObserver](https://devel
1010

1111
</div>
1212

13+
## `svelte-put`
14+
15+
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
16+
1317
## Usage & Documentation
1418

1519
[See the dedicated documentation page here][docs].
1620

17-
## `svelte-put`
21+
## Quick Start
1822

19-
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
23+
```html
24+
<script lang="ts">
25+
import { intersect, type IntersectDetail } from '@svelte-put/intersect';
26+
function onIntersect(e: CustomEvent<IntersectDetail>) {
27+
const { observer, entries, direction } = e.detail;
28+
console.log('the observer itself', observer);
29+
console.log('scrolling direction:', direction);
30+
console.log('intersecting:', entries[0]?.isIntersecting ? 'entering' : 'leaving');
31+
}
32+
</script>
33+
34+
<div use:intersect on:intersect="{onIntersect}" on:intersectonce />
35+
```
2036
2137
## [Changelog][github.changelog]
2238

packages/actions/movable/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@ Svelte action `use:movable` - make a node move on mousedown & mousemove
1010

1111
</div>
1212

13+
## `svelte-put`
14+
15+
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
16+
1317
## Usage & Documentation
1418

1519
[See the dedicated documentation page here][docs].
1620

17-
## `svelte-put`
21+
## Quick Start
1822

19-
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
23+
```html
24+
<script lang="ts">
25+
import { movable } from '@svelte-put/movable';
26+
</script>
27+
28+
<div class="h-20 w-20" use:movable>...</div>
29+
```
2030

2131
## [Changelog][github.changelog]
2232

packages/actions/resize/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# `@svelte-put/resize`
44

5-
[![npm.badge]][npm] [![bundlephobia.badge]][bundlephobia]
5+
[![npm.badge]][npm] [![bundlephobia.badge]][bundlephobia] [![docs.badge]][docs]
66

77
Svelte action `use:resize` for pointer drag-to-scroll behavior
88

@@ -12,27 +12,26 @@ Svelte action `use:resize` for pointer drag-to-scroll behavior
1212

1313
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
1414

15-
## [Changelog][github.changelog]
15+
## Usage & Documentation
1616

17-
## Installation
17+
[See the dedicated documentation page here][docs].
1818

19-
```bash
20-
npm install -D @svelte-put/resize
21-
```
19+
## Quick Start
2220

23-
```bash
24-
yarn add -D @svelte-put/resize
25-
```
21+
```html
22+
<script lang="ts">
23+
import { resize } from '@svelte-put/resize';
24+
import type { ResizeDetail } from '@svelte-put/resize';
2625
27-
```bash
28-
pnpm add -D @svelte-put/resize
29-
```
26+
function onResized(e: CustomEvent<ResizeDetail>) {
27+
console.log(e.detail);
28+
}
29+
</script>
3030

31-
</details>
32-
33-
## Documentation
31+
<div use:resize on:resized="{onResized}" />
32+
```
3433

35-
For detailed documentation, see the [extracted API][github.api].
34+
## [Changelog][github.changelog]
3635

3736
<p align="center">
3837
<a href="https://www.buymeacoffee.com/vnphanquang" target="_blank">
@@ -50,11 +49,12 @@ For detailed documentation, see the [extracted API][github.api].
5049
[github.monorepo]: https://github.com/vnphanquang/svelte-put
5150
[github.changelog]: https://github.com/vnphanquang/svelte-put/blob/main/packages/actions/resize/CHANGELOG.md
5251
[github.issues]: https://github.com/vnphanquang/svelte-put/issues?q=
53-
[github.api]: https://github.com/vnphanquang/svelte-put/blob/main/packages/actions/resize/api/docs/index.md
5452

5553
<!-- heading badge -->
5654

5755
[npm.badge]: https://img.shields.io/npm/v/@svelte-put/resize
5856
[npm]: https://www.npmjs.com/package/@svelte-put/resize
5957
[bundlephobia.badge]: https://img.shields.io/bundlephobia/minzip/@svelte-put/resize?label=minzipped
6058
[bundlephobia]: https://bundlephobia.com/package/@svelte-put/resize
59+
[docs]: https://svelte-put.vnphanquang.com/docs/resize
60+
[docs.badge]: https://img.shields.io/badge/-Docs%20Site-blue

packages/actions/shortcut/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,29 @@ Svelte action `use:shortcut` - add event listener for keyboard shortcuts
88

99
</div>
1010

11+
## `svelte-put`
12+
13+
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
14+
1115
## Usage & Documentation
1216

1317
[See the dedicated documentation page here][docs].
1418

15-
## `svelte-put`
19+
## Quick Start
1620

17-
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
21+
```html
22+
<script lang="ts">
23+
import { shortcut, type ShortcutEventDetails } from '@svelte-put/shortcut';
24+
25+
function handleK(detail: ShortcutEventDetails) {
26+
console.log('attached node:', detail.node);
27+
console.log('original trigger config:', detail.trigger);
28+
}
29+
</script>
30+
31+
<svelte:window use:shortcut={{ trigger: { key: 'k', modifier: ['ctrl', 'meta'], callback: handleK,
32+
}, }} />
33+
```
1834

1935
## [Changelog][github.changelog]
2036

packages/actions/toc/README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,51 @@ Svelte `use:toc` action for building table of contents
88

99
</div>
1010

11+
## `svelte-put`
12+
13+
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
14+
1115
## Usage & Documentation
1216

1317
[See the dedicated documentation page here][docs].
1418

15-
## `svelte-put`
16-
17-
This package is part of the [@svelte-put][github.monorepo] family. For contributing guideline and more, refer to its [readme][github.monorepo].
19+
## Quick Start
20+
21+
```html
22+
<script>
23+
import { toc, createTocStore, toclink } from '@svelte-put/toc';
24+
const tocStore = createTocStore();
25+
</script>
26+
27+
<main use:toc={{ store: tocStore, observe: true }}>
28+
<h1>Page Heading</h1>
29+
30+
<section>
31+
<h2>Table of Contents</h2>
32+
{#if Object.values($tocStore.items).length}
33+
<ul>
34+
{#each Object.values($tocStore.items) as tocItem}
35+
<li>
36+
<!-- svelte-ignore a11y-missing-attribute -->
37+
<a use:toclink={{ store: tocStore, tocItem, observe: true }} />
38+
</li>
39+
{/each}
40+
</ul>
41+
{/if}
42+
</section>
43+
44+
<section>
45+
<h2>Section Heading Level 2</h2>
46+
<p>...</p>
47+
</section>
48+
49+
<section>
50+
<h3>Section Heading Level 3</h3>
51+
<p>...</p>
52+
</section>
53+
<!-- ... -->
54+
</main>
55+
```
1856

1957
## Acknowledgement
2058

0 commit comments

Comments
 (0)