Skip to content

Commit

Permalink
✨ Tweaks to the Radial theme (#17)
Browse files Browse the repository at this point in the history
* 🚧 Added some components that I forgot about from my old template

* 🚧 You really shouldn't be paying attention to whats happening here

* ✨ Add the ability to calculate weighted properties to the decision matrix

* 📝 Documented the label function

* 🎨 Restructured the theme to reduce file count

* 🎨 Update package import to new organization

* 🐛 Fixed headings not being blocks

* 🩹 Removed redundant comment

* 📝 Added some missing documentation

* 💄 Removed redundant linebreaks from the table of contents

* 🩹 Removed missing witness and author lines

* 🐛 Fixed the decision matrix not being able to check which choice was highest
  • Loading branch information
BattleCh1cken authored Feb 2, 2024
1 parent 0b42734 commit 9bc5f0b
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 130 deletions.
46 changes: 21 additions & 25 deletions docs.typ
Original file line number Diff line number Diff line change
Expand Up @@ -182,34 +182,30 @@ Minimal starting point:
```

=== Components

#let radial-toc-module = tidy.parse-module(read("./themes/radial/components/toc.typ"))
#show-module(radial-toc-module)

#let radial-glossary-module = tidy.parse-module(read("./themes/radial/components/glossary.typ"))
#show-module(radial-glossary-module)

#let radial-admonitions-module = tidy.parse-module(read("./themes/radial/components/admonitions.typ"))
#show-module(radial-admonitions-module)

#let radial-pro-con-module = tidy.parse-module(read("./themes/radial/components/pro-con.typ"))
#show-module(radial-pro-con-module)
#let parse-modules(predicate, ..names) = {
for name in names.pos() {
read(predicate + name + ".typ")
}
}

#let radial-decision-matrix-module = tidy.parse-module(read("./themes/radial/components/decision-matrix.typ"))
#show-module(radial-decision-matrix-module)

#let radial-tournament-module = tidy.parse-module(read("./themes/radial/components/tournament.typ"))
#show-module(radial-tournament-module)

#let radial-graph-module = tidy.parse-module(read("./themes/radial/components/graphs.typ"))
#show-module(radial-graph-module)
=== Components

#let radial-graph-module = tidy.parse-module(read("./themes/radial/components/graphs.typ"))
#show-module(radial-graph-module)
#let raw-radial-module = parse-modules(
"./themes/radial/components/",
"toc",
"glossary",
"admonitions",
"pro-con",
"decision-matrix",
"tournament",
"graphs",
"gantt-chart",
"team",
"label",
)

#let radial_gantt_chart = tidy.parse-module(read("./themes/radial/components/gantt-chart.typ"))
#show-module(radial_gantt_chart)
#let radial-module = tidy.parse-module(raw-radial-module)
#show-module(first-heading-level: 3, radial-module)

== Linear Theme

Expand Down
5 changes: 4 additions & 1 deletion entries.typ
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
// Inject the proper labels and settings changes into the user's entry body
let final-body = if entries.len() == 0 {
[#counter(page).update(1)] // Correctly set the page number for each section
} + [ #metadata(none) #entry-label ] + body // Place a label on blank content to the table of contents can find each entry
} + [
#metadata(none) #entry-label
#counter(footnote).update(0)
] + body // Place a label on blank content to the table of contents can find each entry

entries.push(
(
Expand Down
35 changes: 0 additions & 35 deletions themes/radial/components/code-blocks.typ

This file was deleted.

2 changes: 2 additions & 0 deletions themes/radial/components/components.typ
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#import "./glossary.typ": *
#import "./gantt-chart.typ": *
#import "./admonitions.typ": *
#import "./label.typ": *
#import "./team.typ": *
#import "./pro-con.typ": *
#import "./decision-matrix.typ": *
#import "./tournament.typ": *
Expand Down
32 changes: 0 additions & 32 deletions themes/radial/components/headings.typ

This file was deleted.

18 changes: 18 additions & 0 deletions themes/radial/components/label.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import "../colors.typ": *
#import "../metadata.typ": *
#import "/utils.typ"

/// A label that corresponds with one of the entry types.
///
/// - type (string): Any of the radial entry types
/// - size (size): The size of the label
/// -> content
#let label(type, size: 0.7em) = {
let data = entry-type-metadata.at(type)
let colored-image = utils.change-icon-color(raw-icon: data.icon, fill: white)

box(fill: data.color, outset: 3pt, radius: 1.5pt)[
#set align(center + horizon)
#image.decode(colored-image, height: size)
]
}
47 changes: 47 additions & 0 deletions themes/radial/components/team.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#import "../colors.typ": *

/// Display information about your team.
///
/// Example Usage:
/// ```typ
/// #team(
/// (
/// name: "Random Person",
/// picture: image("./path-to-image.png", width: 90pt, height: 90pt),
/// about: [
/// Likes Coding
/// ],
/// ),
/// )
/// ```
/// - ..members (dictionary): A list of members in your team. Each dictionary must contain the following fields:
/// - name `<string>`: The name of the team member
/// - picture `<content>`: An image of the team member
/// - about `<content>`: About the team member
/// -> content
#let team(..members) = {
set align(center)
grid(
columns: (1fr, 1fr),
gutter: 20pt,
..for member in members.pos() {
(
rect(
fill: surface-1,
inset: 20pt,
radius: 1.5pt,
)[
* #member.name *
#line(length: 100%, stroke: (cap: "round", dash: "solid", thickness: 1.5pt))
#v(8pt)
#grid(
columns: (1fr, 1fr),
gutter: 20pt,
align(center, member.picture),
align(left, member.about),
)
],
)
},
)
}
44 changes: 16 additions & 28 deletions themes/radial/components/toc.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "/utils.typ"
#import "../metadata.typ": *
#import "./label.typ": *

