-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathcolorMatchers.ts
More file actions
25 lines (23 loc) · 838 Bytes
/
colorMatchers.ts
File metadata and controls
25 lines (23 loc) · 838 Bytes
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
// const INTEGER = '[-+]?\\d+';
const NUMBER = '[-+]?\\d*\\.?\\d+'
const PERCENTAGE = NUMBER + '%'
function call(...parts: string[]) {
return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)'
}
export const rgb = new RegExp(
'rgb' + /* @__PURE__ */ call(NUMBER, NUMBER, NUMBER)
)
export const rgba = new RegExp(
'rgba' + /* @__PURE__ */ call(NUMBER, NUMBER, NUMBER, NUMBER)
)
export const hsl = new RegExp(
'hsl' + /* @__PURE__ */ call(NUMBER, PERCENTAGE, PERCENTAGE)
)
export const hsla = new RegExp(
'hsla' + /* @__PURE__ */ call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)
)
export const hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/
export const hex4 =
/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/
export const hex6 = /^#([0-9a-fA-F]{6})$/
export const hex8 = /^#([0-9a-fA-F]{8})$/