Skip to content

Commit 91d4f41

Browse files
committed
feat: add config argument for xxx-slide functions
1 parent 8fd7c23 commit 91d4f41

File tree

6 files changed

+128
-60
lines changed

6 files changed

+128
-60
lines changed

themes/aqua.typ

+25-15
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,19 @@
7272
///
7373
/// #title-slide(subtitle: [Subtitle], extra: [Extra information])
7474
/// ```
75-
#let title-slide(..args) = touying-slide-wrapper(self => {
75+
///
76+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more configurations, you can use `utils.merge-dicts` to merge them.
77+
/// ```
78+
#let title-slide(config: (:), ..args) = touying-slide-wrapper(self => {
79+
self = utils.merge-dicts(
80+
self,
81+
config,
82+
config-common(freeze-slide-counter: true),
83+
config-page(
84+
background: utils.call-or-display(self, self.store.background),
85+
margin: (x: 0em, top: 30%, bottom: 0%),
86+
),
87+
)
7688
let info = self.info + args.named()
7789
let body = {
7890
set align(center)
@@ -94,22 +106,16 @@
94106
},
95107
)
96108
}
97-
self = utils.merge-dicts(
98-
self,
99-
config-common(freeze-slide-counter: true),
100-
config-page(
101-
background: utils.call-or-display(self, self.store.background),
102-
margin: (x: 0em, top: 30%, bottom: 0%),
103-
),
104-
)
105109
touying-slide(self: self, body)
106110
})
107111

108112

109113
/// Outline slide for the presentation.
114+
///
115+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more configurations, you can use `utils.merge-dicts` to merge them.
110116
///
111117
/// - leading (length): The leading of paragraphs in the outline. Default is `50pt`.
112-
#let outline-slide(leading: 50pt) = touying-slide-wrapper(self => {
118+
#let outline-slide(config: (:), leading: 50pt) = touying-slide-wrapper(self => {
113119
set text(size: 30pt, fill: self.colors.primary)
114120
set par(leading: leading)
115121

@@ -160,18 +166,20 @@
160166
margin: 0em,
161167
),
162168
)
163-
touying-slide(self: self, body)
169+
touying-slide(self: self, config: config, body)
164170
})
165171

166172

167173
/// New section slide for the presentation. You can update it by updating the `new-section-slide-fn` argument for `config-common` function.
168174
///
169175
/// Example: `config-common(new-section-slide-fn: new-section-slide.with(numbered: false))`
170176
///
177+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more configurations, you can use `utils.merge-dicts` to merge them.
178+
///
171179
/// - level (int): The level of the heading.
172180
///
173181
/// - body (content): The body of the section. It will be passed by touying automatically.
174-
#let new-section-slide(level: 1, body) = touying-slide-wrapper(self => {
182+
#let new-section-slide(config: (:), level: 1, body) = touying-slide-wrapper(self => {
175183
let slide-body = {
176184
stack(
177185
dir: ttb,
@@ -203,21 +211,23 @@
203211
background: utils.call-or-display(self, self.store.background),
204212
),
205213
)
206-
touying-slide(self: self, slide-body)
214+
touying-slide(self: self, config: config, slide-body)
207215
})
208216

209217

210218
/// Focus on some content.
211219
///
212220
/// Example: `#focus-slide[Wake up!]`
213-
#let focus-slide(body) = touying-slide-wrapper(self => {
221+
///
222+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more configurations, you can use `utils.merge-dicts` to merge them.
223+
#let focus-slide(config: (:), body) = touying-slide-wrapper(self => {
214224
self = utils.merge-dicts(
215225
self,
216226
config-common(freeze-slide-counter: true),
217227
config-page(fill: self.colors.primary, margin: 2em),
218228
)
219229
set text(fill: self.colors.neutral-lightest, size: 2em, weight: "bold")
220-
touying-slide(self: self, align(horizon + center, body))
230+
touying-slide(self: self, config: config, align(horizon + center, body))
221231
})
222232

223233

themes/dewdrop.typ

