Skip to content

Commit

Permalink
Merge pull request #258 from jayperryworks/feature/print-types
Browse files Browse the repository at this point in the history
Print type sorting and edition tabs
  • Loading branch information
jayperryworks committed Aug 30, 2023
2 parents 43bcfdd + 00cc545 commit 512f6ab
Show file tree
Hide file tree
Showing 34 changed files with 762 additions and 3,528 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"janisdd.vscode-edit-csv",
"EditorConfig.EditorConfig",
"ms-vscode-remote.remote-containers",
"jenkey2011.string-highlight"
"jenkey2011.string-highlight",
"AndrsDC.base16-themes"
]
}
},
Expand Down
5 changes: 3 additions & 2 deletions lib/colorHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
HSLColor,
HSLChannel,
HSLObject,
HSLAColor,
} from './types.ts';

export function convertHexToHSL(hex: HexColor): HSLColor {
export function convertHexToHSL(hex: HexColor): HSLColor | HSLAColor {
// convert the color from a hex to an array of hsl values...
const hsl = convertColor.hex.hsl(hex);

Expand Down Expand Up @@ -38,7 +39,7 @@ export function convertHexToHSLObject(hex: HexColor): Partial<HSLObject> {
}, { h: null, s: null, l: null });
}

export function convertHSLObjectToHSL(object: HSLObject): HSLColor {
export function convertHSLObjectToHSL(object: HSLObject): HSLColor | HSLAColor {
if (object?.a < 1) return `hsl(${object.h}deg ${object.s}% ${object.l}% / ${object.a})`;
return `hsl(${object.h}deg ${object.s}% ${object.l}%)`;
}
Expand Down
57 changes: 40 additions & 17 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
ImageField,
LinkField,
RichTextField,
TitleField,
} from '@prismicio/types';
Expand All @@ -9,10 +11,11 @@ export type ColorRoles = 'primary' | 'secondary' | 'highlight' | 'bg' | 'island'
export type CSSVariable = `var(--${string})`;
export type CSSHue = `${number | string}deg` | CSSVariable;
export type CSSPercentage = `${number | string}%` | CSSVariable;
export type CSSAlpha = `/ ${number | string}`;

export type HexColor = `#${number}`;
export type HSLColor = `hsl(${CSSHue} ${CSSPercentage} ${CSSPercentage})`
| `hsl(${CSSHue} ${CSSPercentage} ${CSSPercentage} / ${number | string})`;
export type HSLColor = `hsl(${CSSHue} ${CSSPercentage} ${CSSPercentage})`;
export type HSLAColor = `hsl(${CSSHue} ${CSSPercentage} ${CSSPercentage} ${CSSAlpha})`;

type HSLChannel = 'h' | 's' | 'l' | 'a';

Expand All @@ -33,21 +36,6 @@ export type GallerySize = 'small' | 'medium' | 'large';
export type ImageFit = 'default' | 'contain' | 'cover';
export type Device = 'None' | 'Phone' | 'Tablet (horizontal)' | 'Tablet (vertical)';

export type PaginationLink = {
path: string,
title: TitleField,
subtitle?: TitleField,
};

export interface Block {
type: string;
includeInExcerpt?: boolean;
prominence?: Prominence;
// the arbitrary props for any given Block component, defined on each component
// e.g. a Passage with a prismicText prop
[key: string]: unknown;
}

// --- type ---
export type TypeScale = 'alpha' | 'beta' | 'gamma' | 'delta' | 'epsilon' | 'zeta';

Expand Down Expand Up @@ -79,3 +67,38 @@ export interface PublicationDates {
posted?: Date;
updated?: Date;
}

// --- components ---
export type PaginationLink = {
path: string,
title: TitleField,
subtitle?: TitleField,
};

export interface Block {
type: string;
includeInExcerpt?: boolean;
prominence?: Prominence;
// the arbitrary props for any given Block component, defined on each component
// e.g. a Passage with a prismicText prop
[key: string]: unknown;
}

export interface PrintType {
name: string;
description: FormattedText;
}

export type EditionInfo = {
label: string,
value: string,
};

export type Edition = {
etsyLink: LinkField,
image: ImageField,
info: EditionInfo[],
name: string,
limit?: number,
type?: PrintType,
};
Loading

0 comments on commit 512f6ab

Please sign in to comment.