Skip to content

Commit 15e7cca

Browse files
authored
Bump dependencies, move to TypeScript 6 and clean up the site (#1433)
1 parent 9409924 commit 15e7cca

14 files changed

Lines changed: 2225 additions & 1413 deletions

File tree

‎.eslintrc.json‎

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module.exports = {
1+
const config = {
22
trailingSlash: true,
33
output: 'export'
44
};
5+
6+
export default config;

‎package-lock.json‎

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

‎package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"devDependencies": {
1010
"@octokit/rest": "22.0.1",
1111
"@personnummer/generate": "1.0.3",
12-
"@tailwindcss/postcss": "^4.1.18",
13-
"@types/node": "25.9.9",
12+
"@tailwindcss/postcss": "^4.3.3",
13+
"@types/node": "26.6.4",
1414
"@types/react": "19.3.0",
1515
"eslint": "^9.39.2",
1616
"eslint-config-next": "16.3.8",
@@ -21,8 +21,8 @@
2121
"react": "19.3.0",
2222
"react-dom": "19.3.0",
2323
"react-qr-code": "2.2.0",
24-
"tailwindcss": "^4.1.18",
25-
"typescript": "5.9.3",
24+
"tailwindcss": "^4.3.3",
25+
"typescript": "6.0.3",
2626
"yaml": "2.9.1"
2727
},
2828
"scripts": {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
module.exports = {
1+
const config = {
22
plugins: {
33
'@tailwindcss/postcss': {},
44
}
55
};
6+
7+
export default config;

‎src/components/Block/index.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ export type BlockProps = Partial<{
88
const Block = ({
99
border = true,
1010
children,
11-
className,
11+
className = '',
1212
title = ''
1313
}: BlockProps) => (
1414
<div className={`mt-5 ${className}`}>
1515
{title && (
1616
<h2
1717
className={`text-lg md:text-xl text-gray-700 mb-2 ${
18-
border ? 'border-b border-gray' : ''
18+
border ? 'border-b border-gray-200' : ''
1919
}`}
2020
id={title.toLowerCase().replace(/ /g, '-')}
2121
>

‎src/components/Generate/index.tsx‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import gen from '@personnummer/generate';
44
import QRCode from 'react-qr-code';
55
import Block, { BlockProps } from '../Block';
66

7-
const computePersonnummer = (y: number, m: number, d: number) =>
8-
gen(new Date(y, m, d));
7+
const computePersonnummer = (y: number, m: number, d: number) => {
8+
const date = new Date(y, m, d);
9+
10+
// Reject dates that rolled over, such as February 31.
11+
return date.getMonth() === m ? gen(date) : '';
12+
};
913

1014
const Generate = (props: BlockProps) => {
1115
const today = useMemo(() => new Date(), []);
@@ -42,7 +46,7 @@ const Generate = (props: BlockProps) => {
4246
min={1}
4347
value={year}
4448
onChange={(e) => setYear(Number(e.target.value))}
45-
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
49+
className="shadow-sm appearance-none border rounded-sm w-full py-2 px-3 text-gray-700 leading-tight focus:outline-hidden focus:ring-2 focus:ring-blue-300"
4650
/>
4751
</div>
4852

@@ -58,7 +62,7 @@ const Generate = (props: BlockProps) => {
5862
max={12}
5963
value={month}
6064
onChange={(e) => setMonth(Number(e.target.value))}
61-
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
65+
className="shadow-sm appearance-none border rounded-sm w-full py-2 px-3 text-gray-700 leading-tight focus:outline-hidden focus:ring-2 focus:ring-blue-300"
6266
/>
6367
</div>
6468

@@ -74,7 +78,7 @@ const Generate = (props: BlockProps) => {
7478
max={31}
7579
value={day}
7680
onChange={(e) => setDay(Number(e.target.value))}
77-
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
81+
className="shadow-sm appearance-none border rounded-sm w-full py-2 px-3 text-gray-700 leading-tight focus:outline-hidden focus:ring-2 focus:ring-blue-300"
7882
/>
7983
</div>
8084
</div>
@@ -85,7 +89,7 @@ const Generate = (props: BlockProps) => {
8589
type="tel"
8690
readOnly
8791
value={displayValue}
88-
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
92+
className="shadow-sm appearance-none border rounded-sm w-full py-2 px-3 text-gray-700 leading-tight focus:outline-hidden focus:ring-2 focus:ring-blue-300"
8993
/>
9094
</div>
9195
</div>

‎src/components/Try/index.tsx‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from 'react';
22
import personnummer from 'personnummer';
33
import Block, { BlockProps } from '../Block';
4-
import pkg from '../../../package.json';
4+
import { version } from 'personnummer/package.json';
55

66
type Output = {
77
age: number;
@@ -19,7 +19,7 @@ const personnummerOptions = {
1919
};
2020

2121
const getPersonnummerObj = (pin: string): Output => {
22-
const output = {
22+
const output: Output = {
2323
age: 0,
2424
long: 'n/a',
2525
short: 'n/a',
@@ -29,10 +29,6 @@ const getPersonnummerObj = (pin: string): Output => {
2929
valid: personnummer.valid(pin, personnummerOptions)
3030
};
3131

32-
if (typeof pin !== 'string') {
33-
return output;
34-
}
35-
3632
try {
3733
const p = personnummer.parse(pin, personnummerOptions);
3834

@@ -44,7 +40,7 @@ const getPersonnummerObj = (pin: string): Output => {
4440
output.con = p.isCoordinationNumber();
4541
output.interim = p.isInterimNumber();
4642
}
47-
} catch (err) {
43+
} catch {
4844
output.sex = 'n/a';
4945
}
5046

@@ -62,7 +58,7 @@ const Try = (props: BlockProps) => {
6258
type="text"
6359
placeholder="YYMMDDXXXX"
6460
onChange={(e) => setPin(e.target.value)}
65-
className="appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
61+
className="appearance-none border rounded-sm w-full py-2 px-3 text-gray-700 leading-tight focus:outline-hidden focus:ring-2 focus:ring-blue-300"
6662
/>
6763
<p className="pt-3">result</p>
6864
<table className="table-fixed w-full">
@@ -115,10 +111,7 @@ const Try = (props: BlockProps) => {
115111
</tr>
116112
</tbody>
117113
</table>
118-
<p className="mt-3 italic">
119-
using javascript version{' '}
120-
{pkg.devDependencies.personnummer.replace('^', '')}
121-
</p>
114+
<p className="mt-3 italic">using javascript version {version}</p>
122115
</Block>
123116
);
124117
};

‎src/pages/_app.tsx‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import React from 'react';
22
import Head from 'next/head';
33
import type { AppProps } from 'next/app';
4+
import { Source_Sans_3 } from 'next/font/google';
45
import '../styles/main.css';
56

7+
const font = Source_Sans_3({ subsets: ['latin'] });
8+
69
const App = ({ Component, pageProps }: AppProps) => (
7-
<>
10+
<div className={font.className}>
811
<div className="flex flex-col flex-1 md:justify-center max-w-3xl mx-auto p-5 w-full">
912
<Head>
1013
<title>Personnummer</title>
@@ -34,15 +37,6 @@ const App = ({ Component, pageProps }: AppProps) => (
3437
className="text-blue-500 hover:underline"
3538
>
3639
GitHub
37-
</a>{' '}
38-
-{' '}
39-
<a
40-
target="_blank"
41-
rel="noopener noreferrer"
42-
href="https://twitter.com/sweidproject"
43-
className="text-blue-500 hover:underline"
44-
>
45-
Twitter
4640
</a>
4741
</p>
4842
<p className="text-center text-gray-600 mt-2">
@@ -51,7 +45,7 @@ const App = ({ Component, pageProps }: AppProps) => (
5145
it, carries his work. He is missed.
5246
</p>
5347
</div>
54-
</>
48+
</div>
5549
);
5650

5751
export default App;

‎src/pages/_document.tsx‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ const Document = () => (
44
<Html lang="en">
55
<Head>
66
<meta charSet="UTF-8" />
7-
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
8-
<link rel="dns-prefetch" href="//fonts.googleapis.com/" />
9-
<link rel="dns-prefetch" href="//www.google-analytics.com" />
10-
<link
11-
rel="sitemap"
12-
type="application/xml"
13-
title="Sitemap"
14-
href="/sitemap.xml"
15-
/>
167
<link
178
rel="apple-touch-icon"
189
sizes="180x180"
@@ -30,14 +21,6 @@ const Document = () => (
3021
sizes="16x16"
3122
href="/favicon-16x16.png"
3223
/>
33-
<link
34-
rel="stylesheet"
35-
href="https://highlightjs.org/static/demo/styles/railscasts.css"
36-
/>
37-
<link
38-
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap"
39-
rel="stylesheet"
40-
/>
4124
<meta
4225
name="description"
4326
content="Validate swedish personal identity numbers"
@@ -47,13 +30,19 @@ const Document = () => (
4730
property="og:description"
4831
content="Validate swedish personal identity numbers"
4932
/>
50-
<meta property="og:image" content="https://personnummer.dev/" />
33+
<meta
34+
property="og:image"
35+
content="https://personnummer.dev/android-chrome-512x512.png"
36+
/>
5137
<meta name="twitter:title" content="Personnummer" />
5238
<meta
5339
name="twitter:description"
5440
content="Validate swedish personal identity numbers"
5541
/>
56-
<meta name="twitter:image" content="https://personnummer.dev/" />
42+
<meta
43+
name="twitter:image"
44+
content="https://personnummer.dev/android-chrome-512x512.png"
45+
/>
5746
<meta name="twitter:card" content="summary" />
5847
</Head>
5948
<body>

0 commit comments

Comments
 (0)