-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes.d.ts
161 lines (145 loc) · 4.06 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
interface Strings extends Required<Base & Record<never, never>> {}
type Union<T extends Base, Base extends Primitive = string> = T | Strings;
declare enum LogLevel {
Debug = 0,
Info = 1,
Warn = 2,
Error = 3,
Fatal = 4,
}
type LogLevelName = Lowercase<`${keyof typeof LogLevel}`>;
type PathParams<T = unknown> = Record<string, T>;
type HeadingLevel = Lowercase<`h${1 | 2 | 3 | 4 | 5 | 6}`>;
// deno-fmt-ignore
type Id<U, Optional = true> =
| Optional extends true ? Partial<Id<U, false>>
: U extends infer T extends Record<string, any>
? { -readonly [K in keyof T]: Id<T[K], Optional> }
: U;
type Maybe<T> = T | null | undefined;
type MaybeArray<T> = Maybe<T> | Maybe<T>[];
declare namespace Props {
type ViewBox = `${number} ${number} ${number} ${number}`;
type RemoteURL = `http${"s" | ""}://${string}`;
type DataURL = `data:${string}`;
type LocalURL = `file:${string}`;
type Url = RemoteURL | DataURL | LocalURL;
type FontFamily = "sans-serif" | "serif" | "monospace";
type FontWeight = "normal" | "bold";
type TextAnchor = "left" | "middle" | "right";
type StrokeLinecap = "butt" | "round" | "square";
type StrokeLinejoin = "miter" | "round" | "bevel";
type SVG = Partial<{
xmlns: "http://www.w3.org/2000/svg";
viewBox: ViewBox;
width: number | `${number}`;
height: number | `${number}`;
pxRatio: number | `${number}`;
borderRadius: number | `${number}`;
bgColor: string;
title: string;
subtitle: string;
}>;
type Text = {
x: number | `${number}`;
y: number | `${number}`;
color: string;
fontSize: number | `${number}`;
fontFamily: FontFamily | "default";
fontWeight: FontWeight | "default";
textAnchor: TextAnchor | "default";
dominantBaseline: string;
shadow: string;
shadowColor: string;
shadowOpacity: number | `${number}`;
stroke: string;
strokeWidth: number | `${number}`;
strokeOpacity: number | `${number}`;
strokeLinecap: StrokeLinecap;
strokeLinejoin: StrokeLinejoin;
strokeDasharray: string;
strokeDashoffset: number | `${number}`;
};
// love these mappable types from TS 4.x 😍
// props for the subtitle component
type Title = Partial<
{
[K in keyof Text as `title${Capitalize<K>}`]: Text[K];
}
>;
// props for the subtitle component
type Subtitle = Partial<
{
[K in keyof Title as `sub${K}`]: Title[K];
}
>;
type StrokesNShadows = Extract<keyof Text, `${"stroke" | "shadow"}${string}`>;
// deno-fmt-ignore
type Icon = Partial<
& {
[K in StrokesNShadows as `icon${Capitalize<K>}`]: Text[K];
}
& { [K in `icon${"W" | "H" | "X" | "Y"}`]: number | `${number}`; }
& {
icon: boolean | string;
iconUrl: RemoteURL | DataURL;
iconColor: string;
viewBox: ViewBox;
}
>;
}
interface SVGProps extends Partial<Props.SVG> {
/* inherit */
}
interface TitleProps extends Partial<Props.Title> {
/* inherit */
}
interface SubtitleProps extends Partial<Props.Subtitle> {
/* inherit */
}
interface IconProps extends Partial<Props.Icon> {
/* inherit */
}
interface AllProps extends TitleProps, SubtitleProps, IconProps, SVGProps {
[key: string]: unknown;
}
declare namespace Meta {
type SEO = Partial<OpenGraph & Twitter & Generic & Layout>;
type OpenGraph = {
"og:image": string;
"og:url": string;
"og:type": string;
"og:title": string;
"og:description": string;
"og:author": string;
"og:image:width": string;
"og:image:height": string;
"og:image:alt": string;
"og:image:src": string;
};
type Twitter = {
"twitter:card": string;
"twitter:creator": string;
"twitter:image": string;
"twitter:site": string;
"twitter:summary": string;
"twitter:title": string;
"twitter:description": string;
};
type Generic = {
title: string;
author: string;
description: string;
keywords: string;
};
type Layout = {
viewport: string;
canonical: string;
favicon: string;
"mask-icon": string;
"theme-color": string;
};
}
interface Meta extends Meta.SEO {
/* inherit */
}