Skip to content

Commit 9846aa7

Browse files
committed
Add a tool
1 parent 3b04304 commit 9846aa7

File tree

7 files changed

+109
-14
lines changed

7 files changed

+109
-14
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
"@types/enzyme-adapter-react-16": "^1.0.6",
169169
"@types/history": "4.7.6",
170170
"@types/jest": "^26.0.15",
171+
"@types/marked": "^2.0.4",
171172
"@types/node": "14.14.10",
172173
"@types/react": "^16.9.44",
173174
"@types/react-dom": "^16.9.9",
@@ -240,11 +241,14 @@
240241
"yarn-deduplicate": "^3.1.0"
241242
},
242243
"dependencies": {
244+
"@tailwindcss/typography": "^0.4.1",
243245
"caniuse-lite": "^1.0.30001246",
246+
"dayjs": "^1.10.6",
244247
"electron-debug": "^3.1.0",
245248
"electron-log": "^4.2.4",
246249
"electron-updater": "^4.3.4",
247250
"history": "^5.0.0",
251+
"marked": "^2.1.3",
248252
"react": "^17.0.1",
249253
"react-dom": "^17.0.1",
250254
"react-router-dom": "^5.2.0",

src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import React from 'react';
2-
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
2+
import {
3+
BrowserRouter as Router,
4+
Switch,
5+
Route,
6+
Redirect,
7+
} from 'react-router-dom';
38
import Main from './components/Main';
49
import './App.global.css';
510

@@ -9,6 +14,7 @@ export default function App() {
914
<Switch>
1015
<Route path="/" component={Main} />
1116
</Switch>
17+
<Redirect from="*" to="/unix" />
1218
</Router>
1319
);
1420
}

src/components/Main.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import UnixTimestamp from './unix-timestamp/UnixTimestamp';
55

