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

View file

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

View file

@ -19,7 +19,7 @@
{{ .Content -}} {{ .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 -}} {{- partial "photostream/exif_table.html" $img.Exif -}}
{{- end -}} {{- end -}}
{{ end }}{{/* if eq (len $images) 1 */}} {{ end }}{{/* if eq (len $images) 1 */}}