Use a list view on the desktop instead of calendar
| Desktop | Mobile | | --- | --- | |  |  | Co-authored-by: stb <stb@noreply.git.hamburg.ccc.de> Reviewed-on: #73
This commit is contained in:
parent
bb970cae03
commit
3471d2487d
5 changed files with 277 additions and 65 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* Tour schedule shortcode: one column of cards per day, a day picker on narrow screens. */
|
||||
/* Tour schedule shortcode: a mobile day picker and a wide-screen list, with a no-JavaScript grid fallback. */
|
||||
|
||||
.schedule {
|
||||
--schedule-line: color-mix(in oklch, var(--color-text) 20%, transparent);
|
||||
|
|
@ -109,6 +109,7 @@
|
|||
grid-template-columns: 1fr auto;
|
||||
gap: 0.15rem 0.5rem;
|
||||
margin: 0;
|
||||
max-width: none;
|
||||
padding: 0.5rem 0.75rem 0.6rem;
|
||||
border: 1px solid var(--schedule-line);
|
||||
border-inline-start: 3px solid var(--schedule-accent);
|
||||
|
|
@ -133,6 +134,59 @@
|
|||
gap: 0 0.5rem;
|
||||
}
|
||||
|
||||
.schedule__photo {
|
||||
display: none;
|
||||
position: absolute;
|
||||
inset: 0 0 0 60%;
|
||||
z-index: -1;
|
||||
margin: 0;
|
||||
pointer-events: none;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
mask-image: linear-gradient(90deg,
|
||||
transparent 0%,
|
||||
rgb(0 0 0 / 3%) 10%,
|
||||
rgb(0 0 0 / 10%) 40%,
|
||||
rgb(0 0 0 / 80%) 100%);
|
||||
}
|
||||
}
|
||||
|
||||
.schedule__photo-credit {
|
||||
display: none;
|
||||
grid-column: 1 / -1;
|
||||
grid-row: 3;
|
||||
font-size: var(--fs-xs);
|
||||
color: var(--color-text-meta);
|
||||
}
|
||||
|
||||
@media (width >= 667px) {
|
||||
.schedule--picker .schedule__card--photo {
|
||||
isolation: isolate;
|
||||
overflow: hidden;
|
||||
min-height: 7rem;
|
||||
align-items: start;
|
||||
|
||||
.schedule__title,
|
||||
.schedule__photo-credit {
|
||||
max-width: 70%;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.schedule__lang {
|
||||
background: var(--color-body-bg);
|
||||
}
|
||||
}
|
||||
|
||||
.schedule--picker .schedule__photo,
|
||||
.schedule--picker .schedule__photo-credit {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.schedule__status {
|
||||
font-family: var(--ff-alt);
|
||||
font-size: var(--fs-xs);
|
||||
|
|
@ -196,61 +250,61 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* The picker only exists with JavaScript and is only used on narrow screens. */
|
||||
/* The picker is only shown on mobile with JavaScript. */
|
||||
.schedule__picker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@container (width < 48rem) {
|
||||
/* Keeps a focused card from scrolling under the sticky day picker. */
|
||||
.schedule__title {
|
||||
scroll-margin-block-start: 6rem;
|
||||
}
|
||||
/* Keeps a focused card from scrolling under the sticky day picker. */
|
||||
.schedule__title {
|
||||
scroll-margin-block-start: 6rem;
|
||||
}
|
||||
|
||||
.schedule__picker:not([hidden]) {
|
||||
position: sticky;
|
||||
inset-block-start: 0;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
margin-block-end: 1rem;
|
||||
padding: 0.25rem;
|
||||
border-radius: var(--radius-l);
|
||||
background: var(--color-body-bg);
|
||||
box-shadow: inset 0 0 0 1px var(--schedule-line);
|
||||
}
|
||||
.schedule__picker:not([hidden]) {
|
||||
position: sticky;
|
||||
inset-block-start: 0;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
margin-block-end: 1rem;
|
||||
padding: 0.25rem;
|
||||
border-radius: var(--radius-l);
|
||||
background: var(--color-body-bg);
|
||||
box-shadow: inset 0 0 0 1px var(--schedule-line);
|
||||
}
|
||||
|
||||
.schedule__pick {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 0.35rem 0.25rem;
|
||||
border: 0;
|
||||
border-radius: var(--radius-m);
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
font-family: var(--ff-alt);
|
||||
font-size: var(--fs-s);
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
.schedule__pick {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 0.35rem 0.25rem;
|
||||
border: 0;
|
||||
border-radius: var(--radius-m);
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
font-family: var(--ff-alt);
|
||||
font-size: var(--fs-s);
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
|
||||
&[aria-pressed="true"] {
|
||||
background: var(--schedule-accent);
|
||||
color: var(--color-body-bg);
|
||||
&[aria-pressed="true"] {
|
||||
background: var(--schedule-accent);
|
||||
color: var(--color-body-bg);
|
||||
|
||||
.schedule__pick-date {
|
||||
color: inherit;
|
||||
}
|
||||
.schedule__pick-date {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.schedule__pick-date {
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: normal;
|
||||
color: var(--color-text-meta);
|
||||
}
|
||||
.schedule__pick-date {
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: normal;
|
||||
color: var(--color-text-meta);
|
||||
}
|
||||
|
||||
@media (width < 667px) {
|
||||
.schedule--picker {
|
||||
.schedule__day:not(.schedule__day--selected) {
|
||||
display: none;
|
||||
|
|
@ -267,3 +321,47 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@container (width >= 48rem) {
|
||||
.schedule--picker {
|
||||
.schedule__days {
|
||||
display: grid;
|
||||
grid-template-columns: none;
|
||||
grid-template-rows: none;
|
||||
gap: var(--spacing-l);
|
||||
}
|
||||
|
||||
.schedule__day {
|
||||
display: block;
|
||||
grid-column: auto;
|
||||
grid-row: auto;
|
||||
}
|
||||
|
||||
.schedule__list {
|
||||
grid-template-rows: none;
|
||||
}
|
||||
|
||||
.schedule__card {
|
||||
grid-row: auto;
|
||||
}
|
||||
|
||||
.schedule__title {
|
||||
display: block;
|
||||
-webkit-line-clamp: unset;
|
||||
line-clamp: unset;
|
||||
overflow: visible;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.schedule__hour {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (width >= 667px) {
|
||||
.schedule__picker:not([hidden]),
|
||||
.schedule--picker .schedule__day--past {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// Day picker for the schedule shortcode. The CSS only uses it on narrow screens;
|
||||
// without JavaScript all days stack vertically there.
|
||||
// Responsive schedule for the shortcode. Without JavaScript all days remain visible.
|
||||
for (const schedule of document.querySelectorAll('[data-schedule]')) {
|
||||
const picker = schedule.querySelector('.schedule__picker');
|
||||
const buttons = [...picker.querySelectorAll('button')];
|
||||
|
|
@ -22,6 +21,13 @@ for (const schedule of document.querySelectorAll('[data-schedule]')) {
|
|||
const today = new Date().toLocaleDateString('sv');
|
||||
select(buttons.find((button) => button.dataset.date === today) ?? buttons[0]);
|
||||
|
||||
const hasUpcomingDays = buttons.some((button) => button.dataset.date >= today);
|
||||
for (const button of buttons) {
|
||||
document
|
||||
.getElementById(button.getAttribute('aria-controls'))
|
||||
.classList.toggle('schedule__day--past', hasUpcomingDays && button.dataset.date < today);
|
||||
}
|
||||
|
||||
picker.hidden = false;
|
||||
schedule.classList.add('schedule--picker');
|
||||
}
|
||||
|
|
|
|||
19
themes/hackertours/layouts/_partials/first-page-image.html
Normal file
19
themes/hackertours/layouts/_partials/first-page-image.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{{- $result := dict -}}
|
||||
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
|
||||
{{- $alt := index . 0 1 -}}
|
||||
{{- $dest := index . 0 2 -}}
|
||||
{{- $credit := "" -}}
|
||||
{{- with index . 0 3 -}}
|
||||
{{- $dest = "" -}}
|
||||
{{- $alt = "" -}}
|
||||
{{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
||||
{{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
||||
{{- with findRESubmatch "\\bcredit=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $credit = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- $resource := false -}}
|
||||
{{- if not (findRE `^https?://` $dest) -}}
|
||||
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
|
||||
{{- end -}}
|
||||
{{- $result = dict "alt" $alt "credit" $credit "dest" $dest "resource" $resource -}}
|
||||
{{- end -}}
|
||||
{{- return $result -}}
|
||||
|
|
@ -6,24 +6,15 @@ gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt t
|
|||
og:image:alt.
|
||||
*/ -}}
|
||||
{{- if not ($.Param "image") -}}
|
||||
{{- /* Whichever comes first: a Markdown image or a gallery-image shortcode (src and alt in "…" or `…`). */ -}}
|
||||
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
|
||||
{{- $alt := index . 0 1 -}}
|
||||
{{- $dest := index . 0 2 -}}
|
||||
{{- with index . 0 3 -}}
|
||||
{{- $dest = "" -}}
|
||||
{{- $alt = "" -}}
|
||||
{{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
||||
{{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- with partialCached "first-page-image.html" . .RelPermalink -}}
|
||||
{{- $alt := .alt -}}
|
||||
{{- $dest := .dest -}}
|
||||
{{- $url := "" -}}
|
||||
{{- $width := 0 -}}
|
||||
{{- $height := 0 -}}
|
||||
{{- $resource := false -}}
|
||||
{{- $resource := .resource -}}
|
||||
{{- if findRE `^https?://` $dest -}}
|
||||
{{- $url = $dest -}}
|
||||
{{- else -}}
|
||||
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
|
||||
{{- end -}}
|
||||
{{- with $resource -}}
|
||||
{{- $image := . -}}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{{- /*
|
||||
Tour schedule from data/schedule/<event>.yaml, one column of tour cards per day.
|
||||
On narrow screens the days stack; with JavaScript a day picker shows one day at a time.
|
||||
Tour schedule from data/schedule/<event>.yaml.
|
||||
With JavaScript a day picker shows one day at a time; without it all days are visible.
|
||||
|
||||
Usage: {{< schedule >}} on a section page (the event is the section name),
|
||||
or {{< schedule 39c3 >}}.
|
||||
|
|
@ -81,7 +81,23 @@ so an hour without tours still gets a row.
|
|||
{{- /* A tour's own title, in the page's language, replaces its page's title. */}}
|
||||
{{- $ownTitle := "" }}
|
||||
{{- with .title }}{{ $ownTitle = index . site.Language.Name | default (index . "en") }}{{ end }}
|
||||
<li class="schedule__card{{ if $soldOut }} schedule__card--soldout{{ end }}" style="--schedule-row: {{ add (index $slotRow .time) $nth }}">
|
||||
{{- $photo := false }}
|
||||
{{- $photoAlt := "" }}
|
||||
{{- $photoCredit := "" }}
|
||||
{{- with $page }}
|
||||
{{- with partialCached "first-page-image.html" . .RelPermalink }}
|
||||
{{- if and .resource .alt }}
|
||||
{{- if and (eq .resource.ResourceType "image") (ne .resource.MediaType.SubType "svg") }}
|
||||
{{- $oriented := .resource.Filter images.AutoOrient }}
|
||||
{{- $photo = $oriented }}
|
||||
{{- if gt $oriented.Width 1600 }}{{ $photo = $oriented.Resize "1600x" }}{{ end }}
|
||||
{{- $photoAlt = .alt }}
|
||||
{{- $photoCredit = .credit }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<li class="schedule__card{{ if $soldOut }} schedule__card--soldout{{ end }}{{ if $photo }} schedule__card--photo{{ end }}" style="--schedule-row: {{ add (index $slotRow .time) $nth }}">
|
||||
<span class="schedule__when">
|
||||
<time class="schedule__time" datetime="{{ $day.date }}T{{ .time }}">{{ .time }}</time>
|
||||
{{- if $soldOut }}
|
||||
|
|
@ -97,6 +113,12 @@ so an hour without tours still gets a row.
|
|||
{{- else }}
|
||||
<span class="schedule__title">{{ $ownTitle | default $entry.tour }}</span>
|
||||
{{- end }}
|
||||
{{- with $photo }}
|
||||
<figure class="schedule__photo">
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="{{ $photoAlt }}" loading="lazy" decoding="async">
|
||||
</figure>
|
||||
{{- with $photoCredit }}<span class="schedule__photo-credit">{{ . }}</span>{{ end }}
|
||||
{{- end }}
|
||||
</li>
|
||||
{{- end }}
|
||||
</ol>
|
||||
|
|
|
|||
Loading…
Reference in a new issue