@farm-investimentos/front-mfe-components 7.6.2 → 8.0.0
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/dist/front-mfe-components.common.js +277 -1749
- package/dist/front-mfe-components.common.js.map +1 -1
- package/dist/front-mfe-components.css +1 -1
- package/dist/front-mfe-components.umd.js +251 -1723
- package/dist/front-mfe-components.umd.js.map +1 -1
- package/dist/front-mfe-components.umd.min.js +1 -1
- package/dist/front-mfe-components.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Typography/Typography.scss +28 -0
- package/src/components/Typography/Typography.stories.js +25 -0
- package/src/components/Typography/Typography.vue +66 -0
- package/src/components/Typography/__tests__/Typography.spec.js +38 -0
- package/src/components/Typography/index.ts +4 -0
- package/src/configurations/_functions.scss +4 -0
- package/src/configurations/_variables.scss +12 -2
- package/src/examples/Typography.stories.js +117 -0
- package/src/main.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@import '../../configurations/variables';
|
|
2
|
+
|
|
3
|
+
.farm-typography {
|
|
4
|
+
font-size: 1rem;
|
|
5
|
+
|
|
6
|
+
&[bold] {
|
|
7
|
+
font-weight: bold;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&[italic] {
|
|
11
|
+
font-style: italic;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@each $k in $colors {
|
|
16
|
+
&#{'[color=' + $k + ']'} {
|
|
17
|
+
color: var(--v-#{$k}-base);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@each $s, $val in $fontSizes {
|
|
22
|
+
&--#{$s} {
|
|
23
|
+
font-size: $val;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
}
|
|
@@ -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,66 @@
|
|
|
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
|
+
|
|
16
|
+
const breakPoints = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
17
|
+
|
|
18
|
+
export default Vue.extend({
|
|
19
|
+
inheritAttrs: true,
|
|
20
|
+
props: {
|
|
21
|
+
tag: {
|
|
22
|
+
type: String as PropType<
|
|
23
|
+
| 'p'
|
|
24
|
+
| 'span'
|
|
25
|
+
| 'h1'
|
|
26
|
+
| 'h2'
|
|
27
|
+
| 'h3'
|
|
28
|
+
| 'h4'
|
|
29
|
+
| 'h5'
|
|
30
|
+
| 'h6'
|
|
31
|
+
| 'legend'
|
|
32
|
+
| 'label'
|
|
33
|
+
| 'li'
|
|
34
|
+
>,
|
|
35
|
+
default: 'p',
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
setup(props, context) {
|
|
42
|
+
let style = ref({});
|
|
43
|
+
|
|
44
|
+
const { weight } = context.attrs;
|
|
45
|
+
const { size } = props;
|
|
46
|
+
|
|
47
|
+
const isSizeFromBreakpoints = computed(() => breakPoints.includes(size));
|
|
48
|
+
|
|
49
|
+
if (props.size !== undefined && !isSizeFromBreakpoints.value) {
|
|
50
|
+
style.value.fontSize = size;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (weight) {
|
|
54
|
+
style.value.fontWeight = weight;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
style,
|
|
59
|
+
isSizeFromBreakpoints,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
<style lang="scss" scoped>
|
|
65
|
+
@import './Typography.scss';
|
|
66
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
import Typography from '../Typography';
|
|
4
|
+
|
|
5
|
+
describe('Typography component', () => {
|
|
6
|
+
let wrapper;
|
|
7
|
+
let component;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
wrapper = shallowMount(Typography, {});
|
|
11
|
+
component = wrapper.vm;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Created hook', () => {
|
|
15
|
+
expect(wrapper).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('mount component', () => {
|
|
19
|
+
it('renders correctly', () => {
|
|
20
|
+
expect(wrapper.element).toMatchSnapshot();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Computed properties', () => {
|
|
25
|
+
it('Should have isSizeFromBreakpoints', () => {
|
|
26
|
+
expect(component.isSizeFromBreakpoints).toBeFalsy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('Should have isSizeFromBreakpoints truthy', async () => {
|
|
30
|
+
const wrapperTest = shallowMount(Typography, {
|
|
31
|
+
propsData: {
|
|
32
|
+
size: 'lg',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
expect(wrapperTest.vm.isSizeFromBreakpoints).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
$colors: primary, secondary, error,
|
|
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
|
+
);
|
|
@@ -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
|
@@ -70,6 +70,7 @@ export * from './components/Stepper';
|
|
|
70
70
|
export * from './components/Switcher';
|
|
71
71
|
export * from './components/TextField';
|
|
72
72
|
export * from './components/Tooltip';
|
|
73
|
+
export * from './components/Typography';
|
|
73
74
|
|
|
74
75
|
export * from './components/layout/Container';
|
|
75
76
|
export * from './components/layout/ContainerFooter';
|