@mixd-id/web-scaffold 0.1.230406049 → 0.1.230406050

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406049",
4
+ "version": "0.1.230406050",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -110,7 +110,7 @@ export default {
110
110
  return this.close(() => {
111
111
  window.setTimeout(() => {
112
112
  this.open(caller, context)
113
- }, 30)
113
+ }, 66)
114
114
  })
115
115
  }
116
116
 
@@ -129,86 +129,106 @@ export default {
129
129
 
130
130
  if(caller){
131
131
 
132
- this.$nextTick(() => {
133
- const rect = caller.getBoundingClientRect()
134
-
135
- let maxHeight
136
- let top, right, bottom, left
137
- let transformOrigin
138
-
139
- switch(this.position){
140
-
141
- case 'bottom-right':
142
- right = window.innerWidth - (Math.round(rect.x) + rect.width)
143
- top = Math.round(rect.y + rect.height + 8)
144
- maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
145
- transformOrigin = 'top right'
146
- break
147
-
148
- case 'top-left':
149
- maxHeight = Math.round(rect.top - 16)
150
- bottom = window.innerHeight - rect.top + 8
151
- left = Math.round(rect.x)
152
- transformOrigin = 'bottom left'
153
- break
154
-
155
- case 'top-right':
156
- maxHeight = Math.round(rect.top - 16)
157
- bottom = window.innerHeight - rect.top + 8
158
- right = window.innerWidth - (Math.round(rect.x) + rect.width)
159
- transformOrigin = 'bottom right'
160
- break
161
-
162
- default:
163
- left = Math.round(rect.x)
164
- top = Math.round(rect.y + rect.height + 8)
165
- //maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
166
- transformOrigin = 'top left'
167
- break
168
- }
169
-
170
- if(left){
171
- if(left + this.$refs.contextMenu.clientWidth >= (window.innerWidth - 16)){
172
- left = window.innerWidth - (this.$refs.contextMenu.clientWidth + 16)
173
-
174
- if(transformOrigin === 'top left'){
175
- transformOrigin = 'top right'
176
- }
132
+ const media = this.$util.getMediaPrefix(window.innerWidth)
133
+ let maxHeight, transformOrigin
134
+ let top, right, bottom, left
135
+ if([ '*', 'sm' ].includes(media)){
136
+ this.$nextTick(() => {
137
+ const rect = caller.getBoundingClientRect()
138
+
139
+ top = Math.round(rect.y + rect.height + 10)
140
+ transformOrigin = 'top left'
141
+ maxHeight = this.$refs.contextMenu.clientHeight > window.innerHeight * .8 ?
142
+ Math.round(window.innerHeight * .8) : this.$refs.contextMenu.clientHeight + 30
143
+
144
+ this.computedStyle = {
145
+ left: '10px',
146
+ right: '10px',
147
+ top: top ? top + 'px' : top,
148
+ maxHeight: maxHeight ? maxHeight + 'px' : maxHeight,
149
+ transformOrigin: transformOrigin
177
150
  }
178
- }
179
151
 
180
- if(top){
181
- if(top + this.$refs.contextMenu.clientHeight >= (window.innerHeight - 16)){
182
- top = window.innerHeight - (this.$refs.contextMenu.clientHeight + 16)
152
+ this.onOpen()
153
+ })
154
+ }
155
+ else{
156
+ this.$nextTick(() => {
157
+ const rect = caller.getBoundingClientRect()
158
+
159
+ switch(this.position){
160
+
161
+ case 'bottom-right':
162
+ right = window.innerWidth - (Math.round(rect.x) + rect.width)
163
+ top = Math.round(rect.y + rect.height + 8)
164
+ maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
165
+ transformOrigin = 'top right'
166
+ break
183
167
 
184
- if(transformOrigin === 'top left'){
168
+ case 'top-left':
169
+ maxHeight = Math.round(rect.top - 16)
170
+ bottom = window.innerHeight - rect.top + 8
171
+ left = Math.round(rect.x)
185
172
  transformOrigin = 'bottom left'
186
- }
187
- else if(transformOrigin === 'top right'){
173
+ break
174
+
175
+ case 'top-right':
176
+ maxHeight = Math.round(rect.top - 16)
177
+ bottom = window.innerHeight - rect.top + 8
178
+ right = window.innerWidth - (Math.round(rect.x) + rect.width)
188
179
  transformOrigin = 'bottom right'
189
- }
180
+ break
181
+
182
+ default:
183
+ left = Math.round(rect.x)
184
+ top = Math.round(rect.y + rect.height + 8)
185
+ //maxHeight = window.innerHeight - Math.round(rect.y + rect.height + 16)
186
+ transformOrigin = 'top left'
187
+ break
190
188
  }
191
189
 
192
- if(top < 0){
193
- top = 0
190
+ if(left){
191
+ if(left + this.$refs.contextMenu.clientWidth >= (window.innerWidth - 16)){
192
+ left = window.innerWidth - (this.$refs.contextMenu.clientWidth + 16)
193
+
194
+ if(transformOrigin === 'top left'){
195
+ transformOrigin = 'top right'
196
+ }
197
+ }
194
198
  }
195
- }
196
199
 
197
- maxHeight = this.$refs.contextMenu.clientHeight > window.innerHeight * .8 ?
198
- Math.round(window.innerHeight * .8) : this.$refs.contextMenu.clientHeight + 24
200
+ if(top){
201
+ if(top + this.$refs.contextMenu.clientHeight >= (window.innerHeight - 16)){
202
+ top = window.innerHeight - (this.$refs.contextMenu.clientHeight + 16)
203
+
204
+ if(transformOrigin === 'top left'){
205
+ transformOrigin = 'bottom left'
206
+ }
207
+ else if(transformOrigin === 'top right'){
208
+ transformOrigin = 'bottom right'
209
+ }
210
+ }
211
+
212
+ if(top < 0){
213
+ top = 0
214
+ }
215
+ }
199
216
 
200
- this.computedStyle = {
201
- left: left ? left + 'px' : left,
202
- right: right ? right + 'px' : right,
203
- top: top ? top + 'px' : top,
204
- bottom: bottom ? bottom + 'px' : bottom,
205
- maxHeight: maxHeight ? maxHeight + 'px' : maxHeight,
206
- transformOrigin: transformOrigin
207
- }
217
+ maxHeight = this.$refs.contextMenu.clientHeight > window.innerHeight * .8 ?
218
+ Math.round(window.innerHeight * .8) : this.$refs.contextMenu.clientHeight + 24
208
219
 
209
- this.onOpen()
210
- })
220
+ this.computedStyle = {
221
+ left: left ? left + 'px' : left,
222
+ right: right ? right + 'px' : right,
223
+ top: top ? top + 'px' : top,
224
+ bottom: bottom ? bottom + 'px' : bottom,
225
+ maxHeight: maxHeight ? maxHeight + 'px' : maxHeight,
226
+ transformOrigin: transformOrigin
227
+ }
211
228
 
229
+ this.onOpen()
230
+ })
231
+ }
212
232
  }
213
233
  else{
214
234
  console.error('Undefined caller for context menu')
@@ -230,11 +250,25 @@ export default {
230
250
  this.computedStyle = null
231
251
  this.isOpen = false
232
252
  this.$emit('dismiss')
233
- if(fn) fn()
253
+ if(typeof fn === 'function') fn()
234
254
  }
235
255
  this.$refs.contextMenu.removeEventListener('transitionend', transitionEnd)
236
256
  this.$refs.contextMenu.addEventListener('transitionend', transitionEnd)
237
257
  this.$refs.contextMenu.classList.remove(this.$style.active)
258
+ },
259
+
260
+ toggle(caller, context){
261
+
262
+ if(this.isOpen){
263
+ this.close()
264
+ }
265
+ else{
266
+ this.open(caller, context)
267
+ }
268
+ },
269
+
270
+ opened(){
271
+ return this.isOpen
238
272
  }
239
273
 
240
274
  }
@@ -250,12 +284,29 @@ export default {
250
284
  @apply border-[1px] border-text-50 shadow-2xl whitespace-nowrap;
251
285
  transition: all 150ms cubic-bezier(0.25, 1, 0.5, 1);
252
286
  opacity: 0;
253
- transform: scale(.3);
287
+ transform: translate3d(0, -10px, 0);
254
288
  }
255
289
 
256
290
  .active{
257
291
  opacity: 1;
258
- transform: scale(1);
292
+ transform: translate3d(0, 0, 0);
293
+ }
294
+
295
+ @media screen(md){
296
+
297
+ .contextMenu{
298
+ @apply fixed z-20 bg-base-50 backdrop-blur-md min-w-[150px] overflow-y-auto rounded-lg;
299
+ @apply border-[1px] border-text-50 shadow-2xl whitespace-nowrap;
300
+ transition: all 150ms cubic-bezier(0.25, 1, 0.5, 1);
301
+ opacity: 0;
302
+ transform: scale(.1);
303
+ }
304
+
305
+ .active{
306
+ opacity: 1;
307
+ transform: scale(1);
308
+ }
309
+
259
310
  }
260
311
 
261
- </style>
312
+ </style>
@@ -150,7 +150,7 @@ export default {
150
150
  <style module>
151
151
 
152
152
  .dropdown{
153
- @apply h-[var(--h-cp)];
153
+ @apply min-h-[var(--h-cp)];
154
154
  @apply flex items-center rounded-lg overflow-hidden cursor-pointer relative;
155
155
  @apply border-[1px] border-text-200 bg-base-50 hover:border-text-300;
156
156
  }
@@ -195,4 +195,4 @@ export default {
195
195
  @apply border-red-500
196
196
  }
197
197
 
198
- </style>
198
+ </style>
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <div :style="computedStyle" :class="computedClass">
3
+ <div :style="lineStyle"></div>
4
+ <div :style="lineStyle"></div>
5
+ </div>
6
+ </template>
7
+
8
+ <script>
9
+
10
+ export default {
11
+
12
+ props: {
13
+
14
+ width: {
15
+ type: String,
16
+ required: true
17
+ },
18
+
19
+ height: {
20
+ type: String,
21
+ required: true
22
+ },
23
+
24
+ color: String,
25
+
26
+ state: {
27
+ type: Number,
28
+ default: 1
29
+ }
30
+
31
+ },
32
+
33
+ computed: {
34
+
35
+ computedClass(){
36
+ return [
37
+ this.$style.comp,
38
+ this.state === 2 ? this.$style.active : ''
39
+ ]
40
+ .join(' ')
41
+ },
42
+
43
+ computedStyle(){
44
+ return {
45
+ height: parseInt(this.height) + 'px',
46
+ width: parseInt(this.width) + 'px'
47
+ }
48
+ },
49
+
50
+ lineStyle(){
51
+ return {
52
+ backgroundColor: this.color
53
+ }
54
+ }
55
+
56
+ }
57
+
58
+ }
59
+
60
+ </script>
61
+
62
+ <style module>
63
+
64
+ .comp{
65
+ @apply relative flex justify-center items-center;
66
+ }
67
+ .comp>*{
68
+ transition: all 400ms cubic-bezier(0.25, 1, 0.5, 1);
69
+ }
70
+
71
+ .comp>*:nth-child(1){
72
+ @apply absolute top-[3px] left-0 right-0 h-[2px] rounded-sm;
73
+ }
74
+ .comp>*:nth-child(2){
75
+ @apply absolute bottom-[3px] left-0 right-0 h-[2px] rounded-sm;
76
+ }
77
+
78
+ .comp.active>*:nth-child(1){
79
+ transform: rotate(45deg);
80
+ transform-origin: 50% 50%;
81
+ top: 50%;
82
+ }
83
+ .comp.active>*:nth-child(2){
84
+ transform: rotate(-45deg);
85
+ transform-origin: 50% 50%;
86
+ top: 50%;
87
+ }
88
+
89
+ </style>
@@ -2,7 +2,7 @@
2
2
  <div :class="$style.comp" v-if="configLoaded">
3
3
 
4
4
  <slot v-if="$slots.head" name="head"></slot>
5
- <div v-else class="flex flex-row items-center gap-4 px-6 md:px-0 p-4">
5
+ <div v-else class="flex flex-row items-center gap-4 px-6 md:px-0 py-4 md:py-0">
6
6
  <div class="flex-1 flex flex-row gap-4">
7
7
  <button type="button" ref="presetSelectorBtn"
8
8
  class="flex-1 md:flex-none flex flex-row gap-1 items-center text-left md:ml-2"
@@ -565,7 +565,7 @@ export default{
565
565
  <style module>
566
566
 
567
567
  .comp{
568
- @apply flex-1 flex flex-col;
568
+ @apply flex-1 flex flex-col md:gap-4;
569
569
  }
570
570
 
571
571
  .header{
package/src/index.js CHANGED
@@ -12,6 +12,14 @@ const uniqid = () => {
12
12
  return _UNIQID++
13
13
  }
14
14
 
15
+ const mediaBreakpoints = {
16
+ 640: 'sm',
17
+ 768: 'md',
18
+ 1024: 'lg',
19
+ 1280: 'xl',
20
+ 1536: '2xl',
21
+ }
22
+
15
23
  const download = (url, as) => {
16
24
  const downloader = document.createElement('a')
17
25
  downloader.setAttribute('href', url)
@@ -181,6 +189,18 @@ const util = {
181
189
  break
182
190
  }
183
191
  })
192
+ },
193
+
194
+ getMediaPrefix(width){
195
+
196
+ let prefix = '*'
197
+ for(let breakpoint in mediaBreakpoints){
198
+ if(width > breakpoint){
199
+ prefix = mediaBreakpoints[breakpoint]
200
+ }
201
+ }
202
+
203
+ return prefix
184
204
  }
185
205
 
186
206
  }
@@ -225,6 +245,7 @@ export default{
225
245
  app.component('Ahref', defineAsyncComponent(() => import("./components/Ahref.vue")))
226
246
  app.component('Switch', defineAsyncComponent(() => import("./components/Switch.vue")))
227
247
  app.component('IconMenu', defineAsyncComponent(() => import("./components/IconMenu.vue")))
248
+ app.component('IconMenu2', defineAsyncComponent(() => import("./components/IconMenu2.vue")))
228
249
  app.component('IconPlus', defineAsyncComponent(() => import("./components/IconPlus.vue")))
229
250
  app.component('Image', defineAsyncComponent(() => import("./components/Image.vue")))
230
251
  app.component('Image360', defineAsyncComponent(() => import("./components/Image360.vue")))
@@ -94,7 +94,7 @@ const plugin = Plugin(function({ addBase, config, theme }) {
94
94
  'fontSize': '16px',
95
95
  },
96
96
 
97
- "input, input[type='text'], input[type='number'], textarea": { fontSize:"16px" }
97
+ "input, input[type='text'], input[type='number'], textarea, select, option": { fontSize:"16px" }
98
98
  },
99
99
 
100
100
  '::-webkit-scrollbar': {