/// Print out the table of contents
///
Expand All @@ -10,42 +11,29 @@
/// #components.toc()
/// ]
/// ```
#let toc() = utils.print-toc(
(frontmatter, body, appendix) => {
let label(label: "", size: 0.7em) = {
let data = entry-type-metadata.at(label)
let colored-image = utils.change-icon-color(raw-icon: data.icon, fill: white)
#let toc() = utils.print-toc((frontmatter, body, appendix) => {
heading(level: 1)[Entries]

box(fill: data.color, outset: 3pt, radius: 1.5pt)[
#set align(center + horizon)
#image.decode(colored-image, height: size)
]
}

heading(level: 1)[Entries]
linebreak()

for entry in body [
stack(spacing: 1em, ..for entry in body {
([
#entry.date.display("[year]/[month]/[day]")
#h(5pt)
#label(label: entry.type)
#label(entry.type)
#h(5pt)
#entry.title
#box(width: 1fr, line(length: 100%, stroke: (dash: "dotted")))
#entry.page-number
]
],)
})
linebreak()
linebreak()
linebreak()
heading(level: 1)[Appendix]
linebreak()
heading(level: 1)[Appendix]
for entry in appendix [
#entry.title
#box(width: 1fr, line(length: 100%, stroke: (dash: "dotted")))
#entry.page-number
for entry in appendix [
#entry.title
#box(width: 1fr, line(length: 100%, stroke: (dash: "dotted")))
#entry.page-number
]
},
)
]
})
2 changes: 1 addition & 1 deletion themes/radial/entries.typ
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
), footer: [
#line(length: 100%)
#align(left, [
*Designed by:* #h(2pt) #context.author \
*Designed by:* #context.author #h(2pt) \
*Witnessed by:* #context.witness
#h(1fr) #counter(page).display()
])
Expand Down
76 changes: 76 additions & 0 deletions themes/radial/format.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#import "/packages.typ": tablex
#import tablex: *
#import "./colors.typ": *

#let table(it) = {
tablex(
columns: it.columns,
auto-lines: false,
inset: 10pt,
fill: (_, row) => {
if calc.odd(row) { surface-3 }
if calc.even(row) { surface-1 }
},
hlinex(stroke: (cap: "round", thickness: 2pt)),
..for child in it.children {
([#child],)
},
hlinex(stroke: (cap: "round", thickness: 2pt)),
)
}

#let heading(it) = {
set block(below: 1em)

let content = if it.level == 1 {
set text(size: 15pt)
box(fill: surface-3, outset: 0.5em, radius: 1.5pt, it.body)
} else if it.level == 2 {
set text(size: 14pt)
it.body
} else {
set text(size: 11pt)
it.body
}

block(content)
}

#let raw-not-block = box.with(
fill: surface-2,
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
)

#let raw-block(it) = {
set par(justify: false);
// the line counter
let i = 0;
let box-radius = 1.5pt;

let detail-radius = 1.5pt;
if (it.lang != none) {
grid(
columns: (100%, 100%),
column-gutter: (-100%),
block(width: 100%, inset: 1em, {
for line in it.text.split("\n") {
box(width: 0pt, align(right, str(i + 1) + h(2em)))
hide(line)
linebreak()
i = i + 1;
}
}),
block(radius: box-radius, fill: surface-1, width: 100%, inset: 1em, {
place(
top + right,
box(fill: surface-3, radius: detail-radius, outset: 3pt, it.lang),
)
it
}),
)
} else {
block(radius: box-radius, fill: surface-2, width: 100%, inset: 1em, it)
}
}
4 changes: 2 additions & 2 deletions themes/radial/radial.typ
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#import "./rules.typ": rules
#import "./entries.typ": cover, frontmatter-entry, body-entry, appendix-entry
#import "./components/components.typ"
#import "./colors.typ"

#let radial-theme = (
// Global show and set rules
rules: rules,
cover: cover,

// Entry pages
frontmatter-entry: frontmatter-entry,
body-entry: body-entry,
appendix-entry: appendix-entry
appendix-entry: appendix-entry,
)
Loading

0 comments on commit 9bc5f0b

Please sign in to comment.