Update inde.html
Browse files
inde.html
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>CSS Preprocessor Example</title>
|
| 7 |
+
<style id="processed-css"></style>
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div class="container">
|
| 11 |
+
<h1>Hello, World!</h1>
|
| 12 |
+
<p>This is a simple example of using a CSS preprocessor.</p>
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<script>
|
| 16 |
+
// Define variables
|
| 17 |
+
const variables = {
|
| 18 |
+
primaryColor: '#007bff',
|
| 19 |
+
secondaryColor: '#6c757d',
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
// Define mixins
|
| 23 |
+
const mixins = {
|
| 24 |
+
flexCenter: `
|
| 25 |
+
display: flex;
|
| 26 |
+
justify-content: center;
|
| 27 |
+
align-items: center;
|
| 28 |
+
`,
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
// Parse and process CSS
|
| 32 |
+
function preprocessCSS(css) {
|
| 33 |
+
// Resolve variables
|
| 34 |
+
for (const [key, value] of Object.entries(variables)) {
|
| 35 |
+
css = css.replace(new RegExp(`\\$${key}`, 'g'), value);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// Expand mixins
|
| 39 |
+
for (const [key, value] of Object.entries(mixins)) {
|
| 40 |
+
css = css.replace(new RegExp(`@mixin ${key}`, 'g'), value);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
return css;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// Example usage
|
| 47 |
+
const inputCSS = `
|
| 48 |
+
body {
|
| 49 |
+
background-color: $primaryColor;
|
| 50 |
+
color: $secondaryColor;
|
| 51 |
+
@mixin flexCenter;
|
| 52 |
+
}
|
| 53 |
+
`;
|
| 54 |
+
|
| 55 |
+
const processedCSS = preprocessCSS(inputCSS);
|
| 56 |
+
document.getElementById('processed-css').innerText = processedCSS;
|
| 57 |
+
</script>
|
| 58 |
+
</body>
|
| 59 |
+
</html>
|