@eturnity/eturnity_reusable_components 1.2.22 → 1.2.23-3d-master.0

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.
@@ -0,0 +1,116 @@
1
+ <template>
2
+ <Wrapper
3
+ :disabled="disabled"
4
+ :size="size"
5
+ :backgroundColor="backgroundColor"
6
+ :borderRadius="borderRadius"
7
+ :hoveredBackgroundColor="hoveredBackgroundColor"
8
+ :isHovered="isHovered"
9
+ >
10
+ <icon :disabled="disabled"
11
+ :size="iconSize"
12
+ :name="name"
13
+ :color="iconColor"
14
+ :hoveredColor="hoveredIconColor" />
15
+ <caret v-if="hasCaret">
16
+ <iconWrapper :disabled="disabled"
17
+ size="10px"
18
+ name="arrow_down"
19
+ :iconColor="iconColor"
20
+ :hoveredBackgroundColor="hoveredIconColor"
21
+ borderRadius="1px"
22
+ />
23
+ </caret>
24
+ </Wrapper>
25
+ </template>
26
+
27
+ <script>
28
+ // import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
29
+ // How to use:
30
+ //<icon
31
+ // name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
32
+ // color="red"
33
+ // hoveredColor="blue"
34
+ // size="60px" by default, this is 30px
35
+ // />
36
+
37
+ import styled from 'vue-styled-components'
38
+ import icon from '../icon'
39
+ const wrapperAttrs = { isHovered:Boolean,borderRadius:String,disabled: Boolean, size: String,backgroundColor:String,hoveredBackgroundColor:String }
40
+ const Wrapper = styled('div', wrapperAttrs)`
41
+ position:relative;
42
+ display: inline-flex;
43
+ width: ${(props) => props.size};
44
+ height: ${(props) => props.size};
45
+ justify-content:center;
46
+ align-items:center;
47
+ cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
48
+ background-color: ${(props)=>props.theme.colors[props.backgroundColor] || props.backgroundColor};
49
+ border-radius: ${(props) => props.borderRadius};
50
+ ${(props)=>(props.isHovered ? 'background-color:'+props.theme.colors[props.hoveredBackgroundColor] || props.hoveredBackgroundColor : "")};
51
+ &:hover{
52
+ background-color:${(props)=>props.theme.colors[props.hoveredBackgroundColor] || props.hoveredBackgroundColor};
53
+ }
54
+ `
55
+ const caret=styled.div`
56
+ position:absolute;
57
+ bottom:3px;
58
+ right:2px;
59
+ height:10px;
60
+ `
61
+
62
+ export default {
63
+ name: 'iconWrapper',
64
+ components: {
65
+ Wrapper,
66
+ icon,
67
+ caret
68
+ },
69
+ props: {
70
+ disabled: {
71
+ required: false,
72
+ default: false
73
+ },
74
+ name: {
75
+ required: true
76
+ },
77
+ iconColor: {
78
+ required: false,
79
+ default: 'white'
80
+ },
81
+ hoveredIconColor: {
82
+ required: false
83
+ },
84
+ backgroundColor: {
85
+ required: false,
86
+ },
87
+ hoveredBackgroundColor: {
88
+ required: false,
89
+ default:"transparentWhite1"
90
+ },
91
+ size: {
92
+ required: false,
93
+ default: '32px'
94
+ },
95
+ iconSize:{
96
+ required: false,
97
+ default:'18px'
98
+ },
99
+ hasCaret:{
100
+ required: false,
101
+ default: false
102
+ },
103
+ borderRadius:{
104
+ required:false,
105
+ default:'6px'
106
+ },
107
+ isHovered:{
108
+ required:false,
109
+ default:false
110
+ }
111
+ },
112
+ data() {
113
+ return {}
114
+ }
115
+ }
116
+ </script>
@@ -1,34 +1,25 @@
1
1
  <template>
2
2
  <component-wrapper>
3
- <icon-wrapper>
3
+ <icon-wrapper :size="size">
4
4
  <icon-img
5
5
  :isActive="showInfo"
6
6
  :size="size"
7
7
  :borderColor="borderColor"
