Skip to content

Commit 3d013ab

Browse files
committed
Refactor code structure and remove redundant sections for improved readability and maintainability
1 parent 61d6fbc commit 3d013ab

29 files changed

Lines changed: 8026 additions & 10 deletions

pdf-template.zip

-3.59 KB
Binary file not shown.

pdf-template/other.html

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,77 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html>
33

44
<head>
55
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>Placeholder File</title>
8-
<link rel="stylesheet" href="styles.css">
9-
<script src="script.js"></script>
6+
<title>Transcription Document</title>
7+
<script src="https://cdn.tailwindcss.com"></script>
8+
<link
9+
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
10+
rel="stylesheet">
11+
<script>
12+
tailwind.config = {
13+
theme: {
14+
extend: {
15+
fontFamily: {
16+
'sans': ['Roboto', 'sans-serif'],
17+
}
18+
}
19+
}
20+
}
21+
</script>
1022
</head>
1123

12-
<body>
13-
<!-- Your content goes here -->
14-
<h1>Placeholder File</h1>
15-
DO NOT DELETE THIS FILE
16-
<p>This is a placeholder file to prevent the folder from being empty.</p>
24+
<body class="w-full h-full m-0 p-0 font-sans flex">
25+
<div class="p-10 h-full w-full flex flex-col">
26+
<div class="flex justify-between items-center mb-8 border-b-2 border-blue-500 pb-4">
27+
<span id="title" class="text-3xl font-bold text-blue-800">Transcription</span>
28+
<span id="date" class="text-base text-gray-500"></span>
29+
</div>
30+
<div id="content" class="flex-1 leading-relaxed whitespace-pre-wrap text-lg">
31+
<!-- Transcription content will go here -->
32+
</div>
33+
<div class="mt-8 border-t border-gray-200 pt-4 text-sm text-gray-500 text-center">
34+
<a href="https://transcriptr.aramb.dev"> Generated with Transcriptr (https://transcriptr.aramb.dev) </a>
35+
</div>
36+
</div>
37+
38+
<script type="module">
39+
import { setup, onRender } from "https://cdn.skypack.dev/@printerz-app/template-sdk"
40+
setup();
41+
42+
const { register } = onRender((variables) => {
43+
console.log(variables);
44+
45+
// Set title if provided, otherwise use default
46+
if (variables.title) {
47+
document.getElementById("title").innerHTML = variables.title;
48+
}
49+
50+
// Set current date with better formatting
51+
const today = new Date();
52+
const options = {
53+
weekday: 'short',
54+
year: 'numeric',
55+
month: 'short',
56+
day: 'numeric',
57+
hour: '2-digit',
58+
minute: '2-digit',
59+
second: '2-digit'
60+
};
61+
document.getElementById("date").innerHTML = today.toLocaleDateString('en-US', options);
62+
63+
// Set content with proper formatting
64+
document.getElementById("content").innerHTML = variables.content || '';
65+
66+
// Handle RTL text if it contains Arabic
67+
if (/[\u0600-\u06FF]/.test(variables.content)) {
68+
document.getElementById("content").classList.add("rtl");
69+
document.getElementById("content").dir = "rtl";
70+
}
71+
});
72+
73+
register();
74+
</script>
1775
</body>
1876

1977
</html>

pdf-template/pdf-template.zip

49.2 KB
Binary file not shown.
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
ignorePatterns: ['dist', '.eslintrc.cjs'],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': [
14+
'warn',
15+
{ allowConstantExport: true },
16+
],
17+
},
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Printerz Invoice template example
2+
3+
Built with :
4+
- React
5+
- TailwindCSS
6+
- Vite
7+
- TypeScript
8+
- shadcn UI
9+
- v0.dev
10+
11+
## Preview
12+
![Preview](./assets/preview.png)
13+
14+
## How to use
15+
16+
### Want to use it as it is ?
17+
18+
Go download the template from the release page and upload it to your printerz dashboard.
19+
20+
### Want to modify it ?
21+
22+
1. Clone the repository and run the following commands :
23+
24+
```bash
25+
npx degit https://github.com/printerz-app/printerz-example-templates/react-invoice-template
26+
```
27+
28+
2. Install dependencies
29+
30+
```bash
31+
pnpm install
32+
## or
33+
npm install
34+
## or
35+
yarn install
36+
```
37+
38+
3. Run the development server
39+
40+
```bash
41+
pnpm dev
42+
## or
43+
npm run dev
44+
## or
45+
yarn dev
46+
```
47+
48+
4. Make your changes
49+
50+
You can test the print variable behavior by copy pasting the following code in the console of your browser :
51+
```js
52+
window.printerzRender({
53+
"invoiceNumber": "INV-1001",
54+
"invoiceDate": "2024-08-15",
55+
"customer": {
56+
"name": "John Doe",
57+
"address": "123 Maple Street, Springfield, IL, 62704"
58+
},
59+
"invoiceItems": [
60+
{
61+
"name": "Widget A",
62+
"quantity": 10,
63+
"unitPrice": 1999
64+
},
65+
{
66+
"name": "Gadget B",
67+
"quantity": 5,
68+
"unitPrice": 4995
69+
},
70+
{
71+
"name": "Thingamajig C",
72+
"quantity": 2,
73+
"unitPrice": 14950
74+
}
75+
]
76+
})
77+
```
78+
79+
5. Build the project
80+
81+
```bash
82+
pnpm build
83+
## or
84+
npm run build
85+
## or
86+
yarn build
87+
```
88+
89+
6. Zip the dist folder and upload it to your printerz dashboard
58.5 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "src/globals.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)