Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/preview/heroic/0.1.1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
assets/icons/

.DS_Store
Thumbs.db
21 changes: 21 additions & 0 deletions packages/preview/heroic/0.1.1/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Jonas Neugebauer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions packages/preview/heroic/0.1.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# heroic (v0.1.1)

Use [Heroicons](https://heroicons.com/) (v2.2.0) in Typst.

Compared to other icon packages `heroic` can be used without the need to install
any icon fonts and works out of the box with bundled SVG files.

## Usage

Import the package and use either the `#icon` or `#hi` commands.

```typst
#import "@preview/heroic:0.1.1": icon, hi

Use `#icon` to add icons as images as seen in @map-pin-icon.
#figure(
icon("map-pin", height: 2cm, color: green),
caption: [`map-pin` icon],
) <map-pin-icon>

#text(fill: orange)[Use #hi("megaphone", solid: false) `#hi` for context aware inline icons]\
that adapt to the surrounding text.
```

![](assets/example.png)

## Commands

Both commands use the same arguments:

- **name** (`str`): Name of the icon.
- **color** (`color` | `auto`): Color of the icon (default: `auto`).
- **height** (`length`): Height of the icon (default: `1em`).
- **solid** (`boolean`): If the icon should be filled with a solid color or outlined (default: `true`).

`#hi` also takes additional arguments:

- **baseline** (`length`): Baseline of the icon.

## Development

### Bundling Heroicons

To update the icon files to a new version, run the `bundle.py` script from the `scripts` folder:
```sh
python3 scripts/bundle.py <release_version>
```

## Changelog

- Vesion 0.1.1 (2025-12-23)
- Updated Heroicons to 2.2.0.
- Improved `scripts/bundler.py` script to download and bundle new Heroicon versions.
- Added auto-generated `src/icon-index.txt` instead of fixed list of icon names.
- Added parameter `columns` for `#list-icons`.

- Version 0.1.0 (2025-05-15)
- Initial release.
Binary file added packages/preview/heroic/0.1.1/assets/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions packages/preview/heroic/0.1.1/assets/example.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import "../src/heroic.typ": hi, icon

Check warning on line 1 in packages/preview/heroic/0.1.1/assets/example.typ

View check run for this annotation

Typst package check / @preview/heroic:0.1.1

packages/preview/heroic/0.1.1/assets/example.typ#L1

This file seems to be an example, and should probably be added to `exclude` in your `typst.toml`.

Check warning on line 1 in packages/preview/heroic/0.1.1/assets/example.typ

View check run for this annotation

Typst package check / @preview/heroic:0.1.1

packages/preview/heroic/0.1.1/assets/example.typ#L1

This import should use the package specification, not a relative path.

#set page(width: auto, height: auto, margin: 1cm)

Use `#icon` to add icons as images as seen in @map-pin-icon.
#figure(
icon("map-pin", height: 2cm, color: green),
caption: [`map-pin` icon],
) <map-pin-icon>

#text(fill: orange)[Use #hi("megaphone", solid: false) `#hi` for context aware inline icons]\
that adapt to the surrounding text.
Binary file added packages/preview/heroic/0.1.1/assets/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/preview/heroic/0.1.1/assets/icons.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "../src/heroic.typ"

Check warning on line 1 in packages/preview/heroic/0.1.1/assets/icons.typ

View check run for this annotation

Typst package check / @preview/heroic:0.1.1

packages/preview/heroic/0.1.1/assets/icons.typ#L1

This import should use the package specification, not a relative path.

#set page(width: auto, height: auto, margin: 1cm)

#heroic.list-icons(columns: 2)
49 changes: 49 additions & 0 deletions packages/preview/heroic/0.1.1/src/heroic.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#import "index.typ": icon-names, icon-sprites


#let icon(name, height: 1em, solid: true, color: none) = {
if name not in icon-names {
panic("Icon " + name + " does not exists. See https://heroicons.com/ for valid icon names.")
}


let color = if color == none { "currentColor" } else { color.to-hex() }

let icon-data = if solid {
icon-sprites.solid + "<use href=\"#" + name + "\" fill=\"" + color + "\" />" + "</svg>"
} else {
icon-sprites.outline + "<use href=\"#" + name + "\" stroke=\"" + color + "\" />" + "</svg>"
}

image(
bytes(icon-data),
alt: name,
format: "svg",
fit: "contain",
height: height,
)
}

#let hi(name, baseline: 20%, ..icon-args) = context {
box(
baseline: baseline,
icon(name, color: text.fill, ..icon-args),
)
}


#let list-icons(sort: k => k, columns: 1, ..grid-args) = grid(
columns: 4 * columns,
align: (right + horizon, center + horizon, center + horizon, left + horizon),
inset: .5em,
stroke: (y: .75pt),
..grid-args,
..for (i, name) in icon-names.sorted(key: sort).enumerate() {
(
grid.cell(stroke: if columns > 1 and calc.rem(i, columns) > 0 { (left: .75pt) } + (y: .75pt))[#{ i + 1 }.],
icon(name, height: 10pt),
icon(name, height: 10pt, solid: false),
raw(block: false, name),
)
}
)
Loading