Skip to content

Commit 0ce52e0

Browse files
committed
Use typescript
1 parent bc8392c commit 0ce52e0

12 files changed

+246
-43
lines changed

www/.eslintrc

Lines changed: 0 additions & 26 deletions
This file was deleted.

www/.eslintrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
root: true,
3+
parser: "@typescript-eslint/parser",
4+
plugins: ["@typescript-eslint"],
5+
extends: [
6+
"prettier/@typescript-eslint",
7+
"react-app",
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
],
12+
rules: {
13+
"@typescript-eslint/explicit-function-return-type": "off",
14+
},
15+
};

www/package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"react-helmet": "6.0.0"
1919
},
2020
"scripts": {
21-
"analyze:lint": "eslint --ext .jsx --ext .js src",
22-
"analyze:prettier": "prettier --list-different \"src/**/*.{css,js,jsx,json,md}\"",
21+
"analyze:lint": "eslint src --ext .ts,.tsx",
22+
"analyze:prettier": "prettier --list-different \"src/**/*.{css,js,jsx,ts,tsx,json,md}\"",
2323
"analyze": "npm run analyze:lint && npm run analyze:prettier",
2424
"fix:lint": "eslint --ext .jsx --ext .js src --fix",
25-
"fix:prettier": "prettier --write \"src/**/*.{css,js,jsx,json,md}\"",
25+
"fix:prettier": "prettier --write \"src/**/*.{css,js,jsx,ts,tsx,json,md}\"",
2626
"fix": "npm run fix:lint && npm run fix:prettier",
2727
"build": "gatsby build",
2828
"build-gh-pages": "gatsby build --prefix-paths",
@@ -31,20 +31,27 @@
3131
"start": "npm run develop",
3232
"serve": "gatsby serve",
3333
"clean": "gatsby clean",
34+
"type-check": "tsc --noEmit",
35+
"type-check:watch": "yarn type-check -- --watch",
3436
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
3537
},
3638
"devDependencies": {
3739
"@tailwindcss/custom-forms": "0.2.1",
40+
"@typescript-eslint/eslint-plugin": "^2.33.0",
41+
"@typescript-eslint/parser": "^2.33.0",
3842
"autoprefixer": "9.7.6",
3943
"babel-eslint": "10.1.0",
4044
"cssnano": "4.1.10",
41-
"eslint": "6.8.0",
45+
"eslint": "^7.0.0",
46+
"eslint-config-prettier": "^6.11.0",
4247
"eslint-loader": "3.0.4",
4348
"eslint-plugin-import": "2.20.2",
49+
"eslint-plugin-prettier": "^3.1.3",
4450
"eslint-plugin-react": "7.19.0",
4551
"gatsby-plugin-eslint": "2.0.8",
4652
"prettier": "2.0.5",
47-
"tailwindcss": "1.4.6"
53+
"tailwindcss": "1.4.6",
54+
"typescript": "^3.9.2"
4855
},
4956
"repository": {
5057
"type": "git",

www/src/components/header.js renamed to www/src/components/header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function Header() {
1919
<Link to="/">
2020
<h1 className="flex items-center no-underline text-blue-600">
2121
<img
22+
alt="icon"
2223
className="w-16 h-16 mr-2 "
2324
src={require("../images/code-bar-icon.png")}
2425
/>
File renamed without changes.
File renamed without changes.

www/src/components/table.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from "react";
2+
3+
export const Table = ({
4+
headers,
5+
items,
6+
}: {
7+
headers: string[];
8+
items: string[];
9+
}) => (
10+
<div className="flex flex-col">
11+
<div className="py-2 -my-2 overflow-x-auto sm:-mx-6 sm:px-6 lg:-mx-8 lg:px-8">
12+
<div className="inline-block min-w-full overflow-hidden align-middle border-b border-gray-200 shadow sm:rounded-lg">
13+
<table className="min-w-full">
14+
<thead>
15+
<tr>
16+
{headers.map((header) => (
17+
<th
18+
key={header}
19+
className="px-6 py-3 text-xs font-medium tracking-wider text-left text-gray-500 uppercase border-b border-gray-200 bg-gray-50 leading-4"
20+
>
21+
{header}
22+
</th>
23+
))}
24+
</tr>
25+
</thead>
26+
<tbody className="bg-white">
27+
<tr>
28+
{items.map((item) => (
29+
<td
30+
key={item}
31+
className="px-6 py-4 text-sm font-medium text-gray-900 whitespace-no-wrap border-b border-gray-200 leading-5"
32+
>
33+
{item}
34+
</td>
35+
))}
36+
</tr>
37+
</tbody>
38+
</table>
39+
</div>
40+
</div>
41+
</div>
42+
);
File renamed without changes.
File renamed without changes.

www/src/pages/index.js renamed to www/src/pages/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import React from "react";
2+
import { BarChart } from "react-chartkick";
3+
import "chart.js";
4+
import { colors } from "tailwindcss/defaultTheme";
25

6+
import { Table } from "../components/table";
37
import Layout from "../components/layout";
48
import SEO from "../components/seo";
59
import lastUpdateAt from "../../data/last_updated_at.json";
610
import countedStats from "../../data/counted_stats.json";
711
import returningMembers from "../../data/returning_members.json";
812
import studentCoachConversion from "../../data/student_to_coach_conversion.json";
913
import attendedPerYear from "../../data/attended_per_year.json";
10-
import { BarChart } from "react-chartkick";
11-
import "chart.js";
12-
import { colors } from "tailwindcss/defaultTheme";
1314

1415
const data = {
1516
...countedStats,
@@ -82,6 +83,7 @@ function IndexPage() {
8283
stacked
8384
colors={[colors.blue["500"], colors.pink["600"]]}
8485
/>
86+
<Table headers={["", "Attendances", "Growth"]} />
8587
</section>
8688
</Layout>
8789
);

www/tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const defaultTheme = require("tailwindcss/defaultTheme");
22
// See https://tailwindcss.com/docs/configuration for details
33
module.exports = {
4-
purge: ["./src/**/*.js"],
4+
purge: ["./src/**/*.js", "./src/**/*.tsx", "./src/**/*.ts"],
55
theme: {
66
extend: {
77
fontFamily: {

0 commit comments

Comments
 (0)