-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.html
244 lines (228 loc) · 11.1 KB
/
preview.html
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Preview</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Google Fonts will be dynamically loaded -->
<link id="googleFontsLink" href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap" rel="stylesheet">
<!-- Custom Preview Styles -->
<style id="customStyles">
/* Custom styles will be injected here */
:root {
/* Default variables that will be overridden */
--bs-primary: #0d6efd;
--bs-secondary: #6c757d;
--bs-success: #198754;
--bs-info: #0dcaf0;
--bs-warning: #ffc107;
--bs-danger: #dc3545;
--bs-light: #f8f9fa;
--bs-dark: #212529;
--bs-font-sans-serif: 'Roboto', sans-serif;
--bs-border-radius: 0.375rem;
--bs-border-radius-sm: 0.25rem;
--bs-border-radius-lg: 0.5rem;
--bs-border-radius-xl: 1rem;
}
body {
font-family: var(--bs-font-sans-serif);
padding: 2rem;
}
.preview-section {
margin-bottom: 2rem;
}
.preview-title {
margin-bottom: 1rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid #dee2e6;
}
</style>
</head>
<body>
<div class="container">
<h1 class="preview-title">Bootstrap Preview</h1>
<!-- Colors Section -->
<section class="preview-section">
<h2 class="h5 mb-3">Colors</h2>
<div class="row g-2">
<div class="col-6 col-md-3">
<div class="p-3 bg-primary text-white rounded">Primary</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-secondary text-white rounded">Secondary</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-success text-white rounded">Success</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-danger text-white rounded">Danger</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-warning text-dark rounded">Warning</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-info text-dark rounded">Info</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-light text-dark rounded">Light</div>
</div>
<div class="col-6 col-md-3">
<div class="p-3 bg-dark text-white rounded">Dark</div>
</div>
</div>
</section>
<!-- Typography Section -->
<section class="preview-section">
<h2 class="h5 mb-3">Typography</h2>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<p class="lead">This is a lead paragraph. It stands out from regular paragraphs.</p>
<p>This is a regular paragraph with <strong>bold text</strong> and <em>italic text</em>.</p>
<blockquote class="blockquote">
<p>A well-known quote, contained in a blockquote element.</p>
<footer class="blockquote-footer">Someone famous</footer>
</blockquote>
</section>
<!-- Buttons Section -->
<section class="preview-section">
<h2 class="h5 mb-3">Buttons</h2>
<div class="mb-3">
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
</div>
<div>
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-secondary">Secondary</button>
<button type="button" class="btn btn-outline-success">Success</button>
<button type="button" class="btn btn-outline-danger">Danger</button>
</div>
</section>
<!-- Cards Section -->
<section class="preview-section">
<h2 class="h5 mb-3">Cards</h2>
<div class="row">
<div class="col-md-4 mb-3">
<div class="card">
<div class="card-header">Featured</div>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="card">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="card-link">Card link</a>
<a href="#" class="card-link">Another link</a>
</div>
</div>
</div>
<div class="col-md-4 mb-3">
<div class="card bg-primary text-white">
<div class="card-body">
<h5 class="card-title">Primary card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
</div>
</div>
</section>
<!-- Forms Section -->
<section class="preview-section">
<h2 class="h5 mb-3">Forms</h2>
<form>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
<div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1">
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</section>
</div>
<!-- Bootstrap JS Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- Preview JS -->
<script>
// This script will receive messages from the parent window to update styles
window.addEventListener('message', function(event) {
if (event.data && event.data.type === 'updateStyles') {
updatePreviewStyles(event.data.variables);
}
});
function updatePreviewStyles(variables) {
// Update custom styles
const styleElement = document.getElementById('customStyles');
let cssVars = ':root {\n';
// Map Picostrap variables to CSS variables
const variableMapping = {
'$primary': '--bs-primary',
'$secondary': '--bs-secondary',
'$success': '--bs-success',
'$info': '--bs-info',
'$warning': '--bs-warning',
'$danger': '--bs-danger',
'$light': '--bs-light',
'$dark': '--bs-dark',
'$body-bg': '--bs-body-bg',
'$body-color': '--bs-body-color',
'$border-radius': '--bs-border-radius',
'$border-radius-sm': '--bs-border-radius-sm',
'$border-radius-lg': '--bs-border-radius-lg',
'$border-radius-xl': '--bs-border-radius-xl',
'$border-radius-2xl': '--bs-border-radius-2xl',
'$btn-border-radius': '--bs-btn-border-radius',
'$btn-border-radius-sm': '--bs-btn-border-radius-sm',
'$btn-border-radius-lg': '--bs-btn-border-radius-lg'
};
// Add all CSS variables
for (const [key, value] of Object.entries(variables)) {
if (key === '$font-family-base' || key === '$headings-font-family') {
// Extract font name from the quoted string (e.g., "\"Poppins\"" -> Poppins)
const fontName = value.replace(/\\"/g, '').replace(/"/g, '');
// Update Google Font
const fontLink = document.getElementById('googleFontsLink');
fontLink.href = `https://fonts.googleapis.com/css2?family=${fontName.replace(/ /g, '+')}:wght@300;400;500;700&display=swap`;
// Update font family variable
if (key === '$font-family-base') {
cssVars += ` --bs-font-sans-serif: '${fontName}', sans-serif;\n`;
}
} else if (variableMapping[key]) {
// Map Picostrap variable to CSS variable
cssVars += ` ${variableMapping[key]}: ${value};\n`;
} else if (key.startsWith('$')) {
// Convert other $ variables to CSS variables
const cssVarName = '--bs-' + key.substring(1);
cssVars += ` ${cssVarName}: ${value};\n`;
}
}
cssVars += '}\n';
cssVars += `\nbody {\n font-family: var(--bs-font-sans-serif);\n padding: 2rem;\n}\n`;
cssVars += `\n.preview-section {\n margin-bottom: 2rem;\n}\n`;
cssVars += `\n.preview-title {\n margin-bottom: 1rem;\n padding-bottom: 0.5rem;\n border-bottom: 1px solid #dee2e6;\n}\n`;
styleElement.textContent = cssVars;
}
</script>
</body>
</html>