-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Home.vue
367 lines (348 loc) · 9.69 KB
/
Home.vue
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<template>
<div class="document">
<div class="document-header">
<h2 style="padding: 0">Document</h2>
<blockquote>
<p>
Smart widget is a flexible and extensible content container component.
It includes header and body part, and widget body includes
<em>editbox</em>、<em>content</em>、<em>footer</em>. If you use with
grid, it also have a draggable and resizable grid layout, base on
<strong>Vue 3.x</strong> & <strong>vue-grid-layout@vue3</strong>.
</p>
</blockquote>
</div>
<section class="example-wrap">
<h3>Default Widget</h3>
<div class="example-bg">
<el-row type="flex" :gutter="32">
<el-col :offset="8" :span="8">
<smart-widget title="Widget Title">
<p>{{ placeholder }}</p>
</smart-widget>
</el-col>
</el-row>
</div>
<div class="example-code">
<div class="example-link">
<a :href="defaultUrl" target="_blank">
<el-tooltip
class="item"
effect="dark"
content="View On CodeSandBox"
placement="left"
>
<img :src="codesandboxIcon" alt="View On CodeSandbox" />
</el-tooltip>
</a>
</div>
<CodeBlock lang="html" :sourcecode="defaultWidget" />
</div>
</section>
<section class="example-wrap">
<h3>Advanced Widget</h3>
<blockquote>
<p>The widget extend useful display options.</p>
</blockquote>
<div class="example-bg">
<el-row type="flex" :gutter="32">
<el-col :span="8">
<smart-widget title="With additional fullscreen button" fullscreen>
<p>{{ placeholder }}</p>
</smart-widget>
</el-col>
<el-col :span="8">
<smart-widget title="Widget with Editbox & Footer">
<template #editbox>
<div class="widget-alert">
<div class="widget-alert__content">
<span class="el-alert__title">I am Editbox slot</span>
</div>
</div>
</template>
<p>I am content</p>
<template #footer>
<div class="widget-alert">
<div class="widget-alert__content">
<span class="el-alert__title">I am Footer slot</span>
</div>
</div>
</template>
</smart-widget>
</el-col>
<el-col :span="8">
<smart-widget title="Widget with custom toolbar">
<template #toolbar>
<div style="margin: 0 12px">
<button class="widget-button">Action</button>
</div>
</template>
<p>{{ placeholder }}</p>
</smart-widget>
</el-col>
</el-row>
</div>
<div class="example-code">
<div class="example-link">
<a :href="advanedUrl" target="_blank">
<el-tooltip
class="item"
effect="dark"
content="View On CodeSandBox"
placement="left"
>
<img :src="codesandboxIcon" alt="View On Jsfiddle" />
</el-tooltip>
</a>
</div>
<CodeBlock lang="html" :sourcecode="advanedWidget" />
</div>
</section>
<section class="example-wrap">
<h3>Widget With Grid</h3>
<blockquote>
<p>The widget is draggable & resizable. work with [vue-grid-layout].</p>
</blockquote>
<div class="example-bg">
<smart-widget-grid :layout="layout">
<template #0>
<smart-widget simple>
<div class="layout-center">
<h3>Simple Widget Without Header</h3>
</div>
</smart-widget>
</template>
<template #1>
<smart-widget title="Default Widget" sub-title="Drag on me">
<div class="layout-center">
<h3>Default Widget With Header</h3>
</div>
</smart-widget>
</template>
<template #2>
<smart-widget title="Full Screen" sub-title="Drag on me" fullscreen>
<div class="layout-center">
<h3>Make any widget full screen</h3>
</div>
</smart-widget>
</template>
</smart-widget-grid>
</div>
<div class="example-code">
<div class="example-link">
<a :href="gridUrl" target="_blank">
<el-tooltip
class="item"
effect="dark"
content="View On CodeSandBox"
placement="left"
>
<img :src="codesandboxIcon" alt="View On Jsfiddle" />
</el-tooltip>
</a>
</div>
<el-row>
<el-col :span="12">
<CodeBlock lang="html" :sourcecode="widgetWithGridJS" />
</el-col>
<div class="line"></div>
<el-col :span="12">
<CodeBlock lang="html" :sourcecode="widgetWithGridHTML" />
</el-col>
</el-row>
</div>
</section>
<section class="much-more">
For
<a
href="https://github.com/xiaoluoboding/vue-smart-widget/tree/next#usage"
target="_black"
>More</a
>
Details.
</section>
</div>
</template>
<script setup>
import CodeBlock from '@/components/CodeBlock.vue'
import codesandboxIcon from '@/assets/icons/codesandbox.svg'
import {
placeholder,
defaultWidget,
advanedWidget,
widgetWithGridHTML,
widgetWithGridJS
} from '@/constants/template'
const layout = [
{ x: 0, y: 0, w: 4, h: 4, i: '0' },
{ x: 4, y: 0, w: 4, h: 4, i: '1' },
{ x: 8, y: 0, w: 4, h: 4, i: '2' }
]
const defaultUrl =
'https://codesandbox.io/s/vuesmartwidget-default-2ghmi?autoresize=1&fontsize=14&hidenavigation=1&theme=dark&view=preview'
const advanedUrl =
'https://codesandbox.io/s/vuesmartwidget-advanced-8i7x0?autoresize=1&fontsize=14&hidenavigation=1&theme=dark&view=preview'
const gridUrl =
'https://codesandbox.io/s/vuesmartwidget-grid-dgf9d?autoresize=1&fontsize=14&hidenavigation=1&theme=dark&view=preview'
</script>
<style lang="scss">
.document {
margin: 1.25rem 0;
padding: 20px;
border: 1px solid #ebeef5;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
.document-header {
padding: 0 20px;
}
blockquote {
margin: 0;
padding: 0 1rem;
color: #6a737d;
border-left: 0.25em solid #dfe2e5;
}
.example-wrap {
padding: 0.5rem 1.5rem;
.example-bg {
padding: 1.5rem;
background: #f5f7fb;
border: 1px solid rgba(0, 40, 100, 0.12);
border-radius: 3px 3px 0 0;
}
.example-code {
position: relative;
background: #f8f8f8;
border: 1px solid rgba(0, 40, 100, 0.12);
border-top: none;
pre {
padding: 0 20px;
}
.line {
position: absolute;
left: 50%;
height: 100%;
width: 1px;
background: rgba(0, 40, 100, 0.12);
}
.example-link {
position: absolute;
top: 0;
right: 0;
font-size: 14px;
padding: 8px;
z-index: 2;
a {
text-decoration: none;
}
img {
height: 24px;
width: 24px;
}
}
}
}
.much-more {
background: #f5f7fb;
margin: 20px;
padding: 1.5rem 2.5rem;
text-align: center;
}
}
.tooltip {
display: block !important;
z-index: 10000;
.tooltip-inner {
background: #616161;
opacity: 0.9;
color: white;
font-size: 12px;
border-radius: 3px;
padding: 4px 10px;
}
.tooltip-arrow {
width: 0;
height: 0;
border-style: solid;
position: absolute;
margin: 6px;
border-color: #616161;
opacity: 0.9;
z-index: 1;
}
&[x-placement^='top'] {
margin-bottom: 5px;
.tooltip-arrow {
border-width: 5px 5px 0 5px;
border-left-color: transparent !important;
border-right-color: transparent !important;
border-bottom-color: transparent !important;
bottom: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
}
&[x-placement^='bottom'] {
margin-top: 5px;
.tooltip-arrow {
border-width: 0 5px 5px 5px;
border-left-color: transparent !important;
border-right-color: transparent !important;
border-top-color: transparent !important;
top: -5px;
left: calc(50% - 5px);
margin-top: 0;
margin-bottom: 0;
}
}
&[x-placement^='right'] {
margin-left: 5px;
.tooltip-arrow {
border-width: 5px 5px 5px 0;
border-left-color: transparent !important;
border-top-color: transparent !important;
border-bottom-color: transparent !important;
left: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
}
&[x-placement^='left'] {
margin-right: 5px;
.tooltip-arrow {
border-width: 5px 0 5px 5px;
border-top-color: transparent !important;
border-right-color: transparent !important;
border-bottom-color: transparent !important;
right: -5px;
top: calc(50% - 5px);
margin-left: 0;
margin-right: 0;
}
}
&[aria-hidden='true'] {
visibility: hidden;
opacity: 0;
transition: opacity 0.15s, visibility 0.15s;
}
&[aria-hidden='false'] {
visibility: visible;
opacity: 1;
transition: opacity 0.15s;
}
}
// widget alert
.widget-alert {
background-color: #f0f9eb;
color: #67c23a;
padding: 8px 16px;
}
.widget-button {
font-size: 12px;
border-radius: 3px;
color: #fff;
background-color: #409eff;
border-color: #409eff;
padding: 7px 15px;
}
</style>