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
28
pulls
pipelines
added tab component, rm activity tab from profile
cozylittle.house
3 months ago
16b6fa89
9a1805aa
+38
-56
4 changed files
expand all
collapse all
unified
split
app
p
[didOrHandle]
ProfilePageLayout.tsx
ProfileTabs
Tabs.tsx
components
PageLayouts
DashboardLayout.tsx
Tab.tsx
+2
-6
app/p/[didOrHandle]/ProfilePageLayout.tsx
···
39
39
);
40
40
};
41
41
42
42
-
export type profileTabsType =
43
43
-
| "activity"
44
44
-
| "posts"
45
45
-
| "comments"
46
46
-
| "subscriptions";
42
42
+
export type profileTabsType = "posts" | "comments" | "subscriptions";
47
43
const ProfilePageContent = (props: {
48
44
profile: {
49
45
did: string;
···
52
48
record: Json;
53
49
} | null;
54
50
}) => {
55
55
-
let [tab, setTab] = useState<profileTabsType>("activity");
51
51
+
let [tab, setTab] = useState<profileTabsType>("posts");
56
52
57
53
let profileRecord = props.profile?.record as AppBskyActorProfile.Record;
58
54
console.log(profileRecord);
+16
-29
app/p/[didOrHandle]/ProfileTabs/Tabs.tsx
···
1
1
+
import { Tab } from "components/Tab";
1
2
import { profileTabsType } from "../ProfilePageLayout";
2
3
3
4
export const ProfileTabs = (props: {
4
5
tab: profileTabsType;
5
6
setTab: (t: profileTabsType) => void;
6
7
}) => {
7
7
-
let buttonStyle = "text-secondary";
8
8
return (
9
9
<div className="flex flex-col w-full">
10
10
<div className="flex gap-2 justify-between">
11
11
<div className="flex gap-2">
12
12
-
<button
13
13
-
className={buttonStyle}
14
14
-
onClick={() => {
15
15
-
props.setTab("activity");
16
16
-
}}
17
17
-
>
18
18
-
Activity
19
19
-
</button>
20
20
-
<button
21
21
-
className={buttonStyle}
22
22
-
onClick={() => {
12
12
+
<Tab
13
13
+
name="Posts"
14
14
+
selected={props.tab === "posts"}
15
15
+
onSelect={() => {
23
16
props.setTab("posts");
24
17
}}
25
25
-
>
26
26
-
Posts
27
27
-
</button>
28
28
-
<button
29
29
-
className={buttonStyle}
30
30
-
onClick={() => {
18
18
+
/>
19
19
+
<Tab
20
20
+
name="Comments"
21
21
+
selected={props.tab === "comments"}
22
22
+
onSelect={() => {
31
23
props.setTab("comments");
32
24
}}
33
33
-
>
34
34
-
Comments
35
35
-
</button>
25
25
+
/>
36
26
</div>
37
37
-
<button
38
38
-
className={buttonStyle}
39
39
-
onClick={() => {
27
27
+
<Tab
28
28
+
name="Subscriptions"
29
29
+
selected={props.tab === "subscriptions"}
30
30
+
onSelect={() => {
40
31
props.setTab("subscriptions");
41
32
}}
42
42
-
>
43
43
-
Subscriptions
44
44
-
</button>
33
33
+
/>
45
34
</div>
46
35
<hr className="border-border-light mb-2 mt-1" />
47
36
</div>
···
50
39
51
40
export const TabContent = (props: { tab: profileTabsType }) => {
52
41
switch (props.tab) {
53
53
-
case "activity":
54
54
-
return <div>activty stuff here!</div>;
55
42
case "posts":
56
43
return <div>posts here!</div>;
57
44
case "comments":
+2
-21
components/PageLayouts/DashboardLayout.tsx
···
25
25
import Link from "next/link";
26
26
import { ExternalLinkTiny } from "components/Icons/ExternalLinkTiny";
27
27
import { usePreserveScroll } from "src/hooks/usePreserveScroll";
28
28
+
import { Tab } from "components/Tab";
28
29
29
30
export type DashboardState = {
30
31
display?: "grid" | "list";
···
355
356
);
356
357
};
357
358
358
358
-
function Tab(props: {
359
359
-
name: string;
360
360
-
selected: boolean;
361
361
-
onSelect: () => void;
362
362
-
href?: string;
363
363
-
}) {
364
364
-
return (
365
365
-
<div
366
366
-
className={`pubTabs px-1 py-0 flex gap-1 items-center rounded-md hover:cursor-pointer ${props.selected ? "text-accent-2 bg-accent-1 font-bold -mb-px" : "text-tertiary"}`}
367
367
-
onClick={() => props.onSelect()}
368
368
-
>
369
369
-
{props.name}
370
370
-
{props.href && <ExternalLinkTiny />}
371
371
-
</div>
372
372
-
);
373
373
-
}
374
374
-
375
375
-
const FilterOptions = (props: {
376
376
-
hasPubs: boolean;
377
377
-
hasArchived: boolean;
378
378
-
}) => {
359
359
+
const FilterOptions = (props: { hasPubs: boolean; hasArchived: boolean }) => {
379
360
let { filter } = useDashboardState();
380
361
let setState = useSetDashboardState();
381
362
let filterCount = Object.values(filter).filter(Boolean).length;
+18
components/Tab.tsx
···
1
1
+
import { ExternalLinkTiny } from "./Icons/ExternalLinkTiny";
2
2
+
3
3
+
export const Tab = (props: {
4
4
+
name: string;
5
5
+
selected: boolean;
6
6
+
onSelect: () => void;
7
7
+
href?: string;
8
8
+
}) => {
9
9
+
return (
10
10
+
<div
11
11
+
className={`pubTabs px-1 py-0 flex gap-1 items-center rounded-md hover:cursor-pointer ${props.selected ? "text-accent-2 bg-accent-1 font-bold -mb-px" : "text-tertiary"}`}
12
12
+
onClick={() => props.onSelect()}
13
13
+
>
14
14
+
{props.name}
15
15
+
{props.href && <ExternalLinkTiny />}
16
16
+
</div>
17
17
+
);
18
18
+
};