@farm-investimentos/front-mfe-components 11.4.1 → 11.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farm-investimentos/front-mfe-components",
3
- "version": "11.4.1",
3
+ "version": "11.4.2",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -5,7 +5,7 @@
5
5
  .farm-btn {
6
6
  font-size: 14px;
7
7
  align-items: center;
8
- border-radius: 4px;
8
+ border-radius: 6px;
9
9
  display: inline-flex;
10
10
  flex: 0 0 auto;
11
11
  font-weight: 700;
@@ -25,6 +25,10 @@
25
25
  min-width: 64px;
26
26
  padding: 0 16px;
27
27
 
28
+ &.farm-btn--full {
29
+ width: 100%;
30
+ }
31
+
28
32
  @each $size,
29
33
  $value in $sizes {
30
34
  &#{'.farm-btn[size=' + $size +']'} {
@@ -37,6 +41,7 @@
37
41
  display: flex;
38
42
  flex-direction: row;
39
43
  align-items: center;
44
+ gap: 8px;
40
45
 
41
46
  ::v-deep i.mdi {
42
47
  font-size: 1rem;
@@ -62,6 +67,8 @@
62
67
  }
63
68
  }
64
69
 
70
+
71
+
65
72
  &:before {
66
73
  transition: all 0.28s ease;
67
74
  background-color: currentColor;
@@ -220,10 +227,15 @@
220
227
  background-color: white;
221
228
 
222
229
  i.mdi.farm-icon {
223
- color: white;
230
+ color: #D6D6D6;
224
231
  }
225
232
  }
226
233
 
234
+ .farm-btn--plain.farm-btn--disabled {
235
+ background-color: transparent;
236
+ border: none;
237
+ }
238
+
227
239
  .farm-btn--elevated {
228
240
  box-shadow: 0px 3px 1px -2px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
229
241
  }
@@ -1,8 +1,8 @@
1
- import DefaultButton from './DefaultButton.vue';
2
1
  import { withDesign } from 'storybook-addon-designs';
3
2
  import baseThemeColors from '../../../configurations/_theme-colors-base.scss';
4
- const colors = Object.keys(baseThemeColors);
5
3
  import './Buttons.stories.scss';
4
+ import DefaultButton from './DefaultButton.vue';
5
+ const colors = Object.keys(baseThemeColors);
6
6
 
7
7
  export default {
8
8
  title: 'Buttons/Default',
@@ -25,8 +25,42 @@ export default {
25
25
  },
26
26
  };
27
27
 
28
- export const Primary = () => ({
29
- template: '<farm-btn title="Pass text as slot">Pass text as slot</farm-btn>',
28
+ export const Default = () => ({
29
+ template: '<farm-btn color="primary"> Pass text as slot </farm-btn>',
30
+ });
31
+
32
+ export const Full = () => ({
33
+ template:
34
+ '<farm-btn color="primary" full> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
35
+ });
36
+
37
+ export const PrimaryActive = () => ({
38
+ template:
39
+ '<farm-btn color="primary"> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
40
+ });
41
+
42
+ export const PrimaryInactive = () => ({
43
+ template:
44
+ '<farm-btn disabled> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
45
+ });
46
+ export const SecondaryActive = () => ({
47
+ template:
48
+ '<farm-btn outlined> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
49
+ });
50
+
51
+ export const SecondaryInactive = () => ({
52
+ template:
53
+ '<farm-btn outlined disabled> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
54
+ });
55
+
56
+ export const TertiaryActive = () => ({
57
+ template:
58
+ '<farm-btn plain> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
59
+ });
60
+
61
+ export const TertiaryInactive = () => ({
62
+ template:
63
+ '<farm-btn plain disabled> <farm-icon>plus</farm-icon> Pass text as slot <farm-icon>plus</farm-icon></farm-btn>',
30
64
  });
31
65
 
32
66
  export const HtmlMarkup = () => ({
@@ -34,7 +68,7 @@ export const HtmlMarkup = () => ({
34
68
  });
35
69
 
36
70
  export const Props = () => ({
37
- template: '<farm-btn color="secondary" outlined>props</farm-btn>',
71
+ template: '<farm-btn outlined>props</farm-btn>',
38
72
  });
39
73
 
40
74
  export const Listener = () => ({
@@ -44,7 +78,7 @@ export const Listener = () => ({
44
78
  };
45
79
  },
46
80
  template: `
47
- <farm-btn color="error" @click="x = 2">click me to change: {{ x }}</farm-btn>
81
+ <farm-btn color="error" @click="x++">click me to change: {{ x }}</farm-btn>
48
82
  `,
49
83
  });
50
84
 
@@ -38,7 +38,6 @@ export default Vue.extend({
38
38
  | 'success'
39
39
  | 'error'
40
40
  | 'warning'
41
- | 'success'
42
41
  | 'extra-1'
43
42
  | 'extra-2'
44
43
  >,
@@ -52,6 +51,10 @@ export default Vue.extend({
52
51
  * Is plain
53
52
  */
54
53
  plain: { type: Boolean, default: false },
54
+ /**
55
+ * Is full
56
+ */
57
+ full: { type: Boolean, default: false },
55
58
  /**
56
59
  * Is disabled
57
60
  */
@@ -69,10 +72,17 @@ export default Vue.extend({
69
72
  type: String,
70
73
  default: 'button',
71
74
  },
75
+ /**
76
+ * Denotes the target route of the link
77
+ * Will transform button into a router-link
78
+ */
72
79
  to: {
73
80
  type: String,
74
81
  default: null,
75
82
  },
83
+ /**
84
+ * Size
85
+ */
76
86
  size: {
77
87
  type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
78
88
  default: 'default',
@@ -93,6 +103,7 @@ export default Vue.extend({
93
103
  'farm-btn--round': this.isRound,
94
104
  'farm-btn--rounded': this.rounded,
95
105
  'farm-btn--icon': this.icon,
106
+ 'farm-btn--full': this.full,
96
107
  ['farm-btn--' + this.color]: true,
97
108
  ...obj,
98
109
  };
@@ -1,8 +1,8 @@
1
1
  import { withDesign } from 'storybook-addon-designs';
2
- import baseThemeColors from '../../configurations/_theme-colors-base.scss';
3
- const colors = Object.keys(baseThemeColors);
4
2
  import sizes from '../../configurations/sizes';
3
+ import baseThemeColors from '../../configurations/_theme-colors-base.scss';
5
4
  import iconsList from './icons_list';
5
+ const colors = Object.keys(baseThemeColors);
6
6
 
7
7
  import('./Icons.stories.scss');
8
8
 
@@ -4,14 +4,18 @@
4
4
  .farm-tooltip {
5
5
  display: inline-block;
6
6
  position: relative;
7
+ }
8
+
9
+ .farm-tooltip__popup {
10
+ background-color: themeColor('primary');
7
11
 
8
12
  @each $color in $colors {
9
13
  @each $color in $theme-colors-list {
10
-
11
- &--#{$color} {
12
- .farm-tooltip__popup {
13
- background-color: themeColor($color);
14
- }
14
+
15
+ &.farm-tooltip--#{$color} {
16
+
17
+ background-color: themeColor($color);
18
+
15
19
  }
16
20
  }
17
21
  }
@@ -27,8 +31,11 @@
27
31
  padding: 8px 12px;
28
32
  position: absolute;
29
33
  width: 160px;
30
- left: 50%;
31
- transform: translate(-50%, -110%);
34
+ background-color: themeColor('primary');
35
+ contain: content;
36
+
37
+ display: block;
38
+ font-family: 'Montserrat', sans-serif !important;
32
39
 
33
40
  &--visible {
34
41
  opacity: 1;
@@ -37,7 +37,9 @@ export const Tooltips = () => ({
37
37
  :color="color"
38
38
  style="margin-right: 4px"
39
39
  >
40
- this is the tooltip for {{ color }}
40
+ <span>
41
+ this is the tooltip for {{ color }}
42
+ </span>
41
43
  <template v-slot:activator="{ on, attrs }">
42
44
  {{ color }}
43
45
  </template>
@@ -83,3 +85,16 @@ export const Visibility = () => ({
83
85
  </farm-tooltip>
84
86
  </div>`,
85
87
  });
88
+
89
+ export const TooltipTest = () => ({
90
+ template: `<div style="padding-left: 80px; padding-top: 80px;">
91
+ <farm-card style="padding: 32px">
92
+ <farm-tooltip>
93
+ this is the tooltip!
94
+ <template v-slot:activator="{ on, attrs }">
95
+ <farm-btn style="height: 80px">try me</farm-btn>
96
+ </template>
97
+ </farm-tooltip>
98
+ </farm-card>
99
+ </div>`,
100
+ });
@@ -1,24 +1,26 @@
1
1
  <template>
2
- <span
3
- :class="{ 'farm-tooltip': true, ['farm-tooltip--' + color]: true }"
4
- @mouseover="onOver"
5
- @mouseout="onOut"
6
- ref="parent"
7
- >
8
- <slot name="activator"></slot>
2
+ <span :class="{ 'farm-tooltip': true }" ref="parent">
3
+ <span @mouseover="onOver" @mouseout="onOut" ref="activator">
4
+ <slot name="activator"></slot>
5
+ </span>
6
+
9
7
  <span
8
+ ref="popup"
10
9
  :class="{
11
10
  'farm-tooltip__popup': true,
11
+ ['farm-tooltip--' + color]: true,
12
12
  'farm-tooltip__popup--visible':
13
13
  (!externalControl && showOver) || (externalControl && toggleComponent),
14
14
  }"
15
+ :style="styles"
16
+ @mouseout="onOut"
15
17
  >
16
18
  <slot></slot>
17
19
  </span>
18
20
  </span>
19
21
  </template>
20
22
  <script lang="ts">
21
- import Vue, { PropType, ref, computed } from 'vue';
23
+ import Vue, { PropType, ref, computed, reactive, onBeforeUnmount } from 'vue';
22
24
 
23
25
  export default Vue.extend({
24
26
  name: 'farm-tooltip',
@@ -52,23 +54,60 @@ export default Vue.extend({
52
54
  },
53
55
  setup(props) {
54
56
  const parent = ref(null);
57
+ const popup = ref(null);
58
+ const activator = ref(null);
55
59
  const showOver = ref(false);
60
+ const styles = reactive({
61
+ left: '0',
62
+ top: '0',
63
+ });
56
64
 
57
65
  const toggleComponent = computed(() => props.value);
58
66
  const externalControl = computed(() => props.value !== undefined);
59
67
 
68
+ let hasBeenBoostrapped = false;
69
+
60
70
  const onOver = () => {
61
71
  showOver.value = true;
72
+
73
+ if (!hasBeenBoostrapped) {
74
+ document.querySelector('body').appendChild(popup.value);
75
+ const parentBoundingClientRect = parent.value.getBoundingClientRect();
76
+ const activatorBoundingClientRect = activator.value.getBoundingClientRect();
77
+ const popupBoundingClientRect = popup.value.getBoundingClientRect();
78
+
79
+ styles.left =
80
+ parentBoundingClientRect.left +
81
+ window.scrollX -
82
+ (80 - activatorBoundingClientRect.width / 2) +
83
+ 'px';
84
+ styles.top =
85
+ parentBoundingClientRect.top +
86
+ window.scrollY -
87
+ (popupBoundingClientRect.height + 8) +
88
+ 'px';
89
+
90
+ hasBeenBoostrapped = true;
91
+ }
62
92
  };
63
93
  const onOut = (event: MouseEvent) => {
64
94
  showOver.value = parent.value.contains(event.relatedTarget);
65
95
  };
66
96
 
97
+ onBeforeUnmount(() => {
98
+ if (hasBeenBoostrapped) {
99
+ document.querySelector('body').removeChild(popup.value);
100
+ }
101
+ });
102
+
67
103
  return {
68
104
  parent,
105
+ popup,
106
+ activator,
69
107
  showOver,
70
108
  toggleComponent,
71
109
  externalControl,
110
+ styles,
72
111
  onOver,
73
112
  onOut,
74
113
  };