Spaces:
Sleeping
Sleeping
| export function analyzeCSS(css: string) { | |
| const colors = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /#[0-9a-fA-F]{3,8}\b|rgba?\([^)]+\)|hsla?\([^)]+\)/g | |
| ) || [] | |
| ) | |
| ) | |
| ].slice(0, 100); | |
| const fonts = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /font-family\s*:\s*([^;]+)/gi | |
| ) || [] | |
| ).map(v => | |
| v.replace(/font-family\s*:/i, "") | |
| .trim() | |
| ) | |
| ) | |
| ]; | |
| const gradients = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /(linear-gradient|radial-gradient)\([^)]+\)/gi | |
| ) || [] | |
| ) | |
| ) | |
| ]; | |
| const borderRadius = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /border-radius\s*:\s*[^;]+/gi | |
| ) || [] | |
| ).map(v => | |
| v.replace(/border-radius\s*:/i, "") | |
| .trim() | |
| ) | |
| ) | |
| ]; | |
| const spacing = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /(margin|padding)\s*:\s*[^;]+/gi | |
| ) || [] | |
| ) | |
| ) | |
| ]; | |
| const animations = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /animation\s*:\s*[^;]+/gi | |
| ) || [] | |
| ) | |
| ) | |
| ]; | |
| const shadows = [ | |
| ...new Set( | |
| ( | |
| css.match( | |
| /box-shadow\s*:\s*[^;]+/gi | |
| ) || [] | |
| ) | |
| ) | |
| ]; | |
| return { | |
| colors, | |
| fonts, | |
| gradients, | |
| borderRadius, | |
| spacing, | |
| animations, | |
| shadows | |
| }; | |
| } | |