@eturnity/eturnity_reusable_components 1.2.70 → 1.2.71
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,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eturnity/eturnity_reusable_components",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.71",
|
4
4
|
"private": false,
|
5
5
|
"scripts": {
|
6
6
|
"dev": "vue-cli-service serve",
|
@@ -60,4 +60,4 @@
|
|
60
60
|
"author": "Aaron Enser",
|
61
61
|
"license": "ISC",
|
62
62
|
"homepage": "https://bitbucket.org/eturnitydevs/eturnity_reusable_components#readme"
|
63
|
-
}
|
63
|
+
}
|
package/src/App.vue
CHANGED
@@ -26,7 +26,18 @@
|
|
26
26
|
<div>Interactive Label</div>
|
27
27
|
</template>
|
28
28
|
</input-number>
|
29
|
-
|
29
|
+
before button
|
30
|
+
<dropdown-component openingMode="click">
|
31
|
+
<template #trigger><i>Click Me</i></template>
|
32
|
+
<template #dropdown>
|
33
|
+
<div>
|
34
|
+
<a href="">test1</a>
|
35
|
+
<button href="">test2</button><br>
|
36
|
+
<p>Text</p>
|
37
|
+
</div>
|
38
|
+
</template>
|
39
|
+
</dropdown-component>
|
40
|
+
after menu
|
30
41
|
<SwitchField
|
31
42
|
@on-switch-change="onInputChange($event)"
|
32
43
|
:options="[
|
@@ -85,6 +96,7 @@ import Select from '@/components/inputs/select'
|
|
85
96
|
import SwitchField from '@/components/inputs/switchField'
|
86
97
|
import Option from '@/components/inputs/select/option'
|
87
98
|
import iconCollection from '@/components/icon/iconCollection'
|
99
|
+
import dropdownComponent from '@/components/dropdown'
|
88
100
|
// import TableDropdown from "@/components/tableDropdown"
|
89
101
|
|
90
102
|
const PageContainer = styled.div`
|
@@ -106,7 +118,8 @@ export default {
|
|
106
118
|
Option,
|
107
119
|
Select,
|
108
120
|
SwitchField,
|
109
|
-
iconCollection
|
121
|
+
iconCollection,
|
122
|
+
dropdownComponent
|
110
123
|
},
|
111
124
|
data() {
|
112
125
|
return {
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import Dropdown from './index.vue'
|
2
|
+
|
3
|
+
export default {
|
4
|
+
title: 'Dropdown',
|
5
|
+
component: Dropdown
|
6
|
+
// argTypes: {},
|
7
|
+
}
|
8
|
+
|
9
|
+
const Template = (args, { argTypes }) => ({
|
10
|
+
// Components used in your story `template` are defined in the `components` object
|
11
|
+
components: { Dropdown },
|
12
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
13
|
+
props: Object.keys(argTypes),
|
14
|
+
template: `<Dropdown v-bind="$props">
|
15
|
+
<template #trigger>
|
16
|
+
trigger button
|
17
|
+
</template>
|
18
|
+
<template #dropdown>
|
19
|
+
<div>
|
20
|
+
<h3>fully customizable dropdown</h3>
|
21
|
+
<ul>
|
22
|
+
<li>item</li>
|
23
|
+
<li>item</li>
|
24
|
+
<li>item</li>
|
25
|
+
</ul>
|
26
|
+
</div>
|
27
|
+
</template>
|
28
|
+
</Dropdown>`,
|
29
|
+
// import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
|
30
|
+
// How to use:
|
31
|
+
//<icon
|
32
|
+
// name="House" //required. a svg file named [name].svg should be present in /assets/svgIcons
|
33
|
+
// color="red"
|
34
|
+
// hoveredColor="blue"
|
35
|
+
// size="60px" by default, this is 30px
|
36
|
+
// />
|
37
|
+
})
|
38
|
+
|
39
|
+
export const Default = Template.bind({})
|
40
|
+
Default.args = {
|
41
|
+
openingMode:"click",
|
42
|
+
gap:"0px",
|
43
|
+
justify:"left",
|
44
|
+
width:"150px"
|
45
|
+
}
|
46
|
+
|
47
|
+
export const withHover = Template.bind({})
|
48
|
+
withHover.args = {
|
49
|
+
openingMode:"hover",
|
50
|
+
gap:"20px",
|
51
|
+
justify:"right",
|
52
|
+
width:"250px"
|
53
|
+
}
|
54
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
<template>
|
2
|
+
<wrapper ref="dropdown" :openingMode="openingMode">
|
3
|
+
<WrapperButton @click="isOpenByClick=!isOpenByClick">
|
4
|
+
<slot name="trigger"/>
|
5
|
+
</WrapperButton>
|
6
|
+
<WrapperDropdown class="dropdown-content" :class="{openDropdown:isOpenByClick && openingMode=='click'}" :gap="gap" :justify="justify" :position="position" :width="width" :backgroundColor="backgroundColor">
|
7
|
+
<slot name="dropdown"/>
|
8
|
+
</WrapperDropdown>
|
9
|
+
</wrapper>
|
10
|
+
</template>
|
11
|
+
|
12
|
+
<script>
|
13
|
+
// import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
|
14
|
+
// How to use:
|
15
|
+
//<DropdownComponent
|
16
|
+
// width="300px"
|
17
|
+
// backgroundColor="red">
|
18
|
+
|
19
|
+
// <DropdownComponent/>
|
20
|
+
|
21
|
+
import styled from 'vue-styled-components'
|
22
|
+
|
23
|
+
const wrapperAttrs = { width: String, backgroundColor:String,openingMode:String,gap:Number,justify:String }
|
24
|
+
const Wrapper = styled('div', wrapperAttrs)`
|
25
|
+
display: inline-block;
|
26
|
+
position: relative;
|
27
|
+
|
28
|
+
&:hover .dropdown-content {
|
29
|
+
${props=>props.openingMode=='hover'?"display:block":""}
|
30
|
+
}
|
31
|
+
& .openDropdown{
|
32
|
+
${props=>props.openingMode=='click'?"display:block !important":""}
|
33
|
+
}
|
34
|
+
`
|
35
|
+
const WrapperDropdown = styled('div', wrapperAttrs)`
|
36
|
+
width: ${(props) => props.width};
|
37
|
+
background-color: ${(props) => props.theme.colors[props.backgroundColor] || props.backgroundColor};
|
38
|
+
border-radius: 4px;
|
39
|
+
margin-top: ${(props) => props.gap};
|
40
|
+
display: none;
|
41
|
+
position: absolute;
|
42
|
+
min-width: 160px;
|
43
|
+
box-shadow: -1px 0px 5px rgba(0, 0, 0, 0.302);
|
44
|
+
z-index: 1;
|
45
|
+
${(props) => props.justify=="right"?"right:0;":""}
|
46
|
+
`
|
47
|
+
|
48
|
+
const WrapperButton = styled('div', wrapperAttrs)`
|
49
|
+
display: inline-block;
|
50
|
+
`
|
51
|
+
|
52
|
+
export default {
|
53
|
+
name: 'DropdownComponent',
|
54
|
+
components: {
|
55
|
+
WrapperDropdown,
|
56
|
+
WrapperButton,
|
57
|
+
Wrapper
|
58
|
+
},
|
59
|
+
props: {
|
60
|
+
width: {
|
61
|
+
required: false,
|
62
|
+
default: '300px'
|
63
|
+
},
|
64
|
+
gap: {
|
65
|
+
required: false,
|
66
|
+
default: '10px'
|
67
|
+
},
|
68
|
+
position: {
|
69
|
+
required: false,
|
70
|
+
default: 'bottom'
|
71
|
+
},
|
72
|
+
justify: {
|
73
|
+
required: false,
|
74
|
+
default: 'left'
|
75
|
+
},
|
76
|
+
openingMode: {
|
77
|
+
required: false,
|
78
|
+
default: 'hover'
|
79
|
+
},
|
80
|
+
backgroundColor: {
|
81
|
+
required: false,
|
82
|
+
default: 'white'
|
83
|
+
}
|
84
|
+
},
|
85
|
+
data() {
|
86
|
+
return {
|
87
|
+
isOpenByClick:false
|
88
|
+
}
|
89
|
+
},
|
90
|
+
methods:{
|
91
|
+
clickOutside(event) {
|
92
|
+
if (this.openingMode!="click") return
|
93
|
+
if (
|
94
|
+
this.$refs.dropdown.$el == event.target ||
|
95
|
+
this.$refs.dropdown.$el.contains(event.target)
|
96
|
+
) {
|
97
|
+
return
|
98
|
+
} else {
|
99
|
+
this.isOpenByClick=false
|
100
|
+
}
|
101
|
+
},
|
102
|
+
},
|
103
|
+
mounted() {
|
104
|
+
document.addEventListener('click', this.clickOutside)
|
105
|
+
},
|
106
|
+
beforeDestroy() {
|
107
|
+
document.removeEventListener('click', this.clickOutside)
|
108
|
+
},
|
109
|
+
}
|
110
|
+
</script>
|
111
|
+
|