Skip to content

Commit

Permalink
theme(stargazer): complete stargazer theme
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeX4 committed Sep 2, 2024
1 parent 607c12f commit 35c9e5c
Show file tree
Hide file tree
Showing 7 changed files with 647 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you like it, consider [giving a star on GitHub](https://github.com/touying-ty
![GitHub](https://img.shields.io/github/license/touying-typ/touying)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/touying-typ/touying)
![GitHub Repo stars](https://img.shields.io/github/stars/touying-typ/touying)
![Themes badge](https://img.shields.io/badge/themes-5-aqua)
![Themes badge](https://img.shields.io/badge/themes-6-aqua)

## Document

Expand Down Expand Up @@ -374,6 +374,7 @@ Thanks to...
- [@Enivex](https://github.com/Enivex) for the `metropolis` theme
- [@drupol](https://github.com/drupol) for the `university` theme
- [@pride7](https://github.com/pride7) for the `aqua` theme
- [@Coekjan](https://github.com/Coekjan) and [@QuadnucYard](https://github.com/QuadnucYard) for the `stargazer` theme
- [@ntjess](https://github.com/ntjess) for contributing to `fit-to-height`, `fit-to-width` and `cover-with-rect`

## Star History
Expand Down
66 changes: 66 additions & 0 deletions examples/stargazer.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#import "../lib.typ": *
#import themes.stargazer: *

#import "@preview/numbly:0.1.0": numbly

#show: stargazer-theme.with(
aspect-ratio: "16-9",
config-info(
title: [Stargazer in Touying: Customize Your Slide Title Here],
subtitle: [Customize Your Slide Subtitle Here],
author: [Authors],
date: datetime.today(),
institution: [Institution],
logo: emoji.school,
),
)

#set heading(numbering: numbly("{1}.", default: "1.1"))

#title-slide()

#outline-slide()

= Section A

== Subsection A.1

#tblock(title: [Theorem])[
A simple theorem.

$ x_(n+1) = (x_n + a / x_n) / 2 $
]

== Subsection A.2

A slide without a title but with *important* information.

= Section B

== Subsection B.1

#lorem(80)

#focus-slide[
Wake up!
]

== Subsection B.2

We can use `#pause` to #pause display something later.

#pause

Just like this.

#meanwhile

Meanwhile, #pause we can also use `#meanwhile` to #pause display other content synchronously.

#show: appendix

= Appendix

== Appendix

Please pay attention to the current slide number.
87 changes: 83 additions & 4 deletions src/components.typ
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,18 @@
transform: (cover: false, alpha: alpha, ..args, it) => {
let array-at(arr, idx) = arr.at(idx, default: arr.last())
let set-text(level, body) = {
set text(fill: (
set text(fill: {
let text-color = if type(text-fill) == array and text-fill.len() > 0 {
array-at(text-fill, level - 1)
} else {
text.fill
}
if cover {
utils.update-alpha(array-at(text-fill, level - 1), alpha)
utils.update-alpha(text-color, alpha)
} else {
array-at(text-fill, level - 1)
text-color
}
)) if type(text-fill) == array and text-fill.len() > 0
})
set text(
size: array-at(text-size, level - 1),
) if type(text-size) == array and text-size.len() > 0
Expand Down Expand Up @@ -458,4 +463,78 @@
set text(size: .7em)
grid(columns: cols.map(_ => auto).intersperse(1fr), ..cols.intersperse([]))
}
)



#let simple-navigation(
self: none,
short-heading: true,
primary: white,
secondary: gray,
background: black,
logo: none,
) = (
context {
let body() = {
let sections = query(heading.where(level: 1))
if sections.len() == 0 {
return
}
let current-page = here().page()
set text(size: 0.5em)
for (section, next-section) in sections.zip(sections.slice(1) + (none,)) {
set text(fill: if section.location().page() <= current-page and (
next-section == none or current-page < next-section.location().page()
) {
primary
} else {
secondary
})
box(inset: 0.5em)[#link(
section.location(),
if short-heading {
utils.short-heading(self: self, section)
} else {
section.body
},
)<touying-link>]
}
}
block(
fill: background,
inset: 0pt,
outset: 0pt,
grid(
align: center + horizon,
columns: (1fr, auto),
rows: 1.8em,
gutter: 0em,
cell(
fill: background,
body(),
),
block(fill: background, inset: 4pt, height: 100%, text(fill: primary, logo)),
),
)
}
)


/// LaTeX-like knob marker for list
///
/// Example: `#set list(marker: components.knob-marker(primary: rgb("005bac")))`
#let knob-marker(primary: rgb("#005bac")) = box(
width: 0.5em,
place(
dy: 0.1em,
circle(
fill: gradient.radial(
primary.lighten(100%),
primary.darken(40%),
focal-center: (30%, 30%),
),
radius: 0.25em,
),
),
)
20 changes: 20 additions & 0 deletions src/utils.typ
Original file line number Diff line number Diff line change
Expand Up @@ -1055,4 +1055,24 @@
if show-notes-on-second-screen != none {
slide-note-state.update(setting(note))
}
}


/// i18n Outline Title
#let i18n-outline-title = context {
let mapping = (
ar: "المحتويات",
ca: "Índex",
cs: "Obsah",
da: "Indhold",
en: "Outline",
es: "Índice",
et: "Sisukord",
fi: "Sisällys",
ja: "目次",
ru: "Содержание",
zh-TW: "目錄",
zh: "目录",
)
mapping.at(text.lang, default: mapping.en)
}
8 changes: 3 additions & 5 deletions themes/dewdrop.typ
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@


/// Outline slide for the presentation.
#let outline-slide(..args) = touying-slide-wrapper(self => {
#let outline-slide(title: utils.i18n-outline-title, ..args) = touying-slide-wrapper(self => {
self = utils.merge-dicts(
self,
config-page(
Expand All @@ -182,7 +182,7 @@
1.2em,
fill: self.colors.primary,
weight: "bold",
utils.call-or-display(self, self.store.outline-title),
utils.call-or-display(self, title),
),
text(
fill: self.colors.neutral-darkest,
Expand Down Expand Up @@ -272,7 +272,7 @@
///
/// - `alpha` is the alpha of transparency. Default is `60%`.
///
/// - `outline-title` is the title of the outline. Default is `[Outline]`.
/// - `outline-title` is the title of the outline. Default is `utils.i18n-outline-title`.
///
/// - `subslide-preamble` is the preamble of the subslide. Default is `self => block(text(1.2em, weight: "bold", fill: self.colors.primary, utils.display-current-heading(depth: self.slide-level)))`.
///
Expand All @@ -298,7 +298,6 @@
footer-right: context utils.slide-counter.display() + " / " + utils.last-slide-number,
primary: rgb("#0c4842"),
alpha: 60%,
outline-title: [Outline],
subslide-preamble: self => block(
text(1.2em, weight: "bold", fill: self.colors.primary, utils.display-current-heading(depth: self.slide-level)),
),
Expand Down Expand Up @@ -349,7 +348,6 @@
footer: footer,
footer-right: footer-right,
alpha: alpha,
outline-title: outline-title,
subslide-preamble: subslide-preamble,
),
..args,
Expand Down
Loading

0 comments on commit 35c9e5c

Please sign in to comment.