Skip to content

Commit 177f47b

Browse files
committed
refactor: Make constants kebab case.
1 parent 62dfe78 commit 177f47b

2 files changed

Lines changed: 43 additions & 43 deletions

File tree

src/lib.typ

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
// Shared constants for the article template and helper functions
77
// --------------------------------------------------------------
88

9-
#let ccPrimaryYellow = "#f8d7b0"
10-
#let ccSecondaryBrown = "#392518"
11-
#let ccAccentBlue = "#7bd4ff"
12-
#let ccLighterBlue = "#cceeff"
13-
#let ccAccentGreen = "#90ee90"
14-
#let ccLightGrey = "#666666"
15-
#let ccDividerGrey = "#dddddd"
16-
#let ccCodeBackground = "#f8f9fa"
17-
#let blockRadiusValue = 2pt
9+
#let cc-primary-yellow = "#f8d7b0"
10+
#let cc-secondary-brown = "#392518"
11+
#let cc-accent-blue = "#7bd4ff"
12+
#let cc-lighter-blue = "#cceeff"
13+
#let cc-accent-green = "#90ee90"
14+
#let cc-light-grey = "#666666"
15+
#let cc-divider-grey = "#dddddd"
16+
#let cc-code-background = "#f8f9fa"
17+
#let block-radius-value = 2pt
1818

1919

2020
// ------------------------------------------------
@@ -123,39 +123,39 @@
123123
align: (left, right),
124124
gutter: 1em,
125125
[
126-
#text(size: 0.8em, weight: "semibold", fill: rgb(ccSecondaryBrown))[
126+
#text(size: 0.8em, weight: "semibold", fill: rgb(cc-secondary-brown))[
127127
#publication
128128
]
129129
],
130130
[
131-
#text(size: 0.8em, style: "italic", fill: rgb(ccSecondaryBrown))[
131+
#text(size: 0.8em, style: "italic", fill: rgb(cc-secondary-brown))[
132132
#short-title
133133
]
134134
],
135135
)
136-
line(length: 100%, stroke: 0.5pt + rgb(ccDividerGrey))
136+
line(length: 100%, stroke: 0.5pt + rgb(cc-divider-grey))
137137
}
138138

139139
// The first page header is an article metadata bar
140140
let article-metadata() = {
141141
rect(
142142
width: 100%,
143-
fill: rgb(ccPrimaryYellow),
144-
stroke: rgb(ccSecondaryBrown),
143+
fill: rgb(cc-primary-yellow),
144+
stroke: rgb(cc-secondary-brown),
145145
inset: .6em,
146-
radius: blockRadiusValue
146+
radius: block-radius-value
147147
)[
148148
#grid(
149149
columns: (1fr, auto),
150150
gutter: 1em,
151151
[
152-
#text(size: 0.9em, fill: rgb(ccSecondaryBrown))[
152+
#text(size: 0.9em, fill: rgb(cc-secondary-brown))[
153153
*Category:* Article
154154
#if reading-time != none [ • *Reading time:* #reading-time ]
155155
]
156156
],
157157
[
158-
#text(size: 0.9em, fill: rgb(ccSecondaryBrown))[
158+
#text(size: 0.9em, fill: rgb(cc-secondary-brown))[
159159
#date.display("[day] [month repr:long] [year]")
160160
]
161161
]
@@ -186,21 +186,21 @@
186186
""
187187
}
188188

189-
line(length: 100%, stroke: 0.5pt + rgb(ccDividerGrey))
189+
line(length: 100%, stroke: 0.5pt + rgb(cc-divider-grey))
190190
grid(
191191
columns: (1fr, auto, 1fr),
192192
align: (left, center, right),
193193
gutter: 1em,
194194
[
195-
#text(size: 0.8em, fill: rgb(ccLightGrey))[
195+
#text(size: 0.8em, fill: rgb(cc-light-grey))[
196196
#author-text
197197
]
198198
],
199199
[
200200
#context counter(page).get().first()
201201
],
202202
[
203-
#text(size: 0.7em, fill: rgb(ccLightGrey), style: "italic")[
203+
#text(size: 0.7em, fill: rgb(cc-light-grey), style: "italic")[
204204
#if watermark != none [
205205
#watermark
206206
] else [
@@ -287,7 +287,7 @@
287287
#block(text(
288288
weight: "medium",
289289
size: 1.4em,
290-
fill: rgb(ccLightGrey),
290+
fill: rgb(cc-light-grey),
291291
subtitle
292292
))
293293
]
@@ -315,24 +315,24 @@
315315
if abstract != none {
316316
rect(
317317
width: 100%,
318-
fill: rgb(ccLighterBlue),
319-
stroke: (left: 3pt + rgb(ccAccentBlue)),
318+
fill: rgb(cc-lighter-blue),
319+
stroke: (left: 3pt + rgb(cc-accent-blue)),
320320
inset: 1.2em,
321-
radius: blockRadiusValue,
321+
radius: block-radius-value,
322322
)[
323323
#set par(justify: true)
324324
#heading(outlined: false, numbering: none, text(0.85em)[Abstract])
325325
#abstract
326326
// Keywords (if provided)
327327
#if keywords.len() > 0 {
328328
v(1em)
329-
text(size: 10pt, fill: rgb(ccLightGrey))[
329+
text(size: 10pt, fill: rgb(cc-light-grey))[
330330
*Keywords:* #keywords.join(", ")
331331
]
332332
}
333333

334334
// The website URL
335-
#text(size: 0.9em, fill: rgb(ccLightGrey))[
335+
#text(size: 0.9em, fill: rgb(cc-light-grey))[
336336
*Latest Version:* #link(website-url)[#website-url]
337337
]
338338
]
@@ -349,7 +349,7 @@
349349