66
const Main = () => {
77
const routes = [
8+
{
9+
path: '/unix',
10+
name: 'Unix Time Converter',
11+
Component: UnixTimestamp,
12+
},
813
{
914
path: '/md-to-html',
1015
name: 'Markdown to HTML',
1116
Component: MarkdownToHtml,
1217
},
13-
{
14-
path: '/unix',
15-
name: 'Unix Converter',
16-
Component: UnixTimestamp,
17-
},
1818
];
1919

2020
return (
@@ -23,7 +23,7 @@ const Main = () => {
2323
{/* Left sidebar */}
2424
<nav className="flex flex-col w-1/4 overflow-x-hidden overflow-y-auto bg-gray-200">
2525
<div
26-
className="px-2 mt-6"
26+
className="px-2 my-6"
2727
role="menu"
2828
aria-orientation="horizontal"
2929
aria-labelledby="options-menu"
@@ -42,8 +42,8 @@ const Main = () => {
4242
</nav>
4343

4444
{/* Main content */}
45-
<section className="relative flex flex-col w-full bg-gray-100">
46-
<div className="h-full overflow-x-hidden overflow-y-auto">
45+
<section className="relative flex flex-col w-full bg-gray-100 text-base">
46+
<div className="h-full overflow-x-hidden overflow-y-auto px-6 my-6">
4747
{routes.map(({ path, Component }) => (
4848
<Route key={path} exact path={path}>
4949
<Component />
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
1-
import React from 'react';
1+
/* eslint-disable react/no-danger */
2+
import React, { useState } from 'react';
3+
import marked from 'marked';
24

3-
const Md2Html = () => <div>Use `marked` here!</div>;
5+
const Md2Html = () => {
6+
const [md, setMd] = useState('# Hello\n> This is a quote');
7+
8+
const handleChange = (evt: { target: { value: string } }) =>
9+
setMd(evt.target.value);
10+
11+
return (
12+
<div className="flex min-h-full">
13+
<textarea
14+
onChange={handleChange}
15+
className="flex-1 min-h-full bg-white p-4 whitespace-pre"
16+
value={md}
17+
/>
18+
<div className="mx-1" />
19+
<textarea
20+
className="flex-1 min-h-full bg-blue-100 p-4 whitespace-pre"
21+
value={marked(md)}
22+
disabled
23+
/>
24+
</div>
25+
);
26+
};
427

528
export default Md2Html;
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1-
import React from 'react';
1+
import dayjs from 'dayjs';
2+
import React, { useState, useEffect } from 'react';
23

3-
const UnixTimestampConverter = () => <div>Use `dayjs` here!</div>;
4+
const UnixTimestampConverter = () => {
5+
const [date, setDate] = useState(dayjs());
6+
7+
useEffect(() => {
8+
const timerID = setInterval(() => setDate(dayjs()), 1000);
9+
10+
return function cleanup() {
11+
clearInterval(timerID);
12+
};
13+
});
14+
15+
return (
16+
<div>
17+
The current Unix epoch time is
18+
<span className="text-lg bg-blue-200 mx-2 p-2 rounded inline-flex items-center content-center">
19+
{date.unix()}
20+
</span>
21+
</div>
22+
);
23+
};
424

525
export default UnixTimestampConverter;

tailwind.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
const typography = require('@tailwindcss/typography');
2+
13
module.exports = {
24
theme: {},
35
variants: {},
4-
plugins: [],
6+
plugins: [typography],
57
};

yarn.lock

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,16 @@
14391439
dependencies:
14401440
defer-to-connect "^2.0.0"
14411441

1442+
"@tailwindcss/typography@^0.4.1":
1443+
version "0.4.1"
1444+
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.4.1.tgz#51ddbceea6a0ee9902c649dbe58871c81a831212"
1445+
integrity sha512-ovPPLUhs7zAIJfr0y1dbGlyCuPhpuv/jpBoFgqAc658DWGGrOBWBMpAWLw2KlzbNeVk4YBJMzue1ekvIbdw6XA==
1446+
dependencies:
1447+
lodash.castarray "^4.4.0"
1448+
lodash.isplainobject "^4.0.6"
1449+
lodash.merge "^4.6.2"
1450+
lodash.uniq "^4.5.0"
1451+
14421452
"@teamsupercell/typings-for-css-modules-loader@^2.4.0":
14431453
version "2.4.0"
14441454
resolved "https://registry.yarnpkg.com/@teamsupercell/typings-for-css-modules-loader/-/typings-for-css-modules-loader-2.4.0.tgz#b15f9f0e6efb37cc84eede162eba9f1ff4dda96c"
@@ -1663,6 +1673,11 @@
16631673
dependencies:
16641674
"@types/node" "*"
16651675

1676+
"@types/marked@^2.0.4":
1677+
version "2.0.4"
1678+
resolved "https://registry.yarnpkg.com/@types/marked/-/marked-2.0.4.tgz#34a0ea548afe6e0c01095229d47b48b2af650613"
1679+
integrity sha512-L9VRSe0Id8xbPL99mUo/4aKgD7ZoRwFZqUQScNKHi2pFjF9ZYSMNShUHD6VlMT6J/prQq0T1mxuU25m3R7dFzg==
1680+
16661681
"@types/minimatch@*":
16671682
version "3.0.3"
16681683
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@@ -4101,6 +4116,11 @@ date-fns@^2.0.1:
41014116
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b"
41024117
integrity sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ==
41034118

4119+
dayjs@^1.10.6:
4120+
version "1.10.6"
4121+
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.6.tgz#288b2aa82f2d8418a6c9d4df5898c0737ad02a63"
4122+
integrity sha512-AztC/IOW4L1Q41A86phW5Thhcrco3xuAA+YX/BLpLWWjRcTj5TOt/QImBLmCKlrF7u7k47arTnOyL6GnbG8Hvw==
4123+
41044124
[email protected], debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
41054125
version "2.6.9"
41064126
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -7850,6 +7870,11 @@ locate-path@^5.0.0:
78507870
dependencies:
78517871
p-locate "^4.1.0"
78527872

7873+
lodash.castarray@^4.4.0:
7874+
version "4.4.0"
7875+
resolved "https://registry.yarnpkg.com/lodash.castarray/-/lodash.castarray-4.4.0.tgz#c02513515e309daddd4c24c60cfddcf5976d9115"
7876+
integrity sha1-wCUTUV4wna3dTCTGDP3c9ZdtkRU=
7877+
78537878
lodash.escape@^4.0.1:
78547879
version "4.0.1"
78557880
resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-4.0.1.tgz#c9044690c21e04294beaa517712fded1fa88de98"
@@ -7865,11 +7890,21 @@ lodash.isequal@^4.5.0:
78657890
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
78667891
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
78677892

7893+
lodash.isplainobject@^4.0.6:
7894+
version "4.0.6"
7895+
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
7896+
integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=
7897+
78687898
[email protected], lodash.memoize@^4.1.2:
78697899
version "4.1.2"
78707900
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
78717901
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
78727902

7903+
lodash.merge@^4.6.2:
7904+
version "4.6.2"
7905+
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
7906+
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
7907+
78737908
lodash.sortby@^4.7.0:
78747909
version "4.7.0"
78757910
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@@ -8003,6 +8038,11 @@ map-visit@^1.0.0:
80038038
dependencies:
80048039
object-visit "^1.0.0"
80058040

8041+
marked@^2.1.3:
8042+
version "2.1.3"
8043+
resolved "https://registry.yarnpkg.com/marked/-/marked-2.1.3.tgz#bd017cef6431724fd4b27e0657f5ceb14bff3753"
8044+
integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==
8045+
80068046
matcher@^3.0.0:
80078047
version "3.0.0"
80088048
resolved "https://registry.yarnpkg.com/matcher/-/matcher-3.0.0.tgz#bd9060f4c5b70aa8041ccc6f80368760994f30ca"

0 commit comments

Comments
 (0)