Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit 476cbd5

Browse files
committed
chore: implement session card part of the front page
1 parent 767545d commit 476cbd5

File tree

9 files changed

+157
-8
lines changed

9 files changed

+157
-8
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ module.exports = {
342342
settings: {
343343
"import/resolver": {
344344
alias: [
345+
["icons", "./icons"],
345346
["_pages", "./_pages"],
346347
["subgraph", "./subgraph"],
347348
],

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## (2021-01-25)
22

33
- chore: build subgraph schema ([9810923](https://github.com/kleros/governor-web/commit/9810923))
4+
- chore: fix subgraph bugs ([767545d](https://github.com/kleros/governor-web/commit/767545d))
45
- chore: generate first changelog ([2e41de7](https://github.com/kleros/governor-web/commit/2e41de7))
56
- chore: map appeal funding in subgraph ([990a87d](https://github.com/kleros/governor-web/commit/990a87d))
67
- chore: map governance functions in subgraph ([360d007](https://github.com/kleros/governor-web/commit/360d007))

_pages/index/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
import { useQuery } from "@kleros/components";
12
import { graphql } from "relay-hooks";
23

4+
import SessionCard from "./session-card";
5+
36
export default function Index() {
4-
return "Index";
7+
const { props } = useQuery();
8+
return (
9+
<SessionCard contract={props?.contract} session={props?.sessions?.[0]} />
10+
);
511
}
612

713
export const indexQuery = graphql`
814
query indexQuery {
915
contract(id: 0) {
10-
id
16+
...sessionCardContract
17+
}
18+
sessions(orderBy: creationTime, orderDirection: desc, first: 1) {
19+
...sessionCardSession
1120
}
1221
}
1322
`;

_pages/index/session-card.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Box, Card, Link, Text } from "@kleros/components";
2+
import { graphql, useFragment } from "relay-hooks";
3+
4+
const sessionCardFragments = {
5+
contract: graphql`
6+
fragment sessionCardContract on Contract {
7+
submissionTimeout
8+
lastApprovalTime
9+
}
10+
`,
11+
session: graphql`
12+
fragment sessionCardSession on Session {
13+
durationOffset
14+
}
15+
`,
16+
};
17+
export default function SessionCard({ contract, session }) {
18+
const { lastApprovalTime, submissionTimeout } =
19+
useFragment(sessionCardFragments.contract, contract) || {};
20+
const { durationOffset } =
21+
useFragment(sessionCardFragments.session, session) || {};
22+
const sessionStart = lastApprovalTime && new Date(lastApprovalTime * 1000);
23+
const sessionEnd =
24+
lastApprovalTime &&
25+
submissionTimeout &&
26+
durationOffset &&
27+
new Date(
28+
(Number(lastApprovalTime) +
29+
Number(submissionTimeout) +
30+
Number(durationOffset)) *
31+
1000
32+
);
33+
return (
34+
<Card
35+
variant="muted"
36+
sx={{
37+
borderTopColor: "primary",
38+
borderTopStyle: "solid",
39+
borderTopWidth: 2,
40+
}}
41+
mainSx={{
42+
color: "accent",
43+
justifyContent: "space-between",
44+
padding: 1,
45+
}}
46+
>
47+
<Box>
48+
<Text>
49+
Governor decisions from{" "}
50+
<Link newTab href="https://snapshot.page/#/kleros">
51+
Snapshot.
52+
</Link>
53+
</Text>
54+
<Text>
55+
<Text as="span" sx={{ fontWeight: "bold" }}>
56+
Session:
57+
</Text>{" "}
58+
Votes approved before{" "}
59+
<Text as="span">{sessionStart?.toLocaleString()}</Text>
60+
</Text>
61+
</Box>
62+
<Box sx={{ textAlign: "center" }}>
63+
<Text>Session ends</Text>
64+
<Text sx={{ fontWeight: "bold" }}>{sessionEnd?.toLocaleString()}</Text>
65+
</Box>
66+
</Card>
67+
);
68+
}

icons/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as WhiteKlerosLogo } from "./white-kleros-logo";
2+
export { default as WhiteSecuredByKleros } from "./white-secured-by-kleros";

icons/white-kleros-logo.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { SVG } from "@kleros/components";
2+
3+
export default function WhiteKlerosLogo(props) {
4+
return (
5+
<SVG viewBox="0 0 148 49" {...props}>
6+
<g clipPath="url(#clip0)">
7+
<path
8+
fillRule="evenodd"
9+
clipRule="evenodd"
10+
d="M66.813 24.9095H66.1854V19.3144H64.5029V32.4443H66.1854V26.295H66.763L72.0608 32.7721L73.3414 31.6884L68.2441 25.5142L72.5882 19.9951L71.3074 18.9873L66.813 24.9095ZM81.4521 19.3141H79.7699V32.444H88.307V30.9319H81.4521V19.3141ZM94.5096 19.3141H102.67V20.8264H96.1917V24.7576H101.54V26.2695H96.1917V30.9318H102.67V32.4439H94.5096V19.3141ZM113.819 19.3141H109.375V32.444H111.057V26.8241H113.493L116.832 32.7718L118.289 31.8898L115.075 26.572C116.657 26.0933 117.736 24.5056 117.736 22.8929C117.736 20.3474 116.004 19.3141 113.819 19.3141ZM115.978 22.8927C115.978 24.3795 114.899 25.312 113.267 25.312H111.057V20.8264H113.769C115.276 20.8264 115.978 21.7084 115.978 22.8927ZM132.878 25.892C132.878 26.9503 132.802 32.6711 128.232 32.6711C126.123 32.6711 123.587 31.159 123.587 25.892C123.587 20.65 126.073 19.0876 128.232 19.0876C130.316 19.0876 132.878 20.5996 132.878 25.892ZM125.345 25.892C125.345 27.8072 125.696 31.0833 128.232 31.0833C130.769 31.0833 131.12 27.8072 131.12 25.892C131.12 23.9512 130.768 20.6754 128.232 20.6754C125.696 20.6752 125.345 23.9512 125.345 25.892ZM143.424 31.0833C141.666 31.0833 140.888 29.8988 140.562 28.2861L139.055 28.7648C139.457 31.1085 140.989 32.6711 143.424 32.6711C145.835 32.6711 147.567 31.2598 147.567 28.7648C147.567 27.4039 146.94 26.3455 145.759 25.6903L142.972 24.4555C141.968 24.0019 141.215 23.649 141.215 22.4142C141.215 21.2296 142.269 20.6754 143.349 20.6754C144.78 20.6754 145.458 21.5824 145.759 22.8677L147.366 22.389C146.839 20.3476 145.559 19.0876 143.374 19.0876C141.315 19.0876 139.532 20.3224 139.532 22.5401C139.532 24.7927 141.036 25.4102 142.749 26.1132C142.914 26.1809 143.081 26.2494 143.248 26.3202C143.353 26.3635 143.458 26.406 143.563 26.4483C144.742 26.9236 145.885 27.3847 145.885 28.8657C145.885 30.3273 144.805 31.0833 143.424 31.0833Z"
11+
fill="white"
12+
/>
13+
<path
14+
fillRule="evenodd"
15+
clipRule="evenodd"
16+
d="M15.6356 1.5L42.4109 2.69704L53.2512 26.788L37.9576 48.8055L11.0367 47.0812L0 20.9788L15.6356 1.5ZM35.2655 15.3866L15.8604 23.8666L32.4506 36.6964L35.2655 15.3866ZM33.0188 11.1374L17.511 4.45872L14.2534 18.5009L33.0188 11.1374ZM29.0882 39.9245L12.2342 27.8872L12.6418 44.1985L29.0882 39.9245ZM50.5592 26.7349L39.0741 15.0781L36.0427 37.4936L50.5592 26.7349ZM33.0397 42.5464L18.8256 46.2623L35.5413 47.3329L33.0397 42.5464ZM48.3148 32.0236L35.8723 41.2944L38.3447 46.1271L48.3148 32.0236ZM42.4294 6.06301L40.0127 11.0252L49.008 20.1709L42.4294 6.06301ZM39.4184 3.68844L23.6224 3.04712L36.6522 8.74748L39.4184 3.68844ZM13.3289 5.98314L2.26489 19.9568L9.66208 21.524L13.3289 5.98314ZM9.21605 24.2651L1.78321 22.6911L9.5388 40.966L9.21605 24.2651Z"
17+
fill="white"
18+
/>
19+
</g>
20+
<defs>
21+
<clipPath id="clip0">
22+
<rect
23+
width={148}
24+
height={48}
25+
fill="white"
26+
transform="translate(0 0.5)"
27+
/>
28+
</clipPath>
29+
</defs>
30+
</SVG>
31+
);
32+
}

icons/white-secured-by-kleros.js

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
}
7373
},
7474
"scripts": {
75-
"depcheck": "depcheck . --ignores=_pages,subgraph,eslint-import-resolver-alias,@commitlint/cli,@commitlint/config-conventional,electron",
75+
"depcheck": "depcheck . --ignores=icons,_pages,subgraph,eslint-import-resolver-alias,@commitlint/cli,@commitlint/config-conventional,electron,@kleros/icons",
7676
"lint": "eslint .",
7777
"dev": "next",
7878
"dev:relay": "get-graphql-schema https://api.thegraph.com/subgraphs/name/epiqueras/governor-kovan > subgraph/build/full-schema.graphql && get-graphql-schema https://api.thegraph.com/subgraphs/name/epiqueras/governor-kovan --json | node subgraph/eslint-compat.js > subgraph/build/full-schema.json && relay-compiler --watch",

pages/_app.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@ import {
66
NextLink,
77
RelayProvider,
88
SocialIcons,
9-
Text,
109
ThemeProvider,
1110
Web3Provider,
1211
AccountSettingsPopup as _AccountSettingsPopup,
1312
createWrapConnection,
1413
klerosTheme,
1514
} from "@kleros/components";
16-
import { SecuredByKleros } from "@kleros/icons";
1715
import { useRouter } from "next/router";
1816
import { useCallback, useEffect, useMemo, useState } from "react";
1917
import { animated, useTransition } from "react-spring";
2018

2119
import { indexQuery } from "_pages/index";
20+
import { WhiteKlerosLogo, WhiteSecuredByKleros } from "icons";
2221
import Governor from "subgraph/abis/governor";
2322
import { address } from "subgraph/config/kovan";
2423

@@ -70,15 +69,19 @@ const header = {
7069
left: (
7170
<NextLink href="/">
7271
<Link variant="unstyled" sx={{ marginLeft: 1 }}>
73-
<Text>KLEROS</Text>
74-
<Text>GOVERNOR</Text>
72+
<WhiteKlerosLogo height={49} width={148} />
7573
</Link>
7674
</NextLink>
7775
),
76+
middle: (
77+
<NextLink href="/">
78+
<Link variant="unstyled">Governor</Link>
79+
</NextLink>
80+
),
7881
right: <AccountSettingsPopup />,
7982
};
8083
const footer = {
81-
left: <SecuredByKleros width={100} />,
84+
left: <WhiteSecuredByKleros height={24} width={130} />,
8285
right: <SocialIcons />,
8386
};
8487
const AnimatedBox = animated(Box);

0 commit comments

Comments
 (0)