-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think you could improve this grouping the dates by week, eg. dates = Time.utc(2024, 9, 2).step(to: Time.utc(2024, 11, 2), by: 1.day)
grouped_by_week = dates.group_by(&.calendar_week)
grouped_by_week.each do |_week, week_dates|
tr do
week_dates.each do |date|
td do
# ... code here
end
end
end
end Another solution is using grid layout, so you wouldn't need to control the rows with html structure, just an element with multiple elements inside. <style>
ol.calendar {
display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr));
}
ol.calendar > li {
aspect-ratio: 1 / 1;
}
</style>
<ol class="calendar">
<li>29</li>
<li>30</li>
<li>1</li>
...
<li>31</li>
<li>1</li>
<li>2</li>
</li> I'm not sure if makes sense for blueprint exposing something like class MyComponent
include Blueprint::HTML
def blueprint
open_tr if date.monday?
...
close_tr if date.sunday?
end
def open_tr : Nil
raw safe "<tr>"
end
def close_tr : Nil
raw safe "</tr>"
end
end What do you think? Do you have any other ideas how can blueprint help in this case? |
Beta Was this translation helpful? Give feedback.
I think you could improve this grouping the dates by week, eg.
Another solution is using grid layout, so you wouldn't need to control the rows with html structure, just an element with multiple elements inside.