Clean up the photo parameters table

Add a .no-value style to the items in the table. Streamline the logic for filling
in table values.
This commit is contained in:
Eryn Wells 2024-11-04 08:36:57 -08:00
parent cf0aa69a87
commit 63eb00bf4a
3 changed files with 55 additions and 33 deletions

View file

@ -9,9 +9,6 @@
}
.photo-params {
--background-color: var(--gray7);
--container-background-color: var(--gray6);
--color: var(--gray2);
--border-color: var(--gray6);
--border-style: 2px solid;
@ -76,6 +73,11 @@
.location {
border-right: 0;
}
.no-value {
color: var(--text-color-secondary);
text-align: center;
}
}
}

View file

@ -13,23 +13,30 @@
</td>
</thead>
{{ end }}
{{ with .Tags.LensModel }}
<tr>
<td colspan=4 class="lens">{{ . }}</td>
</tr>
{{ with .Tags.LensModel -}}
<tr><td colspan="4" class="lens">{{ . }}</td></tr>
{{ end }}
<tr>
{{- $hasLocation := and .Lat .Long -}}
{{- $hasPixelDimensions := and .Tags.PixelXDimension .Tags.PixelYDimension -}}
{{ if $hasLocation -}}
<td colspan=2 class="location">
{{ $lat := float .Lat }}{{ $latDir := cond (eq $lat 0) "" (cond (gt $lat 0) "N" "S") }}
<data class="latitude" value="{{ $lat }}">{{ .Lat | lang.FormatNumber (cond (ne $lat 0) 3 0) }}º{{ $latDir }}</data>,
{{ $long := float .Long }}{{ $longDir := cond (eq $long 0) "" (cond (gt $long 0) "E" "W") }}
<data class="longitude" value="{{ $long }}">{{ .Long | lang.FormatNumber (cond (ne $long 0) 3 0) }}º{{ $longDir }}</data>
</td>
<td
colspan="{{ cond $hasPixelDimensions 2 4 }}"
class="location">
{{ $latitude := float .Lat }}
{{ $latitudeDirection := cond (eq $latitude 0) "" (cond (gt $latitude 0) "N" "S") }}
<data class="latitude" value="{{ $latitude }}">
{{ $latitude | lang.FormatNumber (cond (ne $latitude 0) 3 0) }}º{{ $latitudeDirection }}
</data>,
{{ $longitude := float .Long }}
{{ $longitudeDirection := cond (eq $longitude 0) "" (cond (gt $longitude 0) "E" "W") }}
<data class="longitude" value="{{ $longitude }}">
{{ $longitude | lang.FormatNumber (cond (ne $longitude 0) 3 0) }}º{{ $longitudeDirection }}
</data>
</td>
{{- end -}}
{{ if and .Tags.PixelXDimension .Tags.PixelYDimension -}}
<td colspan={{ if $hasLocation }}2{{ else }}4{{ end }} class="size">
{{ if $hasPixelDimensions -}}
<td colspan="{{ cond $hasLocation 2 4 }}" class="size">
{{- $widthpx := .Tags.PixelXDimension -}}
{{- $heightpx := .Tags.PixelYDimension -}}
{{- if and (gt $widthpx 0) (gt $heightpx 0) -}}
@ -41,24 +48,37 @@
</td>
{{ end }}
</tr>
{{ if or .Tags.ISOSpeedRatings .Tags.FocalLengthIn35mmFilm .Tags.FNumber .Tags.ExposureTime }}
<tr class="exposure-attributes">
<td class="iso">{{ with .Tags.ISOSpeedRatings }}ISO {{ . }}{{ end }}</td>
<td class="focal-length">
{{- $focalLength := .Tags.FocalLengthIn35mmFilm | default .Tags.FocalLength -}}
{{- with $focalLength -}}{{ . }} mm{{- end -}}
</td>
<td class="f-number">{{ with .Tags.FNumber }}{{ printf "ƒ%0.1f" . }}{{ end }}</td>
<td class="exposure-time">
{{- with $exposureTime := .Tags.ExposureTime -}}
{{- if in $exposureTime "/" -}}
{{ . }} s
{{- else -}}
1/{{ printf "%.0f" (div 1.0 (float $exposureTime)) }} s
{{- end -}}
{{ if or
.Tags.ISOSpeedRatings
.Tags.FocalLengthIn35mmFilm
.Tags.FocalLength
.Tags.FNumber
.Tags.ExposureTime
}}
<tr class="exposure-attributes">
{{ with .Tags.ISOSpeedRatings -}}
<td class="iso">ISO {{ . }}</td>
{{ else }}
<td class="iso no-value">--</td>
{{- end -}}
</td>
</tr>
<td class="focal-length">
{{- with .Tags.FocalLengthIn35mmFilm | default .Tags.FocalLength -}}
{{ printf "%3.2f" (float .) }} mm
{{- end -}}
</td>
<td class="f-number">
{{ with .Tags.FNumber }}{{ printf "ƒ%0.1f" (float .) }}{{ end }}
</td>
<td class="exposure-time">
{{- with $exposureTime := .Tags.ExposureTime -}}
{{- if in $exposureTime "/" -}}
{{ . }} s
{{- else -}}
1/{{ printf "%.0f" (div 1.0 (float $exposureTime)) }} s
{{- end -}}
{{- end -}}
</td>
</tr>
{{ end }}
</table>
</div>

View file

@ -19,7 +19,7 @@
{{ .Content -}}
{{- if .Params.photo_details | default .Params.photoDetails | default true -}}
{{- if .Params.photoDetails | default .Params.photo_details | default true -}}
{{- partial "photostream/exif_table.html" $img.Exif -}}
{{- end -}}
{{ end }}{{/* if eq (len $images) 1 */}}