Skip to content

Commit

Permalink
improve GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
cletqui committed Jul 6, 2024
1 parent d4fe6a4 commit ab001c1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 65 deletions.
8 changes: 7 additions & 1 deletion public/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ body {
transform: rotate(360deg);
}
}
.header button .icon {
margin: 0;
}

/* CONTAINER */
/* Title */
Expand Down Expand Up @@ -346,6 +349,9 @@ a:hover {
}
}
@media (max-width: 800px) {
html {
font-size: small !important;
}
.layout-main-header {
display: inline-block;
}
Expand All @@ -355,7 +361,7 @@ a:hover {
}
@media (max-width: 600px) {
html {
font-size: small;
font-size: smaller !important;
}
.container-layout {
flex-direction: column-reverse;
Expand Down
28 changes: 0 additions & 28 deletions src/components/landing.tsx

This file was deleted.

9 changes: 5 additions & 4 deletions src/components/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ import { getAuthenticatedUser } from "../utils/octokit";
const LoginButton = () => {
return (
<button class="button">
<a href="/github/login">{"Login"}</a>
<img src="/static/icons/github.svg" alt="GitHub" class="icon" />
<a href="/github/login">{"Login with GitHub"}</a>
</button>
);
};

const User = async ({ user }: { user: Promise<UserResponse> }) => {
try {
const c = useRequestContext();
const { path } = c.req;
const {
data: { login, avatar_url },
} = await user;
return (
<button class="button" onclick="logout">
<a href={`/github/logout?callback_url=${c.req.path}`}>
<a href={`/github/logout?callback_url=${path}`}>
<img class="avatar" src={avatar_url} alt="avatar" />
{login}
</a>
</button>
);
} catch (error) {
console.error(error);
} catch (_) {
return <LoginButton />;
}
};
Expand Down
7 changes: 6 additions & 1 deletion src/components/repository.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { JSX } from "hono/jsx/jsx-runtime";
import { Suspense } from "hono/jsx";

import { timeAgo } from "../utils/time";
import { constructUrl } from "../utils/url";
Expand All @@ -8,7 +9,11 @@ export const Repository = async ({
}: {
repository: Promise<Repository>;
}) => {
return <Container repository={await repository} />;
return (
<Suspense fallback={<div>{"prout"}</div>}>
<Container repository={await repository} />
</Suspense>
);
}; // TODO handle errors like https://docs.github.com/en/rest/guides/scripting-with-the-rest-api-and-javascript?apiVersion=2022-11-28#handling-rate-limit-errors

const Container = ({ repository }: { repository: Repository }): JSX.Element => {
Expand Down
2 changes: 0 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { handleTokens } from "./utils/tokens";

import api from "./routes/api";
import github from "./routes/github";
import welcome from "./routes/welcome";
import template from "./routes/template";
import id from "./routes/id";

Expand Down Expand Up @@ -41,7 +40,6 @@ app.use("/", handleTokens);
/* ROUTES */
app.route("/api", api);
app.route("/github", github);
app.route("/welcome", welcome);
app.route("/template", template);
app.route("/id", id);

Expand Down
25 changes: 0 additions & 25 deletions src/routes/welcome.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions src/utils/octokit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const verifyToken = async (
try {
const { status } = await getRepos(octokit, "octocat", "Hello-World");
return status === 200;
} catch (error) {
} catch (_) {
return false;
}
};
Expand Down Expand Up @@ -100,7 +100,7 @@ const getRepositories = async (
since: number
): Promise<RepositoriesResponse> => {
try {
return await octokit.rest.repos.listPublic({ since }); // octokit.request("GET /repositories", { since });
return octokit.rest.repos.listPublic({ since }); // octokit.request("GET /repositories", { since });
} catch (error: any) {
throw error;
}
Expand All @@ -120,7 +120,7 @@ export const getRepos = async (
repo: string
): Promise<RepositoryResponse> => {
try {
return await octokit.rest.repos.get({ owner, repo }); // octokit.request("GET /repos/{owner}/{repo}", { owner, repo });
return octokit.rest.repos.get({ owner, repo }); // octokit.request("GET /repos/{owner}/{repo}", { owner, repo });
} catch (error: any) {
throw error;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ export const getAuthenticatedUser = async (
octokit: Octokit
): Promise<UserResponse> => {
try {
return await octokit.rest.users.getAuthenticated(); // octokit.request("GET /user");
return octokit.rest.users.getAuthenticated(); // octokit.request("GET /user");
} catch (error: any) {
throw error;
}
Expand Down

0 comments on commit ab001c1

Please sign in to comment.