Skip to content

Commit

Permalink
refactor(sample): styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Sep 20, 2024
1 parent 542d3fe commit 2c182c9
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 62 deletions.
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
"playwright-core": "^1.47.1"
},
"devDependencies": {
"@nice-move/cli": "^0.11.16",
"@nice-move/eslint-config-base": "^0.11.21",
"@nice-move/prettier-config": "^0.12.5",
"@nice-move/all-in-base": "^0.2.0",
"@nice-move/syncpack-config": "^0.2.8",
"@nice-move/tsconfig": "^0.2.5",
"best-shot": "0.7.4",
"eslint": "^8.57.1",
"garou": "^0.7.8",
"log-symbols": "^4.1.0",
"prettier": "^3.3.3",
"syncpack": "^13.0.0",
"typescript": "~5.5.4"
Expand All @@ -52,7 +50,7 @@
},
"packageManager": "[email protected]",
"engines": {
"node": ">=22.0.0 || ^18.20.0 || ^20.4.0",
"node": ">=22.0.0 || ^18.20.0 || ^20.5.0",
"npm": "^10.5.0",
"pnpm": "^9.6.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"execa": "^9.4.0",
"ini": "^4.1.3",
"ini": "^5.0.0",
"is-url": "^1.2.4",
"semver": "^7.6.3",
"validate-npm-package-name": "^5.0.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/sample/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/sample",
"version": "0.4.16",
"version": "0.4.18",
"description": "Generate code sample files",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"bin": {
"bring-it": "dist/bin.mjs"
},
"main": "src/cmd.mjs",
"main": "dist/sub.mjs",
"files": [
"dist"
],
Expand Down
6 changes: 3 additions & 3 deletions packages/sample/src/lib/pdf.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ const style = html`
display: flex;
margin: 0 5%;
width: 92%;
font-size: 8pt;
font-size: 10pt;
font-family: 'Noto Sans Mono CJK SC', monospace;
text-align: center;
}
.title {
margin-right: auto;
}
.pageNumber {
margin-right: 4pt;
margin-right: 5pt;
}
.totalPages {
margin-left: 4pt;
margin-left: 5pt;
}
</style>
`;
Expand Down
15 changes: 12 additions & 3 deletions packages/sample/src/lib/picker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,19 @@ export function scan(config) {
caseSensitiveMatch: false,
})
.then((list) =>
list.filter((item) =>
config.extensions.includes(extname(item).replace(/^\./, '')),
),
config.extensions.length > 0
? list.filter((item) =>
config.extensions.includes(extname(item).replace(/^\./, '')),
)
: list,
)
.then((list) => {
if (list.length === 0) {
throw new Error('Not match anything');
}

return list;
})
.then((list) => list.sort())
.then((list) => {
for (const item of list) {
Expand Down
55 changes: 32 additions & 23 deletions packages/sample/src/lib/template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
@page {
margin: 60pt 24pt 24pt;
}
body {
margin: 0;
}
body,
pre,
code {
Expand All @@ -22,24 +25,29 @@
h3 {
margin-top: 100pt;
}
pre {
display: block;
}
pre,
code {
display: block;
margin: 0;
width: 100%;
font-size: 12pt;
line-height: 1.25;
white-space: pre-wrap;
}
code {
display: flex;
counter-increment: line;
overflow: hidden;
word-break: break-all;
}
code::before {
display: inline-block;
flex-shrink: 0;
align-self: stretch;
margin-right: 1em;
background-color: #f5f5f5;
padding-right: 2px;
background-color: #f3f3f3;
padding: 0 2px;
width: 2em;
content: counter(line);
text-align: right;
Expand All @@ -53,29 +61,30 @@
</header>
<pre></pre>
</body>
<script defer>
const { body } = document;
window
.mock()
.then((result) => {
const header = body.querySelector('header');
<script defer type="module">
if (window.mock) {
window
.mock()
.then((result) => {
const header = document.body.querySelector('header');

header.querySelector('h1').textContent = result.title;
header.querySelector('h1').textContent = result.title;

header.querySelector('h2').textContent = result.version;
header.querySelector('h2').textContent = result.version;

document.title = [result.title, result.version].join(' ');
document.title = [result.title, result.version].join(' ');

const pre = body.querySelector('pre');
const pre = document.body.querySelector('pre');

for (const line of result.data.split('\n')) {
const code = document.createElement('code');
code.textContent = line;
pre.append(code);
}
})
.catch((error) => {
console.error(error);
});
for (const line of result.data.split('\n')) {
const code = document.createElement('code');
code.textContent = line;
pre.append(code);
}
})
.catch((error) => {
console.error(error);
});
}
</script>
</html>
70 changes: 45 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c182c9

Please sign in to comment.