its_ui_vite 0.0.1

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/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # UI Kit для Интелектуальной Транспортной Системы (ИТС) для Vue3
2
+
3
+ ## components props
4
+
5
+ * CButton
6
+
7
+ ```
8
+ {
9
+ size: 'lg' | 'md' | 'sm',
10
+ variant: 'tonal' | 'outlined' | 'text',
11
+ color: 'green' | 'black',
12
+ disabled: Boolean,
13
+ }
14
+ ```
15
+
16
+ * CTabs
17
+
18
+ ```
19
+ {
20
+ tabs: Record<string, any> & { id: any, text: string }[],
21
+ activeId: any,
22
+ }
23
+ ```
24
+
25
+ * CInput
26
+
27
+ ```
28
+ {
29
+ <!-- реактивна -->
30
+ status: 'static' | 'focus' | 'error' | 'success'
31
+
32
+ width: string,
33
+ type: string,
34
+ name: string,
35
+ placeholder: string,
36
+ value: string,
37
+ }
38
+ ```
39
+
40
+ * CCheckbox
41
+
42
+ ```
43
+ {
44
+ variant: 'checkbox' | 'radio' | 'toggle'
45
+ <!-- по сути 'sm' используется только в CSelect -->
46
+ size: 'lg' | 'sm',
47
+ checked: Boolean,
48
+ disabled: Boolean,
49
+ text: string,
50
+ name:string,
51
+ value: string,
52
+ }
53
+ ```
54
+
55
+ * CSelect
56
+
57
+ ```
58
+ {
59
+ options: Array,
60
+ variant: 'default' | 'multiple',
61
+ placeholder: string,
62
+ }
63
+ ```
64
+
65
+ * CTooltip
66
+
67
+ ```
68
+ {
69
+ position: 'top' | 'bottom',
70
+ interactive: Boolean,
71
+ }
72
+ ```
73
+
74
+ * CPopup
75
+
76
+ ```
77
+ {
78
+ <!-- нет props -->
79
+ }
80
+ ```
81
+
82
+ * CAlert
83
+
84
+ ```
85
+ {
86
+ liveTime: number,
87
+ variant: 'notification' | 'success' | 'error',
88
+ width: string,
89
+ text: string,
90
+ }
91
+ ```
92
+
93
+ ## Docker
94
+
95
+ * Build container:
96
+ ```shell
97
+ docker build -t its-ui-kit_vue-host .
98
+ ```
99
+
100
+ * Run container:
101
+ ```shell
102
+ docker run -d -p 3000:3000 --env-file .env its-ui-kit_vue-host
103
+ ```
104
+
105
+ Откройте в браузере: http://localhost:3000
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "its_ui_vite",
3
+ "version": "0.0.1",
4
+ "main": "./src/libIndex.js",
5
+ "module": "./src/libIndex.js",
6
+ "files": [
7
+ "src"
8
+ ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/LopanovCo/its_ui_kit-3"
12
+ },
13
+ "publishConfig": {
14
+ "@lopanovco:registry": "https://npm.pkg.github.com"
15
+ },
16
+ "scripts": {
17
+ "dev": "vite",
18
+ "build": "vite build",
19
+ "preview": "vite preview"
20
+ },
21
+ "dependencies": {
22
+ "compression": "^1.7.4",
23
+ "dotenv": "^16.3.1",
24
+ "express": "4.18.2",
25
+ "vue": "^3.3.11",
26
+ "vue3-perfect-scrollbar": "^2.0.0",
27
+ "yargs": "^17.7.2"
28
+ },
29
+ "devDependencies": {
30
+ "@vitejs/plugin-vue": "^4.6.2",
31
+ "sass": "^1.69.5",
32
+ "vite": "^5.0.8"
33
+ }
34
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @param {String} componentName componentName
3
+ * @param {String} propName propName
4
+ * @param {String[]} validValues
5
+ */
6
+ export function getPropValidator(componentName, propName, validValues) {
7
+ return (value) => {
8
+ const isValid = validValues.includes(value)
9
+ if (isValid) return true
10
+
11
+ throw new Error(`${componentName}: \n invalid prop: ${propName} "${value}". Valid values: ${validValues}`)
12
+ }
13
+ }
14
+
15
+ /**
16
+ * @description есть баг с двойны срабатыванием click event (проблема со stackoverflow: https://stackoverflow.com/questions/10819699/simple-click-on-labels-makes-double-click)
17
+ * @description по сути это просто debounce
18
+ */
19
+ export function fixDblEvent(foo) {
20
+ let timer
21
+
22
+ return (...arg) => {
23
+ clearTimeout(timer)
24
+ timer = setTimeout(() => {
25
+ console.log('fixDblEvent');
26
+ foo(...arg)
27
+ }, 10)
28
+ }
29
+ }
@@ -0,0 +1,40 @@
1
+ :root {
2
+ // green
3
+ --green-light: #0FC176;
4
+ --green-medium: #26776F;
5
+ --green-dark: #02423C;
6
+ --green-low: #123234;
7
+ --green-bg: #152829;
8
+
9
+ // red
10
+ --red: #EA1246;
11
+ --red-medium: #920023;
12
+ --red-dark: #490012;
13
+
14
+ // orange
15
+ --orange: #E2670D;
16
+ --orange-medium: #7D3500;
17
+ --orange-dark: #471F02;
18
+
19
+ // black
20
+ --black: #000;
21
+ --black-light: #252525;
22
+ --black-dark: #123234;
23
+ --shadow: 0px 4px 12px rgba(0, 0, 0, 0.6);
24
+
25
+ // grey
26
+ --grey: #B5B5B5;
27
+ --grey-light: #ECEAEA;
28
+ --grey-dark: #505050;
29
+
30
+ // dis
31
+ --dis-text: #324F4A;
32
+
33
+ --white: #fff;
34
+ --yellow:#E9C400;
35
+ --scroll: rgba(55, 120, 113, 0.45);
36
+ --hover: #0A8A54;
37
+ --disable: #084A36;
38
+
39
+ --transition: .2s;
40
+ }
@@ -0,0 +1,230 @@
1
+ <template>
2
+ <div
3
+ v-if="isShow"
4
+ ref="root"
5
+ :style="`--width: ${width}; --transition-fade: ${timeFade}ms`"
6
+ :class="[classes.root, variant, {fade: isFade}]"
7
+ >
8
+ <div class="c-alert__icon">
9
+ <CIcon :iconId="iconId" />
10
+ </div>
11
+
12
+ <div class="c-alert__content">
13
+ <slot>{{ text }}</slot>
14
+ </div>
15
+
16
+ <div @click="close" class="c-alert__close">
17
+ <CIcon iconId="close" />
18
+ </div>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ import { getPropValidator } from '../assets/js/helpers'
24
+ import CIcon from './CIcons/index.vue'
25
+
26
+ export default {
27
+ data() {
28
+ return {
29
+ isLockLiveTime: false,
30
+ isShow: true,
31
+ isFade: false,
32
+ timeFade: 5000,
33
+
34
+ timers: {
35
+ live: undefined,
36
+ fade: undefined,
37
+ },
38
+
39
+ classes: {
40
+ root: 'c-alert',
41
+ },
42
+ }
43
+ },
44
+
45
+ props: {
46
+ liveTime: {
47
+ type: Number,
48
+
49
+ default: 10000,
50
+ },
51
+
52
+ variant: {
53
+ type: String,
54
+
55
+ default: 'notification',
56
+ validator: getPropValidator('CAlert', 'variant', ['notification', 'success', 'error']),
57
+ },
58
+
59
+ width: {
60
+ type: String,
61
+
62
+ default: 'auto',
63
+ },
64
+
65
+ text: {
66
+ type: String,
67
+
68
+ default: '',
69
+ }
70
+ },
71
+
72
+ methods: {
73
+ close() {
74
+ this.isShow = false
75
+ this.isLockLiveTime = true
76
+ },
77
+
78
+ updateLiveTime() {
79
+ if (!this.isShow) return
80
+
81
+ this.isShow = true
82
+ this.isFade = false
83
+
84
+ clearTimeout(this.timers.fade)
85
+ clearTimeout(this.timers.live)
86
+
87
+ if (this.isLockLiveTime) return
88
+
89
+ this.timers.fade = setTimeout(() => {
90
+ this.isFade = true
91
+ }, Math.max(this.liveTime - this.timeFade, 0));
92
+
93
+ this.timers.live = setTimeout(() => {
94
+ this.isShow = false
95
+ }, this.liveTime);
96
+ },
97
+
98
+ // слушатели
99
+ /**
100
+ * @param {MouseEvent} evt
101
+ */
102
+ handleMouseover(evt){
103
+ const tooltipTarget = evt.target.closest(`.${this.classes.root}`)
104
+
105
+ if (tooltipTarget !== this.$refs.root) return
106
+
107
+ this.isLockLiveTime = true
108
+ evt.stopPropagation()
109
+ this.updateLiveTime()
110
+ },
111
+
112
+ /**
113
+ * @param {MouseEvent} evt
114
+ */
115
+ handleMouseout(evt) {
116
+ const tooltipTarget = evt.target.closest(`.${this.classes.root}`)
117
+
118
+ if (tooltipTarget !== this.$refs.root) return
119
+
120
+ this.isLockLiveTime = false
121
+ this.updateLiveTime()
122
+ },
123
+
124
+ addListener() {
125
+ document.body.addEventListener('mouseover', this.handleMouseover)
126
+ document.body.addEventListener('mouseout', this.handleMouseout)
127
+ },
128
+
129
+ removeListener() {
130
+ document.body.removeEventListener('mouseover', this.handleMouseover)
131
+ document.body.removeEventListener('mouseout', this.handleMouseout)
132
+ },
133
+ },
134
+
135
+ mounted() {
136
+ this.addListener()
137
+ },
138
+
139
+ beforeDestroy() {
140
+ this.removeListener()
141
+ },
142
+
143
+ watch: {
144
+ $props: {
145
+ deep: true,
146
+ immediate: true,
147
+
148
+ handler(newWal) {
149
+ this.updateLiveTime()
150
+ },
151
+ },
152
+ },
153
+
154
+ computed: {
155
+ iconId() {
156
+ const iconsIds = {
157
+ notification: 'bell',
158
+ success: 'success',
159
+ error: 'error',
160
+ }
161
+
162
+ return iconsIds[this.variant]
163
+ },
164
+ },
165
+
166
+ components: {
167
+ CIcon,
168
+ },
169
+ }
170
+
171
+ </script>
172
+
173
+ <style lang="scss">
174
+ .c-alert {
175
+ width: var(--width, auto);
176
+
177
+ display: flex;
178
+ align-items: center;
179
+
180
+ padding: 12px 25px;
181
+
182
+ border-radius: 8px;
183
+
184
+ background: var(--green-bg);
185
+ box-shadow: var(--shadow);
186
+
187
+ transition: var(--transition);
188
+
189
+ // prop.variant
190
+ &.notification {
191
+ border: 1px solid var(--orange-dark);
192
+
193
+ color: var(--orange);
194
+ }
195
+
196
+ &.success {
197
+ border: 1px solid var(--green-dark);
198
+
199
+ color: var(--green-light);
200
+ }
201
+
202
+ &.error {
203
+ border: 1px solid var(--red-dark);
204
+
205
+ color: var(--red);
206
+ }
207
+ // ./prop.variant
208
+
209
+ &.fade{
210
+ opacity: 0;
211
+ transform: skewX(10%);
212
+
213
+ transition: var(--transition-fade);
214
+ }
215
+
216
+ &__icon {
217
+ margin-right: 15px;
218
+ }
219
+
220
+ &__close {
221
+ margin-left: 25px;
222
+
223
+ cursor: pointer;
224
+
225
+ svg:hover {
226
+ opacity: 0.6;
227
+ }
228
+ }
229
+ }
230
+ </style>
@@ -0,0 +1,149 @@
1
+ <template>
2
+ <button :class="['c-btn', size, variant, color]" :disabled="disabled">
3
+ <div class="c-btn__container">
4
+ <slot></slot>
5
+ </div>
6
+ </button>
7
+ </template>
8
+
9
+ <script>
10
+ import { getPropValidator } from '../assets/js/helpers.js'
11
+
12
+ export default {
13
+ props: {
14
+ size: {
15
+ type: String,
16
+
17
+ default: "lg",
18
+ validator: getPropValidator('CButton', 'size', ['lg', 'md', 'sm']),
19
+ },
20
+
21
+ variant: {
22
+ type: String,
23
+
24
+ default: "tonal",
25
+ validator: getPropValidator('CButton', 'variant', ['tonal', 'outlined', 'text']),
26
+ },
27
+
28
+ disabled: {
29
+ type: Boolean,
30
+
31
+ default: false,
32
+ },
33
+
34
+ color: {
35
+ type: String,
36
+
37
+ default: "green",
38
+ validator: getPropValidator('CButton', 'color', ['green', 'black']),
39
+ },
40
+ },
41
+ }
42
+ </script>
43
+
44
+ <style lang="scss">
45
+ @import "../assets/scss/main.scss";
46
+
47
+ .c-btn {
48
+ border-radius: 30px;
49
+
50
+ transition: var(--transition);
51
+ cursor: pointer;
52
+
53
+ outline: none;
54
+ border: none;
55
+
56
+ &:disabled {
57
+ cursor: default;
58
+ }
59
+
60
+ // prop.size
61
+ &.lg {
62
+ padding: 15px 70px;
63
+ font-size: 16px;
64
+ }
65
+
66
+ &.md {
67
+ padding: 8px 40px;
68
+ font-size: 16px;
69
+ }
70
+
71
+ &.sm {
72
+ padding: 6px 20px;
73
+ font-size: 14px;
74
+ }
75
+ // ./prop.size
76
+
77
+ // prop.color
78
+ &.green {
79
+ --bg-color: var(--green-light);
80
+ --text-color: var(--black);
81
+
82
+ --bg-hover-color: #0A8A54;
83
+ --text-hover-color: #252525;
84
+
85
+ --bg-disable-color: #084A36;
86
+ --text-disable-color: #252525;
87
+ }
88
+
89
+ &.black {
90
+ --bg-color: var(--black);
91
+ --text-color: var(--white);
92
+
93
+ --bg-hover-color: #06100F;
94
+ --text-hover-color: #787878;
95
+
96
+ --bg-disable-color: #101D19;
97
+ --text-disable-color: #324F4A;
98
+ }
99
+ // ./prop.color
100
+
101
+ // prop.variant
102
+ &.tonal {
103
+ background: var(--bg-color);
104
+ color: var(--text-color);
105
+
106
+ &:hover, &.hover {
107
+ background: var(--bg-hover-color);
108
+ color: var(--text-hover-color);
109
+ }
110
+
111
+ &:disabled {
112
+ background: var(--bg-disable-color);
113
+ color: var(--text-disable-color);
114
+ }
115
+ }
116
+
117
+ &.outlined {
118
+ --text-color: var(--white);
119
+
120
+ border: 1px solid var(--bg-color);
121
+ background: transparent;
122
+ color: var(--text-color);
123
+
124
+ &:hover, &.hover {
125
+ border: 1px solid var(--bg-hover-color);
126
+ color: var(--bg-hover-color);
127
+ }
128
+
129
+ &:disabled {
130
+ border: 1px solid var(--bg-disable-color);
131
+ color: var(--bg-disable-color);
132
+ }
133
+ }
134
+
135
+ &.text {
136
+ background: transparent;
137
+ color: var(--bg-color);
138
+
139
+ &:hover, &.hover {
140
+ color: var(--bg-hover-color);
141
+ }
142
+
143
+ &:disabled {
144
+ color: var(--bg-disable-color);
145
+ }
146
+ }
147
+ // ./prop.variant
148
+ }
149
+ </style>