« get me outta code hell

data: dimensions utility - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-08 16:22:10 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-08 16:22:10 -0300
commite01b73d286fbb11ac8ded59b4c23738dff195171 (patch)
tree0e512aa948de3e9cf55aec3507a2c7d68356b1c4 /src
parentf39164ed44fe5c86f1f1911514d38a5549e51f92 (diff)
data: dimensions utility
Diffstat (limited to 'src')
-rw-r--r--src/data/things/album.js8
-rw-r--r--src/data/things/thing.js10
2 files changed, 13 insertions, 5 deletions
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) {