hrmkmdtv commited on
Commit
01236e0
·
verified ·
1 Parent(s): aa4e3c0

create for me a app where i can create on a mockup desktop dimension or mock phone screen dimension grid layout builder. Allow for the adding major colums into the grid 1 or more, then allow for row sectons to be added to each column desired by an add row button. the rows added in one column should not effect the other columns, also make all row lines and major column lines dragable and resizeable. ultimately allowing you to create ui layouts - Initial Deployment

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +279 -18
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Layout Builder
3
- emoji: 🐠
4
- colorFrom: purple
5
- colorTo: gray
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: layout-builder
3
+ emoji: 🐳
4
+ colorFrom: red
5
+ colorTo: red
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,280 @@
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>Grid Layout Builder</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
9
+ <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
11
+ <script src="https://unpkg.com/feather-icons"></script>
12
+ <script src="https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js"></script>
13
+ <style>
14
+ .grid-container {
15
+ touch-action: none;
16
+ position: relative;
17
+ }
18
+ .column {
19
+ position: relative;
20
+ min-width: 50px;
21
+ min-height: 100%;
22
+ }
23
+ .column-resize-handle {
24
+ position: absolute;
25
+ top: 0;
26
+ right: -5px;
27
+ width: 10px;
28
+ height: 100%;
29
+ cursor: col-resize;
30
+ background-color: rgba(59, 130, 246, 0.3);
31
+ z-index: 10;
32
+ }
33
+ .row-resize-handle {
34
+ position: absolute;
35
+ left: 0;
36
+ bottom: -5px;
37
+ width: 100%;
38
+ height: 10px;
39
+ cursor: row-resize;
40
+ background-color: rgba(59, 130, 246, 0.3);
41
+ z-index: 10;
42
+ }
43
+ .row {
44
+ position: relative;
45
+ min-height: 30px;
46
+ background-color: rgba(249, 250, 251, 0.8);
47
+ border: 1px dashed #d1d5db;
48
+ }
49
+ .device-frame {
50
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
51
+ background-color: white;
52
+ overflow: hidden;
53
+ }
54
+ .desktop-frame {
55
+ width: 1200px;
56
+ height: 800px;
57
+ border-radius: 12px;
58
+ }
59
+ .mobile-frame {
60
+ width: 375px;
61
+ height: 667px;
62
+ border-radius: 40px;
63
+ border: 12px solid #1f2937;
64
+ }
65
+ </style>
66
+ </head>
67
+ <body class="bg-gray-100 min-h-screen">
68
+ <div class="container mx-auto p-6">
69
+ <header class="mb-8 text-center">
70
+ <h1 class="text-3xl font-bold text-gray-800 mb-2">Grid Layout Builder</h1>
71
+ <p class="text-gray-600">Create responsive UI layouts with drag-and-drop columns and rows</p>
72
+ </header>
73
+
74
+ <div class="bg-white rounded-xl shadow-lg p-6 mb-6">
75
+ <div class="flex flex-wrap gap-4 justify-center mb-6">
76
+ <button id="desktop-mode" class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-colors flex items-center gap-2">
77
+ <i data-feather="monitor"></i> Desktop Mode
78
+ </button>
79
+ <button id="mobile-mode" class="px-4 py-2 bg-purple-500 text-white rounded-lg hover:bg-purple-600 transition-colors flex items-center gap-2">
80
+ <i data-feather="smartphone"></i> Mobile Mode
81
+ </button>
82
+ <button id="add-column" class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 transition-colors flex items-center gap-2">
83
+ <i data-feather="plus"></i> Add Column
84
+ </button>
85
+ <button id="reset-grid" class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-2">
86
+ <i data-feather="trash-2"></i> Reset Grid
87
+ </button>
88
+ </div>
89
+
90
+ <div id="device-container" class="flex justify-center">
91
+ <div id="desktop-frame" class="device-frame desktop-frame">
92
+ <div id="grid-container" class="grid-container w-full h-full flex"></div>
93
+ </div>
94
+ </div>
95
+ </div>
96
+
97
+ <div class="bg-white rounded-xl shadow-lg p-6">
98
+ <h2 class="text-xl font-semibold mb-4">Instructions</h2>
99
+ <ul class="list-disc list-inside space-y-2 text-gray-700">
100
+ <li>Select Desktop or Mobile mode to change the canvas size</li>
101
+ <li>Click "Add Column" to create new layout columns</li>
102
+ <li>Click the "+" button on any column to add rows</li>
103
+ <li>Drag column edges to resize columns</li>
104
+ <li>Drag row edges to resize rows</li>
105
+ <li>Create your perfect UI layout structure</li>
106
+ </ul>
107
+ </div>
108
+ </div>
109
+
110
+ <script>
111
+ document.addEventListener('DOMContentLoaded', function() {
112
+ feather.replace();
113
+ AOS.init();
114
+
115
+ const gridContainer = document.getElementById('grid-container');
116
+ const desktopModeBtn = document.getElementById('desktop-mode');
117
+ const mobileModeBtn = document.getElementById('mobile-mode');
118
+ const addColumnBtn = document.getElementById('add-column');
119
+ const resetGridBtn = document.getElementById('reset-grid');
120
+ const deviceContainer = document.getElementById('device-container');
121
+ const desktopFrame = document.getElementById('desktop-frame');
122
+
123
+ let currentDeviceMode = 'desktop';
124
+ let columnCount = 0;
125
+
126
+ // Set up device mode switching
127
+ desktopModeBtn.addEventListener('click', () => switchDeviceMode('desktop'));
128
+ mobileModeBtn.addEventListener('click', () => switchDeviceMode('mobile'));
129
+
130
+ function switchDeviceMode(mode) {
131
+ currentDeviceMode = mode;
132
+ deviceContainer.innerHTML = '';
133
+
134
+ if (mode === 'desktop') {
135
+ const frame = desktopFrame.cloneNode(true);
136
+ deviceContainer.appendChild(frame);
137
+ gridContainer = frame.querySelector('#grid-container');
138
+ } else {
139
+ const mobileFrame = document.createElement('div');
140
+ mobileFrame.className = 'device-frame mobile-frame';
141
+ mobileFrame.innerHTML = '<div id="grid-container" class="grid-container w-full h-full flex"></div>';
142
+ deviceContainer.appendChild(mobileFrame);
143
+ gridContainer = mobileFrame.querySelector('#grid-container');
144
+ }
145
+
146
+ // Reinitialize interact.js for the new container
147
+ initInteract();
148
+ }
149
+
150
+ // Add column functionality
151
+ addColumnBtn.addEventListener('click', addColumn);
152
+
153
+ function addColumn() {
154
+ columnCount++;
155
+ const column = document.createElement('div');
156
+ column.className = 'column bg-gray-50 border border-gray-200 relative';
157
+ column.id = `column-${columnCount}`;
158
+
159
+ // Add column resize handle
160
+ const resizeHandle = document.createElement('div');
161
+ resizeHandle.className = 'column-resize-handle';
162
+ column.appendChild(resizeHandle);
163
+
164
+ // Add row container
165
+ const rowContainer = document.createElement('div');
166
+ rowContainer.className = 'row-container h-full';
167
+ column.appendChild(rowContainer);
168
+
169
+ // Add add row button
170
+ const addRowBtn = document.createElement('button');
171
+ addRowBtn.className = 'absolute top-2 right-2 p-1 bg-blue-500 text-white rounded-full hover:bg-blue-600 transition-colors z-20';
172
+ addRowBtn.innerHTML = '<i data-feather="plus" width="16" height="16"></i>';
173
+ addRowBtn.addEventListener('click', () => addRow(column.id));
174
+ column.appendChild(addRowBtn);
175
+
176
+ gridContainer.appendChild(column);
177
+ feather.replace();
178
+
179
+ // Make column resizable
180
+ initColumnResize(column);
181
+ }
182
+
183
+ function addRow(columnId) {
184
+ const column = document.getElementById(columnId);
185
+ const rowContainer = column.querySelector('.row-container');
186
+
187
+ const row = document.createElement('div');
188
+ row.className = 'row mb-2 rounded';
189
+
190
+ // Add row resize handle
191
+ const resizeHandle = document.createElement('div');
192
+ resizeHandle.className = 'row-resize-handle';
193
+ row.appendChild(resizeHandle);
194
+
195
+ rowContainer.appendChild(row);
196
+
197
+ // Make row resizable
198
+ initRowResize(row);
199
+ }
200
+
201
+ // Reset grid functionality
202
+ resetGridBtn.addEventListener('click', () => {
203
+ gridContainer.innerHTML = '';
204
+ columnCount = 0;
205
+ });
206
+
207
+ // Initialize interact.js for resizing
208
+ function initInteract() {
209
+ document.querySelectorAll('.column').forEach(initColumnResize);
210
+ document.querySelectorAll('.row').forEach(initRowResize);
211
+ }
212
+
213
+ function initColumnResize(column) {
214
+ interact(column).resizable({
215
+ edges: { right: true },
216
+ listeners: {
217
+ move: function (event) {
218
+ let target = event.target;
219
+ let x = (parseFloat(target.getAttribute('data-x')) || 0);
220
+
221
+ // Update the element's style
222
+ target.style.width = event.rect.width + 'px';
223
+
224
+ // Translate when resizing from top or left edges
225
+ x += event.deltaRect.left;
226
+
227
+ target.style.transform = 'translate(' + x + 'px)';
228
+
229
+ target.setAttribute('data-x', x);
230
+ }
231
+ },
232
+ modifiers: [
233
+ interact.modifiers.restrictEdges({
234
+ outer: 'parent'
235
+ }),
236
+ interact.modifiers.restrictSize({
237
+ min: { width: 50 }
238
+ })
239
+ ],
240
+ inertia: true
241
+ });
242
+ }
243
+
244
+ function initRowResize(row) {
245
+ interact(row).resizable({
246
+ edges: { bottom: true },
247
+ listeners: {
248
+ move: function (event) {
249
+ let target = event.target;
250
+ let y = (parseFloat(target.getAttribute('data-y')) || 0);
251
+
252
+ // Update the element's style
253
+ target.style.height = event.rect.height + 'px';
254
+
255
+ // Translate when resizing from top or left edges
256
+ y += event.deltaRect.top;
257
+
258
+ target.style.transform = 'translate(' + y + 'px)';
259
+
260
+ target.setAttribute('data-y', y);
261
+ }
262
+ },
263
+ modifiers: [
264
+ interact.modifiers.restrictEdges({
265
+ outer: 'parent'
266
+ }),
267
+ interact.modifiers.restrictSize({
268
+ min: { height: 30 }
269
+ })
270
+ ],
271
+ inertia: true
272
+ });
273
+ }
274
+
275
+ // Initialize with one column
276
+ addColumn();
277
+ });
278
+ </script>
279
+ </body>
280
  </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ create for me a app where i can create on a mockup desktop dimension or mock phone screen dimension grid layout builder. Allow for the adding major colums into the grid 1 or more, then allow for row sectons to be added to each column desired by an add row button. the rows added in one column should not effect the other columns, also make all row lines and major column lines dragable and resizeable. ultimately allowing you to create ui layouts