@jump-section/vue 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +137 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # @jump-section/vue
2
+
3
+ Vue composables for jump-section scroll management. Easily add scroll-to-section navigation to your Vue 3 applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @jump-section/vue
9
+ # or
10
+ pnpm add @jump-section/vue
11
+ # or
12
+ yarn add @jump-section/vue
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Basic Example
18
+
19
+ ```vue
20
+ <script setup>
21
+ import { useScrollSection } from '@jump-section/vue';
22
+
23
+ // Initialize scroll manager with options
24
+ const { scrollTo, activeId } = useScrollSection({
25
+ offset: -80,
26
+ behavior: 'smooth',
27
+ });
28
+
29
+ // Register sections
30
+ const { registerRef: section1Ref } = useScrollSection('section-1');
31
+ const { registerRef: section2Ref } = useScrollSection('section-2');
32
+ </script>
33
+
34
+ <template>
35
+ <div>
36
+ <nav>
37
+ <button @click="scrollTo('section-1')" :class="{ active: activeId === 'section-1' }">
38
+ Section 1
39
+ </button>
40
+ <button @click="scrollTo('section-2')" :class="{ active: activeId === 'section-2' }">
41
+ Section 2
42
+ </button>
43
+ </nav>
44
+
45
+ <main>
46
+ <section :ref="section1Ref">
47
+ <h2>Section 1</h2>
48
+ <p>Content for section 1...</p>
49
+ </section>
50
+ <section :ref="section2Ref">
51
+ <h2>Section 2</h2>
52
+ <p>Content for section 2...</p>
53
+ </section>
54
+ </main>
55
+ </div>
56
+ </template>
57
+ ```
58
+
59
+ ### With Active State
60
+
61
+ ```vue
62
+ <script setup>
63
+ import { useScrollSection } from '@jump-section/vue';
64
+
65
+ const props = defineProps({
66
+ id: String,
67
+ title: String,
68
+ });
69
+
70
+ const { registerRef, isActive } = useScrollSection(props.id);
71
+ </script>
72
+
73
+ <template>
74
+ <section :ref="registerRef" :class="{ active: isActive }">
75
+ <h2>{{ title }}</h2>
76
+ <slot />
77
+ </section>
78
+ </template>
79
+ ```
80
+
81
+ ### Composition API
82
+
83
+ ```vue
84
+ <script setup>
85
+ import { useScrollSection } from '@jump-section/vue';
86
+ import { watch } from 'vue';
87
+
88
+ const { activeId, scrollTo } = useScrollSection({
89
+ offset: -100,
90
+ behavior: 'smooth',
91
+ });
92
+
93
+ // Watch for active section changes
94
+ watch(activeId, (newId) => {
95
+ console.log('Active section changed to:', newId);
96
+ });
97
+
98
+ // Programmatic scroll
99
+ const handleClick = () => {
100
+ scrollTo('target-section');
101
+ };
102
+ </script>
103
+ ```
104
+
105
+ ## API
106
+
107
+ ### `useScrollSection(options?: ScrollOptions | string)`
108
+
109
+ Composable for managing scroll sections.
110
+
111
+ **Parameters:**
112
+
113
+ - `options?: ScrollOptions | string` - Configuration options or section ID
114
+ - If `string`: Section ID to register
115
+ - If `ScrollOptions`: Configuration object
116
+ - `offset?: number` - Vertical offset in pixels
117
+ - `behavior?: ScrollBehavior` - Scroll behavior: `'smooth'` | `'instant'` | `'auto'`
118
+
119
+ **Returns:**
120
+
121
+ - `registerRef: (element: HTMLElement | null) => void` - Ref callback to register the section element
122
+ - `scrollTo: (id: string) => void` - Function to scroll to a specific section
123
+ - `activeId: Ref<string | null>` - Currently active section ID (reactive)
124
+ - `isActive: ComputedRef<boolean>` - Whether this section is currently active (only if sectionId provided)
125
+ - `manager: ScrollManager` - The underlying scroll manager instance
126
+
127
+ ## TypeScript
128
+
129
+ This package includes TypeScript definitions.
130
+
131
+ ## Requirements
132
+
133
+ - Vue 3.0.0 or higher
134
+
135
+ ## License
136
+
137
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jump-section/vue",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Vue composables for jump-section scroll management",
5
5
  "keywords": [
6
6
  "scroll",
@@ -22,7 +22,8 @@
22
22
  "types": "dist/index.d.ts",
23
23
  "sideEffects": false,
24
24
  "files": [
25
- "dist"
25
+ "dist",
26
+ "README.md"
26
27
  ],
27
28
  "dependencies": {
28
29
  "@jump-section/core": "workspace:*"