From a0ef972489597335fa58a61c501c0e0988777b1a Mon Sep 17 00:00:00 2001 From: OrangeX4 <34951714+OrangeX4@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:32:50 +0800 Subject: [PATCH] feat: don't export variable `s` by default anymore (#15) --- examples/aqua-zh.typ | 2 +- examples/aqua.typ | 2 +- examples/dewdrop.typ | 1 - examples/example.typ | 2 +- examples/metropolis.typ | 2 +- examples/simple.typ | 2 +- examples/slides.typ | 7 ++++--- examples/university.typ | 2 +- lib.typ | 2 +- themes/aqua.typ | 9 +++++---- themes/default.typ | 9 +++++++++ themes/dewdrop.typ | 9 +++++---- themes/metropolis.typ | 9 +++++---- themes/simple.typ | 5 +++-- themes/themes.typ | 1 + themes/university.typ | 7 ++++--- 16 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 themes/default.typ diff --git a/examples/aqua-zh.typ b/examples/aqua-zh.typ index 6b478709e..56f12c82a 100644 --- a/examples/aqua-zh.typ +++ b/examples/aqua-zh.typ @@ -1,6 +1,6 @@ #import "../lib.typ": * -#let s = themes.aqua.register(s, aspect-ratio: "16-9", lang: "zh") +#let s = themes.aqua.register(aspect-ratio: "16-9", lang: "zh") #let s = (s.methods.info)( self: s, diff --git a/examples/aqua.typ b/examples/aqua.typ index 76f01c484..78a06bdcc 100644 --- a/examples/aqua.typ +++ b/examples/aqua.typ @@ -1,6 +1,6 @@ #import "../lib.typ": * -#let s = themes.aqua.register(s, aspect-ratio: "16-9") +#let s = themes.aqua.register(aspect-ratio: "16-9") #let s = (s.methods.info)( self: s, diff --git a/examples/dewdrop.typ b/examples/dewdrop.typ index 56225f227..8060e65e2 100644 --- a/examples/dewdrop.typ +++ b/examples/dewdrop.typ @@ -1,7 +1,6 @@ #import "../lib.typ": * #let s = themes.dewdrop.register( - s, aspect-ratio: "16-9", footer: [Dewdrop], navigation: "mini-slides", diff --git a/examples/example.typ b/examples/example.typ index 33af612ba..83f2366c9 100644 --- a/examples/example.typ +++ b/examples/example.typ @@ -9,7 +9,7 @@ // Register university theme // You can remove the theme registration or replace other themes // it can still work normally -#let s = themes.university.register(s, aspect-ratio: "16-9") +#let s = themes.university.register(aspect-ratio: "16-9") // Global information configuration #let s = (s.methods.info)( diff --git a/examples/metropolis.typ b/examples/metropolis.typ index 687dd7453..537122f30 100644 --- a/examples/metropolis.typ +++ b/examples/metropolis.typ @@ -1,6 +1,6 @@ #import "../lib.typ": * -#let s = themes.metropolis.register(s, aspect-ratio: "16-9", footer: self => self.info.institution) +#let s = themes.metropolis.register(aspect-ratio: "16-9", footer: self => self.info.institution) #let s = (s.methods.info)( self: s, title: [Title], diff --git a/examples/simple.typ b/examples/simple.typ index 5e43cc004..25197e694 100644 --- a/examples/simple.typ +++ b/examples/simple.typ @@ -1,6 +1,6 @@ #import "../lib.typ": * -#let s = themes.simple.register(s, aspect-ratio: "16-9", footer: [Simple slides]) +#let s = themes.simple.register(aspect-ratio: "16-9", footer: [Simple slides]) #let (init, slides) = utils.methods(s) #show: init diff --git a/examples/slides.typ b/examples/slides.typ index 5fade8f9a..3b3068e10 100644 --- a/examples/slides.typ +++ b/examples/slides.typ @@ -1,8 +1,9 @@ #import "../lib.typ": * -// #let s = themes.simple.register(s, aspect-ratio: "16-9", footer: [Simple slides]) -// #let s = themes.metropolis.register(s, aspect-ratio: "16-9", footer: [Custom footer]) -// #let s = themes.dewdrop.register(s, aspect-ratio: "16-9", footer: [Dewdrop]) +#let s = themes.default.register(aspect-ratio: "16-9") +// #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 = (s.methods.info)( self: s, title: [Title], diff --git a/examples/university.typ b/examples/university.typ index 5bbdd30ce..2d6306153 100644 --- a/examples/university.typ +++ b/examples/university.typ @@ -1,6 +1,6 @@ #import "../lib.typ": * -#let s = themes.university.register(s, aspect-ratio: "16-9") +#let s = themes.university.register(aspect-ratio: "16-9") #let s = (s.methods.info)( self: s, title: [Title], diff --git a/lib.typ b/lib.typ index d779b1a5b..87abfb3a7 100644 --- a/lib.typ +++ b/lib.typ @@ -1,4 +1,4 @@ -#import "slide.typ": s, pause, meanwhile, slides-end, touying-equation, touying-reducer +#import "slide.typ": pause, meanwhile, slides-end, touying-equation, touying-reducer #import "utils/utils.typ" #import "utils/states.typ" #import "utils/pdfpc.typ" diff --git a/themes/aqua.typ b/themes/aqua.typ index f9255d1d4..0acf8543c 100644 --- a/themes/aqua.typ +++ b/themes/aqua.typ @@ -1,10 +1,11 @@ +#import "../slide.typ": s #import "../utils/utils.typ" #import "../utils/states.typ" #import "../utils/components.typ" #let title-slide(self: none, ..args) = { self = utils.empty-page(self) - self.page-args = self.page-args + ( + self.page-args += ( margin: (top: 30%, left: 17%, right: 17%, bottom: 0%), background: utils.call-or-display(self, self.aqua-background), ) @@ -35,7 +36,7 @@ #let outline-slide(self: none, enum-args: (:), leading: 50pt) = { self = utils.empty-page(self) - self.page-args = self.page-args + ( + self.page-args += ( background: utils.call-or-display(self, self.aqua-background), ) set text(size: 30pt, fill: self.colors.primary) @@ -79,7 +80,7 @@ #let new-section-slide(self: none, section) = { self = utils.empty-page(self) - self.page-args = self.page-args + ( + self.page-args += ( margin: (left:0%, right:0%, top: 20%, bottom:0%), background: utils.call-or-display(self, self.aqua-background), ) @@ -134,9 +135,9 @@ } #let register( + self: s, aspect-ratio: "16-9", lang: "en", - self, ) = { assert(lang in ("zh", "en"), message: "lang must be 'zh' or 'en'") diff --git a/themes/default.typ b/themes/default.typ new file mode 100644 index 000000000..5464d0fb0 --- /dev/null +++ b/themes/default.typ @@ -0,0 +1,9 @@ +#import "../slide.typ": s + +// export default self +#let register(self: s, aspect-ratio: "16-9") = { + self.page-args += ( + paper: "presentation-" + aspect-ratio, + ) + self +} diff --git a/themes/dewdrop.typ b/themes/dewdrop.typ index 2d8cf2f4b..63a05ccf3 100644 --- a/themes/dewdrop.typ +++ b/themes/dewdrop.typ @@ -1,6 +1,7 @@ // This theme is inspired by https://github.com/zbowang/BeamerTheme // The typst version was written by https://github.com/OrangeX4 +#import "../slide.typ": s #import "../utils/utils.typ" #import "../utils/states.typ" @@ -11,7 +12,7 @@ footer: auto, ..args, ) = { - self.page-args = self.page-args + ( + self.page-args += ( fill: self.colors.neutral-lightest, ) if footer != auto { @@ -82,7 +83,7 @@ #let focus-slide(self: none, body) = { self = utils.empty-page(self) - self.page-args = self.page-args + ( + self.page-args += ( fill: self.colors.primary, margin: 2em, ) @@ -223,6 +224,7 @@ } #let register( + self: s, aspect-ratio: "16-9", navigation: "sidebar", sidebar: (width: 10em), @@ -231,7 +233,6 @@ footer-right: states.slide-counter.display() + " / " + states.last-slide-number, primary: rgb("#0c4842"), alpha: 70%, - self, ) = { assert(navigation in ("sidebar", "mini-slides", none), message: "navigation must be one of sidebar, mini-slides, none") // color theme @@ -268,7 +269,7 @@ h(1fr) text(fill: self.colors.neutral-darkest.lighten(20%), utils.call-or-display(self, self.d-footer-right)) } - self.page-args = self.page-args + ( + self.page-args += ( paper: "presentation-" + aspect-ratio, fill: self.colors.neutral-lightest, header: header, diff --git a/themes/metropolis.typ b/themes/metropolis.typ index 515c13b5e..377d49b42 100644 --- a/themes/metropolis.typ +++ b/themes/metropolis.typ @@ -7,6 +7,7 @@ // #set strong(delta: 100) // #set par(justify: true) +#import "../slide.typ": s #import "../utils/utils.typ" #import "../utils/states.typ" #import "../utils/components.typ" @@ -20,7 +21,7 @@ align: horizon, ..args, ) = { - self.page-args = self.page-args + ( + self.page-args += ( fill: self.colors.neutral-lightest, ) if title != auto { @@ -92,7 +93,7 @@ #let focus-slide(self: none, body) = { self = utils.empty-page(self) - self.page-args = self.page-args + ( + self.page-args += ( fill: self.colors.primary-dark, margin: 2em, ) @@ -111,12 +112,12 @@ } #let register( + self: s, aspect-ratio: "16-9", header: states.current-section-title, footer: [], footer-right: states.slide-counter.display() + " / " + states.last-slide-number, footer-progress: true, - self, ) = { // color theme self = (self.methods.colors)( @@ -160,7 +161,7 @@ place(bottom, block(height: 2pt, width: 100%, spacing: 0pt, utils.call-or-display(self, self.m-progress-bar))) } } - self.page-args = self.page-args + ( + self.page-args += ( paper: "presentation-" + aspect-ratio, header: header, footer: footer, diff --git a/themes/simple.typ b/themes/simple.typ index 1cb6cafd8..0ef440b8a 100644 --- a/themes/simple.typ +++ b/themes/simple.typ @@ -1,6 +1,7 @@ // This theme is from https://github.com/andreasKroepelin/polylux/blob/main/themes/simple.typ // Author: Andreas Kröpelin +#import "../slide.typ": s #import "../utils/utils.typ" #import "../utils/states.typ" @@ -40,13 +41,13 @@ } #let register( + self: s, aspect-ratio: "16-9", footer: [], footer-right: states.slide-counter.display() + " / " + states.last-slide-number, background: rgb("#ffffff"), foreground: rgb("#000000"), primary: aqua.darken(50%), - self, ) = { let deco-format(it) = text(size: .6em, fill: gray, it) // color theme @@ -67,7 +68,7 @@ deco-format(sections.last().title) }) let footer(self) = deco-format(self.simple-footer + h(1fr) + self.simple-footer-right) - self.page-args = self.page-args + ( + self.page-args += ( paper: "presentation-" + aspect-ratio, fill: self.colors.neutral-lightest, header: header, diff --git a/themes/themes.typ b/themes/themes.typ index 3ec07d35b..f89f85410 100644 --- a/themes/themes.typ +++ b/themes/themes.typ @@ -1,3 +1,4 @@ +#import "default.typ" #import "simple.typ" #import "metropolis.typ" #import "dewdrop.typ" diff --git a/themes/university.typ b/themes/university.typ index c3bb1336a..233275bbc 100644 --- a/themes/university.typ +++ b/themes/university.typ @@ -2,6 +2,7 @@ // Originally contributed by Pol Dellaiera - https://github.com/drupol +#import "../slide.typ": s #import "../utils/utils.typ" #import "../utils/states.typ" #import "../utils/components.typ" @@ -105,7 +106,7 @@ background-color } self = utils.empty-page(self) - self.page-args = self.page-args + ( + self.page-args += ( fill: self.colors.primary-dark, margin: 1em, ..(if background-color != none { (fill: background-color) }), @@ -169,9 +170,9 @@ } #let register( + self: s, aspect-ratio: "16-9", progress-bar: true, - self, ) = { // color theme self = (self.methods.colors)( @@ -228,7 +229,7 @@ utils.call-or-display(self, self.uni-footer) } - self.page-args = self.page-args + ( + self.page-args += ( paper: "presentation-" + aspect-ratio, header: header, footer: footer,