tangled
alpha
login
or
join now
t1c.dev
/
rocksky
forked from
rocksky.app/rocksky
2
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
2
fork
atom
overview
issues
pulls
pipelines
add link to Rocksky's tangled repo
tsiry-sandratraina.com
5 months ago
907b627b
7543c478
+210
-203
1 changed file
expand all
collapse all
unified
split
apps
web
src
layouts
Main.tsx
+210
-203
apps/web/src/layouts/Main.tsx
···
51
51
`;
52
52
53
53
export type MainProps = {
54
54
-
children: React.ReactNode;
55
55
-
withRightPane?: boolean;
54
54
+
children: React.ReactNode;
55
55
+
withRightPane?: boolean;
56
56
};
57
57
58
58
function Main(props: MainProps) {
59
59
-
const { children } = props;
60
60
-
const withRightPane = props.withRightPane ?? true;
61
61
-
const [handle, setHandle] = useState("");
62
62
-
const jwt = localStorage.getItem("token");
63
63
-
const profile = useAtomValue(profileAtom);
64
64
-
const [token, setToken] = useState<string | null>(null);
65
65
-
const { did, cli } = useSearch({ strict: false });
59
59
+
const { children } = props;
60
60
+
const withRightPane = props.withRightPane ?? true;
61
61
+
const [handle, setHandle] = useState("");
62
62
+
const jwt = localStorage.getItem("token");
63
63
+
const profile = useAtomValue(profileAtom);
64
64
+
const [token, setToken] = useState<string | null>(null);
65
65
+
const { did, cli } = useSearch({ strict: false });
66
66
67
67
-
useEffect(() => {
68
68
-
if (did && did !== "null") {
69
69
-
localStorage.setItem("did", did);
67
67
+
useEffect(() => {
68
68
+
if (did && did !== "null") {
69
69
+
localStorage.setItem("did", did);
70
70
71
71
-
const fetchToken = async () => {
72
72
-
try {
73
73
-
const response = await fetch(`${API_URL}/token`, {
74
74
-
method: "GET",
75
75
-
headers: {
76
76
-
"session-did": did,
77
77
-
},
78
78
-
});
79
79
-
const data = await response.json();
80
80
-
localStorage.setItem("token", data.token);
81
81
-
setToken(data.token);
71
71
+
const fetchToken = async () => {
72
72
+
try {
73
73
+
const response = await fetch(`${API_URL}/token`, {
74
74
+
method: "GET",
75
75
+
headers: {
76
76
+
"session-did": did,
77
77
+
},
78
78
+
});
79
79
+
const data = await response.json();
80
80
+
localStorage.setItem("token", data.token);
81
81
+
setToken(data.token);
82
82
83
83
-
if (cli) {
84
84
-
await fetch("http://localhost:6996/token", {
85
85
-
method: "POST",
86
86
-
headers: {
87
87
-
"Content-Type": "application/json",
88
88
-
},
89
89
-
body: JSON.stringify({ token: data.token }),
90
90
-
});
91
91
-
}
83
83
+
if (cli) {
84
84
+
await fetch("http://localhost:6996/token", {
85
85
+
method: "POST",
86
86
+
headers: {
87
87
+
"Content-Type": "application/json",
88
88
+
},
89
89
+
body: JSON.stringify({ token: data.token }),
90
90
+
});
91
91
+
}
92
92
93
93
-
if (!jwt && data.token) {
94
94
-
window.location.href = "/";
95
95
-
}
96
96
-
} catch (e) {
97
97
-
console.error(e);
98
98
-
}
99
99
-
};
100
100
-
fetchToken();
101
101
-
}
102
102
-
// eslint-disable-next-line react-hooks/exhaustive-deps
103
103
-
}, []);
93
93
+
if (!jwt && data.token) {
94
94
+
window.location.href = "/";
95
95
+
}
96
96
+
} catch (e) {
97
97
+
console.error(e);
98
98
+
}
99
99
+
};
100
100
+
fetchToken();
101
101
+
}
102
102
+
// eslint-disable-next-line react-hooks/exhaustive-deps
103
103
+
}, []);
104
104
105
105
-
useProfile(token || localStorage.getItem("token"));
105
105
+
useProfile(token || localStorage.getItem("token"));
106
106
107
107
-
const onLogin = async () => {
108
108
-
if (!handle.trim()) {
109
109
-
return;
110
110
-
}
107
107
+
const onLogin = async () => {
108
108
+
if (!handle.trim()) {
109
109
+
return;
110
110
+
}
111
111
112
112
-
if (API_URL.includes("localhost")) {
113
113
-
window.location.href = `${API_URL}/login?handle=${handle}`;
114
114
-
return;
115
115
-
}
112
112
+
if (API_URL.includes("localhost")) {
113
113
+
window.location.href = `${API_URL}/login?handle=${handle}`;
114
114
+
return;
115
115
+
}
116
116
117
117
-
window.location.href = `https://rocksky.pages.dev/loading?handle=${handle}`;
118
118
-
};
117
117
+
window.location.href = `https://rocksky.pages.dev/loading?handle=${handle}`;
118
118
+
};
119
119
120
120
-
return (
121
121
-
<Container className="bg-[var(--color-background)] text-[var(--color-text)]">
122
122
-
<ToasterContainer
123
123
-
placement={PLACEMENT.top}
124
124
-
overrides={{
125
125
-
ToastBody: {
126
126
-
style: {
127
127
-
zIndex: 2,
128
128
-
boxShadow: "none",
129
129
-
},
130
130
-
},
131
131
-
}}
132
132
-
/>
133
133
-
<Flex style={{ width: withRightPane ? "770px" : "1090px" }}>
134
134
-
<Navbar />
135
135
-
<div
136
136
-
style={{
137
137
-
position: "relative",
138
138
-
}}
139
139
-
>
140
140
-
{children}
141
141
-
</div>
142
142
-
</Flex>
143
143
-
{withRightPane && (
144
144
-
<RightPane className="relative w-[300px]">
145
145
-
<div className="fixed top-[100px] w-[300px] bg-white p-[20px]">
146
146
-
<div className="mb-[30px]">
147
147
-
<Search />
148
148
-
</div>
149
149
-
{jwt && profile && !profile.spotifyConnected && <SpotifyLogin />}
150
150
-
{jwt && profile && <CloudDrive />}
151
151
-
{!jwt && (
152
152
-
<div className="mt-[40px]">
153
153
-
<div className="mb-[20px]">
154
154
-
<div className="mb-[15px]">
155
155
-
<LabelMedium className="!text-[var(--color-text)]">
156
156
-
Bluesky handle
157
157
-
</LabelMedium>
158
158
-
</div>
159
159
-
<Input
160
160
-
name="handle"
161
161
-
startEnhancer={
162
162
-
<div className="text-[var(--color-text-muted)] bg-[var(--color-input-background)]">
163
163
-
@
164
164
-
</div>
165
165
-
}
166
166
-
placeholder="<username>.bsky.social"
167
167
-
value={handle}
168
168
-
onChange={(e) => setHandle(e.target.value)}
169
169
-
overrides={{
170
170
-
Root: {
171
171
-
style: {
172
172
-
backgroundColor: "var(--color-input-background)",
173
173
-
borderColor: "var(--color-input-background)",
174
174
-
},
175
175
-
},
176
176
-
StartEnhancer: {
177
177
-
style: {
178
178
-
backgroundColor: "var(--color-input-background)",
179
179
-
},
180
180
-
},
181
181
-
InputContainer: {
182
182
-
style: {
183
183
-
backgroundColor: "var(--color-input-background)",
184
184
-
},
185
185
-
},
186
186
-
Input: {
187
187
-
style: {
188
188
-
color: "var(--color-text)",
189
189
-
caretColor: "var(--color-text)",
190
190
-
},
191
191
-
},
192
192
-
}}
193
193
-
/>
194
194
-
</div>
195
195
-
<Button
196
196
-
onClick={onLogin}
197
197
-
overrides={{
198
198
-
BaseButton: {
199
199
-
style: {
200
200
-
width: "100%",
201
201
-
backgroundColor: "var(--color-primary)",
202
202
-
":hover": {
203
203
-
backgroundColor: "var(--color-primary)",
204
204
-
},
205
205
-
":focus": {
206
206
-
backgroundColor: "var(--color-primary)",
207
207
-
},
208
208
-
},
209
209
-
},
210
210
-
}}
211
211
-
>
212
212
-
Sign In
213
213
-
</Button>
214
214
-
<LabelMedium className="text-center mt-[20px] !text-[var(--color-text-muted)]">
215
215
-
Don't have an account?
216
216
-
</LabelMedium>
217
217
-
<div className="text-center text-[var(--color-text-muted)] ">
218
218
-
<a
219
219
-
href="https://bsky.app"
220
220
-
className="no-underline cursor-pointer !text-[var(--color-primary)]"
221
221
-
target="_blank"
222
222
-
>
223
223
-
Sign up for Bluesky
224
224
-
</a>{" "}
225
225
-
to create one now!
226
226
-
</div>
227
227
-
</div>
228
228
-
)}
120
120
+
return (
121
121
+
<Container className="bg-[var(--color-background)] text-[var(--color-text)]">
122
122
+
<ToasterContainer
123
123
+
placement={PLACEMENT.top}
124
124
+
overrides={{
125
125
+
ToastBody: {
126
126
+
style: {
127
127
+
zIndex: 2,
128
128
+
boxShadow: "none",
129
129
+
},
130
130
+
},
131
131
+
}}
132
132
+
/>
133
133
+
<Flex style={{ width: withRightPane ? "770px" : "1090px" }}>
134
134
+
<Navbar />
135
135
+
<div
136
136
+
style={{
137
137
+
position: "relative",
138
138
+
}}
139
139
+
>
140
140
+
{children}
141
141
+
</div>
142
142
+
</Flex>
143
143
+
{withRightPane && (
144
144
+
<RightPane className="relative w-[300px]">
145
145
+
<div className="fixed top-[100px] w-[300px] bg-white p-[20px]">
146
146
+
<div className="mb-[30px]">
147
147
+
<Search />
148
148
+
</div>
149
149
+
{jwt && profile && !profile.spotifyConnected && <SpotifyLogin />}
150
150
+
{jwt && profile && <CloudDrive />}
151
151
+
{!jwt && (
152
152
+
<div className="mt-[40px]">
153
153
+
<div className="mb-[20px]">
154
154
+
<div className="mb-[15px]">
155
155
+
<LabelMedium className="!text-[var(--color-text)]">
156
156
+
Bluesky handle
157
157
+
</LabelMedium>
158
158
+
</div>
159
159
+
<Input
160
160
+
name="handle"
161
161
+
startEnhancer={
162
162
+
<div className="text-[var(--color-text-muted)] bg-[var(--color-input-background)]">
163
163
+
@
164
164
+
</div>
165
165
+
}
166
166
+
placeholder="<username>.bsky.social"
167
167
+
value={handle}
168
168
+
onChange={(e) => setHandle(e.target.value)}
169
169
+
overrides={{
170
170
+
Root: {
171
171
+
style: {
172
172
+
backgroundColor: "var(--color-input-background)",
173
173
+
borderColor: "var(--color-input-background)",
174
174
+
},
175
175
+
},
176
176
+
StartEnhancer: {
177
177
+
style: {
178
178
+
backgroundColor: "var(--color-input-background)",
179
179
+
},
180
180
+
},
181
181
+
InputContainer: {
182
182
+
style: {
183
183
+
backgroundColor: "var(--color-input-background)",
184
184
+
},
185
185
+
},
186
186
+
Input: {
187
187
+
style: {
188
188
+
color: "var(--color-text)",
189
189
+
caretColor: "var(--color-text)",
190
190
+
},
191
191
+
},
192
192
+
}}
193
193
+
/>
194
194
+
</div>
195
195
+
<Button
196
196
+
onClick={onLogin}
197
197
+
overrides={{
198
198
+
BaseButton: {
199
199
+
style: {
200
200
+
width: "100%",
201
201
+
backgroundColor: "var(--color-primary)",
202
202
+
":hover": {
203
203
+
backgroundColor: "var(--color-primary)",
204
204
+
},
205
205
+
":focus": {
206
206
+
backgroundColor: "var(--color-primary)",
207
207
+
},
208
208
+
},
209
209
+
},
210
210
+
}}
211
211
+
>
212
212
+
Sign In
213
213
+
</Button>
214
214
+
<LabelMedium className="text-center mt-[20px] !text-[var(--color-text-muted)]">
215
215
+
Don't have an account?
216
216
+
</LabelMedium>
217
217
+
<div className="text-center text-[var(--color-text-muted)] ">
218
218
+
<a
219
219
+
href="https://bsky.app"
220
220
+
className="no-underline cursor-pointer !text-[var(--color-primary)]"
221
221
+
target="_blank"
222
222
+
>
223
223
+
Sign up for Bluesky
224
224
+
</a>{" "}
225
225
+
to create one now!
226
226
+
</div>
227
227
+
</div>
228
228
+
)}
229
229
230
230
-
<div className="mt-[40px]">
231
231
-
<ScrobblesAreaChart />
232
232
-
</div>
233
233
-
<ExternalLinks />
234
234
-
<div className="inline-flex mt-[40px]">
235
235
-
<Link
236
236
-
href="https://docs.rocksky.app/introduction-918639m0"
237
237
-
target="_blank"
238
238
-
className="mr-[10px] text-[var(--color-primary)]"
239
239
-
>
240
240
-
About
241
241
-
</Link>
242
242
-
<Link
243
243
-
href="https://docs.rocksky.app/faq-918661m0"
244
244
-
target="_blank"
245
245
-
className="mr-[10px] text-[var(--color-primary)]"
246
246
-
>
247
247
-
FAQ
248
248
-
</Link>
249
249
-
<Link
250
250
-
href="https://doc.rocksky.app/"
251
251
-
target="_blank"
252
252
-
className="mr-[10px] text-[var(--color-primary)]"
253
253
-
>
254
254
-
API Docs
255
255
-
</Link>
230
230
+
<div className="mt-[40px]">
231
231
+
<ScrobblesAreaChart />
232
232
+
</div>
233
233
+
<ExternalLinks />
234
234
+
<div className="inline-flex mt-[40px]">
235
235
+
<Link
236
236
+
href="https://docs.rocksky.app/introduction-918639m0"
237
237
+
target="_blank"
238
238
+
className="mr-[10px] text-[var(--color-primary)]"
239
239
+
>
240
240
+
About
241
241
+
</Link>
242
242
+
<Link
243
243
+
href="https://docs.rocksky.app/faq-918661m0"
244
244
+
target="_blank"
245
245
+
className="mr-[10px] text-[var(--color-primary)]"
246
246
+
>
247
247
+
FAQ
248
248
+
</Link>
249
249
+
<Link
250
250
+
href="https://doc.rocksky.app/"
251
251
+
target="_blank"
252
252
+
className="mr-[10px] text-[var(--color-primary)]"
253
253
+
>
254
254
+
API Docs
255
255
+
</Link>
256
256
257
257
-
<Link
258
258
-
href="https://discord.gg/EVcBy2fVa3"
259
259
-
target="_blank"
260
260
-
className="text-[var(--color-primary)]"
261
261
-
>
262
262
-
Discord
263
263
-
</Link>
264
264
-
</div>
265
265
-
</div>
266
266
-
</RightPane>
267
267
-
)}
268
268
-
<StickyPlayer />
269
269
-
</Container>
270
270
-
);
257
257
+
<Link
258
258
+
href="https://discord.gg/EVcBy2fVa3"
259
259
+
target="_blank"
260
260
+
className="text-[var(--color-primary)]"
261
261
+
>
262
262
+
Discord
263
263
+
</Link>
264
264
+
<Link
265
265
+
href="https://tangled.org/@rocksky.app/rocksky"
266
266
+
target="_blank"
267
267
+
className="text-[var(--color-primary)]"
268
268
+
>
269
269
+
Source
270
270
+
</Link>
271
271
+
</div>
272
272
+
</div>
273
273
+
</RightPane>
274
274
+
)}
275
275
+
<StickyPlayer />
276
276
+
</Container>
277
277
+
);
271
278
}
272
279
273
280
export default Main;