+23-9
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,20 @@
115115
/// #title-slide(subtitle: [Subtitle], extra: [Extra information])
116116
/// ```
117117
///
118+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
119+
///
118120
/// - extra (string, none): The extra information you want to display on the title slide.
119121
#let title-slide(
122+
config: (:),
120123
extra: none,
121124
..args,
122125
) = touying-slide-wrapper(self => {
126+
self = utils.merge-dicts(
127+
self,
128+
config,
129+
config-common(freeze-slide-counter: true),
130+
config-page(fill: self.colors.neutral-lightest, margin: 0em),
131+
)
123132
let info = self.info + args.named()
124133
let body = {
125134
set text(fill: self.colors.neutral-darkest)
@@ -158,17 +167,16 @@
158167
},
159168
)
160169
}
161-
self = utils.merge-dicts(
162-
self,
163-
config-common(freeze-slide-counter: true),
164-
config-page(fill: self.colors.neutral-lightest, margin: 0em),
165-
)
166170
touying-slide(self: self, body)
167171
})
168172

169173

170174
/// Outline slide for the presentation.
171-
#let outline-slide(title: utils.i18n-outline-title, ..args) = touying-slide-wrapper(self => {
175+
///
176+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
177+
///
178+
/// - title (string): The title of the slide. Default is `utils.i18n-outline-title`.
179+
#let outline-slide(config: (:), title: utils.i18n-outline-title, ..args) = touying-slide-wrapper(self => {
172180
self = utils.merge-dicts(
173181
self,
174182
config-page(
@@ -178,6 +186,7 @@
178186
)
179187
touying-slide(
180188
self: self,
189+
config: config,
181190
components.adaptive-columns(
182191
start: text(
183192
1.2em,
@@ -197,11 +206,13 @@
197206
/// New section slide for the presentation. You can update it by updating the `new-section-slide-fn` argument for `config-common` function.
198207
///
199208
/// Example: `config-common(new-section-slide-fn: new-section-slide.with(numbered: false))`
209+
///
210+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
200211
///
201212
/// - title (string): The title of the slide. Default is `utils.i18n-outline-title`.
202213
///
203214
/// - body (array): The contents of the slide.
204-
#let new-section-slide(title: utils.i18n-outline-title, ..args, body) = touying-slide-wrapper(self => {
215+
#let new-section-slide(config: (:), title: utils.i18n-outline-title, ..args, body) = touying-slide-wrapper(self => {
205216
self = utils.merge-dicts(
206217
self,
207218
config-page(
@@ -211,6 +222,7 @@
211222
)
212223
touying-slide(
213224
self: self,
225+
config: config,
214226
components.adaptive-columns(
215227
start: text(
216228
1.2em,
@@ -236,14 +248,16 @@
236248
/// Focus on some content.
237249
///
238250
/// Example: `#focus-slide[Wake up!]`
239-
#let focus-slide(body) = touying-slide-wrapper(self => {
251+
///
252+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
253+
#let focus-slide(config: (:), body) = touying-slide-wrapper(self => {
240254
self = utils.merge-dicts(
241255
self,
242256
config-common(freeze-slide-counter: true),
243257
config-page(fill: self.colors.primary, margin: 2em),
244258
)
245259
set text(fill: self.colors.neutral-lightest, size: 1.5em)
246-
touying-slide(self: self, align(horizon + center, body))
260+
touying-slide(self: self, config: config, align(horizon + center, body))
247261
})
248262

249263

themes/metropolis.typ

+17-9
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,21 @@
106106
///
107107
/// #title-slide(subtitle: [Subtitle], extra: [Extra information])
108108
/// ```
109+
///
110+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For several configurations, you can use `utils.merge-dicts` to merge them.
109111
///
110112
/// - extra (string, none): The extra information you want to display on the title slide.
111113
#let title-slide(
114+
config: (:),
112115
extra: none,
113116
..args,
114117
) = touying-slide-wrapper(self => {
118+
self = utils.merge-dicts(
119+
self,
120+
config,
121+
config-common(freeze-slide-counter: true),
122+
config-page(fill: self.colors.neutral-lightest),
123+
)
115124
let info = self.info + args.named()
116125
let body = {
117126
set text(fill: self.colors.neutral-darkest)
@@ -148,25 +157,22 @@
148157
},
149158
)
150159
}
151-
self = utils.merge-dicts(
152-
self,
153-
config-common(freeze-slide-counter: true),
154-
config-page(fill: self.colors.neutral-lightest),
155-
)
156160
touying-slide(self: self, body)
157161
})
158162

159163

160164
/// New section slide for the presentation. You can update it by updating the `new-section-slide-fn` argument for `config-common` function.
161165
///
162166
/// Example: `config-common(new-section-slide-fn: new-section-slide.with(numbered: false))`
167+
///
168+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For several configurations, you can use `utils.merge-dicts` to merge them.
163169
///
164170
/// - level (int): The level of the heading.
165171
///
166172
/// - numbered (boolean): Indicates whether the heading is numbered.
167173
///
168174
/// - body (auto): The body of the section. It will be passed by touying automatically.
169-
#let new-section-slide(level: 1, numbered: true, body) = touying-slide-wrapper(self => {
175+
#let new-section-slide(config: (:), level: 1, numbered: true, body) = touying-slide-wrapper(self => {
170176
let slide-body = {
171177
set align(horizon)
172178
show: pad.with(20%)
@@ -188,16 +194,18 @@
188194
self,
189195
config-page(fill: self.colors.neutral-lightest),
190196
)
191-
touying-slide(self: self, slide-body)
197+
touying-slide(self: self, config: config, slide-body)
192198
})
193199

194200

195201
/// Focus on some content.
196202
///
197203
/// Example: `#focus-slide[Wake up!]`
204+
///
205+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For several configurations, you can use `utils.merge-dicts` to merge them.
198206
///
199207
/// - align (alignment): The alignment of the content. Default is `horizon + center`.
200-
#let focus-slide(align: horizon + center, body) = touying-slide-wrapper(self => {
208+
#let focus-slide(config: (:), align: horizon + center, body) = touying-slide-wrapper(self => {
201209
let _align = align
202210
let align = _typst-builtin-align
203211
self = utils.merge-dicts(
@@ -206,7 +214,7 @@
206214
config-page(fill: self.colors.neutral-dark, margin: 2em),
207215
)
208216
set text(fill: self.colors.neutral-lightest, size: 1.5em)
209-
touying-slide(self: self, align(_align, body))
217+
touying-slide(self: self, config: config, align(_align, body))
210218
})
211219