8
8
  @click.prevent="toggleShowInfo()"
9
- @mouseenter="toggleShowInfo()"
10
- @mouseleave="toggleShowInfo()"
9
+ @mouseenter="openTrigger == 'onHover' ? toggleShowInfo() : ''"
10
+ @mouseleave="openTrigger == 'onHover' ? toggleShowInfo() : ''"
11
11
  >
12
- <svg
13
- class="img-icon"
14
- :width="size"
15
- :height="size"
16
- viewBox="0 0 24 24"
17
- fill="none"
18
- xmlns="http://www.w3.org/2000/svg"
19
- >
20
- <path
21
- class="img-icon"
22
- d="M20.4853 3.51469C18.2188 1.24823 15.2053 0 12 0C8.79469 0 5.78123 1.24823 3.51469 3.51469C1.24823 5.78123 0 8.79469 0 12C0 15.2053 1.24823 18.2188 3.51469 20.4853C5.78123 22.7518 8.79469 24 12 24C15.2053 24 18.2188 22.7518 20.4853 20.4853C22.7518 18.2188 24 15.2053 24 12C24 8.79469 22.7518 5.78123 20.4853 3.51469ZM12 3.28125C13.4216 3.28125 14.5781 4.4378 14.5781 5.85938C14.5781 7.28095 13.4216 8.4375 12 8.4375C10.5784 8.4375 9.42188 7.28095 9.42188 5.85938C9.42188 4.4378 10.5784 3.28125 12 3.28125ZM15.2812 19.6875H8.71875V18.2812H10.125V11.9167H8.71875V10.5104H13.875V18.2812H15.2812V19.6875Z"
23
- fill="#D5D5D5"
24
- />
25
- </svg>
12
+ <icon :size="size" name="info" :color="iconColor" />
26
13
  </icon-img>
27
14
  <text-overlay
28
15
  v-if="showInfo"
29
16
  :borderColor="borderColor"
30
17
  :alignText="alignText"
31
- >
18
+ :width="width"
19
+ :halfComputedTextInfoWidth="halfComputedTextInfoWidth"
20
+ :alignArrow="alignArrow"
21
+ :iconSize="size"
22
+ ><slot />
32
23
  {{ text }}
33
24
  </text-overlay>
34
25
  </icon-wrapper>
@@ -44,22 +35,23 @@
44
35
  // size="20"
45
36
  // alignText="right" // default is left
46
37
  // />
38
+ import theme from '../../assets/theme.js'
39
+ import styled from 'vue-styled-components'
40
+ import icon from '../icon'
47
41
 
48
- import styled from "vue-styled-components"
49
-
50
- const IconWrapper = styled.div`
51
- position: relative;
52
- `
53
-
54
- const textAttrs = { borderColor: String, alignText: String }
55
- const TextOverlay = styled("div", textAttrs)`
42
+ const textAttrs = { iconSize:String, borderColor: String, alignArrow:String, alignText: String, width:String,halfComputedTextInfoWidth:Number }
43
+ const TextOverlay = styled('div', textAttrs)`
56
44
  position: absolute;
57
- top: 26px;
58
- right: ${(props) => (props.alignText === "left" ? "-10px" : "inherit")};
59
- left: ${(props) => (props.alignText === "left" ? "inherit" : "-10px")};
45
+ top: ${(props) => 'calc('+props.iconSize+' + 15px)'};
46
+ ${(props) => (props.alignArrow === 'left'
47
+ ? 'left: calc('+props.iconSize+' /2 - 18px)'
48
+ : props.alignArrow === 'center'
49
+ ? 'left: calc((-'+props.width+' + '+props.iconSize+') /2 + 2px)'
50
+ : 'right: calc('+props.iconSize+' /2 - 17px)')};
51
+ text-align: ${(props) => props.alignText};
60
52
  background: ${(props) => props.theme.colors.black};
61
53
  padding: 10px;
62
- width: max-content;
54
+ width: ${(props) => props.width };
63
55
  max-width: 400px;
64
56
  font-size: 13px;
65
57
  font-weight: 400;
