|
2 | 2 | import { useNestedProp } from "../useNestedProp"; |
3 | 3 |
|
4 | 4 | const props = defineProps({ |
5 | | - config: { |
6 | | - type: Object, |
7 | | - default() { |
8 | | - return {} |
9 | | - } |
10 | | - }, |
11 | | - lineHeight: { |
12 | | - type: [String, Boolean], |
13 | | - default: false |
| 5 | + config: { |
| 6 | + type: Object, |
| 7 | + default() { |
| 8 | + return {} |
14 | 9 | } |
| 10 | + }, |
| 11 | + lineHeight: { |
| 12 | + type: [String, Boolean], |
| 13 | + default: false |
| 14 | + } |
15 | 15 | }); |
16 | 16 |
|
17 | 17 | const CONFIG = useNestedProp({ |
18 | | - userConfig: props.config, |
19 | | - defaultConfig: { |
20 | | - title: { |
21 | | - cy: "", |
22 | | - text: "", |
23 | | - color: "", |
24 | | - fontSize: 20, |
25 | | - bold: true, |
26 | | - textAlign: 'center', |
27 | | - paddingLeft: 0, |
28 | | - paddingRight: 0 |
29 | | - }, |
30 | | - subtitle: { |
31 | | - cy: "", |
32 | | - text: "", |
33 | | - color: "", |
34 | | - fontSize: 14, |
35 | | - bold: false |
36 | | - }, |
| 18 | + userConfig: props.config, |
| 19 | + defaultConfig: { |
| 20 | + title: { |
| 21 | + cy: "", |
| 22 | + text: "", |
| 23 | + color: "", |
| 24 | + fontSize: 20, |
| 25 | + bold: true, |
| 26 | + textAlign: "center", |
| 27 | + paddingLeft: 0, |
| 28 | + paddingRight: 0 |
| 29 | + }, |
| 30 | + subtitle: { |
| 31 | + cy: "", |
| 32 | + text: "", |
| 33 | + color: "", |
| 34 | + fontSize: 14, |
| 35 | + bold: false |
37 | 36 | } |
| 37 | + } |
38 | 38 | }); |
39 | | -
|
40 | 39 | </script> |
41 | 40 |
|
42 | 41 | <template> |
43 | | - <div |
44 | | - class="atom-title" |
45 | | - :data-cy="CONFIG.title.cy" |
46 | | - :style="`width: calc(100% - ${CONFIG.title.paddingLeft + CONFIG.title.paddingRight}px); text-align:${CONFIG.title.textAlign};color:${ |
47 | | - CONFIG.title.color |
48 | | - };font-size:${CONFIG.title.fontSize}px;font-weight:${ |
49 | | - CONFIG.title.bold ? 'bold' : '' |
50 | | - };padding-left:${CONFIG.title.paddingLeft}px;padding-right:${CONFIG.title.paddingRight}px;${lineHeight ? `line-height:${lineHeight}`: ''}`" |
51 | | - > |
| 42 | + <div class="atom-title" :data-cy="CONFIG.title.cy" :style="{ |
| 43 | + width: `calc(100% - ${CONFIG.title.paddingLeft + CONFIG.title.paddingRight}px)`, |
| 44 | + textAlign: CONFIG.title.textAlign, |
| 45 | + color: CONFIG.title.color, |
| 46 | + fontSize: `var(--title-font-size, ${CONFIG.title.fontSize}px)`, |
| 47 | + fontWeight: CONFIG.title.bold ? 'bold' : '', |
| 48 | + paddingLeft: CONFIG.title.paddingLeft + 'px', |
| 49 | + paddingRight: CONFIG.title.paddingRight + 'px', |
| 50 | + lineHeight: lineHeight ? lineHeight : undefined |
| 51 | + }"> |
52 | 52 | {{ CONFIG.title.text }} |
53 | 53 | </div> |
54 | | - <div |
55 | | - class="atom-subtitle" |
56 | | - :data-cy="CONFIG.subtitle.cy" |
57 | | - v-if="CONFIG.subtitle.text" |
58 | | - :style="`width: calc(100% - ${CONFIG.title.paddingLeft + CONFIG.title.paddingRight}px); text-align:${CONFIG.title.textAlign};color:${ |
59 | | - CONFIG.subtitle.color |
60 | | - };font-size:${CONFIG.subtitle.fontSize}px;font-weight:${ |
61 | | - CONFIG.subtitle.bold ? 'bold' : '' |
62 | | - };padding-left:${CONFIG.title.paddingLeft}px;padding-right:${CONFIG.title.paddingRight}px;${lineHeight ? `line-height:${lineHeight}`: ''}`" |
63 | | - > |
| 54 | + |
| 55 | + <div class="atom-subtitle" :data-cy="CONFIG.subtitle.cy" v-if="CONFIG.subtitle.text" :style="{ |
| 56 | + width: `calc(100% - ${CONFIG.title.paddingLeft + CONFIG.title.paddingRight}px)`, |
| 57 | + textAlign: CONFIG.title.textAlign, |
| 58 | + color: CONFIG.subtitle.color, |
| 59 | + fontSize: `var(--subtitle-font-size, ${CONFIG.subtitle.fontSize}px)`, |
| 60 | + fontWeight: CONFIG.subtitle.bold ? 'bold' : '', |
| 61 | + paddingLeft: CONFIG.title.paddingLeft + 'px', |
| 62 | + paddingRight: CONFIG.title.paddingRight + 'px', |
| 63 | + lineHeight: lineHeight ? lineHeight : undefined |
| 64 | + }"> |
64 | 65 | {{ CONFIG.subtitle.text }} |
65 | 66 | </div> |
66 | | - <div |
67 | | - :data-cy="CONFIG.subtitle.cy" |
68 | | - v-if="CONFIG.subtitle.text" |
69 | | - :style="`width: calc(100% - ${CONFIG.title.paddingLeft + CONFIG.title.paddingRight}px); text-align:${CONFIG.title.textAlign};color:${ |
70 | | - CONFIG.subtitle.color |
71 | | - };font-size:${CONFIG.subtitle.fontSize}px;font-weight:${ |
72 | | - CONFIG.subtitle.bold ? 'bold' : '' |
73 | | - };padding-left:${CONFIG.title.paddingLeft}px;padding-right:${CONFIG.title.paddingRight}px;${lineHeight ? `line-height:${lineHeight}`: ''}`" |
74 | | - > |
75 | | - <slot/> |
| 67 | + |
| 68 | + <div :data-cy="CONFIG.subtitle.cy" v-if="CONFIG.subtitle.text" :style="{ |
| 69 | + width: `calc(100% - ${CONFIG.title.paddingLeft + CONFIG.title.paddingRight}px)`, |
| 70 | + textAlign: CONFIG.title.textAlign, |
| 71 | + color: CONFIG.subtitle.color, |
| 72 | + fontSize: `var(--subtitle-font-size, ${CONFIG.subtitle.fontSize}px)`, |
| 73 | + fontWeight: CONFIG.subtitle.bold ? 'bold' : '', |
| 74 | + paddingLeft: CONFIG.title.paddingLeft + 'px', |
| 75 | + paddingRight: CONFIG.title.paddingRight + 'px', |
| 76 | + lineHeight: lineHeight ? lineHeight : undefined |
| 77 | + }"> |
| 78 | + <slot /> |
76 | 79 | </div> |
77 | 80 | </template> |
0 commit comments