alpha
Login
or
Join now
atpota.to
/
cred.blue
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
add new score breakdown card
author
damedotblog
date
1 year ago
(Feb 17, 2025, 11:52 AM -0500)
commit
0f210ea5
0f210ea506e2cd60d455d3cbf82f2eecff72d9ec
parent
37615413
37615413c0ae0513ba3c986c21ad3297abce7405
+134
-24
4 changed files
Expand all
Collapse all
Unified
Split
src
components
Footer
Footer.css
UserProfile
UserProfile.js
components
AltTextCard.js
ScoreBreakdownCard.js
+1
src/components/Footer/Footer.css
Reviewed
···
64
64
padding: 1rem 2rem;
65
65
text-align: center;
66
66
border-top: 5px solid var(--card-border);
67
67
+
border-bottom: none;
67
68
}
+21
-13
src/components/UserProfile/UserProfile.js
Reviewed
···
13
13
import AltTextCard from "./components/AltTextCard";
14
14
import RawDataCard from "./components/RawDataCard";
15
15
import ActivityCard from "./components/ActivityCard";
16
16
+
import ScoreBreakdownCard from "./components/ScoreBreakdownCard";
16
17
17
18
import "react-grid-layout/css/styles.css";
18
19
import "react-resizable/css/styles.css";
···
46
47
{ i: "PostTypeCard", x: 0, y: 6, w: 1, h: cardHeights.PostTypeCard || 6, static: true },
47
48
{ i: "AltTextCard", x: 1, y: 6, w: 1, h: cardHeights.AltTextCard || 6, static: true },
48
49
{ i: "ActivityCard", x: 0, y: 12, w: 1, h: cardHeights.ActivityCard || 8, static: true },
49
49
-
{ i: "RawDataCard", x: 1, y: 12, w: 1, h: cardHeights.RawDataCard || 8, static: true },
50
50
+
{ i: "ScoreBreakdownCard", x: 1, y: 12, w: 1, h: cardHeights.ScoreBreakdownCard || 8, static: true },
51
51
+
{ i: "RawDataCard", x: 0, y: 20, w: 2, h: cardHeights.RawDataCard || 8, static: true },
50
52
],
51
53
xs: [
52
54
{ i: "ProfileCard", x: 0, y: 0, w: 1, h: cardHeights.ProfileCard || 6, static: true },
···
54
56
{ i: "PostTypeCard", x: 0, y: 12, w: 1, h: cardHeights.PostTypeCard || 6, static: true },
55
57
{ i: "AltTextCard", x: 0, y: 18, w: 1, h: cardHeights.AltTextCard || 6, static: true },
56
58
{ i: "ActivityCard", x: 0, y: 24, w: 1, h: cardHeights.ActivityCard || 8, static: true },
57
57
-
{ i: "RawDataCard", x: 0, y: 32, w: 1, h: cardHeights.RawDataCard || 8, static: true },
59
59
+
{ i: "ScoreBreakdownCard", x: 0, y: 32, w: 1, h: cardHeights.ScoreBreakdownCard || 8, static: true },
60
60
+
{ i: "RawDataCard", x: 0, y: 40, w: 1, h: cardHeights.RawDataCard || 8, static: true },
58
61
]
59
62
});
60
63
···
208
211
</div>
209
212
210
213
<ResponsiveGridLayout
211
211
-
className="layout"
212
212
-
layouts={getLayouts()}
213
213
-
breakpoints={breakpoints}
214
214
-
cols={cols}
215
215
-
rowHeight={50}
216
216
-
margin={[20, 20]}
217
217
-
isDraggable={false}
218
218
-
isResizable={false}
219
219
-
useCSSTransforms={true}
220
220
-
onLayoutChange={() => updateCardHeights()}
221
221
-
>
214
214
+
className="layout"
215
215
+
layouts={getLayouts()}
216
216
+
breakpoints={breakpoints}
217
217
+
cols={cols}
218
218
+
rowHeight={50}
219
219
+
margin={[20, 20]}
220
220
+
isDraggable={false}
221
221
+
isResizable={false}
222
222
+
useCSSTransforms={true}
223
223
+
onLayoutChange={() => updateCardHeights()}
224
224
+
>
222
225
<div key="ProfileCard" className="grid-item" ref={el => cardRefs.current.ProfileCard = el}>
223
226
<Card title="Profile">
224
227
<ProfileCard />
···
242
245
<div key="ActivityCard" className="grid-item" ref={el => cardRefs.current.ActivityCard = el}>
243
246
<Card title="Activity Overview">
244
247
<ActivityCard />
248
248
+
</Card>
249
249
+
</div>
250
250
+
<div key="ScoreBreakdownCard" className="grid-item" ref={el => cardRefs.current.ScoreBreakdownCard = el}>
251
251
+
<Card title="Score Breakdown">
252
252
+
<ScoreBreakdownCard />
245
253
</Card>
246
254
</div>
247
255
<div key="RawDataCard" className="grid-item" ref={el => cardRefs.current.RawDataCard = el}>
+1
-1
src/components/UserProfile/components/AltTextCard.js
Reviewed
···
71
71
<RadialBarChart
72
72
cx="50%"
73
73
cy="50%"
74
74
-
innerRadius="30%"
74
74
+
innerRadius="20%"
75
75
outerRadius="100%"
76
76
barSize={40}
77
77
data={data}
+111
-10
src/components/UserProfile/components/ScoreBreakdownCard.js
Reviewed
···
1
1
-
// frontend/src/components/UserProfile/components/ScoreBreakdownCard.js
1
1
+
import React, { useContext, PureComponent } from 'react';
2
2
+
import { Treemap, ResponsiveContainer } from 'recharts';
3
3
+
import { AccountDataContext } from "../UserProfile";
4
4
+
5
5
+
// Custom colors for the two main categories
6
6
+
const COLORS = ['#0056b3', '#003366'];
7
7
+
8
8
+
// CustomizedContent component for the treemap
9
9
+
class CustomizedContent extends PureComponent {
10
10
+
render() {
11
11
+
const { root, depth, x, y, width, height, index, name, value } = this.props;
12
12
+
13
13
+
return (
14
14
+
<g>
15
15
+
<rect
16
16
+
x={x}
17
17
+
y={y}
18
18
+
width={width}
19
19
+
height={height}
20
20
+
style={{
21
21
+
fill: depth < 2 ? COLORS[Math.floor((index / root.children.length) * 2)] : '#ffffff10',
22
22
+
stroke: '#fff',
23
23
+
strokeWidth: 2 / (depth + 1e-10),
24
24
+
strokeOpacity: 1 / (depth + 1e-10),
25
25
+
}}
26
26
+
/>
27
27
+
{
28
28
+
width > 50 && height > 30 && (
29
29
+
<text
30
30
+
x={x + width / 2}
31
31
+
y={y + height / 2}
32
32
+
textAnchor="middle"
33
33
+
fill="#fff"
34
34
+
fontSize={depth === 1 ? 16 : 14}
35
35
+
className="select-none"
36
36
+
>
37
37
+
{name}
38
38
+
{depth === 2 && (
39
39
+
<tspan x={x + width / 2} y={y + height / 2 + 20}>
40
40
+
{value}
41
41
+
</tspan>
42
42
+
)}
43
43
+
</text>
44
44
+
)
45
45
+
}
46
46
+
</g>
47
47
+
);
48
48
+
}
49
49
+
}
50
50
+
51
51
+
const ScoreBreakdownCard = () => {
52
52
+
const accountData = useContext(AccountDataContext);
53
53
+
54
54
+
if (!accountData) {
55
55
+
return <div>Loading score breakdown...</div>;
56
56
+
}
57
57
+
58
58
+
// Prepare the data for the treemap
59
59
+
const data = [
60
60
+
{
61
61
+
name: 'Bluesky Score',
62
62
+
children: [
63
63
+
{ name: 'Posts', size: accountData.blueskyScore * 0.4 },
64
64
+
{ name: 'Engagement', size: accountData.blueskyScore * 0.3 },
65
65
+
{ name: 'Profile', size: accountData.blueskyScore * 0.2 },
66
66
+
{ name: 'Alt Text', size: accountData.blueskyScore * 0.1 },
67
67
+
],
68
68
+
},
69
69
+
{
70
70
+
name: 'ATProto Score',
71
71
+
children: [
72
72
+
{ name: 'Collections', size: accountData.atprotoScore * 0.35 },
73
73
+
{ name: 'Security', size: accountData.atprotoScore * 0.25 },
74
74
+
{ name: 'Domain', size: accountData.atprotoScore * 0.25 },
75
75
+
{ name: 'PDS', size: accountData.atprotoScore * 0.15 },
76
76
+
],
77
77
+
},
78
78
+
];
2
79
3
3
-
// Atproto Breakdown
4
4
-
// 1. Activity
5
5
-
// 2. Decentralization
6
6
-
// 3.
80
80
+
return (
81
81
+
<div className="w-full h-full min-h-[400px] p-4">
82
82
+
<div className="flex justify-between items-center mb-4">
83
83
+
<div className="text-lg font-semibold">
84
84
+
Total Score: {accountData.combinedScore}
85
85
+
</div>
86
86
+
<div className="flex space-x-4">
87
87
+
<div>
88
88
+
<span className="font-medium">Bluesky: </span>
89
89
+
{accountData.blueskyScore}
90
90
+
</div>
91
91
+
<div>
92
92
+
<span className="font-medium">ATProto: </span>
93
93
+
{accountData.atprotoScore}
94
94
+
</div>
95
95
+
</div>
96
96
+
</div>
97
97
+
98
98
+
<div className="h-[350px]">
99
99
+
<ResponsiveContainer width="100%" height="100%">
100
100
+
<Treemap
101
101
+
data={data}
102
102
+
dataKey="size"
103
103
+
aspectRatio={4 / 3}
104
104
+
stroke="#fff"
105
105
+
content={<CustomizedContent colors={COLORS} />}
106
106
+
/>
107
107
+
</ResponsiveContainer>
108
108
+
</div>
109
109
+
</div>
110
110
+
);
111
111
+
};
7
112
8
8
-
// Bluesky Breakdown
9
9
-
// 1. Activity
10
10
-
// 2. Social Graph
11
11
-
// 3. Profile
12
12
-
// 4. Age
113
113
+
export default ScoreBreakdownCard;