Skip to content

Commit

Permalink
Add optional image (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: Pavel Zwerschke <[email protected]>
  • Loading branch information
Orbion-J and pavelzw authored Jan 22, 2025
1 parent 6191076 commit 3b4e618
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ You can download fontawesome [here](https://fontawesome.com/download).
// custom socials: (icon, link, body)
// any fontawesome icon can be used: https://fontawesome.com/search
website: ("link", "https://example.me", "example.me"),
image-path: "/my-image.png",
),
)
// ...
```
### Image

To add an image to your curriculum vitae, you can a path to that image to the `image-path` parameter (the path should be from the root of your project and start with a `/`). Here are the additional parameters:

- `image-height`: size of the image
- `image-frame-stroke`: stroke of the frame. By default is 1pt + the main of the file. Can be any stroke value. Set to `none` to remove the frame.

## Examples

Expand Down
57 changes: 56 additions & 1 deletion lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#let _header(
title: [],
subtitle: [],
image-path: none,
image-height: none,
image-frame-stroke: auto,
color: moderncv-blue,
socials: (:),
) = {
let titleStack = stack(
Expand Down Expand Up @@ -68,13 +72,53 @@
..socialsList,
)

let imageStack = []

if image-path != none {
let image = image(image-path, height: image-height)

let imageFramed = []

if image-frame-stroke == none {
// no frame
imageFramed = image
} else {
if image-frame-stroke == auto {
// default stroke
image-frame-stroke = 1pt + color
} else {
image-frame-stroke = stroke(image-frame-stroke)
if image-frame-stroke.paint == auto {
// use the main color by default
// fields on stroke are not yet mutable
image-frame-stroke = stroke((
paint: color,
thickness: image-frame-stroke.thickness,
cap: image-frame-stroke.cap,
join: image-frame-stroke.join,
dash: image-frame-stroke.dash,
miter-limit: image-frame-stroke.miter-limit,
))
}
}
imageFramed = rect(image, stroke: image-frame-stroke)
}

imageStack = stack(
dir: ltr,
h(1em),
imageFramed,
)
}

stack(
dir: ltr,
titleStack,
align(
right + top,
socialStack,
),
imageStack,
)
}

Expand All @@ -85,6 +129,9 @@
color: moderncv-blue,
lang: "en",
font: "New Computer Modern",
image-path: none,
image-height: 8em,
image-frame-stroke: auto,
paper: "a4",
margin: (
top: 10mm,
Expand Down Expand Up @@ -123,7 +170,15 @@
)
}

#_header(title: name, subtitle: subtitle, socials: social)
#_header(
title: name,
subtitle: subtitle,
image-path: image-path,
image-height: image-height,
image-frame-stroke: image-frame-stroke,
color: color,
socials: social,
)

#body

Expand Down

0 comments on commit 3b4e618

Please sign in to comment.