@farm-investimentos/front-mfe-components 11.4.1 → 11.4.3

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.3",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <div>alertbox</div>
2
+ <div>
3
+ <!--
4
+ @slot Use this slot for the content
5
+ -->
6
+ <slot></slot>
7
+ </div>
3
8
  </template>
4
9
 
5
10
  <script lang="ts">
@@ -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
  };
@@ -13,7 +13,7 @@
13
13
  </farm-typography>
14
14
  </div>
15
15
  <div class="collapsible__icon collapsible__icon--arrow">
16
- <farm-icon size="md" color="primary">
16
+ <farm-icon size="md" color="secondary">
17
17
  {{ arrowIcon }}
18
18
  </farm-icon>
19
19
  </div>
@@ -42,12 +42,16 @@ export default Vue.extend({
42
42
  required: true,
43
43
  },
44
44
  /**
45
- * Icon
45
+ * Icon (from Material Icons)
46
+ * Example: chart-bar
46
47
  */
47
48
  icon: {
48
49
  type: String,
49
50
  default: '',
50
51
  },
52
+ /**
53
+ * Is open?
54
+ */
51
55
  open: {
52
56
  type: Boolean,
53
57
  default: false,
@@ -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
 
@@ -29,7 +29,8 @@ export default Vue.extend({
29
29
  name: 'farm-idcaption',
30
30
  props: {
31
31
  /**
32
- * Icon
32
+ * Icon (from Material Icons)
33
+ * Example: chart-bar
33
34
  */
34
35
  icon: {
35
36
  type: String,
@@ -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
  };
@@ -6,6 +6,7 @@
6
6
  flex-basis: 0;
7
7
  flex-grow: 1;
8
8
  max-width: 100%;
9
+ width: 100;
9
10
 
10
11
  &--no-gutters {
11
12
  padding: 0;
@@ -13,11 +14,18 @@
13
14
 
14
15
  @each $k in $aligns {
15
16
  &#{'--align-' + $k} {
16
- align-self: $k!important;
17
+ align-self: $k !important;
17
18
  }
18
19
  }
19
20
  }
20
21
 
22
+ @for $i from 1 through 12 {
23
+ .farm-col--cols-#{$i * 1} {
24
+ flex: 0 0 (100/12 * $i)+#{"%"};
25
+ max-width: (100/12 * $i)+#{"%"};
26
+ }
27
+ }
28
+
21
29
  @for $i from 1 through 12 {
22
30
  .farm-col--xs-#{$i * 1} {
23
31
  flex: 0 0 (100/12 * $i)+#{"%"};
@@ -22,51 +22,64 @@ const style = {
22
22
  backgroundColor: 'var(--farm-extra-1-lighten)',
23
23
  };
24
24
 
25
+ const items = Array.from(Array(12).keys());
26
+
25
27
  export const Primary = () => ({
26
28
  data() {
27
29
  return {
28
30
  style,
29
31
  };
30
32
  },
31
- template: '<farm-col :style="style">col</farm-col>',
33
+ template: `<farm-col>
34
+ <farm-col :style="style">col</farm-col>
35
+ </farm-col>`,
32
36
  });
33
- export const Xl = () => ({
37
+
38
+ export const Cols = () => ({
34
39
  data() {
35
40
  return {
36
41
  style,
42
+ items
37
43
  };
38
44
  },
39
45
  template: `<farm-row>
40
- <farm-col xl="4" :style="style">4</farm-col>
41
- <farm-col xl="6" :style="style">6</farm-col>
42
- <farm-col xl="12" :style="style">12</farm-col>
43
- <farm-col xl="2" :style="style">2</farm-col>
46
+ <farm-col v-for="item in items" :key="'col_' + item" :cols="item + 1" :style="style">{{item + 1}}</farm-col>
44
47
  </farm-row>`,
45
48
  });
49
+
50
+ export const Xl = () => ({
51
+ data() {
52
+ return {
53
+ style,
54
+ items
55
+ };
56
+ },
57
+ template: `<farm-row>
58
+ <farm-col v-for="item in items" :key="'xl_' + item" :xl="item + 1" :style="style">{{item + 1}}</farm-col>
59
+ </farm-row>`,
60
+ });
61
+
46
62
  export const Lg = () => ({
47
63
  data() {
48
64
  return {
49
65
  style,
66
+ items
50
67
  };
51
68
  },
52
69
  template: `<farm-row>
53
- <farm-col lg="4" :style="style">4</farm-col>
54
- <farm-col lg="6" :style="style">6</farm-col>
55
- <farm-col lg="12" :style="style">12</farm-col>
56
- <farm-col lg="2" :style="style">2</farm-col>
57
- </farm-row>`,
70
+ <farm-col v-for="item in items" :key="'lg_' + item" :lg="item + 1" :style="style">{{item + 1}}</farm-col>
71
+ </farm-row>`,
58
72
  });
73
+
59
74
  export const Md = () => ({
60
75
  data() {
61
76
  return {
62
77
  style,
78
+ items
63
79
  };
64
80
  },
65
81
  template: `<farm-row>
66
- <farm-col md="4" :style="style">4</farm-col>
67
- <farm-col md="6" :style="style">6</farm-col>
68
- <farm-col md="12" :style="style">12</farm-col>
69
- <farm-col md="2" :style="style">2</farm-col>
82
+ <farm-col v-for="item in items" :key="'md_' + item" :md="item + 1" :style="style">{{item + 1}}</farm-col>
70
83
  </farm-row>`,
71
84
  });
72
85
 
@@ -74,13 +87,11 @@ export const Sm = () => ({
74
87
  data() {
75
88
  return {
76
89
  style,
90
+ items
77
91
  };
78
92
  },
79
93
  template: `<farm-row>
80
- <farm-col sm="4" :style="style">4</farm-col>
81
- <farm-col sm="6" :style="style">6</farm-col>
82
- <farm-col sm="12" :style="style">12</farm-col>
83
- <farm-col sm="2" :style="style">2</farm-col>
94
+ <farm-col v-for="item in items" :key="'sm_' + item" :sm="item + 1" :style="style">{{item + 1}}</farm-col>
84
95
  </farm-row>`,
85
96
  });
86
97
 
@@ -88,14 +99,12 @@ export const Xs = () => ({
88
99
  data() {
89
100
  return {
90
101
  style,
102
+ items
91
103
  };
92
104
  },
93
105
  template: `<farm-row>
94
- <farm-col xs="4" :style="style">4</farm-col>
95
- <farm-col xs="6" :style="style">6</farm-col>
96
- <farm-col xs="12" :style="style">12</farm-col>
97
- <farm-col xs="2" :style="style">2</farm-col>
98
- </farm-row>`,
106
+ <farm-col v-for="item in items" :key="'xs_' + item" :xs="item + 1" :style="style">{{item + 1}}</farm-col>
107
+ </farm-row>`,
99
108
  });
100
109
 
101
110
  export const Combination = () => ({
@@ -105,7 +114,7 @@ export const Combination = () => ({
105
114
  };
106
115
  },
107
116
  template: `<div>
108
- <farm-col lg="5" md="4" sm="3" :style="style">lg: 5 - md: 4 - sm: 3</farm-col>
117
+ <farm-col cols="9" lg="5" md="4" sm="3" :style="style">lg: 5 - md: 4 - sm: 3</farm-col>
109
118
  </div>`,
110
119
  });
111
120
  export const TagP = () => ({
@@ -9,6 +9,7 @@
9
9
  [`farm-col--md-${md}`]: md,
10
10
  [`farm-col--sm-${sm}`]: sm,
11
11
  [`farm-col--xs-${xs}`]: xs,
12
+ [`farm-col--cols-${cols}`]: cols,
12
13
  'farm-col--no-gutters': noGutters,
13
14
  }"
14
15
  >
@@ -25,6 +26,13 @@ export default Vue.extend({
25
26
  * Html tag
26
27
  */
27
28
  tag: { type: String, default: 'div' },
29
+ /**
30
+ * Sets the default number of columns the component extends
31
+ */
32
+ cols: {
33
+ type: [String, Number] as PropType<1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12>,
34
+ default: null,
35
+ },
28
36
  /**
29
37
  * Extra-large breakpoint
30
38
  */