tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
reorg leaflet layout components, add basic sidebar
awarm.space
10 months ago
fa291627
e547f073
+91
-50
4 changed files
expand all
collapse all
unified
split
app
[leaflet_id]
Leaflet.tsx
Sidebar.tsx
components
ActionBar
Sidebar.tsx
Pages
index.tsx
+22
-9
app/[leaflet_id]/Leaflet.tsx
···
1
1
+
"use client";
1
2
import { Fact, PermissionToken, ReplicacheProvider } from "src/replicache";
2
2
-
import { Database } from "../../supabase/database.types";
3
3
import { Attributes } from "src/replicache/attributes";
4
4
-
import { createServerClient } from "@supabase/ssr";
5
4
import { SelectionManager } from "components/SelectionManager";
6
5
import { Pages } from "components/Pages";
7
6
import {
···
9
8
ThemeProvider,
10
9
} from "components/ThemeManager/ThemeProvider";
11
10
import { MobileFooter } from "components/MobileFooter";
12
12
-
import { PopUpProvider } from "components/Toast";
13
13
-
import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment";
14
14
-
import {
15
15
-
EntitySetContext,
16
16
-
EntitySetProvider,
17
17
-
} from "components/EntitySetProvider";
11
11
+
import { EntitySetProvider } from "components/EntitySetProvider";
18
12
import { AddLeafletToHomepage } from "components/utils/AddLeafletToHomepage";
19
13
import { UpdateLeafletTitle } from "components/utils/UpdateLeafletTitle";
14
14
+
import { useUIState } from "src/useUIState";
15
15
+
import { LeafletSidebar } from "./Sidebar";
16
16
+
20
17
export function Leaflet(props: {
21
18
token: PermissionToken;
22
19
initialFacts: Fact<keyof typeof Attributes>[];
···
43
40
className="leafletContentWrapper w-full relative overflow-x-scroll snap-x snap-mandatory no-scrollbar grow items-stretch flex h-full pb-4 pwa-padding"
44
41
id="page-carousel"
45
42
>
46
46
-
<Pages rootPage={props.leaflet_id} />
43
43
+
<div
44
44
+
id="pages"
45
45
+
className="pages flex pt-2 pb-1 sm:pb-8 sm:py-6"
46
46
+
onClick={(e) => {
47
47
+
e.currentTarget === e.target && blurPage();
48
48
+
}}
49
49
+
>
50
50
+
<LeafletSidebar leaflet_id={props.leaflet_id} />
51
51
+
<Pages rootPage={props.leaflet_id} />
52
52
+
</div>
47
53
</div>
48
54
<MobileFooter entityID={props.leaflet_id} />
49
55
</ThemeBackgroundProvider>
···
52
58
</ReplicacheProvider>
53
59
);
54
60
}
61
61
+
62
62
+
const blurPage = () => {
63
63
+
useUIState.setState(() => ({
64
64
+
focusedEntity: null,
65
65
+
selectedBlocks: [],
66
66
+
}));
67
67
+
};
+56
app/[leaflet_id]/Sidebar.tsx
···
1
1
+
"use client";
2
2
+
import { Sidebar } from "components/ActionBar/Sidebar";
3
3
+
import { useEntitySetContext } from "components/EntitySetProvider";
4
4
+
import { HelpPopover } from "components/HelpPopover";
5
5
+
import { HomeButton } from "components/HomeButton";
6
6
+
import { usePublicationContext } from "components/Providers/PublicationContext";
7
7
+
import { ShareOptions } from "components/ShareOptions";
8
8
+
import { PublishToPublication } from "components/ShareOptions/PublicationOptions";
9
9
+
import { ThemePopover } from "components/ThemeManager/ThemeSetter";
10
10
+
import { Watermark } from "components/Watermark";
11
11
+
import { useUIState } from "src/useUIState";
12
12
+
13
13
+
export function LeafletSidebar(props: { leaflet_id: string }) {
14
14
+
let entity_set = useEntitySetContext();
15
15
+
let publication = usePublicationContext();
16
16
+
return (
17
17
+
<div
18
18
+
className="spacer flex justify-end items-start"
19
19
+
style={{ width: `calc(50vw - ((var(--page-width-units)/2))` }}
20
20
+
onClick={(e) => {
21
21
+
e.currentTarget === e.target && blurPage();
22
22
+
}}
23
23
+
>
24
24
+
<Sidebar>
25
25
+
{entity_set.permissions.write ? (
26
26
+
<div className=" flex flex-col justify-center gap-2 mr-4">
27
27
+
{publication.publication && (
28
28
+
<div className="relative w-[30px] h-[76px]">
29
29
+
<div className="origin-top-left -rotate-90 absolute translate-y-[76px]">
30
30
+
<PublishToPublication />
31
31
+
</div>
32
32
+
</div>
33
33
+
)}
34
34
+
<ShareOptions />
35
35
+
<ThemePopover entityID={props.leaflet_id} />
36
36
+
<HelpPopover />
37
37
+
<hr className="text-border my-3" />
38
38
+
<HomeButton />
39
39
+
</div>
40
40
+
) : (
41
41
+
<div>
42
42
+
<HomeButton />
43
43
+
</div>
44
44
+
)}
45
45
+
<Watermark />
46
46
+
</Sidebar>
47
47
+
</div>
48
48
+
);
49
49
+
}
50
50
+
51
51
+
const blurPage = () => {
52
52
+
useUIState.setState(() => ({
53
53
+
focusedEntity: null,
54
54
+
selectedBlocks: [],
55
55
+
}));
56
56
+
};
+11
components/ActionBar/Sidebar.tsx
···
1
1
+
import { Media } from "components/Media";
2
2
+
3
3
+
export function Sidebar(props: { children?: React.ReactNode }) {
4
4
+
return (
5
5
+
<Media mobile={false} className="h-full">
6
6
+
<div className="flex flex-col h-full justify-between mt-1">
7
7
+
{props.children}
8
8
+
</div>
9
9
+
</Media>
10
10
+
);
11
11
+
}
+2
-41
components/Pages/index.tsx
···
60
60
let publication = usePublicationContext();
61
61
62
62
return (
63
63
-
<div
64
64
-
id="pages"
65
65
-
className="pages flex pt-2 pb-1 sm:pb-8 sm:py-6"
66
66
-
onClick={(e) => {
67
67
-
e.currentTarget === e.target && blurPage();
68
68
-
}}
69
69
-
>
70
70
-
<div
71
71
-
className="spacer flex justify-end items-start"
72
72
-
style={{ width: `calc(50vw - ((var(--page-width-units)/2))` }}
73
73
-
onClick={(e) => {
74
74
-
e.currentTarget === e.target && blurPage();
75
75
-
}}
76
76
-
>
77
77
-
<Media mobile={false} className="h-full">
78
78
-
<div className="flex flex-col h-full justify-between mt-1">
79
79
-
{entity_set.permissions.write ? (
80
80
-
<div className=" flex flex-col justify-center gap-2 mr-4">
81
81
-
{publication.publication && (
82
82
-
<div className="relative w-[30px] h-[76px]">
83
83
-
<div className="origin-top-left -rotate-90 absolute translate-y-[76px]">
84
84
-
<PublishToPublication />
85
85
-
</div>
86
86
-
</div>
87
87
-
)}
88
88
-
<ShareOptions />
89
89
-
<ThemePopover entityID={props.rootPage} />
90
90
-
<HelpPopover />
91
91
-
<hr className="text-border my-3" />
92
92
-
<HomeButton />
93
93
-
</div>
94
94
-
) : (
95
95
-
<div>
96
96
-
<HomeButton />
97
97
-
</div>
98
98
-
)}
99
99
-
<Watermark />
100
100
-
</div>
101
101
-
</Media>
102
102
-
</div>
63
63
+
<>
103
64
<div className="flex items-stretch">
104
65
<CardThemeProvider entityID={firstPage}>
105
66
<Page entityID={firstPage} first />
···
119
80
e.currentTarget === e.target && blurPage();
120
81
}}
121
82
/>
122
122
-
</div>
83
83
+
</>
123
84
);
124
85
}
125
86