Skip to content

Commit

Permalink
theme: update aqua theme and simplify codes
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeX4 committed Mar 15, 2024
1 parent 1f9593d commit ebfcb0f
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 54 deletions.
46 changes: 18 additions & 28 deletions examples/aqua-zh.typ
Original file line number Diff line number Diff line change
@@ -1,50 +1,40 @@
#import "../lib.typ": *

#let s = themes.aqua.register(aspect-ratio: "16-9", lang: "zh")

#let s = (s.methods.info)(
self: s,
title: [An Instruction to Typst-Beamer],
author: [Author],
self: s,
title: [标题],
subtitle: [副标题],
author: [作者],
date: datetime.today(),
institution: [机构],
)
#let (init, slides) = utils.methods(s)
#let (init, slides, touying-outline, alert) = utils.methods(s)
#show: init

#set text(font: "Microsoft YaHei") // "Microsoft YaHei" is recommended.
#let (slide, title-slide, outline-slide, new-section-slide) = utils.slides(s)
#show: slides
#show strong: alert

= 制作一个标题页
#let (slide, title-slide, outline-slide, focus-slide) = utils.slides(s)
#show: slides

#slide[
= Typst Beamer 如何做?
欢迎阅读 Typst 的中文文档!Typst 是为科学写作而诞生的基于标记的排版系统。 它被设计之初就是作为一种替代品,用于替代像 LaTeX 这样的高级工具,又或者是像 Word 和 Google Docs 这样的简单工具。 我们对 Typst 的目标是构建一个功能强大的排版工具,并且让用户可以愉快地使用它。
= 第一节

本文档分为两部分:一个适合初学者的教程,其通过实际用例介绍 Typst;以及一个全面的参考,以解释 Typst 的所有概念和功能。
== 小标题

我们还邀请您加入我们为 Typst 建立的社区。Typst 仍是一个非常年轻的项目,因此我们非常希望能够得到您的反馈。
#slide[
#lorem(40)
]

= 制作一个目录页

== 标题2

#grid(
columns: (1fr,1fr),
column-gutter: 50pt,
row-gutter: 20pt,
[属性 1], [属性 2],
[#lorem(20)], [#lorem(20)],
)

#slide[
#lorem(40)
]

== Summary
== 总结

#align(center + horizon)[
#set text(size: 3em, weight: "bold", s.colors.primary)

THANKS FOR ALL

敬请指正!
]
]
38 changes: 19 additions & 19 deletions examples/aqua.typ
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
#import "../lib.typ": *

#let s = themes.aqua.register(aspect-ratio: "16-9")

#let s = (s.methods.info)(
self: s,
title: [An Instruction to Typst-Beamer],
author: [Author],
self: s,
title: [Title],
subtitle: [Subtitle],
author: [Authors],
date: datetime.today(),
institution: [Institution],
)
#let (init, slides) = utils.methods(s)
#let (init, slides, touying-outline, alert) = utils.methods(s)
#show: init

#let (slide, title-slide, outline-slide, new-section-slide) = utils.slides(s)
#show strong: alert

#let (slide, title-slide, outline-slide, focus-slide) = utils.slides(s)
#show: slides

= Title Slide
= The Section

== Slide Title

#slide[
= How to make Typst-Beamer?
#lorem(80)
#lorem(40)
]

= Content Slide

== Test for grid
#slide[
#lorem(40)
]

#grid(
columns: (1fr, 1fr),
column-gutter: 50pt,
row-gutter: 20pt,
[Feature 1], [Feature 2],
[#lorem(20)], [#lorem(20)],
)
#focus-slide[
Another variant with primary color in background...
]

== Summary

Expand Down
2 changes: 2 additions & 0 deletions examples/slides.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// #let s = themes.simple.register(aspect-ratio: "16-9", footer: [Simple slides])
// #let s = themes.metropolis.register(aspect-ratio: "16-9", footer: [Custom footer])
// #let s = themes.dewdrop.register(aspect-ratio: "16-9", footer: [Dewdrop])
// #let s = themes.university.register(aspect-ratio: "16-9")
// #let s = themes.aqua.register(aspect-ratio: "16-9")
#let s = (s.methods.info)(
self: s,
title: [Title],
Expand Down
14 changes: 12 additions & 2 deletions themes/aqua.typ
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
fill: self.colors.primary-light,
size: 20pt,
weight: "regular",
if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date },
utils.info-date(self),
)
}
)
Expand Down Expand Up @@ -110,6 +110,13 @@
(self.methods.touying-slide)(self: self, repeat: none, section: section, body)
}

#let focus-slide(self: none, body) = {
self = utils.empty-page(self)
self.page-args += (fill: self.colors.primary, margin: 2em)
set text(fill: white, size: 2em, weight: "bold")
(self.methods.touying-slide)(self: self, repeat: none, align(horizon + center, body))
}

#let slide(self: none, title: auto, ..args) = {
if title != auto {
self.aqua-title = title
Expand Down Expand Up @@ -137,6 +144,7 @@
#let register(
self: s,
aspect-ratio: "16-9",
footer: states.slide-counter.display(),
lang: "en",
) = {
assert(lang in ("zh", "en"), message: "lang must be 'zh' or 'en'")
Expand All @@ -153,6 +161,7 @@
[ ]
states.current-section-title
}
self.aqua-footer = footer
self.aqua-lang = lang
self.aqua-background = (self) => {
place(left + top, dx: -15pt, dy: -26pt,
Expand Down Expand Up @@ -193,7 +202,7 @@
}
let footer(self) = {
set text(size: 0.8em)
place(right, dx: -5%, states.slide-counter.display())
place(right, dx: -5%, utils.call-or-display(self, self.aqua-footer))
}
self.page-args += (
paper: "presentation-" + aspect-ratio,
Expand All @@ -208,6 +217,7 @@
}
self.methods.title-slide = title-slide
self.methods.outline-slide = outline-slide
self.methods.focus-slide = focus-slide
self.methods.new-section-slide = new-section-slide
self.methods.touying-new-section-slide = new-section-slide
self.methods.slide = slide
Expand Down
2 changes: 1 addition & 1 deletion themes/dewdrop.typ
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}
v(1em)
if info.date != none {
block(spacing: 1em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date })
block(spacing: 1em, utils.info-date(self))
}
set text(size: .8em)
if info.institution != none {
Expand Down
2 changes: 1 addition & 1 deletion themes/metropolis.typ
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
block(spacing: 1em, info.author)
}
if info.date != none {
block(spacing: 1em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date })
block(spacing: 1em, utils.info-date(self))
}
set text(size: .8em)
if info.institution != none {
Expand Down
3 changes: 1 addition & 2 deletions themes/simple.typ
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
}

#let focus-slide(self: none, background: auto, foreground: white, body) = {
self.page-args.header = none
self.page-args.footer = none
self = utils.empty-page(self)
self.page-args.fill = if background == auto { self.colors.primary } else { background }
set text(fill: foreground, size: 1.5em)
centered-slide(self: self, align(center + horizon, body))
Expand Down
2 changes: 1 addition & 1 deletion themes/university.typ
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}
if info.date != none {
parbreak()
text(size: .8em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date })
text(size: .8em, utils.info-date(self))
}
})
}
Expand Down

0 comments on commit ebfcb0f

Please sign in to comment.