Skip to content

Commit a904487

Browse files
committed
Move CI example to repo
1 parent c82d737 commit a904487

File tree

7 files changed

+135
-1
lines changed

7 files changed

+135
-1
lines changed

.codesandbox/ci.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"sandboxes": ["format-quantity-ci-oxw19"]
2+
"sandboxes": ["/ci"],
3+
"node": "18"
34
}

ci/index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>format-quantity CI</title>
5+
</head>
6+
<body>
7+
<h1>format-quantity CI</h1>
8+
<div id="grid">
9+
<div>quantity</div>
10+
<div>default</div>
11+
<div>vulgarFractions</div>
12+
<div>fractionSlash</div>
13+
<div>romanNumerals</div>
14+
</div>
15+
<script src="src/index.ts"></script>
16+
</body>
17+
</html>

ci/package.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "format-quantity-ci",
3+
"version": "1.0.0",
4+
"description": "format-quantity Test Page",
5+
"main": "index.html",
6+
"scripts": {
7+
"start": "parcel index.html --open",
8+
"build": "parcel build index.html"
9+
},
10+
"dependencies": {
11+
"format-quantity": "1.1.0",
12+
"parcel-bundler": "^1.12.5"
13+
},
14+
"devDependencies": {
15+
"typescript": "^5.1.3"
16+
},
17+
"resolutions": {
18+
"@babel/preset-env": "7.13.8"
19+
},
20+
"keywords": []
21+
}

ci/src/index.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { formatQuantity } from 'format-quantity';
2+
import { numbers } from './numbers';
3+
import './styles.css';
4+
5+
const grid = document.querySelector('#grid')!;
6+
7+
const gridInnerHTML: string[] = [];
8+
9+
for (const num of numbers) {
10+
const run = [
11+
num,
12+
formatQuantity(num),
13+
formatQuantity(num, { vulgarFractions: true }),
14+
formatQuantity(num, { fractionSlash: true }),
15+
formatQuantity(num, { romanNumerals: true }),
16+
];
17+
18+
gridInnerHTML.push(...run.map(r => `<div>${JSON.stringify(r)}</div>`));
19+
}
20+
21+
grid.innerHTML = gridInnerHTML.join('');

ci/src/numbers.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export const numbers = [
2+
'NaN',
3+
0,
4+
1,
5+
-1,
6+
100,
7+
1.1,
8+
-1.1,
9+
1.25,
10+
-1.25,
11+
1.75,
12+
-1.75,
13+
0.2,
14+
1.2,
15+
0.4,
16+
1.4,
17+
0.6,
18+
1.6,
19+
0.8,
20+
1.8,
21+
1.32,
22+
1.33,
23+
1.3333333333333333,
24+
1.34,
25+
1.66,
26+
1.667,
27+
1.6666666666666666,
28+
1.67,
29+
1.51,
30+
1.5,
31+
1.52,
32+
1.125,
33+
1.375,
34+
1.625,
35+
1.875,
36+
] as const;

ci/src/styles.css

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
body {
2+
font-family: 'Consolas', 'Courier New', Courier, monospace;
3+
font-size: 14px;
4+
}
5+
6+
#grid {
7+
display: grid;
8+
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
9+
column-gap: 1rem;
10+
row-gap: 0.4rem;
11+
}
12+
13+
#grid > *:nth-child(n + 5) {
14+
border-bottom: 1px solid #dddddd;
15+
}
16+
17+
#grid > *:nth-child(-n + 5) {
18+
border-bottom: 1px solid gray;
19+
font-weight: bold;
20+
text-align: center;
21+
}
22+
23+
#grid > *:nth-child(5n + 1):nth-child(n + 5) {
24+
font-weight: bold;
25+
text-align: right;
26+
}

ci/tsconfig.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"module": "commonjs",
5+
"jsx": "preserve",
6+
"esModuleInterop": true,
7+
"sourceMap": true,
8+
"allowJs": true,
9+
"lib": ["ES6", "DOM"],
10+
"moduleResolution": "node"
11+
}
12+
}

0 commit comments

Comments
 (0)