Skip to content

Commit

Permalink
edit: rearrange examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HPDell committed May 20, 2024
1 parent b6e8dbb commit 00de823
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 10 deletions.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Parameters:
Example:

![](./example.png)
![](./test/day-view.png)

### Month view

Expand Down Expand Up @@ -57,6 +57,45 @@ Example:
)
```

```typst
#let events2 = (
(datetime(year: 2024, month: 5, day: 1, hour: 9, minute: 0, second: 0), ([Lecture], blue)),
(datetime(year: 2024, month: 5, day: 1, hour: 10, minute: 0, second: 0), ([Tutorial], red)),
(datetime(year: 2024, month: 5, day: 1, hour: 11, minute: 0, second: 0), [Lab]),
)
#calendar-month(
events2,
sunday-first: true,
rows: (2em,) * 2 + (8em,),
template: (
day-body: (day, events) => {
show: block.with(width: 100%, height: 100%, inset: 2pt)
set align(left + top)
stack(
spacing: 2pt,
pad(bottom: 4pt, text(weight: "bold", day.display("[day]"))),
..events.map(((d, e)) => {
let col = if type(e) == array and e.len() > 1 { e.at(1) } else { yellow }
show: block.with(
fill: col.lighten(40%),
stroke: col,
width: 100%,
inset: 2pt,
radius: 2pt
)
d.display("[hour]")
h(4pt)
if type(e) == array { e.at(0) } else { e }
})
)
}
)
)
```

![](./test/month-view.png)

### Month-summary view

`calendar-month-summary(events, template, sunday-first, ..args)`
Expand Down Expand Up @@ -88,8 +127,23 @@ Example:
#calendar-month-summary(
events: events
)
#calendar-month-summary(
events: events,
sunday-first: true
)
// An empty calendar
#calendar-month-summary(
events: (
(datetime(year: 2024, month: 05, day: 21), (none,)),
),
stroke: 1pt,
)
```

![](./test/month-summary.png)

## Limitations

- Page breaking may be incorrect.
Expand Down
Binary file removed example.png
Binary file not shown.
Binary file added test/day-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions example.typ → test/day-view.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "@preview/cineca:0.1.0": calendar, events-to-calendar-items

#set page(margin: 0.5in)
#set page(margin: 0.5in, height: 15cm)

#let events = (
(1, 8.00, 10.00, [Lecture 1]),
Expand All @@ -13,4 +13,4 @@
(2, 18.00, 20.00, [Dinner with friends]),
)

#calendar(events)
#calendar(events, hour-range: (8, 14))
Binary file added test/month-summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 9 additions & 7 deletions test/month-summary.typ
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#import "@preview/cineca:0.1.0": *

// An empty calendar
#calendar-month-summary(
events: (
(datetime(year: 2024, month: 05, day: 21), (none,)),
),
stroke: 1pt,
)
#set page(margin: 0.5in, height: 13cm, width: 14cm)

#let events = (
(datetime(year: 2024, month: 05, day: 21), (circle, (stroke: color.green, inset: 2pt))),
Expand All @@ -27,4 +21,12 @@
#calendar-month-summary(
events: events,
sunday-first: true
)

// An empty calendar
#calendar-month-summary(
events: (
(datetime(year: 2024, month: 05, day: 21), (none,)),
),
stroke: 1pt,
)
Binary file added test/month-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 00de823

Please sign in to comment.