Skip to content

Commit

Permalink
Added prettier, formatted all files using prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Karsyz authored and alcpereira committed Jul 1, 2024
1 parent 0c9e4b8 commit fcbf052
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 91 deletions.
19 changes: 10 additions & 9 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier",
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
}
};
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 2,
"printWidth": 80,
"proseWrap": "never",
"trailingComma": "all",
"singleQuote": false,
"semi": true
}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# CV PDF Generator

The CV PDF Generator is a React app used to build a CV and export it as a PDF.

## How To Run

1. Add your picture in `src/assets/profile.jpeg`
2. Fill out your information in `data.json`
3. Adapt CSS or scale in `pdf.ts` if needed
4. Run the following commands in the terminal

```sh
npm install
npm install
# Starts the vite server
npm run dev
# Generate the pdf
npm run pdf
```

## Built With

- React + Vite
- Puppeteer for PDF generation
- Puppeteer for PDF generation
60 changes: 54 additions & 6 deletions package-lock.json

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

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"format": "prettier . --write",
"prelint": "prettier . --write",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"pdf": "tsx pdf.ts"
Expand All @@ -24,8 +26,10 @@
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"prettier": "3.3.2",
"puppeteer": "^22.1.0",
"tsx": "^4.7.1",
"typescript": "^5.2.2",
Expand Down
6 changes: 5 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ function App() {
<div className="app__body">
<div
className="app__body-left"
style={{ display: "flex", flexDirection: "column", gap: "20px" }}
style={{
display: "flex",
flexDirection: "column",
gap: "20px",
}}
>
<Category data={data.workExperience} />
<Category data={data.projects} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ProfileHeader = ({
}: Data["profile"]) => {
return (
<div className="profile__header">
<ProfileImage circular={true} border={true}/>
<ProfileImage circular={true} border={true} />
<div className="profile__header__lines">
{lines.map((line, index) => (
<p key={index}>{line}</p>
Expand Down
24 changes: 12 additions & 12 deletions src/components/Profile/ProfileImage/ProfileImage.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.profile__header__image img {
height: 150px;
overflow: hidden;
}

.profile__header__image__circular img {
border-radius: 9999px;
}

.profile__header__image__border img {
border: 3px solid var(--red);
}
.profile__header__image img {
height: 150px;
overflow: hidden;
}

.profile__header__image__circular img {
border-radius: 9999px;
}

.profile__header__image__border img {
border: 3px solid var(--red);
}
60 changes: 30 additions & 30 deletions src/components/Profile/ProfileImage/ProfileImage.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import useProfilePicture from "../../../hooks/useProfilePicture";
import clsx from "clsx";
import "./ProfileImage.css";

type ImageOptions = {
circular?: boolean;
border?: boolean;
};

const ProfileImage = (options: ImageOptions = {}) => {
const profilePicture = useProfilePicture();

const profilePictureClasses = clsx(
"profile__header__image",
{ profile__header__image__circular: options.circular },
{ profile__header__image__border: options.border }
);

return (
<>
{profilePicture && (
<div className={profilePictureClasses}>
<img src={profilePicture} alt="Profile" />
</div>
)}
</>
);
};

export default ProfileImage;
import useProfilePicture from "../../../hooks/useProfilePicture";
import clsx from "clsx";
import "./ProfileImage.css";

type ImageOptions = {
circular?: boolean;
border?: boolean;
};

const ProfileImage = (options: ImageOptions = {}) => {
const profilePicture = useProfilePicture();

const profilePictureClasses = clsx(
"profile__header__image",
{ profile__header__image__circular: options.circular },
{ profile__header__image__border: options.border },
);

return (
<>
{profilePicture && (
<div className={profilePictureClasses}>
<img src={profilePicture} alt="Profile" />
</div>
)}
</>
);
};

export default ProfileImage;
52 changes: 26 additions & 26 deletions src/hooks/useProfilePicture.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { useState, useEffect } from 'react';

const useProfilePicture = (): string | null => {
const [profilePicture, setProfilePicture] = useState<string | null>(null);

useEffect(() => {
const loadProfilePicture = async () => {
const extensions = ['png', 'jpeg', 'jpg', 'gif', 'webp', 'svg'];
for (const extension of extensions) {
try {
const module = await import(`../assets/profile.${extension}`);
setProfilePicture(module.default);
break;
} catch (error) {
// Ignore error and try next extension
}
}
};

loadProfilePicture();
}, []);

return profilePicture;
};

export default useProfilePicture;
import { useState, useEffect } from "react";

const useProfilePicture = (): string | null => {
const [profilePicture, setProfilePicture] = useState<string | null>(null);

useEffect(() => {
const loadProfilePicture = async () => {
const extensions = ["png", "jpeg", "jpg", "gif", "webp", "svg"];
for (const extension of extensions) {
try {
const module = await import(`../assets/profile.${extension}`);
setProfilePicture(module.default);
break;
} catch (error) {
// Ignore error and try next extension
}
}
};

loadProfilePicture();
}, []);

return profilePicture;
};

export default useProfilePicture;
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import "./normalize.css";
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
Loading

0 comments on commit fcbf052

Please sign in to comment.