krmmrk commited on
Commit
f88ef49
·
verified ·
1 Parent(s): 71cc2a8

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +382 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Html Css To Maui Xaml
3
- emoji: 🦀
4
- colorFrom: purple
5
- colorTo: yellow
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: html-css-to-maui-xaml
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,382 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>HTML/CSS to MAUI XAML Converter</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/atom-one-dark.min.css">
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
10
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/xml.min.js"></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/css.min.js"></script>
12
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
13
+ <style>
14
+ .editor-container {
15
+ height: calc(100vh - 180px);
16
+ }
17
+ .editor-panel {
18
+ height: 100%;
19
+ overflow: auto;
20
+ }
21
+ .hljs {
22
+ background: transparent !important;
23
+ }
24
+ .tab-button {
25
+ transition: all 0.2s ease;
26
+ }
27
+ .tab-button.active {
28
+ border-bottom: 3px solid #3b82f6;
29
+ color: #3b82f6;
30
+ }
31
+ .copy-btn {
32
+ opacity: 0;
33
+ transition: opacity 0.2s ease;
34
+ }
35
+ .code-block:hover .copy-btn {
36
+ opacity: 1;
37
+ }
38
+ .gradient-bg {
39
+ background: linear-gradient(135deg, #6b46c1 0%, #3b82f6 100%);
40
+ }
41
+ </style>
42
+ </head>
43
+ <body class="bg-gray-100">
44
+ <div class="gradient-bg text-white py-6 px-4 shadow-lg">
45
+ <div class="container mx-auto">
46
+ <div class="flex items-center justify-between">
47
+ <div>
48
+ <h1 class="text-3xl font-bold"><i class="fas fa-code mr-2"></i>HTML/CSS to MAUI XAML</h1>
49
+ <p class="text-blue-100 mt-1">Convert your web UI to .NET MAUI XAML instantly</p>
50
+ </div>
51
+ <div class="flex space-x-2">
52
+ <button id="convertBtn" class="bg-white text-blue-600 px-6 py-2 rounded-lg font-semibold hover:bg-blue-50 transition flex items-center">
53
+ <i class="fas fa-sync-alt mr-2"></i> Convert
54
+ </button>
55
+ <button id="clearBtn" class="bg-blue-800 text-white px-4 py-2 rounded-lg font-semibold hover:bg-blue-700 transition flex items-center">
56
+ <i class="fas fa-trash-alt mr-2"></i> Clear
57
+ </button>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ </div>
62
+
63
+ <div class="container mx-auto px-4 mt-6">
64
+ <div class="bg-white rounded-xl shadow-lg overflow-hidden">
65
+ <div class="flex border-b">
66
+ <button class="tab-button active px-6 py-3 font-medium text-gray-700" data-tab="input">
67
+ <i class="fas fa-code mr-2"></i>Input
68
+ </button>
69
+ <button class="tab-button px-6 py-3 font-medium text-gray-500" data-tab="output">
70
+ <i class="fas fa-file-code mr-2"></i>Output
71
+ </button>
72
+ <button class="tab-button px-6 py-3 font-medium text-gray-500" data-tab="preview">
73
+ <i class="fas fa-eye mr-2"></i>Preview
74
+ </button>
75
+ </div>
76
+
77
+ <div class="editor-container flex">
78
+ <!-- Input Panel -->
79
+ <div id="input-panel" class="editor-panel w-1/2 border-r p-4">
80
+ <div class="mb-4">
81
+ <div class="flex justify-between items-center mb-2">
82
+ <h3 class="font-semibold text-gray-700"><i class="fas fa-html5 mr-2 text-orange-500"></i>HTML</h3>
83
+ <button class="copy-btn text-sm bg-gray-100 px-2 py-1 rounded" onclick="copyCode('html-editor')">
84
+ <i class="fas fa-copy mr-1"></i>Copy
85
+ </button>
86
+ </div>
87
+ <div class="relative">
88
+ <textarea id="html-editor" class="w-full h-64 p-3 font-mono text-sm border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Paste your HTML here...">&lt;div class="p-4 bg-blue-100 rounded-lg"&gt;
89
+ &lt;h1 class="text-2xl font-bold text-blue-800"&gt;Hello MAUI!&lt;/h1&gt;
90
+ &lt;p class="text-blue-600 mt-2"&gt;This will be converted to XAML&lt;/p&gt;
91
+ &lt;button class="mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700"&gt;Click Me&lt;/button&gt;
92
+ &lt;/div&gt;</textarea>
93
+ </div>
94
+ </div>
95
+ <div>
96
+ <div class="flex justify-between items-center mb-2">
97
+ <h3 class="font-semibold text-gray-700"><i class="fas fa-css3-alt mr-2 text-blue-500"></i>CSS</h3>
98
+ <button class="copy-btn text-sm bg-gray-100 px-2 py-1 rounded" onclick="copyCode('css-editor')">
99
+ <i class="fas fa-copy mr-1"></i>Copy
100
+ </button>
101
+ </div>
102
+ <div class="relative">
103
+ <textarea id="css-editor" class="w-full h-32 p-3 font-mono text-sm border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Paste your CSS here (optional)..."></textarea>
104
+ </div>
105
+ </div>
106
+ </div>
107
+
108
+ <!-- Output Panel -->
109
+ <div id="output-panel" class="editor-panel w-1/2 p-4 hidden">
110
+ <div class="flex justify-between items-center mb-2">
111
+ <h3 class="font-semibold text-gray-700"><i class="fab fa-microsoft mr-2 text-purple-500"></i>MAUI XAML Output</h3>
112
+ <button class="copy-btn text-sm bg-gray-100 px-2 py-1 rounded" onclick="copyCode('xaml-output')">
113
+ <i class="fas fa-copy mr-1"></i>Copy
114
+ </button>
115
+ </div>
116
+ <div class="relative">
117
+ <pre id="xaml-output" class="p-3 bg-gray-50 rounded-lg h-full overflow-auto"><code class="language-xml">Your XAML output will appear here...</code></pre>
118
+ </div>
119
+ </div>
120
+
121
+ <!-- Preview Panel -->
122
+ <div id="preview-panel" class="editor-panel w-1/2 p-4 hidden">
123
+ <div class="flex justify-between items-center mb-2">
124
+ <h3 class="font-semibold text-gray-700"><i class="fas fa-mobile-alt mr-2 text-green-500"></i>MAUI Preview</h3>
125
+ <div class="flex space-x-2">
126
+ <button id="ios-btn" class="text-sm bg-gray-100 px-2 py-1 rounded">
127
+ <i class="fab fa-apple mr-1"></i>iOS
128
+ </button>
129
+ <button id="android-btn" class="text-sm bg-gray-100 px-2 py-1 rounded">
130
+ <i class="fab fa-android mr-1"></i>Android
131
+ </button>
132
+ </div>
133
+ </div>
134
+ <div class="bg-gray-50 rounded-lg h-full overflow-auto flex items-center justify-center p-6">
135
+ <div id="preview-content" class="w-full max-w-md">
136
+ <div class="text-center text-gray-500">
137
+ <i class="fas fa-mobile-alt text-4xl mb-2"></i>
138
+ <p>Preview will appear here after conversion</p>
139
+ </div>
140
+ </div>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ </div>
145
+
146
+ <div class="mt-6 bg-white rounded-xl shadow-lg p-6">
147
+ <h2 class="text-xl font-semibold text-gray-800 mb-4"><i class="fas fa-lightbulb mr-2 text-yellow-500"></i>Conversion Tips</h2>
148
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
149
+ <div class="bg-blue-50 p-4 rounded-lg">
150
+ <h3 class="font-medium text-blue-800 mb-2"><i class="fas fa-check-circle mr-2"></i>Supported</h3>
151
+ <ul class="text-sm text-blue-700 space-y-1">
152
+ <li>Basic HTML elements (div, span, etc.)</li>
153
+ <li>Tailwind-like classes (p-4, bg-blue-500)</li>
154
+ <li>Common CSS properties</li>
155
+ <li>Flexbox layouts</li>
156
+ </ul>
157
+ </div>
158
+ <div class="bg-yellow-50 p-4 rounded-lg">
159
+ <h3 class="font-medium text-yellow-800 mb-2"><i class="fas fa-exclamation-triangle mr-2"></i>Limited</h3>
160
+ <ul class="text-sm text-yellow-700 space-y-1">
161
+ <li>Complex CSS selectors</li>
162
+ <li>CSS Grid (use StackLayout instead)</li>
163
+ <li>CSS animations</li>
164
+ <li>Pseudo-classes (:hover, etc.)</li>
165
+ </ul>
166
+ </div>
167
+ <div class="bg-purple-50 p-4 rounded-lg">
168
+ <h3 class="font-medium text-purple-800 mb-2"><i class="fas fa-info-circle mr-2"></i>Best Practices</h3>
169
+ <ul class="text-sm text-purple-700 space-y-1">
170
+ <li>Use simple, flat HTML structures</li>
171
+ <li>Prefer Tailwind-like utility classes</li>
172
+ <li>Test in MAUI after conversion</li>
173
+ <li>Adjust margins/padding as needed</li>
174
+ </ul>
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
179
+
180
+ <footer class="bg-gray-800 text-white py-6 mt-8">
181
+ <div class="container mx-auto px-4 text-center">
182
+ <p>HTML/CSS to MAUI XAML Converter Tool</p>
183
+ <p class="text-gray-400 text-sm mt-2">Convert web UI components to native MAUI XAML with ease</p>
184
+ </div>
185
+ </footer>
186
+
187
+ <script>
188
+ // Initialize syntax highlighting
189
+ hljs.highlightAll();
190
+
191
+ // Tab switching
192
+ const tabs = document.querySelectorAll('.tab-button');
193
+ const panels = {
194
+ 'input': document.getElementById('input-panel'),
195
+ 'output': document.getElementById('output-panel'),
196
+ 'preview': document.getElementById('preview-panel')
197
+ };
198
+
199
+ tabs.forEach(tab => {
200
+ tab.addEventListener('click', () => {
201
+ // Update tab styles
202
+ tabs.forEach(t => t.classList.remove('active', 'text-blue-600'));
203
+ tab.classList.add('active', 'text-blue-600');
204
+
205
+ // Show the selected panel
206
+ const tabName = tab.getAttribute('data-tab');
207
+ Object.values(panels).forEach(panel => panel.classList.add('hidden'));
208
+ panels[tabName].classList.remove('hidden');
209
+ });
210
+ });
211
+
212
+ // Copy code function
213
+ function copyCode(elementId) {
214
+ const element = document.getElementById(elementId);
215
+ element.select();
216
+ document.execCommand('copy');
217
+
218
+ // Show feedback
219
+ const originalText = element.nextElementSibling?.innerText;
220
+ if (element.nextElementSibling) {
221
+ element.nextElementSibling.innerHTML = '<i class="fas fa-check mr-1"></i>Copied!';
222
+ setTimeout(() => {
223
+ element.nextElementSibling.innerHTML = originalText;
224
+ }, 2000);
225
+ }
226
+ }
227
+
228
+ // Convert HTML/CSS to MAUI XAML
229
+ document.getElementById('convertBtn').addEventListener('click', () => {
230
+ const html = document.getElementById('html-editor').value;
231
+ const css = document.getElementById('css-editor').value;
232
+
233
+ // Simple conversion logic (this would be more complex in a real app)
234
+ let xaml = convertToXaml(html, css);
235
+
236
+ // Display the XAML output
237
+ const outputElement = document.getElementById('xaml-output');
238
+ outputElement.innerHTML = hljs.highlight(xaml, {language: 'xml'}).value;
239
+
240
+ // Update preview
241
+ updatePreview(html, css);
242
+
243
+ // Switch to output tab
244
+ tabs[1].click();
245
+ });
246
+
247
+ // Clear all inputs
248
+ document.getElementById('clearBtn').addEventListener('click', () => {
249
+ document.getElementById('html-editor').value = '';
250
+ document.getElementById('css-editor').value = '';
251
+ document.getElementById('xaml-output').innerHTML = '<code class="language-xml">Your XAML output will appear here...</code>';
252
+ document.getElementById('preview-content').innerHTML = `
253
+ <div class="text-center text-gray-500">
254
+ <i class="fas fa-mobile-alt text-4xl mb-2"></i>
255
+ <p>Preview will appear here after conversion</p>
256
+ </div>
257
+ `;
258
+ });
259
+
260
+ // Simple conversion function (simplified for demo)
261
+ function convertToXaml(html, css) {
262
+ // This is a simplified conversion - a real converter would be much more sophisticated
263
+ let xaml = `<?xml version="1.0" encoding="utf-8" ?>\n<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"\n xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"\n x:Class="YourNamespace.YourPage">\n\n`;
264
+
265
+ // Convert HTML to XAML
266
+ let convertedHtml = html
267
+ .replace(/class="/g, 'StyleClass="')
268
+ .replace(/<div/g, '<VerticalStackLayout')
269
+ .replace(/<\/div>/g, '</VerticalStackLayout>')
270
+ .replace(/<span/g, '<Label')
271
+ .replace(/<\/span>/g, '</Label>')
272
+ .replace(/<button/g, '<Button')
273
+ .replace(/<\/button>/g, '</Button>')
274
+ .replace(/<h1/g, '<Label FontSize="24" FontAttributes="Bold"')
275
+ .replace(/<h2/g, '<Label FontSize="20" FontAttributes="Bold"')
276
+ .replace(/<h3/g, '<Label FontSize="18" FontAttributes="Bold"')
277
+ .replace(/<p/g, '<Label')
278
+ .replace(/<\/p>/g, '</Label>');
279
+
280
+ // Add converted HTML to XAML
281
+ xaml += ` ${convertedHtml}\n\n`;
282
+
283
+ // Add resources for styles if CSS is provided
284
+ if (css.trim()) {
285
+ xaml += ` <ContentPage.Resources>\n <ResourceDictionary>\n`;
286
+
287
+ // Simple CSS to XAML style conversion (very basic)
288
+ const styles = css.split('}').filter(rule => rule.trim());
289
+ styles.forEach(rule => {
290
+ const [selector, properties] = rule.split('{');
291
+ if (selector && properties) {
292
+ const styleName = selector.trim().replace('.', '').replace(/\s+/g, '');
293
+ xaml += ` <Style x:Key="${styleName}" TargetType="View">\n`;
294
+
295
+ const props = properties.split(';').filter(p => p.trim());
296
+ props.forEach(prop => {
297
+ const [key, value] = prop.split(':').map(p => p.trim());
298
+ if (key && value) {
299
+ // Convert CSS properties to XAML
300
+ if (key === 'background-color' || key === 'background') {
301
+ xaml += ` <Setter Property="BackgroundColor" Value="${convertColor(value)}" />\n`;
302
+ } else if (key === 'color') {
303
+ xaml += ` <Setter Property="TextColor" Value="${convertColor(value)}" />\n`;
304
+ } else if (key === 'font-size') {
305
+ xaml += ` <Setter Property="FontSize" Value="${value.replace('px', '')}" />\n`;
306
+ } else if (key === 'font-weight') {
307
+ xaml += ` <Setter Property="FontAttributes" Value="${value === 'bold' ? 'Bold' : 'None'}" />\n`;
308
+ } else if (key === 'margin') {
309
+ xaml += ` <Setter Property="Margin" Value="${value.replace(' ', ',')}" />\n`;
310
+ } else if (key === 'padding') {
311
+ xaml += ` <Setter Property="Padding" Value="${value.replace(' ', ',')}" />\n`;
312
+ }
313
+ }
314
+ });
315
+
316
+ xaml += ` </Style>\n`;
317
+ }
318
+ });
319
+
320
+ xaml += ` </ResourceDictionary>\n </ContentPage.Resources>\n`;
321
+ }
322
+
323
+ xaml += `</ContentPage>`;
324
+
325
+ return xaml;
326
+ }
327
+
328
+ // Helper function to convert CSS colors to XAML colors
329
+ function convertColor(cssColor) {
330
+ if (cssColor.startsWith('#')) {
331
+ return cssColor;
332
+ } else if (cssColor.startsWith('rgb(')) {
333
+ return `#${cssColor.match(/\d+/g).map(v => parseInt(v).toString(16).padStart(2, '0')).join('')}`;
334
+ } else {
335
+ // Map common color names
336
+ const colorMap = {
337
+ 'red': '#FF0000',
338
+ 'blue': '#0000FF',
339
+ 'green': '#008000',
340
+ 'black': '#000000',
341
+ 'white': '#FFFFFF',
342
+ 'gray': '#808080',
343
+ 'yellow': '#FFFF00',
344
+ 'orange': '#FFA500',
345
+ 'purple': '#800080'
346
+ };
347
+ return colorMap[cssColor] || '#000000';
348
+ }
349
+ }
350
+
351
+ // Update preview panel
352
+ function updatePreview(html, css) {
353
+ const previewContent = document.getElementById('preview-content');
354
+
355
+ // Create a style element for the CSS
356
+ const style = document.createElement('style');
357
+ style.textContent = css;
358
+
359
+ // Create a container for the preview
360
+ previewContent.innerHTML = `
361
+ <div class="p-4">
362
+ ${html}
363
+ </div>
364
+ `;
365
+
366
+ // Add the style to the preview
367
+ previewContent.appendChild(style);
368
+ }
369
+
370
+ // Platform toggle buttons
371
+ document.getElementById('ios-btn').addEventListener('click', () => {
372
+ const preview = document.getElementById('preview-content');
373
+ preview.className = 'ios-preview bg-white rounded-3xl p-6 shadow-lg w-full max-w-xs mx-auto border-8 border-gray-800';
374
+ });
375
+
376
+ document.getElementById('android-btn').addEventListener('click', () => {
377
+ const preview = document.getElementById('preview-content');
378
+ preview.className = 'android-preview bg-white rounded-xl p-6 shadow-lg w-full max-w-xs mx-auto border-4 border-green-500';
379
+ });
380
+ </script>
381
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
382
+ </html>