@farm-investimentos/front-mfe-components 7.6.2 → 8.0.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": "7.6.2",
3
+ "version": "8.0.2",
4
4
  "author": "farm investimentos",
5
5
  "private": false,
6
6
  "main": "./dist/front-mfe-components.common.js",
@@ -0,0 +1,33 @@
1
+ @import '../../configurations/functions';
2
+
3
+ .farm-alert-reload {
4
+ border: 1px solid var(--v-error-base);
5
+ border-radius: 8px;
6
+ padding: gutter('sm') gutter('md');
7
+ display: flex;
8
+ justify-content: space-between;
9
+ align-items: center;
10
+
11
+ &__label {
12
+ padding: 0 gutter('sm');
13
+ }
14
+
15
+ >div {
16
+ display: flex;
17
+ }
18
+
19
+ &--vertical {
20
+ flex-direction: column;
21
+
22
+ >div {
23
+ margin-bottom: gutter('sm');
24
+ }
25
+ }
26
+ }
27
+
28
+ .farm-btn {
29
+ .farm-icon {
30
+ margin-right: gutter('sm');
31
+ }
32
+ }
33
+
@@ -1,13 +1,15 @@
1
1
  import AlertReload from './AlertReload.vue';
2
2
 
3
3
  export default {
4
- title: 'API/AlertReload',
5
- component: AlertReload,
4
+ title: 'API/AlertReload',
5
+ component: AlertReload,
6
6
  };
7
7
 
8
8
  export const Primary = () => ({
9
- components: { AlertReload },
10
- template: '<AlertReload label="Ocorreu um erro ao carregar as informações" />',
9
+ components: { AlertReload },
10
+ template: `<div style="width: 480px;">
11
+ <AlertReload label="Text" />
12
+ </div>`,
11
13
  });
12
14
 
13
15
  Primary.storyName = 'Básico';
@@ -1,30 +1,33 @@
1
1
  <template>
2
- <v-alert dense outlined type="error" class="farm-alert-reload">
3
- <v-row align="center">
4
- <v-col class="grow">
2
+ <div
3
+ :class="{
4
+ 'farm-alert-reload': true,
5
+ 'farm-alert-reload--vertical': $props.vertical,
6
+ }"
7
+ >
8
+ <div>
9
+ <farm-icon color="error">alert</farm-icon>
10
+ <farm-typography tag="span" color="error" class="farm-alert-reload__label">
5
11
  {{ label }}
6
- </v-col>
7
- <v-col class="shrink">
8
- <farm-btn color="secondary" class="ml-3" alt="Recarregar" @click="$emit('onClick')">
9
- <i class="mdi mdi-refresh farm-icon"></i>
10
- Recarregar
11
- </farm-btn>
12
- </v-col>
13
- </v-row>
14
- </v-alert>
12
+ </farm-typography>
13
+ </div>
14
+ <farm-btn color="secondary" alt="Recarregar" @click="$emit('onClick')">
15
+ <farm-icon>refresh</farm-icon>
16
+ Recarregar
17
+ </farm-btn>
18
+ </div>
15
19
  </template>
16
- <script>
17
- import VAlert from 'vuetify/lib/components/VAlert';
18
- import { VRow, VCol } from 'vuetify/lib/components/VGrid';
20
+ <script lang="ts">
19
21
  import DefaultButton from '../Buttons/DefaultButton';
22
+ import Icon from '../Icon';
23
+ import Typography from '../Typography';
20
24
 
21
25
  export default {
22
26
  name: 'farm-alert-reload',
23
27
  components: {
24
- VAlert,
25
- VRow,
26
- VCol,
27
28
  'farm-btn': DefaultButton,
29
+ 'farm-icon': Icon,
30
+ 'farm-typography': Typography,
28
31
  },
29
32
  props: {
30
33
  /**
@@ -34,14 +37,17 @@ export default {
34
37
  type: String,
35
38
  default: '',
36
39
  },
40
+ /**
41
+ * Vertical?
42
+ */
43
+ vertical: {
44
+ type: Boolean,
45
+ default: false,
46
+ },
37
47
  },
38
48
  };
