From e01b73d286fbb11ac8ded59b4c23738dff195171 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Sep 2023 16:22:10 -0300 Subject: data: dimensions utility --- src/data/things/album.js | 8 +++----- src/data/things/thing.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src/data') diff --git a/src/data/things/album.js b/src/data/things/album.js index 01f52c2d..5e281f06 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -1,6 +1,6 @@ import find from '#find'; import {stitchArrays} from '#sugar'; -import {isDate, isDimensions, isTrackSectionList} from '#validators'; +import {isDate, isTrackSectionList} from '#validators'; import { compositeFrom, @@ -19,6 +19,7 @@ import Thing, { commentatorArtists, contribsPresent, contributionList, + dimensions, directory, fileExtension, flag, @@ -171,10 +172,7 @@ export class Album extends Thing { bannerStyle: simpleString(), bannerFileExtension: fileExtension('jpg'), - bannerDimensions: { - flags: {update: true, expose: true}, - update: {validate: isDimensions}, - }, + bannerDimensions: dimensions(), hasTrackNumbers: flag(true), isListedOnHomepage: flag(true), diff --git a/src/data/things/thing.js b/src/data/things/thing.js index 9e7f940f..0484b589 100644 --- a/src/data/things/thing.js +++ b/src/data/things/thing.js @@ -25,6 +25,7 @@ import { isColor, isContributionList, isDate, + isDimensions, isDirectory, isFileExtension, isName, @@ -122,6 +123,15 @@ export function fileExtension(defaultFileExtension = null) { }; } +// Plain ol' image dimensions. This is a two-item array of positive integers, +// corresponding to width and height respectively. +export function dimensions() { + return { + flags: {update: true, expose: true}, + update: {validate: isDimensions}, + }; +} + // Straightforward flag descriptor for a variety of property purposes. // Provide a default value, true or false! export function flag(defaultValue = false) { -- cgit 1.3.0-6-gf8a5