@molecule/app-reading-progress-bar-vue 0.0.0-stage → 0.0.1-stage

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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-11-16T09:14:15.503Z
7
+ -->
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ # @molecule/app-reading-progress-bar-vue
10
+
11
+ Vue reading progress bar.
12
+
13
+ Exports `<ReadingProgressBar>` — a thin top-of-page bar that fills as the
14
+ user scrolls through an article. Used by blog and news-aggregator article
15
+ pages. It is the Vue counterpart of
16
+ `@molecule/app-reading-progress-bar-react`: same export names, same props,
17
+ same DOM for the same input.
18
+
19
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
20
+ > It is written to be read by coding agents as much as by people, and is generated from this
21
+ > package's source — edit `src/index.ts` JSDoc, not this file.
22
+
23
+ ## Quick Start
24
+
25
+ ```ts
26
+ import { createApp, defineComponent, h, ref } from 'vue'
27
+ import { createI18nPlugin } from '@molecule/app-vue'
28
+ import { ReadingProgressBar } from '@molecule/app-reading-progress-bar-vue'
29
+
30
+ const articleEl = ref<Element | null>(null)
31
+
32
+ const Article = defineComponent({
33
+ setup() {
34
+ return () =>
35
+ h('div', [
36
+ h(ReadingProgressBar, { containerRef: articleEl, color: 'var(--brand)', thickness: 4 }),
37
+ h('article', { ref: articleEl }, '…long read…'),
38
+ ])
39
+ },
40
+ })
41
+
42
+ createApp(Article).use(createI18nPlugin(i18nProvider)).mount('#app')
43
+ ```
44
+
45
+ ## Type
46
+
47
+ `feature`
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ npm install @molecule/app-reading-progress-bar-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
53
+ ```
54
+
55
+ ## API
56
+
57
+ ### Interfaces
58
+
59
+ #### `ReadingProgressBarProps`
60
+
61
+ Props accepted by the {@link ReadingProgressBar} component.
62
+
63
+ ```typescript
64
+ interface ReadingProgressBarProps {
65
+ /**
66
+ * Optional ref to the article element. When provided, progress is measured
67
+ * against that element's bounding rect (so the bar fills as the user scrolls
68
+ * through the article body, not the whole page). When omitted, progress
69
+ * falls back to `window` scroll position. React's `containerRef` is an object
70
+ * with a `current` field; a Vue template ref (an object with a `value` field)
71
+ * is accepted too.
72
+ */
73
+ containerRef?: { readonly current?: Element | null; readonly value?: Element | null }
74
+ /** Bar thickness in pixels. Defaults to `3`. */
75
+ thickness?: number
76
+ /**
77
+ * Where the bar pins. Defaults to `'top'`. Both variants render fixed across
78
+ * the full viewport width with a high z-index.
79
+ */
80
+ position?: 'top' | 'bottom'
81
+ /**
82
+ * CSS color for the filled portion of the bar. Defaults to `'currentColor'`
83
+ * so the bar inherits whatever text color is in scope — letting the
84
+ * surrounding theme drive it. Pass a theme-aware color (`'var(--brand)'`,
85
+ * etc.) to override.
86
+ */
87
+ color?: string
88
+ /** Extra classes on the outer wrapper. */
89
+ className?: string
90
+ /** `data-mol-id` for AI-agent / E2E selectors. */
91
+ dataMolId?: string
92
+ }
93
+ ```
94
+
95
+ ### Functions
96
+
97
+ #### `computeArticleProgress(el, viewportHeight)`
98
+
99
+ Computes the scroll progress (0..1) of an element, measured by how much of
100
+ the element has scrolled past the top of the viewport.
101
+
102
+ Returns `0` when the element's top is at or below the viewport top, `1` when
103
+ its bottom is at or above the viewport top plus the viewport height (fully
104
+ read), and linearly interpolates between those endpoints in the middle. An
105
+ element shorter than the viewport counts as fully read once its top reaches
106
+ the viewport top.
107
+
108
+ ```typescript
109
+ function computeArticleProgress(el: Element, viewportHeight: number): number
110
+ ```
111
+
112
+ - `el` — The article element whose read-through progress we want.
113
+ - `viewportHeight` — The viewport height to use as the denominator.
114
+
115
+ **Returns:** A number in `[0, 1]`.
116
+
117
+ #### `computeWindowProgress()`
118
+
119
+ Computes window scroll progress (0..1) using `scrollY` and the document's
120
+ total scrollable height.
121
+
122
+ ```typescript
123
+ function computeWindowProgress(): number
124
+ ```
125
+
126
+ **Returns:** A number in `[0, 1]`. Falls back to `0` when there is nothing to scroll (page shorter than the viewport).
127
+
128
+ ### Constants
129
+
130
+ #### `ReadingProgressBar`
131
+
132
+ Top-of-page reading progress bar.
133
+
134
+ Tracks how far the user has scrolled through an article and renders a thin
135
+ horizontal bar pinned to the top (or bottom) of the viewport, filling
136
+ left-to-right from 0% to 100% as they read.
137
+
138
+ Throttles scroll updates with `requestAnimationFrame` so the work runs at
139
+ most once per frame — the handler attaches in passive mode. Listens to both
140
+ `scroll` and `resize` because progress changes when the viewport height
141
+ changes (e.g. mobile toolbar collapse).
142
+
143
+ ```typescript
144
+ const ReadingProgressBar: DefineComponent<
145
+ ExtractPropTypes<{
146
+ containerRef: {
147
+ type: PropType<NonNullable<ReadingProgressBarProps['containerRef']>>
148
+ default: undefined
149
+ }
150
+ thickness: { type: NumberConstructor; default: number }
151
+ position: { type: PropType<'top' | 'bottom'>; default: string }
152
+ color: StringConstructor
153
+ className: StringConstructor
154
+ dataMolId: StringConstructor
155
+ }>,
156
+ () => VNode,
157
+ {},
158
+ {},
159
+ {},
160
+ ComponentOptionsMixin,
161
+ ComponentOptionsMixin,
162
+ {},
163
+ string,
164
+ PublicProps,
165
+ Readonly<
166
+ ExtractPropTypes<{
167
+ containerRef: {
168
+ type: PropType<NonNullable<ReadingProgressBarProps['containerRef']>>
169
+ default: undefined
170
+ }
171
+ thickness: { type: NumberConstructor; default: number }
172
+ position: { type: PropType<'top' | 'bottom'>; default: string }
173
+ color: StringConstructor
174
+ className: StringConstructor
175
+ dataMolId: StringConstructor
176
+ }>
177
+ > &
178
+ Readonly<{}>,
179
+ {
180
+ containerRef: { readonly current?: Element | null; readonly value?: Element | null }
181
+ thickness: number
182
+ position: 'top' | 'bottom'
183
+ },
184
+ {},
185
+ {},
186
+ {},
187
+ string,
188
+ ComponentProvideOptions,
189
+ true,
190
+ {},
191
+ any
192
+ >
193
+ ```
194
+
195
+ - `props` — Component props (see {@link ReadingProgressBarProps}).
196
+
197
+ **Returns:** The reading progress bar component.
198
+
199
+ ## Injection Notes
200
+
201
+ ### Requirements
202
+
203
+ Peer dependencies:
204
+
205
+ - `@molecule/app-ui` ^1.0.1
206
+ - `@molecule/app-ui-vue` ^1.1.0
207
+ - `@molecule/app-vue` ^3.5.0
208
+ - `vue` ^3.4.0
209
+
210
+ ### Runtime Dependencies
211
+
212
+ - `@molecule/app-ui`
213
+ - `@molecule/app-ui-vue`
214
+ - `@molecule/app-vue`
215
+ - `vue`
216
+
217
+ Companion locale bond: `@molecule/app-locales-reading-progress-bar` (the
218
+ progressbar aria-label). The fill defaults to `currentColor` — it inherits
219
+ the surrounding text color, so pass `color` (e.g. `var(--color-primary)`)
220
+ when the ambient text color is low-contrast against the page edge. The bar
221
+ renders `position: fixed` at `z-index: 1000` spanning the viewport width; it
222
+ only listens to `window` scroll — `containerRef` changes what is measured,
223
+ not which scroller is observed (inner scroll containers won't drive it).
224
+ Requires the Vue binding's i18n provider and a wired ClassMap bond.
225
+
226
+ ## Translations
227
+
228
+ Translation strings are provided by `@molecule/app-locales-reading-progress-bar`.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Vue top-of-page reading progress bar.
3
+ *
4
+ * Vue counterpart of `@molecule/app-reading-progress-bar-react`'s
5
+ * `ReadingProgressBar` — the same props (React names), the same ClassMap
6
+ * tokens, the same i18n key, and the same DOM for the same input.
7
+ *
8
+ * @module
9
+ */
10
+ import { type PropType, type VNode } from 'vue';
11
+ import type { ReadingProgressBarProps } from './types.js';
12
+ /**
13
+ * Top-of-page reading progress bar.
14
+ *
15
+ * Tracks how far the user has scrolled through an article and renders a thin
16
+ * horizontal bar pinned to the top (or bottom) of the viewport, filling
17
+ * left-to-right from 0% to 100% as they read.
18
+ *
19
+ * Throttles scroll updates with `requestAnimationFrame` so the work runs at
20
+ * most once per frame — the handler attaches in passive mode. Listens to both
21
+ * `scroll` and `resize` because progress changes when the viewport height
22
+ * changes (e.g. mobile toolbar collapse).
23
+ *
24
+ * @param props - Component props (see {@link ReadingProgressBarProps}).
25
+ * @returns The reading progress bar component.
26
+ */
27
+ export declare const ReadingProgressBar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
28
+ containerRef: {
29
+ type: PropType<NonNullable<ReadingProgressBarProps["containerRef"]>>;
30
+ default: undefined;
31
+ };
32
+ thickness: {
33
+ type: NumberConstructor;
34
+ default: number;
35
+ };
36
+ position: {
37
+ type: PropType<"top" | "bottom">;
38
+ default: string;
39
+ };
40
+ color: StringConstructor;
41
+ className: StringConstructor;
42
+ dataMolId: StringConstructor;
43
+ }>, () => VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
44
+ containerRef: {
45
+ type: PropType<NonNullable<ReadingProgressBarProps["containerRef"]>>;
46
+ default: undefined;
47
+ };
48
+ thickness: {
49
+ type: NumberConstructor;
50
+ default: number;
51
+ };
52
+ position: {
53
+ type: PropType<"top" | "bottom">;
54
+ default: string;
55
+ };
56
+ color: StringConstructor;
57
+ className: StringConstructor;
58
+ dataMolId: StringConstructor;
59
+ }>> & Readonly<{}>, {
60
+ containerRef: {
61
+ readonly current?: Element | null;
62
+ readonly value?: Element | null;
63
+ };
64
+ thickness: number;
65
+ position: "top" | "bottom";
66
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
67
+ //# sourceMappingURL=ReadingProgressBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReadingProgressBar.d.ts","sourceRoot":"","sources":["../src/ReadingProgressBar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAKL,KAAK,QAAQ,EAEb,KAAK,KAAK,EAEX,MAAM,KAAK,CAAA;AAMZ,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAczD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;;cAIT,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC;;;;;;;;cAQ9D,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC;;;;;;UA4GjC,KAAK;;cApHE,QAAQ,CAAC,WAAW,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC;;;;;;;;cAQ9D,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC;;;;;;;;;;;;;4EAwI9C,CAAA"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Vue top-of-page reading progress bar.
3
+ *
4
+ * Vue counterpart of `@molecule/app-reading-progress-bar-react`'s
5
+ * `ReadingProgressBar` — the same props (React names), the same ClassMap
6
+ * tokens, the same i18n key, and the same DOM for the same input.
7
+ *
8
+ * @module
9
+ */
10
+ import { computed, defineComponent, h, onUnmounted, ref, watch, } from 'vue';
11
+ import { getClassMap } from '@molecule/app-ui';
12
+ import { useTranslation } from '@molecule/app-vue';
13
+ import { computeArticleProgress, computeWindowProgress } from './progress.js';
14
+ /**
15
+ * The element a `containerRef` currently points at.
16
+ *
17
+ * @param ref - The ref, in React's `{ current }` or Vue's `{ value }` shape.
18
+ * @returns The element, or null when there is none.
19
+ */
20
+ const elementOf = (ref) => ref?.current ?? ref?.value ?? null;
21
+ /**
22
+ * Top-of-page reading progress bar.
23
+ *
24
+ * Tracks how far the user has scrolled through an article and renders a thin
25
+ * horizontal bar pinned to the top (or bottom) of the viewport, filling
26
+ * left-to-right from 0% to 100% as they read.
27
+ *
28
+ * Throttles scroll updates with `requestAnimationFrame` so the work runs at
29
+ * most once per frame — the handler attaches in passive mode. Listens to both
30
+ * `scroll` and `resize` because progress changes when the viewport height
31
+ * changes (e.g. mobile toolbar collapse).
32
+ *
33
+ * @param props - Component props (see {@link ReadingProgressBarProps}).
34
+ * @returns The reading progress bar component.
35
+ */
36
+ export const ReadingProgressBar = defineComponent({
37
+ name: 'ReadingProgressBar',
38
+ props: {
39
+ containerRef: {
40
+ type: Object,
41
+ default: undefined,
42
+ },
43
+ thickness: {
44
+ type: Number,
45
+ default: 3,
46
+ },
47
+ position: {
48
+ type: String,
49
+ default: 'top',
50
+ },
51
+ color: String,
52
+ className: String,
53
+ dataMolId: String,
54
+ },
55
+ setup(props) {
56
+ const cm = getClassMap();
57
+ const { t } = useTranslation();
58
+ const progress = ref(0);
59
+ /**
60
+ * Attaches the scroll/resize listeners and schedules the first measurement,
61
+ * exactly as React's effect does; the returned function is its cleanup.
62
+ *
63
+ * @returns What undoes this installation.
64
+ */
65
+ const install = () => {
66
+ let rafId = 0;
67
+ let pending = false;
68
+ let cancelled = false;
69
+ /**
70
+ * Recomputes progress on the next animation frame. Coalesces bursts of
71
+ * scroll events into a single state update.
72
+ */
73
+ const schedule = () => {
74
+ if (pending)
75
+ return;
76
+ pending = true;
77
+ rafId = requestAnimationFrame(() => {
78
+ pending = false;
79
+ rafId = 0;
80
+ if (cancelled)
81
+ return;
82
+ const el = elementOf(props.containerRef);
83
+ const next = el
84
+ ? computeArticleProgress(el, window.innerHeight ?? 0)
85
+ : computeWindowProgress();
86
+ progress.value = next;
87
+ });
88
+ };
89
+ schedule();
90
+ window.addEventListener('scroll', schedule, { passive: true });
91
+ window.addEventListener('resize', schedule, { passive: true });
92
+ return () => {
93
+ cancelled = true;
94
+ if (rafId !== 0)
95
+ cancelAnimationFrame(rafId);
96
+ window.removeEventListener('scroll', schedule);
97
+ window.removeEventListener('resize', schedule);
98
+ };
99
+ };
100
+ let uninstall = install();
101
+ // React's effect depends on `containerRef`: a new ref object tears the
102
+ // listeners down and installs a fresh measurement over the new element.
103
+ watch(() => props.containerRef, () => {
104
+ uninstall();
105
+ uninstall = install();
106
+ }, { flush: 'post' });
107
+ onUnmounted(() => uninstall());
108
+ /**
109
+ * The rounded percentage the bar shows (React's
110
+ * `Math.round(progress * 1000) / 10`).
111
+ *
112
+ * @returns The percentage, to one decimal.
113
+ */
114
+ const pct = computed(() => Math.round(progress.value * 1000) / 10);
115
+ /**
116
+ * The fixed wrapper's inline style, matching React's style object.
117
+ *
118
+ * @returns Style properties, keyed the way Vue's style patcher expects.
119
+ */
120
+ const wrapperStyle = () => {
121
+ const style = {
122
+ position: 'fixed',
123
+ left: '0px',
124
+ right: '0px',
125
+ height: `${props.thickness}px`,
126
+ zIndex: '1000',
127
+ pointerEvents: 'none',
128
+ };
129
+ if (props.position === 'bottom')
130
+ style.bottom = '0px';
131
+ else
132
+ style.top = '0px';
133
+ return style;
134
+ };
135
+ /**
136
+ * The fill's inline style, matching React's style object.
137
+ *
138
+ * @returns Style properties, keyed the way Vue's style patcher expects.
139
+ */
140
+ const fillStyle = () => ({
141
+ width: `${pct.value}%`,
142
+ height: '100%',
143
+ background: props.color ?? 'currentColor',
144
+ transition: 'width 80ms linear',
145
+ });
146
+ return () => h('div', {
147
+ role: 'progressbar',
148
+ 'aria-label': t('readingProgressBar.aria.label', {}, {
149
+ defaultValue: 'Reading progress',
150
+ }),
151
+ 'aria-valuenow': pct.value,
152
+ 'aria-valuemin': 0,
153
+ 'aria-valuemax': 100,
154
+ 'data-mol-id': props.dataMolId ?? 'reading-progress-bar',
155
+ 'data-position': props.position,
156
+ class: cm.cn(props.className),
157
+ style: wrapperStyle(),
158
+ }, [
159
+ h('div', {
160
+ 'data-mol-id': 'reading-progress-bar-fill',
161
+ style: fillStyle(),
162
+ }),
163
+ ]);
164
+ },
165
+ });
166
+ //# sourceMappingURL=ReadingProgressBar.js.map
@@ -0,0 +1 @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,EAAE,CAAC;YAClB,eAAe,EAAE,GAAG;YACpB,aAAa,EAAE,KAAK,CAAC,SAAS,IAAI,sBAAsB;YACxD,eAAe,EAAE,KAAK,CAAC,QAAQ;YAC/B,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;YAC7B,KAAK,EAAE,YAAY,EAAE;SACtB,EACD;YACE,CAAC,CAAC,KAAK,EAAE;gBACP,aAAa,EAAE,2BAA2B;gBAC1C,KAAK,EAAE,SAAS,EAAE;aACnB,CAAC;SACH,CACF,CAAA;IACL,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Vue reading progress bar.
3
+ *
4
+ * Exports `<ReadingProgressBar>` — a thin top-of-page bar that fills as the
5
+ * user scrolls through an article. Used by blog and news-aggregator article
6
+ * pages. It is the Vue counterpart of
7
+ * `@molecule/app-reading-progress-bar-react`: same export names, same props,
8
+ * same DOM for the same input.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createApp, defineComponent, h, ref } from 'vue'
13
+ * import { createI18nPlugin } from '@molecule/app-vue'
14
+ * import { ReadingProgressBar } from '@molecule/app-reading-progress-bar-vue'
15
+ *
16
+ * const articleEl = ref<Element | null>(null)
17
+ *
18
+ * const Article = defineComponent({
19
+ * setup() {
20
+ * return () =>
21
+ * h('div', [
22
+ * h(ReadingProgressBar, { containerRef: articleEl, color: 'var(--brand)', thickness: 4 }),
23
+ * h('article', { ref: articleEl }, '…long read…'),
24
+ * ])
25
+ * },
26
+ * })
27
+ *
28
+ * createApp(Article).use(createI18nPlugin(i18nProvider)).mount('#app')
29
+ * ```
30
+ *
31
+ * @remarks
32
+ * Companion locale bond: `@molecule/app-locales-reading-progress-bar` (the
33
+ * progressbar aria-label). The fill defaults to `currentColor` — it inherits
34
+ * the surrounding text color, so pass `color` (e.g. `var(--color-primary)`)
35
+ * when the ambient text color is low-contrast against the page edge. The bar
36
+ * renders `position: fixed` at `z-index: 1000` spanning the viewport width; it
37
+ * only listens to `window` scroll — `containerRef` changes what is measured,
38
+ * not which scroller is observed (inner scroll containers won't drive it).
39
+ * Requires the Vue binding's i18n provider and a wired ClassMap bond.
40
+ *
41
+ * @module
42
+ */
43
+ export * from './progress.js';
44
+ export * from './ReadingProgressBar.js';
45
+ export * from './types.js';
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Vue reading progress bar.
3
+ *
4
+ * Exports `<ReadingProgressBar>` — a thin top-of-page bar that fills as the
5
+ * user scrolls through an article. Used by blog and news-aggregator article
6
+ * pages. It is the Vue counterpart of
7
+ * `@molecule/app-reading-progress-bar-react`: same export names, same props,
8
+ * same DOM for the same input.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createApp, defineComponent, h, ref } from 'vue'
13
+ * import { createI18nPlugin } from '@molecule/app-vue'
14
+ * import { ReadingProgressBar } from '@molecule/app-reading-progress-bar-vue'
15
+ *
16
+ * const articleEl = ref<Element | null>(null)
17
+ *
18
+ * const Article = defineComponent({
19
+ * setup() {
20
+ * return () =>
21
+ * h('div', [
22
+ * h(ReadingProgressBar, { containerRef: articleEl, color: 'var(--brand)', thickness: 4 }),
23
+ * h('article', { ref: articleEl }, '…long read…'),
24
+ * ])
25
+ * },
26
+ * })
27
+ *
28
+ * createApp(Article).use(createI18nPlugin(i18nProvider)).mount('#app')
29
+ * ```
30
+ *
31
+ * @remarks
32
+ * Companion locale bond: `@molecule/app-locales-reading-progress-bar` (the
33
+ * progressbar aria-label). The fill defaults to `currentColor` — it inherits
34
+ * the surrounding text color, so pass `color` (e.g. `var(--color-primary)`)
35
+ * when the ambient text color is low-contrast against the page edge. The bar
36
+ * renders `position: fixed` at `z-index: 1000` spanning the viewport width; it
37
+ * only listens to `window` scroll — `containerRef` changes what is measured,
38
+ * not which scroller is observed (inner scroll containers won't drive it).
39
+ * Requires the Vue binding's i18n provider and a wired ClassMap bond.
40
+ *
41
+ * @module
42
+ */
43
+ export * from './progress.js';
44
+ export * from './ReadingProgressBar.js';
45
+ export * from './types.js';
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Scroll-progress arithmetic for the Vue reading progress bar.
3
+ *
4
+ * The same formulas as `@molecule/app-reading-progress-bar-react`, exported
5
+ * under the same names so an app can switch framework by changing only its
6
+ * import.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Computes the scroll progress (0..1) of an element, measured by how much of
12
+ * the element has scrolled past the top of the viewport.
13
+ *
14
+ * Returns `0` when the element's top is at or below the viewport top, `1` when
15
+ * its bottom is at or above the viewport top plus the viewport height (fully
16
+ * read), and linearly interpolates between those endpoints in the middle. An
17
+ * element shorter than the viewport counts as fully read once its top reaches
18
+ * the viewport top.
19
+ *
20
+ * @param el - The article element whose read-through progress we want.
21
+ * @param viewportHeight - The viewport height to use as the denominator.
22
+ * @returns A number in `[0, 1]`.
23
+ */
24
+ export declare function computeArticleProgress(el: Element, viewportHeight: number): number;
25
+ /**
26
+ * Computes window scroll progress (0..1) using `scrollY` and the document's
27
+ * total scrollable height.
28
+ *
29
+ * @returns A number in `[0, 1]`. Falls back to `0` when there is nothing to
30
+ * scroll (page shorter than the viewport).
31
+ */
32
+ export declare function computeWindowProgress(): number;
33
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAYlF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAQ9C"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Scroll-progress arithmetic for the Vue reading progress bar.
3
+ *
4
+ * The same formulas as `@molecule/app-reading-progress-bar-react`, exported
5
+ * under the same names so an app can switch framework by changing only its
6
+ * import.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Computes the scroll progress (0..1) of an element, measured by how much of
12
+ * the element has scrolled past the top of the viewport.
13
+ *
14
+ * Returns `0` when the element's top is at or below the viewport top, `1` when
15
+ * its bottom is at or above the viewport top plus the viewport height (fully
16
+ * read), and linearly interpolates between those endpoints in the middle. An
17
+ * element shorter than the viewport counts as fully read once its top reaches
18
+ * the viewport top.
19
+ *
20
+ * @param el - The article element whose read-through progress we want.
21
+ * @param viewportHeight - The viewport height to use as the denominator.
22
+ * @returns A number in `[0, 1]`.
23
+ */
24
+ export function computeArticleProgress(el, viewportHeight) {
25
+ const rect = el.getBoundingClientRect();
26
+ const total = rect.height - viewportHeight;
27
+ if (total <= 0) {
28
+ // Article fits in the viewport — treat as fully read once its top hits the
29
+ // top of the viewport.
30
+ return rect.top <= 0 ? 1 : 0;
31
+ }
32
+ const scrolled = -rect.top;
33
+ if (scrolled <= 0)
34
+ return 0;
35
+ if (scrolled >= total)
36
+ return 1;
37
+ return scrolled / total;
38
+ }
39
+ /**
40
+ * Computes window scroll progress (0..1) using `scrollY` and the document's
41
+ * total scrollable height.
42
+ *
43
+ * @returns A number in `[0, 1]`. Falls back to `0` when there is nothing to
44
+ * scroll (page shorter than the viewport).
45
+ */
46
+ export function computeWindowProgress() {
47
+ const doc = document.documentElement;
48
+ const scrollTop = window.scrollY ?? doc.scrollTop ?? 0;
49
+ const total = (doc.scrollHeight ?? 0) - (window.innerHeight ?? 0);
50
+ if (total <= 0)
51
+ return 0;
52
+ if (scrollTop <= 0)
53
+ return 0;
54
+ if (scrollTop >= total)
55
+ return 1;
56
+ return scrollTop / total;
57
+ }
58
+ //# sourceMappingURL=progress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAW,EAAE,cAAsB;IACxE,MAAM,IAAI,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAA;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,cAAc,CAAA;IAC1C,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QACf,2EAA2E;QAC3E,uBAAuB;QACvB,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,GAAG,CAAA;IAC1B,IAAI,QAAQ,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAC3B,IAAI,QAAQ,IAAI,KAAK;QAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,QAAQ,GAAG,KAAK,CAAA;AACzB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAA;IACpC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,IAAI,GAAG,CAAC,SAAS,IAAI,CAAC,CAAA;IACtD,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC,CAAA;IACjE,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IACxB,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAC5B,IAAI,SAAS,IAAI,KAAK;QAAE,OAAO,CAAC,CAAA;IAChC,OAAO,SAAS,GAAG,KAAK,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Types for the Vue reading progress bar.
3
+ *
4
+ * @module
5
+ */
6
+ /** Props accepted by the {@link ReadingProgressBar} component. */
7
+ export interface ReadingProgressBarProps {
8
+ /**
9
+ * Optional ref to the article element. When provided, progress is measured
10
+ * against that element's bounding rect (so the bar fills as the user scrolls
11
+ * through the article body, not the whole page). When omitted, progress
12
+ * falls back to `window` scroll position. React's `containerRef` is an object
13
+ * with a `current` field; a Vue template ref (an object with a `value` field)
14
+ * is accepted too.
15
+ */
16
+ containerRef?: {
17
+ readonly current?: Element | null;
18
+ readonly value?: Element | null;
19
+ };
20
+ /** Bar thickness in pixels. Defaults to `3`. */
21
+ thickness?: number;
22
+ /**
23
+ * Where the bar pins. Defaults to `'top'`. Both variants render fixed across
24
+ * the full viewport width with a high z-index.
25
+ */
26
+ position?: 'top' | 'bottom';
27
+ /**
28
+ * CSS color for the filled portion of the bar. Defaults to `'currentColor'`
29
+ * so the bar inherits whatever text color is in scope — letting the
30
+ * surrounding theme drive it. Pass a theme-aware color (`'var(--brand)'`,
31
+ * etc.) to override.
32
+ */
33
+ color?: string;
34
+ /** Extra classes on the outer wrapper. */
35
+ className?: string;
36
+ /** `data-mol-id` for AI-agent / E2E selectors. */
37
+ dataMolId?: string;
38
+ }
39
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kEAAkE;AAClE,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,CAAA;IACrF,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAA;IAC3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Types for the Vue reading progress bar.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@molecule/app-reading-progress-bar-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-stage",
4
+ "description": "Top-of-page scroll progress bar for article pages",
5
+ "homepage": "https://www.molecule.dev/packages/app-reading-progress-bar-vue",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "vue-tsc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "reading-progress-bar",
28
+ "vue"
29
+ ],
30
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
31
+ "license": "Apache-2.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/molecule-dev/molecule.git",
35
+ "directory": "packages/app/features/reading-progress-bar-vue"
36
+ },
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "peerDependencies": {
45
+ "@molecule/app-ui": "^1.0.1",
46
+ "@molecule/app-ui-vue": "^1.1.0",
47
+ "@molecule/app-vue": "^3.5.0",
48
+ "vue": "^3.4.0"
49
+ },
50
+ "devDependencies": {
51
+ "@molecule/app-framework-conformance": "0.0.0",
52
+ "@molecule/app-i18n": "1.2.2",
53
+ "@molecule/app-icons": "1.0.4",
54
+ "@molecule/app-ui": "1.4.0",
55
+ "@molecule/app-ui-vue": "1.1.3",
56
+ "@molecule/app-vue": "3.7.0",
57
+ "@types/node": "26.6.5",
58
+ "jsdom": "30.1.3",
59
+ "typescript": "6.0.3",
60
+ "vite": "8.3.5",
61
+ "vitest": "4.1.12",
62
+ "vue": "3.5.44",
63
+ "vue-tsc": "3.3.13"
64
+ }
65
+ }