-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
25 lines (21 loc) · 1.17 KB
/
notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Fallback regex:
allow rgb
/^rgb\(\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*\)$/i
allow rgba
/^rgba\(\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*((0.[1-9])|[01])\s*\)$/
allow rgba - optionally
/^rgb\(\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*,\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*(,\s*(\d?|(\d+\.\d{0,1}))\s*)?\)$/i
allow hsl
/^hsl\(\s*(0|[1-9]\d?|[12]\d\d|3[0-5]\d)\s*,\s*((0|[1-9]\d?|100)%)\s*,\s*((0|[1-9]\d?|100)%)\s*\)$/i;
match integer and float numbers
/(\d+(?:\.\d+)?)/g;
O_TO_250
\s*(0|[1-9]\d?|1\d\d?|2[0-4]\d|25[0-5])%?\s*
OPTIONAL_0_TO_1_DECIMAL
(,\s*(\d?|(\d+\.\d{0,1}))\s*)?
validate and expand shorthand hex to long
// const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
// return shorthandHex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
consider using husky to pre-run required checks before committing
optimize code for treeshaking
use the following link to convert svgs to react components - https://svg2jsx.com/