@eturnity/eturnity_reusable_components 1.2.70 → 1.2.72

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.70",
3
+ "version": "1.2.72",
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="hover" gap="30px">
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,119 @@
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'}" :justify="justify" :position="position" :width="width" :backgroundColor="backgroundColor">
7
+ <DropdownWindow :gap="gap" :backgroundColor="backgroundColor">
8
+ <slot name="dropdown"/>
9
+ </DropdownWindow>
10
+ </WrapperDropdown>
11
+ </wrapper>
12
+ </template>
13
+
14
+ <script>
15
+ // import Icon from "@eturnity/eturnity_reusable_components/src/components/icon"
16
+ // How to use:
17
+ //<DropdownComponent
18
+ // width="300px"
19
+ // backgroundColor="red">
20
+
21
+ // <DropdownComponent/>
22
+
23
+ import styled from 'vue-styled-components'
24
+
25
+ const wrapperAttrs = { width: String, backgroundColor:String,openingMode:String,gap:String,justify:String }
26
+ const Wrapper = styled('div', wrapperAttrs)`
27
+ display: inline-block;
28
+ position: relative;
29
+
30
+ &:hover .dropdown-content {
31
+ ${props=>props.openingMode=='hover'?"display:block":""}
32
+ }
33
+ & .openDropdown{
34
+ ${props=>props.openingMode=='click'?"display:block !important":""}
35
+ }
36
+ `
37
+ const WrapperDropdown = styled('div', wrapperAttrs)`
38
+ margin-top: 0;
39
+ display: none;
40
+ position: absolute;
41
+ z-index: 1;
42
+ ${(props) => props.justify=="right"?"right:0;":""}
43
+ `
44
+ const DropdownWindow = styled('div', wrapperAttrs)`
45
+ width: ${(props) => props.width};
46
+ background-color: ${(props) => props.theme.colors[props.backgroundColor] || props.backgroundColor};
47
+ margin-top: ${(props) => props.gap};
48
+ border-radius: 4px;
49
+ position: relative;
50
+ min-width: 160px;
51
+ box-shadow: -1px 0px 5px rgba(0, 0, 0, 0.302);
52
+ z-index: 1;
53
+ `
54
+
55
+ const WrapperButton = styled('div', wrapperAttrs)`
56
+ display: inline-block;
57
+ `
58
+
59
+ export default {
60
+ name: 'DropdownComponent',
61
+ components: {
62
+ WrapperDropdown,
63
+ WrapperButton,
64
+ Wrapper,
65
+ DropdownWindow
66
+ },
67
+ props: {
68
+ width: {
69
+ required: false,
70
+ default: '300px'
71
+ },
72
+ gap: {
73
+ required: false,
74
+ default: '10px'
75
+ },
76
+ position: {
77
+ required: false,
78
+ default: 'bottom'
79
+ },
80
+ justify: {
81
+ required: false,
82
+ default: 'left'
83
+ },
84
+ openingMode: {
85
+ required: false,
86
+ default: 'hover'
87
+ },
88
+ backgroundColor: {
89
+ required: false,
90
+ default: 'white'
91
+ }
92
+ },
93
+ data() {
94
+ return {
95
+ isOpenByClick:false
96
+ }
97
+ },
98
+ methods:{
99
+ clickOutside(event) {
100
+ if (this.openingMode!="click") return
101
+ if (
102
+ this.$refs.dropdown.$el == event.target ||
103
+ this.$refs.dropdown.$el.contains(event.target)
104
+ ) {
105
+ return
106
+ } else {
107
+ this.isOpenByClick=false
108
+ }
109
+ },
110
+ },
111
+ mounted() {
112
+ document.addEventListener('click', this.clickOutside)
113
+ },
114
+ beforeDestroy() {
115
+ document.removeEventListener('click', this.clickOutside)
116
+ },
117
+ }
118
+ </script>
119
+