@mixd-id/web-scaffold 0.1.2301231339 → 0.1.2301231342

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.2301231339",
4
+ "version": "0.1.2301231342",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -141,13 +141,13 @@ export default{
141
141
  var img = new Image()
142
142
  img.addEventListener('load', () => {
143
143
  this.loaded = true
144
- //this.actualSrc = img.src
145
- //this.loading = false
144
+ this.actualSrc = img.src
145
+ this.loading = false
146
146
  })
147
147
  img.addEventListener('error', () => {
148
148
  this.loaded = true
149
149
  this.actualSrc = this.defaultSrc
150
- //this.loading = false
150
+ this.loading = false
151
151
  })
152
152
  img.src = src[screens[b]]
153
153
  this.loading = true
@@ -120,7 +120,7 @@ export default{
120
120
  },
121
121
 
122
122
  onKeyUp(e){
123
- if(e.keyCode === 13 && this.$refs.input.value.length > 0){
123
+ if(e.keyCode === 13){
124
124
  this.$emit('submit')
125
125
  }
126
126
  else if(e.keyCode === 27 && this.clearable){
package/src/index.js CHANGED
@@ -26,10 +26,112 @@ const download = (url, as) => {
26
26
  }, 100)
27
27
  }
28
28
 
29
+ let preloads = []
30
+
31
+ const preload = (params) => {
32
+
33
+ if(!params) return
34
+
35
+ if(typeof params === 'string'){
36
+ params.split(',').forEach((param) => {
37
+ let media, href
38
+ if(param.startsWith('sm:')){
39
+ media = 'sm'
40
+ href = param.substring(param.indexOf(':') + 1)
41
+ }
42
+ else if(param.startsWith('md:')){
43
+ media = 'md'
44
+ href = param.substring(param.indexOf(':') + 1)
45
+ }
46
+ else if(param.startsWith('lg:')){
47
+ media = 'lg'
48
+ href = param.substring(param.indexOf(':') + 1)
49
+ }
50
+ else if(param.startsWith('xl:')){
51
+ media = 'xl'
52
+ href = param.substring(param.indexOf(':') + 1)
53
+ }
54
+ else if(param.startsWith('2xl:')){
55
+ media = '2xl'
56
+ href = param.substring(param.indexOf(':') + 1)
57
+ }
58
+ else{
59
+ media = ''
60
+ href = param
61
+ }
62
+
63
+ switch(media){
64
+ case 'sm':
65
+ media = "(min-width: 640px)"
66
+ break
67
+ case 'md':
68
+ media = "(min-width: 768px)"
69
+ break
70
+ case 'lg':
71
+ media = "(min-width: 1024px)"
72
+ break
73
+ case 'xl':
74
+ media = "(min-width: 1280px)"
75
+ break
76
+ case '2xl':
77
+ media = "(min-width: 1536px)"
78
+ break
79
+ }
80
+
81
+ const ext = href.split('.').slice(-1).pop()
82
+ let as
83
+ switch(ext){
84
+ case 'png':
85
+ case 'jpg':
86
+ case 'jpeg':
87
+ case 'webp':
88
+ case 'gif':
89
+ as = 'image'
90
+ break
91
+ }
92
+
93
+ if(href && as){
94
+ const preloadObj = {
95
+ href,
96
+ media,
97
+ as
98
+ }
99
+
100
+ preloads.push(preloadObj)
101
+ }
102
+ })
103
+ }
104
+ else{
105
+ if(Array.isArray(params)){
106
+ preloads.push(...params)
107
+ }
108
+ else{
109
+ preloads.push(params)
110
+ }
111
+ }
112
+ }
113
+
114
+ const popPreloads = () => {
115
+
116
+ let link = ''
117
+
118
+ preloads.forEach((obj) => {
119
+ let str = `<link rel="preload" href="${obj.href}" as="${obj.as}"`
120
+ if(obj.media)
121
+ str += ` media="${obj.media}"`
122
+ str += ' />'
123
+
124
+ link += str
125
+ })
126
+
127
+ preloads = []
128
+
129
+ return link
130
+ }
131
+
29
132
  export default{
30
133
 
31
134
  install: (app, options) => {
32
- //console.log('installing webfxfy-vue...')
33
135
 
34
136
  let isMobile = ref(calculateIsMobile())
35
137
 
@@ -44,6 +146,8 @@ export default{
44
146
  app.config.globalProperties.uniqid = uniqid
45
147
  app.config.globalProperties.isMobile = isMobile
46
148
  app.config.globalProperties.$download = download
149
+ app.config.globalProperties.$preload = preload
150
+ app.config.globalProperties.$popPreloads = popPreloads
47
151
 
48
152
  app.component('Alert', defineAsyncComponent(() => import("./components/Alert.vue")))
49
153
  app.component('Button', defineAsyncComponent(() => import("./components/Button.vue")))