@@ -68,12 +60,13 @@ const TextOverlay = styled("div", textAttrs)`
68
60
  color: ${(props) => props.theme.colors.white};
69
61
 
70
62
  :before {
71
- content: "";
63
+ content: '';
72
64
  background-color: ${(props) => props.theme.colors.black};
73
65
  position: absolute;
74
66
  top: 2px;
75
- right: ${(props) => (props.alignText === "left" ? "-12px" : "inherit")};
76
- left: ${(props) => (props.alignText === "left" ? "inherit" : "40px")};
67
+ ${(props) => (props.alignArrow === 'left' ? 'left:40px;' :
68
+ props.alignArrow=='center' ? 'left: calc(50% + 19px);' :
69
+ 'right:-13px;')};
77
70
  height: 8px;
78
71
  width: 8px;
79
72
  transform-origin: center center;
@@ -82,18 +75,15 @@ const TextOverlay = styled("div", textAttrs)`
82
75
  `
83
76
 
84
77
  const iconAttrs = { isActive: Boolean, size: String, borderColor: String }
85
- const IconImg = styled("div", iconAttrs)`
86
- cursor: pointer;
87
- height: ${(props) => props.size + "px"};
88
78
 
89
- .img-icon {
90
- fill: ${(props) =>
91
- props.isActive
92
- ? props.borderColor
93
- ? props.borderColor
94
- : props.theme.colors.secondary
95
- : props.theme.colors.mediumGray};
96
- }
79
+ const IconWrapper = styled('div', iconAttrs)`
80
+ position: relative;
81
+ top: 1px;
82
+ height: ${(props) => props.size};
83
+ `
84
+ const IconImg = styled('div', iconAttrs)`
85
+ cursor: pointer;
86
+ height: ${(props) => props.size};
97
87
  `
98
88
 
99
89
  const ComponentWrapper = styled.div`
@@ -101,38 +91,51 @@ const ComponentWrapper = styled.div`
101
91
  `
102
92
 
103
93
  export default {
104
- name: "info-text",
94
+ name: 'info-text',
105
95
  components: {
106
96
  IconWrapper,
107
97
  TextOverlay,
108
98
  ComponentWrapper,
109
99
  IconImg,
100
+ icon
110
101
  },
111
102
  props: {
112
103
  text: {
113
- required: true,
104
+ required: false,
114
105
  },
115
106
  borderColor: {
116
107
  required: false,
117
- default: null,
108
+ default: null
118
109
  },
119
110
  size: {
120
111
  required: false,
121
- default: "20",
112
+ default: '14px'
122
113
  },
123
114
  alignText: {
124
115
  required: false,
125
- default: "left", // "left" or "right"
116
+ default: 'left' // "left" or "right"
117
+ },
118
+ alignArrow:{
119
+ required:false,
120
+ default:'center'
121
+ },
122
+ openTrigger:{
123
+ required:false,
124
+ default: 'onClick'
126
125
  },
126
+ width:{
127
+ required:false,
128
+ default:'165px'
129
+ }
127
130
  },
128
131
  methods: {
129
132
  toggleShowInfo() {
130
133
  this.showInfo = !this.showInfo
131
134
 
132
135
  if (this.showInfo) {
133
- document.addEventListener("click", this.clickOutside)
136
+ document.addEventListener('click', this.clickOutside)
134
137
  } else {
135
- document.removeEventListener("click", this.clickOutside)
138
+ document.removeEventListener('click', this.clickOutside)
136
139
  }
137
140
  },
138
141
  clickOutside(event) {
@@ -140,12 +143,24 @@ export default {
140
143
  return
141
144
  }
142
145
  this.toggleShowInfo()
143
- },
146
+ }
144
147
  },
145
148
  data() {
146
149
  return {
147
150
  showInfo: false,
148
151
  }
149
152
  },
153
+ computed: {
154
+ iconColor() {
155
+ return this.isActive
156
+ ? this.borderColor
157
+ ? this.borderColor
158
+ : theme.colors.secondary
159
+ : theme.colors.mediumGray
160
+ },
161
+ halfComputedTextInfoWidth() {
162
+ return parseInt(this.width)/2;
163
+ }
164
+ }
150
165
  }
151
- </script>
166
+ </script>