350350
// Bibliography section if provided
351351
if bibliography != none {
352-
line(length: 100%, stroke: 0.5pt + rgb(ccDividerGrey))
352+
line(length: 100%, stroke: 0.5pt + rgb(cc-divider-grey))
353353
bibliography
354354
}
355355
}
@@ -369,7 +369,7 @@
369369
/// The icon to display in the callout box. Optional.
370370
icon: emoji.notepad,
371371
/// The color of the callout box. Optional, defaults to Coders' Compass accent blue.
372-
color: rgb(ccAccentBlue),
372+
color: rgb(cc-accent-blue),
373373
/// The body content of the callout box. This is required.
374374
body
375375
) = {
@@ -378,7 +378,7 @@
378378
fill: color.lighten(95%),
379379
stroke: (left: 3pt + color),
380380
inset: 1em,
381-
radius: blockRadiusValue,
381+
radius: block-radius-value,
382382
)[
383383
#text(
384384
weight: "semibold",
@@ -402,15 +402,15 @@
402402
return quote(block: block, attribution: attribution, ..body)
403403
}
404404

405-
let colour = rgb(ccAccentBlue)
405+
let colour = rgb(cc-accent-blue)
406406
let content = body.pos().join()
407407

408408
return rect(
409409
width: 100%,
410410
fill: colour.lighten(95%),
411411
stroke: (left: 3pt + colour),
412412
inset: 1em,
413-
radius: blockRadiusValue,
413+
radius: block-radius-value,
414414
)[
415415
#content
416416
]

tests/unit1/test.typ

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#import "/src/lib.typ": *
22

33
// Test 1: Color constants are correctly defined
4-
#assert.eq(ccPrimaryYellow, "#f8d7b0")
5-
#assert.eq(ccSecondaryBrown, "#392518")
6-
#assert.eq(ccAccentBlue, "#7bd4ff")
7-
#assert.eq(ccLighterBlue, "#cceeff")
8-
#assert.eq(ccAccentGreen, "#90ee90")
9-
#assert.eq(ccLightGrey, "#666666")
10-
#assert.eq(ccDividerGrey, "#dddddd")
11-
#assert.eq(ccCodeBackground, "#f8f9fa")
12-
#assert.eq(blockRadiusValue, 2pt)
4+
#assert.eq(cc-primary-yellow, "#f8d7b0")
5+
#assert.eq(cc-secondary-brown, "#392518")
6+
#assert.eq(cc-accent-blue, "#7bd4ff")
7+
#assert.eq(cc-lighter-blue, "#cceeff")
8+
#assert.eq(cc-accent-green, "#90ee90")
9+
#assert.eq(cc-light-grey, "#666666")
10+
#assert.eq(cc-divider-grey, "#dddddd")
11+
#assert.eq(cc-code-background, "#f8f9fa")
12+
#assert.eq(block-radius-value, 2pt)
1313

1414
// Test 2: Functions return content (smoke tests)
1515
#let result = callout[This is a test callout]
@@ -100,9 +100,9 @@
100100

101101
// Test 11: Color conversion functionality
102102
// Verify colors can be converted to rgb type
103-
#let primary_rgb = rgb(ccPrimaryYellow)
104-
#let secondary_rgb = rgb(ccSecondaryBrown)
105-
#let accent_rgb = rgb(ccAccentBlue)
103+
#let primary_rgb = rgb(cc-primary-yellow)
104+
#let secondary_rgb = rgb(cc-secondary-brown)
105+
#let accent_rgb = rgb(cc-accent-blue)
106106

107107
#assert.ne(primary_rgb, none)
108108
#assert.ne(secondary_rgb, none)

0 commit comments

Comments
 (0)