From 005f87e98bf3a2b720060185c1600c74693dbd6d Mon Sep 17 00:00:00 2001 From: Hubert Bieszczad Date: Fri, 13 Oct 2023 10:08:37 +0200 Subject: [PATCH] chore: simplify MediaQueries type --- src/types/mediaQueries.ts | 75 +++++---------------------------------- 1 file changed, 8 insertions(+), 67 deletions(-) diff --git a/src/types/mediaQueries.ts b/src/types/mediaQueries.ts index 7495a096..27136297 100644 --- a/src/types/mediaQueries.ts +++ b/src/types/mediaQueries.ts @@ -1,69 +1,10 @@ +type Optional = TOptional | '' +type Separator = ',' | ', ' +type MediaQuery = `[${Separator}${bigint}]` | `[${bigint}${Optional<`${Separator}${bigint}`>}]` +type WidthMediaQuery = `:w${MediaQuery}` +type HeightMediaQuery = `:h${MediaQuery}` + // this is super weird, but number passes empty string and bigint does not export type MediaQueries = -// For :w -`:w[${bigint}]` | -`:w[,${bigint}]` | -`:w[, ${bigint}]` | -`:w[${bigint},${bigint}]` | -`:w[${bigint}, ${bigint}]` | - -// For :h -`:h[${bigint}]` | -`:h[,${bigint}]` | -`:h[, ${bigint}]` | -`:h[${bigint},${bigint}]` | -`:h[${bigint}, ${bigint}]` | - -// Combinations of :w and :h -`:w[${bigint}]:h[${bigint}]` | -`:w[${bigint},${bigint}]:h[${bigint}]` | -`:w[${bigint}, ${bigint}]:h[${bigint}]` | -`:w[${bigint}]:h[${bigint},${bigint}]` | -`:w[${bigint}]:h[${bigint}, ${bigint}]` | -`:w[${bigint},${bigint}]:h[${bigint},${bigint}]` | -`:w[${bigint}, ${bigint}]:h[${bigint},${bigint}]` | -`:w[${bigint},${bigint}]:h[${bigint}, ${bigint}]` | -`:w[${bigint}, ${bigint}]:h[${bigint}, ${bigint}]` | -`:w[,${bigint}]:h[,${bigint}]` | -`:w[, ${bigint}]:h[,${bigint}]` | -`:w[,${bigint}]:h[, ${bigint}]` | -`:w[, ${bigint}]:h[, ${bigint}]` | -`:w[,${bigint}]:h[${bigint}]` | -`:w[, ${bigint}]:h[${bigint}]` | -`:w[${bigint}]:h[,${bigint}]` | -`:w[${bigint}]:h[, ${bigint}]` | -`:w[,${bigint}]:h[${bigint},${bigint}]` | -`:w[, ${bigint}]:h[${bigint},${bigint}]` | -`:w[,${bigint}]:h[${bigint}, ${bigint}]` | -`:w[, ${bigint}]:h[${bigint}, ${bigint}]` | -`:w[${bigint},${bigint}]:h[,${bigint}]` | -`:w[${bigint}, ${bigint}]:h[,${bigint}]` | -`:w[${bigint},${bigint}]:h[, ${bigint}]` | -`:w[${bigint}, ${bigint}]:h[, ${bigint}]` | - -// Combinations of :h and :w -`:h[${bigint}]:w[${bigint}]` | -`:h[${bigint},${bigint}]:w[${bigint}]` | -`:h[${bigint}, ${bigint}]:w[${bigint}]` | -`:h[${bigint}]:w[${bigint},${bigint}]` | -`:h[${bigint}]:w[${bigint}, ${bigint}]` | -`:h[${bigint},${bigint}]:w[${bigint},${bigint}]` | -`:h[${bigint}, ${bigint}]:w[${bigint},${bigint}]` | -`:h[${bigint},${bigint}]:w[${bigint}, ${bigint}]` | -`:h[${bigint}, ${bigint}]:w[${bigint}, ${bigint}]` | -`:h[,${bigint}]:w[,${bigint}]` | -`:h[, ${bigint}]:w[,${bigint}]` | -`:h[,${bigint}]:w[, ${bigint}]` | -`:h[, ${bigint}]:w[, ${bigint}]` | -`:h[,${bigint}]:w[${bigint}]` | -`:h[, ${bigint}]:w[${bigint}]` | -`:h[${bigint}]:w[,${bigint}]` | -`:h[${bigint}]:w[, ${bigint}]` | -`:h[,${bigint}]:w[${bigint},${bigint}]` | -`:h[, ${bigint}]:w[${bigint},${bigint}]` | -`:h[,${bigint}]:w[${bigint}, ${bigint}]` | -`:h[, ${bigint}]:w[${bigint}, ${bigint}]` | -`:h[${bigint},${bigint}]:w[,${bigint}]` | -`:h[${bigint}, ${bigint}]:w[,${bigint}]` | -`:h[${bigint},${bigint}]:w[, ${bigint}]` | -`:h[${bigint}, ${bigint}]:w[, ${bigint}]` + | `${WidthMediaQuery}${Optional}` + | `${HeightMediaQuery}${Optional}`