212220

themes/simple.typ

+19-7
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,28 @@
6363

6464

6565
/// Centered slide for the presentation.
66-
#let centered-slide(..args) = touying-slide-wrapper(self => {
67-
touying-slide(self: self, ..args.named(), align(center + horizon, args.pos().sum(default: none)))
66+
///
67+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
68+
#let centered-slide(config: (:), ..args) = touying-slide-wrapper(self => {
69+
touying-slide(self: self, ..args.named(), config: config, align(center + horizon, args.pos().sum(default: none)))
6870
})
6971

7072

7173
/// Title slide for the presentation.
7274
///
7375
/// Example: `#title-slide[Hello, World!]`
74-
#let title-slide(body) = centered-slide(
75-
config: config-common(freeze-slide-counter: true),
76+
///
77+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
78+
#let title-slide(config: (:), body) = centered-slide(
79+
config: utils.merge-dicts(config, config-common(freeze-slide-counter: true)),
7680
body,
7781
)
7882

7983

8084
/// New section slide for the presentation. You can update it by updating the `new-section-slide-fn` argument for `config-common` function.
81-
#let new-section-slide(body) = centered-slide([
85+
///
86+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
87+
#let new-section-slide(config: (:), body) = centered-slide(config: config, [
8288
#text(1.2em, weight: "bold", utils.display-current-heading(level: 1))
8389

8490
#body
@@ -88,7 +94,13 @@
8894
/// Focus on some content.
8995
///
9096
/// Example: `#focus-slide[Wake up!]`
91-
#let focus-slide(background: auto, foreground: white, body) = touying-slide-wrapper(self => {
97+
///
98+
/// - config (dictionary): The configuration of the slide. You can use `config-xxx` to set the configuration of the slide. For more several configurations, you can use `utils.merge-dicts` to merge them.
99+
///
100+
/// - background (color, auto): The background color of the slide. Default is `auto`, which means the primary color of the slides.
101+
///
102+
/// - foreground (color): The foreground color of the slide. Default is `white`.
103+
#let focus-slide(config: (:), background: auto, foreground: white, body) = touying-slide-wrapper(self => {
92104
self = utils.merge-dicts(
93105
self,
94106
config-common(freeze-slide-counter: true),
@@ -99,7 +111,7 @@
99111
}),
100112
)
101113
set text(fill: foreground, size: 1.5em)
102-
touying-slide(self: self, align(center + horizon, body))
114+
touying-slide(self: self, config: config, align(center + horizon, body))
103115
})
104116

105117

0 commit comments

Comments
 (0)