fu-kit 0.5.1 → 0.6.2

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.
@@ -1,24 +1,23 @@
1
1
  <template>
2
- <label class="fu-select-x" v-bind="$attrs">
2
+ <label v-click-away="onClickAway" class="ui-select-x" v-bind="$attrs">
3
3
  <input
4
- tabindex="0"
5
- class="fu-select-x_input"
6
4
  ref="refSearch"
7
5
  v-model="search"
8
- :placeholder="model"
9
- @keydown="onTextKeydown"
10
- @focus="onTextFocus"
11
- @blur="onSomeBlur"
6
+ :placeholder="placeholder"
7
+ class="ui-select-x_input"
12
8
  spellcheck="false"
9
+ tabindex="0"
10
+ @focus="onTextFocus"
11
+ @keydown="onTextKeydown"
13
12
  />
14
- <span class="fu-select-x_list" v-show="filteredItems.length" ref="refList" @keydown="onArrows">
13
+ <span v-show="filteredItems.length" ref="refList" class="ui-select-x_list" @keydown="onArrows">
15
14
  <button
16
- class="fu-select-x_list-item"
15
+ v-for="(e) in filteredItems"
17
16
  :class="{'_selected': e.value === model}"
17
+ class="ui-select-x_list-item"
18
18
  tabindex="-1"
19
- v-for="(e) in filteredItems"
19
+ type="button"
20
20
  @click="onSelect($event,e)"
21
- @blur="onSomeBlur"
22
21
  >
23
22
  {{ e.label }}
24
23
  </button>
@@ -27,24 +26,27 @@
27
26
  </template>
28
27
 
29
28
  <script>
30
- import { computed, nextTick, ref, watch } from 'vue'
29
+ import { computed, defineComponent, nextTick, ref, watch } from 'vue'
30
+ import { directive as clickAway } from 'vue3-click-away'
31
31
 
32
- import FuText from './FuText.vue'
33
- import FuButton from './FuButton.vue'
32
+ import UiText from './UiText.vue'
33
+ import UiButton from './UiButton.vue'
34
34
 
