Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Linear title margins #25

Merged
merged 7 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 54 additions & 23 deletions themes/linear/entries.typ
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,50 @@

#let frontmatter-entry(context: (:), body) = {
show: page.with(
//margin: (top: 8em),
header: [
#set align(center)
#set text(size: 25pt)

#context.title

#set line(stroke: 1.5pt)
#align(center + horizon, grid(columns: (1fr, auto, 1fr),
[
#line(length: 100%)
],
[
#h(20pt)
#context.title
#h(20pt)
],
[
#line(length: 100%)
]))
],
background: set-margins(8%, 8%),
)

set-border(context.type)

body
}

#let body-entry(context: (:), body) = {
show: page.with(margin: (top: 88pt),
header: [
#set align(center)
#set text(size: 30pt)
#box(
//baseline: 2pt,
fill: entry-type-metadata.at(context.type),
width: 300pt,
inset: 10pt,
[#context.title],
)
],
#set text(size: 30pt)
#set line(stroke: 1.5pt)

#align(center + horizon, grid(columns: (1fr, auto, 1fr),
[
#line(length: 100%)
],
[
#h(20pt)
#box(fill: entry-type-metadata.at(context.type), outset: 10pt, [#context.title])
#h(20pt)
],
[
#line(length: 100%)
]))
],
footer: [
#grid(
columns: (2fr, 2fr, 1fr),
#grid(columns: (2fr, 2fr, 1fr),
[
Written by: #h(10pt) #context.author
],
Expand All @@ -75,7 +90,9 @@
]
)
],
background: set-margins(8%, 8%))
)

set-border(context.type)

show heading: it => {
set-heading(it, context.type)
Expand All @@ -97,10 +114,24 @@

#let appendix-entry(context: (:), body) = {
show: page.with(header: [
#set align(center)
#set text(size: 25pt)
#context.title

], background: set-margins(8%, 8%))
#set line(stroke: 1.5pt)
#align(center + horizon, grid(columns: (1fr, auto, 1fr),
[
#line(length: 100%)
],
[
#h(20pt)
#context.title
#h(20pt)
],
[
#line(length: 100%)
]))
]
)

set-border(context.type)

body
}
64 changes: 25 additions & 39 deletions themes/linear/format.typ
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
#import "entry-types.typ": *
/// Sets the length and width of the margins
/// Formats the border lines
///
/// Example Usage:
///
/// ```typ
/// #set-margins(8%, 15%)
/// #set-border()
/// ```
///
/// - x (size, ratio): the distance from the edge of the page to the left and right margins
/// - y (size, ratio): the distance from the edge of the page to the bottom margin
/// -> content
#let set-margins(x, y) = {
#let set-border(type) = {
let top-axis = -8.4% // The title line height
let bottom-axis = 100% // The automatic bottom border

// Adjusts top and bottom borders for frontmatter and appendix entries
if (type == none) {
top-axis = -6.6%
bottom-axis = 106%
}

let left-axis = -8% // 8% less than the automatic left border (0%)
let right-axis = 108% // 8% more than the automatic right border (100%)

set line(stroke: 1.5pt)
// TL: top left
// TR: top right
let border-TL = 0% + 15%
let border-TR = 100% - 15%
place(
// Left border line
line(start: (0% + x, 5%), end: (0% + x, 100% - y)),
)
place(
// Right border line
line(start: (100% - x, 5%), end: (100% - x, 100% - y)),
)
place(
// Bottom border line
line(start: (0% + x, 100% - y), end: (100% - x, 100% - y)),
)
place(
// TL border line -> ——
line(start: (0% + x, 5%), end: (border-TL + x, 5%)),
)
place(
// TR border line -> ——
line(start: (100% - x, 5%), end: (border-TR - x, 5%)),
)
place(
// TL border line -> ︱
line(start: (border-TL + x, 4%), end: (border-TL + x, 6%)),
)
place(
// TR border line -> ︱
line(start: (border-TR - x, 4%), end: (border-TR - x, 6%)),
)
// Top left border
place(line(start: (left-axis, top-axis), end: (0%, top-axis)))
// Top right border
place(line(start: (right-axis, top-axis), end: (100%, top-axis)))
// Left border
place(line(start: (left-axis, top-axis), end: (left-axis, bottom-axis)))
// Right border
place(line(start: (right-axis, top-axis), end: (right-axis, bottom-axis)))
// Bottom border
place(line(start: (left-axis, bottom-axis), end: (right-axis, bottom-axis)))
}

#let set-heading(it, type) = {
Expand Down
2 changes: 1 addition & 1 deletion themes/linear/linear.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "rules.typ": rules
#import "entries.typ": cover, frontmatter-entry, body-entry, appendix-entry
#import "format.typ": set-margins, set-heading
#import "format.typ": set-border, set-heading
#import "components/components.typ"
#import "colors.typ": *

Expand Down
Loading