@v1nt1248/3nclient-lib 0.2.38 → 0.2.40

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
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.2.38",
5
+ "version": "0.2.40",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -1,6 +1,7 @@
1
1
  export interface Ui3nIconProps {
2
2
  icon: string;
3
3
  title?: string;
4
+ size?: string | number;
4
5
  width?: string | number;
5
6
  height?: string | number;
6
7
  color?: string;
@@ -1,26 +1,27 @@
1
1
  <script lang="ts" setup>
2
- import { computed } from 'vue';
2
+ import { computed, onMounted, useTemplateRef } from 'vue';
3
3
  import type { Ui3nIconEmits, Ui3nIconProps } from './types';
4
4
 
5
5
  const props = withDefaults(
6
6
  defineProps<Ui3nIconProps>(),
7
7
  {
8
8
  title: '',
9
- width: 16,
10
- height: 16,
11
9
  rotate: 0,
12
10
  color: 'var(--color-icon-control-primary-default)',
13
11
  },
14
12
  );
15
13
  const emits = defineEmits<Ui3nIconEmits>();
16
14
 
15
+ const iconEl = useTemplateRef('icon');
16
+
17
+ const widthVal = computed(() => props.size || props.width || 16);
18
+ const heightVal = computed(() => props.size || props.height || 16);
19
+ const widthCss = computed(() => `${widthVal.value}px`);
20
+ const heightCss = computed(() => `${heightVal.value}px`);
21
+
17
22
  const iconClass = computed(() => `ui3n-icon__${props.icon}`);
18
23
  const iconStyle = computed(() => {
19
- const value: Record<string, string> = {
20
- width: `${props.width}px`,
21
- height: `${props.height}px`,
22
- color: props.color,
23
- };
24
+ const value: Record<string, string> = {};
24
25
  const transformData = [];
25
26
  props.horizontalFlip && transformData.push('rotateY(180deg)');
26
27
  props.verticalFlip && transformData.push('rotateX(180deg)');
@@ -35,22 +36,37 @@ const iconStyle = computed(() => {
35
36
  function onClick(ev: Event) {
36
37
  emits('click', ev);
37
38
  }
39
+
40
+ onMounted(() => {
41
+ if (iconEl.value) {
42
+ iconEl.value.classList.add(iconClass.value);
43
+ }
44
+ });
38
45
  </script>
39
46
 
40
47
  <template>
41
48
  <div
42
- :class="['ui3n-icon', iconClass]"
49
+ ref="icon"
50
+ class="ui3n-icon"
51
+ :class="$style.icon"
43
52
  :title="title"
44
53
  :style="iconStyle"
45
54
  @click="onClick"
46
55
  />
47
56
  </template>
48
57
 
49
- <style lang="scss">
58
+ <style lang="scss" module>
50
59
  .icon {
51
- min-width: v-bind(width);
52
- min-height: v-bind(height);
60
+ --ui3n-icon-color: v-bind(color);
61
+
62
+ min-width: v-bind(widthCss);
63
+ width: v-bind(widthCss);
64
+ max-width: v-bind(widthCss);
65
+ min-height: v-bind(heightCss);
66
+ height: v-bind(heightCss);
67
+ max-height: v-bind(heightCss);
53
68
  flex-grow: 0;
54
69
  flex-shrink: 0;
70
+ color: var(--ui3n-icon-color);
55
71
  }
56
72
  </style>