35
- export default {
36
- name: 'fu-select-x',
37
- components: { FuButton, FuText },
35
+ export default defineComponent({
36
+ name: 'ui-select-x',
37
+ components: { UiButton, UiText },
38
+ directives: { clickAway },
38
39
  props: {
39
40
  modelValue: { type: [ String, Number ], default: '' },
40
41
  options: { type: Array, default: [] },
41
42
  allowCustom: { type: Boolean, default: false },
43
+ placeholder: { type: String },
42
44
  },
43
45
  emits: [ 'update:modelValue', 'select' ],
44
46
  setup (props, { emit }) {
45
47
  const refSearch = ref(null)
46
48
  const refList = ref(null)
47
- const search = ref('')
49
+ const search = ref(props.modelValue || '')
48
50
  const model = ref(props.modelValue)
49
51
 
50
52
  watch(() => props.modelValue, (value) => {
@@ -96,6 +98,8 @@ export default {
96
98
  nodes[0].click()
97
99
  } else if (props.allowCustom) {
98
100
  onSelect(e, { label: search.value, value: search.value })
101
+ } else {
102
+ search.value = model.value
99
103
  }
100
104
 
101
105
  e.preventDefault()
@@ -157,14 +161,8 @@ export default {
157
161
  }
158
162
  }
159
163
 
160
- const onSomeBlur = async (e) => {
161
- await nextTick() // todo: investigate why it's required
162
- if (
163
- refSearch.value !== document.activeElement &&
164
- refList.value !== document.activeElement.parentElement
165
- ) {
166
- search.value = model.value
167
- }
164
+ const onClickAway = () => {
165
+ search.value = model.value
168
166
  }
169
167
 
170
168
  return {
@@ -178,16 +176,16 @@ export default {
178
176
  onArrows,
179
177
  onSelect,
180
178
  onTextFocus,
181
- onSomeBlur,
179
+ onClickAway,
182
180
  }
183
181
  },
184
- }
182
+ })
185
183
  </script>
186
184
 
187
185
  <style lang="scss" scoped>
188
186
  @import "../../scss";
189
187
 
190
- .fu-select-x {
188
+ .ui-select-x {
191
189
  @include typo(200);
192
190
 
193
191
  padding: 0;
@@ -208,7 +206,7 @@ export default {
208
206
 
209
207
  &_input {
210
208
  @include typo(200);
211
- @include spacing-padding(100, 300);
209
+ padding: spacing(100, 300);
212
210
 
213
211
  font-family: var(--typo-font-ui);
214
212
  color: var(--ui-pal-text);
@@ -227,14 +225,14 @@ export default {
227
225
  outline: none;
228
226
  }
229
227
 
230
- &:not(:focus)::placeholder {
231
- color: pal(prime);
232
- }
233
-
234
228
  &::selection {
235
229
  background-color: var(--ui-pal);
236
230
  color: var(--ui-pal-text-select);
237
231
  }
232
+
233
+ &::placeholder {
234
+ color: var(--ui-pal-placeholder);
235
+ }
238
236
  }
239
237
 
240
238
  &_list {
@@ -259,7 +257,7 @@ export default {
259
257
  z-index: var(--lt-z-pop);
260
258
 
261
259
  &-item {
262
- @include spacing-padding(200, 300);
260
+ padding: spacing(200, 300);
263
261
  @include typo(200, 300);
264
262
 
265
263
  border: 0 none;
@@ -1,7 +1,10 @@
1
1
  <template>
2
- <div class="fu-sidebar" :class="{'_shown':isOpen}" @click.self="$emit('close')">
2
+ <div :class="{'_shown':isOpen}" class="ui-sidebar" @mousedown.self="$emit('close')">
3
3
  <transition name="bounce">
4
- <div class="fu-sidebar_content" v-if="isOpen">
4
+ <div v-if="isOpen" class="ui-sidebar_content">
5
+ <button v-if="showClose" class="ui-sidebar_close" @click="$emit('close')">
6
+ <ui-icon name="cross" />
7
+ </button>
5
8
  <slot />
6
9
  </div>
7
10
  </transition>
@@ -9,30 +12,42 @@
9
12
  </template>
10
13
 
11
14
  <script>
12
- export default {
13
- name: 'fu-sidebar',
15
+ import { defineComponent } from 'vue'
16
+
17
+ import UiIcon from './UiIcon.vue'
18
+
19
+ export default defineComponent({
20
+ name: 'ui-sidebar',
21
+ components: { UiIcon },
14
22
  emits: [ 'close' ],
15
23
  props: {
16
24
  isOpen: { type: Boolean, default: false },
17
25
  // todo: right side as well
18
26
  side: { type: String, default: 'right' },
27
+ showClose: { type: Boolean, default: false },
19
28
  },
20
- }
29
+ watch: {
30
+ isOpen (val) {
31
+ if (val) document.body.style.overflow = 'hidden'
32
+ else document.body.style.overflow = 'visible'
33
+ },
34
+ },
35
+ })
21
36
  </script>
22
37
 
23
38
  <style lang="scss">
24
39
  @import "../../scss";
25
40
 
26
- :root {
41
+ html {
27
42
  --ui-sidebar-max-w: 45vw;
28
43
  --ui-sidebar-min-w: 25vw;
29
44
  }
30
45
  </style>
31
46
 
32
- <style scoped lang="scss">
47
+ <style lang="scss" scoped>
33
48
  @import "../../scss";
34
49
 
35
- .fu-sidebar {
50
+ .ui-sidebar {
36
51
  position: fixed;
37
52
  left: 0;
38
53
  top: 0;
@@ -41,7 +56,7 @@ export default {
41
56
  z-index: var(--lt-z-nav);
42
57
  background-color: transparent;
43
58
  transition-timing-function: linear;
44
- transition-duration: 600ms;
59
+ transition-duration: 200ms;
45
60
  transition-property: background-color, visibility;
46
61
  pointer-events: none;
47
62
  visibility: hidden;
@@ -61,10 +76,26 @@ export default {
61
76
  top: 0;
62
77
  right: 0;
63
78
  bottom: 0;
64
- background: var(--pal-bg);
79
+ border-top-left-radius: var(--lt-border-radius);
80
+ border-bottom-left-radius: var(--lt-border-radius);
81
+ background: var(--pal-white);
82
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
65
83
  max-width: var(--ui-sidebar-max-w);
66
84
  min-width: var(--ui-sidebar-min-w);
67
85
  transform-origin: 100% 50%;
86
+ width: var(--ui-sidebar-width, auto);
87
+ }
88
+
89
+ &_close {
90
+ --icon-color: var(--pal-grey800);
91
+
92
+ position: absolute;
93
+ top: spacing(500);
94
+ left: spacing(500);
95
+ border: none;
96
+ padding: 0;
97
+ background: transparent;
98
+ cursor: pointer;
68
99
  }
69
100
  }
70
101
 
@@ -84,4 +115,4 @@ export default {
84
115
  transform: translateX(0);
85
116
  }
86
117
  }
87
- </style>
118
+ </style>
@@ -1,15 +1,17 @@
1
1
  <template>
2
2
  <div
3
- class="fu-text"
4
- :class="{'_disabled': $attrs.disabled !== undefined || $attrs.readOnly !== undefined }"
3
+ :class="{'_disabled': disabled || $attrs.readOnly !== undefined, 'ui-text': !naked }"
5
4
  v-bind="{ class: $attrs.class }"
6
5
  >
7
6
  <slot />
8
7
  <slot name="left" />
9
8
  <input
10
- v-bind="{...$attrs, class: undefined}"
9
+ ref="inputRef"
10
+ :class="{ _naked: naked }"
11
11
  :value="modelValue"
12
- class="fu-text_input"
12
+ class="ui-text_input"
13
+ v-bind="{...$attrs, disabled, class: undefined}"
14
+ @focus="handleFocus"
13
15
  @input="$emit('update:modelValue', $event.target.value)"
14
16
  >
15
17
  <slot name="right" />
@@ -17,21 +19,35 @@
17
19
  </template>
18
20
 
19
21
  <script>
20
- export default {
21
- name: 'fu-text',
22
+ import { defineComponent } from 'vue'
23
+
24
+ export default defineComponent({
25
+ name: 'ui-text',
22
26
  props: {
27
+ disabled: { type: Boolean, default: false },
28
+ autoSelect: { type: Boolean, default: false },
29
+ naked: { type: Boolean, default: false },
23
30
  modelValue: {
24
31
  type: [ String, Number ],
25
32
  default: '',
26
33
  },
27
34
  },
28
35
  emits: [ 'update:modelValue' ],
29
- }
36
+ expose: [ 'focus' ],
37
+ methods: {
38
+ focus () {
39
+ this.$refs.inputRef.focus()
40
+ },
41
+ handleFocus () {
42
+ if (this.autoSelect) this.$refs.inputRef.select()
43
+ },
44
+ },
45
+ })
30
46
  </script>
31
47
  <style lang="scss" scoped>
32
48
  @import "../../scss";
33
49
 
34
- .fu-text {
50
+ .ui-text {
35
51
  @include typo(200);
36
52
 
37
53
  padding: 0;
@@ -47,11 +63,11 @@ export default {
47
63
  transition-timing-function: ease-in-out;
48
64
  transition-property: border-color, box-shadow;
49
65
  height: var(--ui-lt-h);
50
- background: var(--ui-pal-bg);
66
+ background: var(--pal-white);
51
67
 
52
68
  &_input {
53
69
  @include typo(200);
54
- @include spacing-padding(100, 300);
70
+ padding: var(--ui-input-padding, #{spacing(100)} #{spacing(300)});
55
71
 
56
72
  font-family: var(--typo-font-ui);
57
73
  color: var(--ui-pal-text);
@@ -76,9 +92,13 @@ export default {
76
92
  }
77
93
 
78
94
  &[disabled], &[read-only] {
79
- cursor: text;
95
+ cursor: not-allowed;
80
96
  color: var(--ui-pal-disabled-border);
81
97
  }
98
+
99
+ &._naked {
100
+ padding: var(--ui-input-padding, 0);
101
+ }
82
102
  }
83
103
 
84
104
  &:hover {
@@ -1,24 +1,24 @@
1
1
  <template>
2
2
  <div
3
- class="fu-text"
4
- v-bind="{ class: $attrs.class }"
5
3
  :class="{'_disabled': $attrs.disabled !== undefined || $attrs.readOnly !== undefined }"
4
+ class="ui-text"
5
+ v-bind="{ class: $attrs.class }"
6
6
  >
7
7
  <textarea
8
8
  ref="textarea"
9
- v-bind="{...$attrs, class: undefined}"
10
9
  :value="modelValue"
11
- class="fu-text_textarea"
10
+ class="ui-text_textarea"
11
+ v-bind="{...$attrs, class: undefined}"
12
12
  @input="handleInput"
13
13
  />
14
14
  </div>
15
15
  </template>
16
16
 
17
17
  <script>
18
- import { onMounted, ref } from 'vue'
18
+ import { defineComponent, onMounted, ref } from 'vue'
19
19
 
20
- export default {
21
- name: 'fu-textarea',
20
+ export default defineComponent({
21
+ name: 'ui-textarea',
22
22
  props: {
23
23
  modelValue: {
24
24
  type: [ String, Number ],
@@ -42,13 +42,12 @@ export default {
42
42
 
43
43
  return { handleInput, textarea }
44
44
  },
45
- }
45
+ })
46
46
  </script>
47
-
48
47
  <style lang="scss" scoped>
49
48
  @import "../../scss";
50
49
 
51
- .fu-text {
50
+ .ui-text {
52
51
  @include typo(200);
53
52
 
54
53
  padding: 0;
@@ -69,20 +68,22 @@ export default {
69
68
  &_textarea {
70
69
  @include scrollbar-awesome();
71
70
  @include typo(200);
72
- @include spacing-padding(200);
73
- @include spacing-margin(100);
71
+ padding: spacing(200, 300);
72
+ margin: spacing(100, 100, 100, 0);
74
73
 
75
74
  color: var(--ui-pal-text);
76
75
  caret-color: var(--ui-pal);
77
- border: none;
76
+ border: 0 none;
78
77
  outline: none;
79
78
  background: transparent;
80
79
  box-sizing: border-box;
81
80
  flex: 1;
82
81
  display: block;
83
- min-width: 0;
82
+ min-width: var(--ui-textarea-min-w, 0);
83
+ max-width: var(--ui-textarea-max-w, unset);
84
84
  resize: var(--ui-textarea-resize, vertical);
85
- min-height: var(--ui-lt-h);
85
+ min-height: var(--ui-textarea-min-h, 4em);
86
+ max-height: var(--ui-textarea-max-h, 400px);
86
87
  height: var(--ui-lt-h);
87
88
  font-family: var(--typo-font-ui);
88
89
 
package/src/entry.js CHANGED
@@ -1,15 +1,17 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
- export { default as FuButton } from './components/FuButton.vue'
3
- export { default as FuButtonLink } from './components/FuButtonLink.vue'
4
- export { default as FuCodeView } from './components/FuCodeView.vue'
5
- export { default as FuCopy } from './components/FuCopy.vue'
6
- export { default as FuProgressRadial } from './components/FuProgressRadial.vue'
7
- export { default as FuSelect } from './components/FuSelect.vue'
8
- export { default as FuSelectX } from './components/FuSelectX.vue'
9
- export { default as FuSidebar } from './components/FuSidebar.vue'
10
- export { default as FuModal } from './components/FuModal.vue'
11
- export { default as FuText } from './components/FuText.vue'
12
- export { default as FuTextarea } from './components/FuTextarea.vue'
13
- export { default as FuCheck } from './components/FuCheck.vue'
14
- export { default as FuDropdown } from './components/FuDropdown.vue'
15
- export { default as FuDropdownItem } from './components/FuDropdownItem.vue'
2
+ export { default as UiButton } from './components/UiButton.vue'
3
+ export { default as UiButtonLink } from './components/UiButtonLink.vue'
4
+ export { default as UiCodeView } from './components/UiCodeView.vue'
5
+ export { default as UiCopy } from './components/UiCopy.vue'
6
+ export { default as UiSelect } from './components/UiSelect.vue'
7
+ export { default as UiSelectX } from './components/UiSelectX.vue'
8
+ export { default as UiModal } from './components/UiModal.vue'
9
+ export { default as UiSidebar } from './components/UiSidebar.vue'
10
+ export { default as UiText } from './components/UiText.vue'
11
+ export { default as UiTextarea } from './components/UiTextarea.vue'
12
+ export { default as UiCheck } from './components/UiCheck.vue'
13
+ export { default as UiDropdown } from './components/UiDropdown.vue'
14
+ export { default as UiDropdownItem } from './components/UiDropdownItem.vue'
15
+ export { default as UiIconProvider } from './components/UiIconProvider.vue'
16
+ export { default as UiIcon } from './components/UiIcon.vue'
17
+ export { default as UiProgressRadial } from './components/UiProgressRadial.vue'
@@ -14,7 +14,7 @@
14
14
  }
15
15
  }
16
16
 
17
- @function spacing($spacing-code: null) {
17
+ @function _spacing($spacing-code) {
18
18
  @if (
19
19
  $spacing-code == 0 or
20
20
  $spacing-code == auto or
@@ -27,16 +27,8 @@
27
27
  @return var(--lt-sp#{$spacing-code});
28
28
  }
29
29
 
30
- @mixin spacing-prop($prop, $t, $r: null, $b: null, $l: null) {
31
- #{$prop}: spacing($t) spacing($r) spacing($b) spacing($l);
32
- }
33
-
34
- @mixin spacing-margin($t, $r: null, $b: null, $l: null) {
35
- @include spacing-prop('margin', $t, $r, $b, $l);
36
- }
37
-
38
- @mixin spacing-padding($t, $r: null, $b: null, $l: null) {
39
- @include spacing-prop('padding', $t, $r, $b, $l);
30
+ @function spacing($t, $r: null, $b: null, $l: null) {
31
+ @return _spacing($t) _spacing($r) _spacing($b) _spacing($l)
40
32
  }
41
33
 
42
34
  @mixin ellipsis($display: block) {
@@ -11,7 +11,7 @@
11
11
  }
12
12
 
13
13
  &::-webkit-scrollbar-thumb {
14
- border: 2px solid var(--ui-scroll-bg);
14
+ border: 1px solid var(--ui-scroll-bg, inherit);
15
15
  border-radius: var(--ui-scroll-width);
16
16
  @if ($hide) {
17
17
  background-color: inherit;
@@ -47,5 +47,3 @@
47
47
  -ms-overflow-style: none;
48
48
  scrollbar-width: none;
49
49
  }
50
-
51
-
@@ -1,136 +0,0 @@
1
- <template>
2
- <label
3
- class="fu-check"
4
- :class="{'_disabled': $attrs.disabled !== undefined, '_checked': modelValue }"
5
- v-bind="{ class: $attrs.class, style: $attrs.style }"
6
- >
7
- <input
8
- v-bind="{...$attrs, class: undefined, style: undefined, type: 'checkbox'}"
9
- class="fu-check_input"
10
- @input="$emit('update:modelValue', $event.target.checked)"
11
- :checked="modelValue"
12
- >
13
- <span class="fu-check_box" :class="switchLike ? 'fu-check_switch' : 'fu-check_check'" />
14
- <slot />
15
- </label>
16
- </template>
17
-
18
- <script>
19
- export default {
20
- name: 'fu-check',
21
- props: {
22
- modelValue: { type: [ Boolean ], default: false },
23
- switchLike: { type: Boolean, default: false },
24
- },
25
- emits: [ 'update:modelValue' ],
26
- }
27
- </script>
28
- <style lang="scss" scoped>
29
- @import "../../scss";
30
-
31
- .fu-check {
32
- @include typo(200);
33
-
34
- user-select: none;
35
- display: flex;
36
- box-sizing: border-box;
37
- align-items: center;
38
- justify-content: stretch;
39
- height: var(--ui-lt-h);
40
- position: relative;
41
- outline: none;
42
- color: var(--pal-text-dimm);
43
- font-family: var(--typo-font-text);
44
-
45
- &_input {
46
- opacity: 0; // weird, but it's working inside the label
47
- visibility: hidden;
48
- position: absolute;
49
- left: 0;
50
- top: 0;
51
- }
52
-
53
- &_check {
54
- border-style: var(--ui-lt-border-style);
55
- border-width: var(--ui-lt-border-width);
56
- border-color: var(--ui-pal-lateral);
57
- height: var(--ui-lt-h-sub);
58
- width: var(--ui-lt-h-sub);
59
- border-radius: var(--ui-lt-border-radius);
60
- display: flex;
61
- justify-content: stretch;
62
- align-items: stretch;
63
- margin-right: spacing(200);
64
-
65
- &:before {
66
- content: "";
67
- display: block;
68
- background-color: var(--ui-pal);
69
- border-radius: calc(var(--ui-lt-border-radius) - #{spacing(100)});
70
- margin: spacing(100);
71
- flex: 1;
72
- transform: scale(0);
73
- transition: all var(--ui-transition);
74
- }
75
- }
76
-
77
- &_switch {
78
- border-style: var(--ui-lt-border-style);
79
- border-width: var(--ui-lt-border-width);
80
- border-color: var(--ui-pal-lateral);
81
- height: var(--ui-lt-h-sub);
82
- width: calc(var(--ui-lt-h-sub) * 2);
83
- border-radius: var(--ui-lt-h-sub);
84
- margin-right: spacing(200);
85
- display: flex;
86
- align-items: center;
87
- justify-content: flex-start;
88
- padding: spacing(100);
89
-
90
- &:before {
91
- content: "";
92
- display: block;
93
- background-color: var(--ui-pal-lateral);
94
- border-radius: calc(var(--ui-lt-h-sub) - #{spacing(100)});
95
- height: 100%;
96
- aspect-ratio: 1;
97
- transition: all var(--ui-transition);
98
- }
99
- }
100
-
101
- &._checked &_switch:before {
102
- transform: translateX(var(--ui-lt-h-sub));
103
- background-color: var(--ui-pal);
104
- }
105
-
106
- &._checked {
107
- color: var(--pal-text);
108
- }
109
-
110
- &._checked &_check:before {
111
- transform: scale(1);
112
- }
113
-
114
- &:hover &_box {
115
- box-shadow: 0 5px 12px -4px rgb(var(--rgb-dark), 0.2);
116
- }
117
-
118
- &:hover {
119
- color: var(--pal-text);
120
- }
121
-
122
- &:focus-within &_box {
123
- border-color: var(--ui-pal);
124
- }
125
-
126
- &._disabled {
127
- color: var(--ui-pal-disabled-border);
128
- cursor: not-allowed;
129
- }
130
-
131
- &._disabled &_box {
132
- border: var(--ui-lt-border-width) var(--ui-lt-disabled-border-style) var(--ui-pal-disabled-border);
133
- box-shadow: none;
134
- }
135
- }
136
- </style>