39
49
  </script>
40
50
 
41
51
  <style lang="scss" scoped>
42
- .farm-btn {
43
- .farm-icon {
44
- margin-right: 1rem;
45
- }
46
- }
52
+ @import 'AlertReload';
47
53
  </style>
@@ -1,3 +1,4 @@
1
1
  import AlertReload from './AlertReload.vue';
2
2
 
3
+ export { AlertReload };
3
4
  export default AlertReload;
@@ -1,4 +1,5 @@
1
1
  @import '../../../configurations/variables';
2
+ @import '../../../configurations/mixins';
2
3
 
3
4
  .farm-btn {
4
5
  font-size: 0.75rem;
@@ -17,7 +18,7 @@
17
18
  user-select: none;
18
19
  vertical-align: middle;
19
20
  white-space: nowrap;
20
- line-height: 1rem;
21
+ line-height: 16px;
21
22
  height: 36px;
22
23
  min-width: 64px;
23
24
  padding: 0 16px;
@@ -213,11 +214,17 @@
213
214
  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%);
214
215
  }
215
216
 
216
- @media screen and (max-width: 600px) {
217
+ @include upToSm {
218
+ .farm-btn {
219
+ padding: 0 12px;
220
+ line-height: 12px;
221
+ min-width: 48px;
222
+ }
223
+ }
217
224
 
225
+ @media screen and (max-width: 600px) {
218
226
  .farm-btn.farm-btn--responsive {
219
227
  width: 100%;
220
228
  margin: 0;
221
229
  }
222
-
223
230
  }
@@ -14,7 +14,7 @@
14
14
  margin-top: 0;
15
15
  }
16
16
 
