@fluid-topics/ft-reader-toc 0.3.7

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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ Main table of content for integrated reader
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ft-reader-toc
7
+ yarn add @fluid-topics/ft-reader-toc
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ft-reader-toc"
15
+
16
+ function render() {
17
+ return html` <ft-reader-toc foo="bar"></ft-reader-toc> `
18
+ }
19
+ ```
@@ -0,0 +1,21 @@
1
+ import { TemplateResult } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
4
+ export interface FtReaderTocProperties {
5
+ }
6
+ export declare const FtReaderTocCssVariables: {
7
+ colorPrimary: import("@fluid-topics/ft-wc-utils").FtCssVariable;
8
+ colorOnPrimary: import("@fluid-topics/ft-wc-utils").FtCssVariable;
9
+ tabulationSize: import("@fluid-topics/ft-wc-utils").FtCssVariable;
10
+ };
11
+ export declare class FtReaderToc extends FtReaderComponent implements FtReaderTocProperties {
12
+ static elementDefinitions: ElementDefinitionsMap;
13
+ static styles: import("lit").CSSResult;
14
+ private toc?;
15
+ private splitToc?;
16
+ private currentPage?;
17
+ private visibleTopics?;
18
+ protected render(): TemplateResult<1>;
19
+ private renderNode;
20
+ }
21
+ //# sourceMappingURL=ft-reader-toc.d.ts.map
@@ -0,0 +1,75 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { css, html, nothing } from "lit";
8
+ import { repeat } from "lit/directives/repeat.js";
9
+ import { designSystemVariables, FtCssVariableFactory, redux } from "@fluid-topics/ft-wc-utils";
10
+ import { FtReaderComponent, } from "@fluid-topics/ft-reader-context/build/registration";
11
+ import { FtButton } from "@fluid-topics/ft-button";
12
+ import { FtTypography } from "@fluid-topics/ft-typography";
13
+ import { FtReaderInternalLink } from "@fluid-topics/ft-reader-internal-link";
14
+ export const FtReaderTocCssVariables = {
15
+ colorPrimary: FtCssVariableFactory.external(designSystemVariables.colorPrimary, "Design system"),
16
+ colorOnPrimary: FtCssVariableFactory.external(designSystemVariables.colorOnPrimary, "Design system"),
17
+ tabulationSize: FtCssVariableFactory.create("--ft-reader-toc-tabulation-size", "SIZE", "8px"),
18
+ };
19
+ export class FtReaderToc extends FtReaderComponent {
20
+ render() {
21
+ var _a;
22
+ return html `
23
+ <div class="ft-reader-toc">
24
+ ${repeat((_a = this.toc) !== null && _a !== void 0 ? _a : [], node => node.tocId, node => this.renderNode(node))}
25
+ </div>
26
+ `;
27
+ }
28
+ renderNode(node) {
29
+ var _a, _b;
30
+ const shouldSplit = this.splitToc && node.page != null && !node.page.onItsOwn;
31
+ const isHighlighted = this.splitToc ? ((_a = this.currentPage) === null || _a === void 0 ? void 0 : _a.rootTocId) === node.tocId : (_b = this.visibleTopics) === null || _b === void 0 ? void 0 : _b.includes(node.tocId);
32
+ return html `
33
+ <div class="ft-reader-toc--node">
34
+ <ft-reader-internal-link
35
+ class="${isHighlighted ? "ft-reader-toc--node-visible" : ""}"
36
+ tocId=${node.tocId}>
37
+ <ft-typography variant="body2">${node.title}</ft-typography>
38
+ </ft-reader-internal-link>
39
+ <div class="ft-reader-toc--node-children">
40
+ ${shouldSplit ? nothing : repeat(node.children, (child) => child.tocId, child => this.renderNode(child))}
41
+ </div>
42
+ </div>
43
+ `;
44
+ }
45
+ }
46
+ // Uncomment to use scoped web components
47
+ FtReaderToc.elementDefinitions = {
48
+ "ft-button": FtButton,
49
+ "ft-typography": FtTypography,
50
+ "ft-reader-internal-link": FtReaderInternalLink
51
+ };
52
+ // language=CSS
53
+ FtReaderToc.styles = css `
54
+ .ft-reader-toc--node-visible {
55
+ background-color: ${FtReaderTocCssVariables.colorPrimary};
56
+ color: ${FtReaderTocCssVariables.colorOnPrimary};
57
+ }
58
+
59
+ .ft-reader-toc--node-children {
60
+ padding-left: ${FtReaderTocCssVariables.tabulationSize};
61
+ }
62
+ `;
63
+ __decorate([
64
+ redux()
65
+ ], FtReaderToc.prototype, "toc", void 0);
66
+ __decorate([
67
+ redux((s) => { var _a; return (_a = s.map) === null || _a === void 0 ? void 0 : _a.shouldSplitCurrentPageToc; })
68
+ ], FtReaderToc.prototype, "splitToc", void 0);
69
+ __decorate([
70
+ redux()
71
+ ], FtReaderToc.prototype, "currentPage", void 0);
72
+ __decorate([
73
+ redux()
74
+ ], FtReaderToc.prototype, "visibleTopics", void 0);
75
+ //# sourceMappingURL=ft-reader-toc.js.map