17
- @include for-sm-breakpoint {
17
+ @include forXsOnly {
18
18
  .farm-btn {
19
19
  margin-left: 0;
20
20
  margin-top: gutter();
@@ -0,0 +1,35 @@
1
+ @import '../../configurations/variables';
2
+ @import '../../configurations/mixins';
3
+
4
+ .farm-typography {
5
+ font-size: 1rem;
6
+
7
+ &[bold] {
8
+ font-weight: bold;
9
+ }
10
+
11
+ &[italic] {
12
+ font-style: italic;
13
+ }
14
+
15
+
16
+ @each $k in $colors {
17
+ &#{'[color=' + $k + ']'} {
18
+ color: var(--v-#{$k}-base);
19
+ }
20
+ }
21
+
22
+ @each $s, $val in $fontSizes {
23
+ &--#{$s} {
24
+ font-size: $val;
25
+ }
26
+ }
27
+ }
28
+
29
+ @include upToSm {
30
+ @each $s, $val in $fontSizes {
31
+ .farm-typography--#{$s} {
32
+ font-size: calc(#{$val} - 2px);
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,25 @@
1
+ import Typography from './Typography.vue';
2
+
3
+ export default {
4
+ title: 'API/Typography',
5
+ component: Typography,
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: `Typography<br />
10
+ selector: <em>farm-typography</em>
11
+ `,
12
+ },
13
+ },
14
+ viewMode: 'docs',
15
+ },
16
+ };
17
+
18
+ export const Primary = () => ({
19
+ components: { 'farm-typography': Typography },
20
+ template: `<farm-typography color="secondary">
21
+ farm typography
22
+ </farm-typography>`,
23
+ });
24
+
25
+ Primary.storyName = 'Basic';
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <component
3
+ :is="tag"
4
+ :class="{
5
+ 'farm-typography': true,
6
+ ['farm-typography--' + $props.size]: isSizeFromBreakpoints,
7
+ }"
8
+ :style="style"
9
+ >
10
+ <slot></slot>
11
+ </component>
12
+ </template>
13
+ <script lang="ts">
14
+ import Vue, { computed, PropType, ref } from 'vue';
15
+ import breakPoints from '../../configurations/sizes';
16
+ import typographyHtmlTags from '../../configurations/typographyHtmlTags';
17
+
18
+ export default Vue.extend({
19
+ inheritAttrs: true,
20
+ name: 'farm-typography',
21
+ props: {
22
+ tag: {
23
+ type: String as PropType<
24
+ 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'legend' | 'label' | 'li'
25
+ >,
26
+ default: 'p',
27
+ },
28
+ size: {
29
+ type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
30
+ },
31
+ },
32
+ setup(props, context) {
33
+
34
+ const { weight } = context.attrs;
35
+ const { size } = props;
36
+
37
+ let style = ref({});
38
+ let tag = ref(typographyHtmlTags.includes(props.tag) ? props.tag : 'p');
39
+
40
+ const isSizeFromBreakpoints = computed(() => breakPoints.includes(size));
41
+
42
+ if (props.size !== undefined && !isSizeFromBreakpoints.value) {
43
+ style.value.fontSize = size;
44
+ }
45
+
46
+ if (weight) {
47
+ style.value.fontWeight = weight;
48
+ }
49
+ return {
50
+ style,
51
+ isSizeFromBreakpoints,
52
+ tag,
53
+ };
54
+ },
55
+ });
56
+ </script>
57
+ <style lang="scss" scoped>
58
+ @import './Typography.scss';
59
+ </style>
@@ -0,0 +1,57 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import Typography from '../Typography';
3
+
4
+ describe('Typography component', () => {
5
+ let wrapper;
6
+ let component;
7
+
8
+ beforeEach(() => {
9
+ wrapper = shallowMount(Typography, {
10
+ propsData: {
11
+ tag: 'li',
12
+ },
13
+ });
14
+ component = wrapper.vm;
15
+ });
16
+
17
+ test('Created hook', () => {
18
+ expect(wrapper).toBeDefined();
19
+ });
20
+
21
+ describe('mount component', () => {
22
+ it('renders correctly', () => {
23
+ expect(wrapper.element).toMatchSnapshot();
24
+ });
25
+ });
26
+
27
+ describe('Computed properties', () => {
28
+ it('Should have isSizeFromBreakpoints', () => {
29
+ expect(component.isSizeFromBreakpoints).toBeFalsy();
30
+ });
31
+
32
+ it('Should have isSizeFromBreakpoints truthy', async () => {
33
+ const wrapperTest = shallowMount(Typography, {
34
+ propsData: {
35
+ size: 'lg',
36
+ },
37
+ });
38
+ expect(wrapperTest.vm.isSizeFromBreakpoints).toBeTruthy();
39
+ });
40
+ });
41
+
42
+ describe('Prop data', () => {
43
+
44
+ it('Should have li tag', async () => {
45
+ expect(wrapper.vm.tag).toEqual('li');
46
+ });
47
+
48
+ it('Should not allow invalid html tag', async () => {
49
+ const wrapperTest = shallowMount(Typography, {
50
+ propsData: {
51
+ tag: 'div',
52
+ },
53
+ });
54
+ expect(wrapperTest.vm.tag).toEqual('p');
55
+ });
56
+ });
57
+ });
@@ -0,0 +1,4 @@
1
+ import Typography from './Typography.vue';
2
+
3
+ export { Typography };
4
+ export default Typography;
@@ -2,4 +2,8 @@
2
2
 
3
3
  @function gutter($key: 'default') {
4
4
  @return map-get($gutters, $key)
5
+ }
6
+
7
+ @function fontSize($key: 'default') {
8
+ @return map-get($fontSizes, $key)
5
9
  }
@@ -1,5 +1,25 @@
1
- @mixin for-sm-breakpoint {
1
+ @mixin forXsOnly {
2
2
  @media (max-width: 599px) {
3
3
  @content;
4
4
  }
5
+ }
6
+ @mixin upToSm {
7
+ @media (max-width: 959px) {
8
+ @content;
9
+ }
10
+ }
11
+ @mixin upToMd {
12
+ @media (max-width: 1263px) {
13
+ @content;
14
+ }
15
+ }
16
+ @mixin fromSm {
17
+ @media (min-width: 960) {
18
+ @content;
19
+ }
20
+ }
21
+ @mixin fromMd {
22
+ @media (min-width: 1264px) {
23
+ @content;
24
+ }
5
25
  }
@@ -1,4 +1,4 @@
1
- $colors: primary, secondary, error, extra, accent, info, success, warning, gray, yellow, white;
1
+ $colors: primary, secondary, error, accent, info, success, warning, gray, yellow, white;
2
2
  $sizes: (
3
3
  "xs": 12px,
4
4
  "sm": 16px,
@@ -12,4 +12,14 @@ $gutters: (
12
12
  "default": 12px,
13
13
  'md': 16px,
14
14
  "lg": 36px,
15
- "xl": 40px);
15
+ "xl": 40px
16
+ );
17
+
18
+ $fontSizes: (
19
+ "xs": 8px,
20
+ "sm": 12px,
21
+ "md": 14px,
22
+ "default": 16px,
23
+ "lg": 20px,
24
+ "xl": 24px
25
+ );
@@ -2,7 +2,6 @@ export default [
2
2
  'primary',
3
3
  'secondary',
4
4
  'error',
5
- 'extra',
6
5
  'accent',
7
6
  'info',
8
7
  'success',
@@ -0,0 +1 @@
1
+ export default ['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'label', 'li'];
@@ -0,0 +1,33 @@
1
+ import { withDesign } from 'storybook-addon-designs';
2
+ import { AlertReload } from '../main';
3
+
4
+ export default {
5
+ title: 'Examples/AlertReload',
6
+ decorators: [withDesign],
7
+ parameters: {
8
+ viewMode: 'docs',
9
+ docs: {
10
+ description: {
11
+ component: `AlertReload`,
12
+ },
13
+ },
14
+ },
15
+ };
16
+
17
+ export const Primary = () => ({
18
+ components: {
19
+ 'farm-alert-reload': AlertReload,
20
+ },
21
+ template: `<div style="width: 480px;">
22
+ <farm-alert-reload label="Text" />
23
+ </div>`,
24
+ });
25
+
26
+ export const Vertical = () => ({
27
+ components: {
28
+ 'farm-alert-reload': AlertReload,
29
+ },
30
+ template: `<div style="width: 480px;">
31
+ <farm-alert-reload label="Text" vertical />
32
+ </div>`,
33
+ });
@@ -0,0 +1,117 @@
1
+ import { Typography } from '../main.ts';
2
+ import sizes from '../configurations/sizes';
3
+ import colors from '../configurations/colors';
4
+
5
+ export default {
6
+ title: 'Examples/Typography',
7
+ parameters: {
8
+ docs: {
9
+ description: {
10
+ component: `Typography<br />selector: <em>farm-typography</em>`,
11
+ },
12
+ },
13
+ viewMode: 'docs',
14
+ },
15
+ };
16
+
17
+ export const Primary = () => ({
18
+ components: { 'farm-typography': Typography },
19
+ template: '<farm-typography type="legenda">Typography</farm-typography>',
20
+ });
21
+
22
+ export const Bold = () => ({
23
+ components: { 'farm-typography': Typography },
24
+ template: '<farm-typography bold>Typography</farm-typography>',
25
+ });
26
+
27
+ export const Italic = () => ({
28
+ components: { 'farm-typography': Typography },
29
+ template: '<farm-typography italic>Typography</farm-typography>',
30
+ });
31
+
32
+ export const Weight = () => ({
33
+ components: { 'farm-typography': Typography },
34
+ data() {
35
+ return {
36
+ weights: [100, 200, 300, 400, 500, 600, 700],
37
+ };
38
+ },
39
+ template: `<div>
40
+ <farm-typography v-for="w in weights" :weight="w" :key="w">Typography - weight {{ w }}</farm-typography>
41
+ </div>`,
42
+ });
43
+
44
+ const newSizes = [...sizes];
45
+ newSizes.splice(3, 0, 'default');
46
+
47
+ export const Sizes = () => ({
48
+ components: { 'farm-typography': Typography },
49
+ data() {
50
+ return {
51
+ sizes: newSizes,
52
+ };
53
+ },
54
+ template: `<div>
55
+ <farm-typography
56
+ v-for="s in sizes"
57
+ :size="s"
58
+ :key="s"
59
+ >
60
+ Typography - size {{ s }}
61
+ </farm-typography>
62
+ </div>`,
63
+ });
64
+
65
+ export const CustomSizes = () => ({
66
+ components: { 'farm-typography': Typography },
67
+ data() {
68
+ return {
69
+ sizes: ['11px', '1.12876rem', '48px'],
70
+ };
71
+ },
72
+ template: `<div>
73
+ <farm-typography
74
+ v-for="s in sizes"
75
+ :size="s"
76
+ :key="s"
77
+ >
78
+ Typography - size {{ s }}
79
+ </farm-typography>
80
+ </div>`,
81
+ });
82
+
83
+ export const Colors = () => ({
84
+ components: { 'farm-typography': Typography },
85
+ data() {
86
+ return {
87
+ colors,
88
+ };
89
+ },
90
+ template: `<div>
91
+ <farm-typography
92
+ v-for="color in colors"
93
+ :color="color"
94
+ :key="color"
95
+ >
96
+ Typography - color {{ color }}
97
+ </farm-typography>
98
+ </div>`,
99
+ });
100
+
101
+ export const Tags = () => ({
102
+ components: { 'farm-typography': Typography },
103
+ data() {
104
+ return {
105
+ tags: ['p', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'legend', 'label', 'li'],
106
+ };
107
+ },
108
+ template: `<div>
109
+ <farm-typography
110
+ v-for="t in tags"
111
+ :tag="t"
112
+ :key="t"
113
+ >
114
+ Typography - tag {{ t }}
115
+ </farm-typography>
116
+ </div>`,
117
+ });
package/src/main.ts CHANGED
@@ -2,7 +2,6 @@ import DataTableEmptyWrapper from './components/DataTableEmptyWrapper';
2
2
 
3
3
  import DataTablePaginator from './components/DataTablePaginator';
4
4
  import DataTableHeader from './components/DataTableHeader';
5
- import AlertReload from './components/AlertReload';
6
5
  import MainFilter from './components/MainFilter';
7
6
  import Loader from './components/Loader';
8
7
  import FilePicker from './components/FilePicker';
@@ -33,7 +32,6 @@ export {
33
32
  Tabs,
34
33
  DialogHeader,
35
34
  DialogFooter,
36
- AlertReload,
37
35
  DefaultTextField,
38
36
  RangeDatePicker,
39
37
  DatePicker,
@@ -47,6 +45,7 @@ export {
47
45
  Collapsible,
48
46
  };
49
47
 
48
+ export * from './components/AlertReload';
50
49
  export * from './components/Buttons/DefaultButton';
51
50
  export * from './components/Buttons/DangerButton';
52
51
  export * from './components/Buttons/ConfirmButton';
@@ -70,6 +69,7 @@ export * from './components/Stepper';
70
69
  export * from './components/Switcher';
71
70
  export * from './components/TextField';
72
71
  export * from './components/Tooltip';
72
+ export * from './components/Typography';
73
73
 
74
74
  export * from './components/layout/Container';
75
75
  export * from './components/layout/ContainerFooter';