@farm-investimentos/front-mfe-components-vue3 1.4.0 → 1.5.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 +435 -422
- 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 +435 -422
- 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/dist/img/currency-exchange.00d6a787.svg +3 -0
- package/package.json +1 -1
- package/src/assets/icons/README.md +33 -0
- package/src/assets/icons/currency-exchange/currency-exchange.scss +14 -0
- package/src/assets/icons/currency-exchange/currency-exchange.svg +3 -0
- package/src/assets/icons/custom-icons-list.ts +3 -0
- package/src/assets/icons/custom-icons.scss +2 -0
- package/src/assets/icons/index.ts +2 -0
- package/src/components/Icon/Icon.scss +1 -0
- package/src/components/Icon/Icon.stories.js +28 -0
- package/src/components/Icon/Icon.vue +7 -2
- package/src/components/Icon/icons_list.ts +3 -0
- package/src/components/Tooltip/Tooltip.scss +0 -21
- package/src/components/Tooltip/Tooltip.stories.js +38 -38
- package/src/components/Tooltip/Tooltip.vue +7 -12
- package/src/components/Tooltip/docs/Tooltip.md +50 -24
- package/src/components/Tooltip/types.ts +3 -11
- package/src/main.ts +4 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M8.59366 6.90002C7.40699 6.50669 6.83366 6.26002 6.83366 5.63335C6.83366 4.95335 7.57366 4.70669 8.04033 4.70669C8.91366 4.70669 9.23366 5.36669 9.30699 5.60002L10.3603 5.15335C10.2603 4.85335 9.81366 3.87335 8.66699 3.66002V2.83335H7.33366V3.67335C5.68033 4.04669 5.67366 5.58002 5.67366 5.64669C5.67366 7.16002 7.17366 7.58669 7.90699 7.85335C8.96033 8.22669 9.42699 8.56669 9.42699 9.20669C9.42699 9.96002 8.72699 10.28 8.10699 10.28C6.89366 10.28 6.54699 9.03335 6.50699 8.88669L5.40033 9.33335C5.82033 10.7934 6.92033 11.1867 7.33366 11.3067V12.1667H8.66699V11.34C8.93366 11.28 10.6003 10.9467 10.6003 9.19335C10.6003 8.26669 10.1937 7.45335 8.59366 6.90002ZM2.00033 13.5H0.666992V9.50002H4.66699V10.8334H3.01366C4.08699 12.44 5.92033 13.5 8.00033 13.5C11.3137 13.5 14.0003 10.8134 14.0003 7.50002H15.3337C15.3337 11.5534 12.0537 14.8334 8.00033 14.8334C5.52033 14.8334 3.32699 13.6 2.00033 11.72V13.5ZM0.666992 7.50002C0.666992 3.44669 3.94699 0.166687 8.00033 0.166687C10.4803 0.166687 12.6737 1.40002 14.0003 3.28002V1.50002H15.3337V5.50002H11.3337V4.16669H12.987C11.9137 2.56002 10.0803 1.50002 8.00033 1.50002C4.68699 1.50002 2.00033 4.18669 2.00033 7.50002H0.666992Z" fill="#F5F5F5"/>
|
|
3
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Custom Icons System
|
|
2
|
+
|
|
3
|
+
This directory contains custom SVG icons for the component library.
|
|
4
|
+
|
|
5
|
+
## How to Add a New Custom Icon
|
|
6
|
+
|
|
7
|
+
1. **Create a folder** with the icon name in this directory: `src/assets/icons/[icon-name]/`
|
|
8
|
+
2. **Add the SVG file**: `[icon-name].svg`
|
|
9
|
+
3. **Create the SCSS file**: `[icon-name].scss` with the appropriate CSS class
|
|
10
|
+
4. **Import the SCSS** in `custom-icons.scss`
|
|
11
|
+
5. **Add to the list** in `custom-icons-list.ts`
|
|
12
|
+
|
|
13
|
+
## Example Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
currency-exchange/
|
|
17
|
+
├── currency-exchange.svg # SVG file from Figma
|
|
18
|
+
└── currency-exchange.scss # CSS styles with .custom-currency-exchange class
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```vue
|
|
24
|
+
<farm-icon>custom-currency-exchange</farm-icon>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## CSS Class Pattern
|
|
28
|
+
|
|
29
|
+
All custom icons must follow the pattern:
|
|
30
|
+
|
|
31
|
+
- **Prefix**: `custom-`
|
|
32
|
+
- **Class name**: `.custom-[icon-name]`
|
|
33
|
+
- **CSS**: Uses `mask` property with `currentColor` for dynamic coloring
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.farm-icon {
|
|
2
|
+
&.custom-currency-exchange:before {
|
|
3
|
+
content: '';
|
|
4
|
+
display: inline-block;
|
|
5
|
+
width: 1em;
|
|
6
|
+
height: 1em;
|
|
7
|
+
background-color: currentColor;
|
|
8
|
+
mask: url('../../assets/icons/currency-exchange/currency-exchange.svg') no-repeat center;
|
|
9
|
+
mask-size: contain;
|
|
10
|
+
-webkit-mask: url('../../assets/icons/currency-exchange/currency-exchange.svg') no-repeat
|
|
11
|
+
center;
|
|
12
|
+
-webkit-mask-size: contain;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="16" height="15" viewBox="0 0 16 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M8.59366 6.90002C7.40699 6.50669 6.83366 6.26002 6.83366 5.63335C6.83366 4.95335 7.57366 4.70669 8.04033 4.70669C8.91366 4.70669 9.23366 5.36669 9.30699 5.60002L10.3603 5.15335C10.2603 4.85335 9.81366 3.87335 8.66699 3.66002V2.83335H7.33366V3.67335C5.68033 4.04669 5.67366 5.58002 5.67366 5.64669C5.67366 7.16002 7.17366 7.58669 7.90699 7.85335C8.96033 8.22669 9.42699 8.56669 9.42699 9.20669C9.42699 9.96002 8.72699 10.28 8.10699 10.28C6.89366 10.28 6.54699 9.03335 6.50699 8.88669L5.40033 9.33335C5.82033 10.7934 6.92033 11.1867 7.33366 11.3067V12.1667H8.66699V11.34C8.93366 11.28 10.6003 10.9467 10.6003 9.19335C10.6003 8.26669 10.1937 7.45335 8.59366 6.90002ZM2.00033 13.5H0.666992V9.50002H4.66699V10.8334H3.01366C4.08699 12.44 5.92033 13.5 8.00033 13.5C11.3137 13.5 14.0003 10.8134 14.0003 7.50002H15.3337C15.3337 11.5534 12.0537 14.8334 8.00033 14.8334C5.52033 14.8334 3.32699 13.6 2.00033 11.72V13.5ZM0.666992 7.50002C0.666992 3.44669 3.94699 0.166687 8.00033 0.166687C10.4803 0.166687 12.6737 1.40002 14.0003 3.28002V1.50002H15.3337V5.50002H11.3337V4.16669H12.987C11.9137 2.56002 10.0803 1.50002 8.00033 1.50002C4.68699 1.50002 2.00033 4.18669 2.00033 7.50002H0.666992Z" fill="#F5F5F5"/>
|
|
3
|
+
</svg>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import Icon from './Icon.vue';
|
|
3
3
|
import iconsList from './icons_list';
|
|
4
4
|
|
|
5
|
+
import { customIconsList } from '../../assets/icons';
|
|
5
6
|
import baseThemeColors from '../../configurations/_theme-colors-base.module.scss';
|
|
6
7
|
import bwThemeColors from '../../configurations/_theme-colors-bw.module.scss';
|
|
7
8
|
import sizes from '../../configurations/sizes';
|
|
@@ -156,3 +157,30 @@ export const ListOfIcons = () => ({
|
|
|
156
157
|
</div>
|
|
157
158
|
</div>`,
|
|
158
159
|
});
|
|
160
|
+
|
|
161
|
+
export const CustomIcons = () => ({
|
|
162
|
+
data() {
|
|
163
|
+
return {
|
|
164
|
+
customIconsList: [...customIconsList],
|
|
165
|
+
colors: [...colors],
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
template: `<div>
|
|
169
|
+
<h3>Custom Icons ({{ customIconsList.length }} available)</h3>
|
|
170
|
+
<div class="icons-container__list">
|
|
171
|
+
<div v-for="icon of customIconsList" :key="'custom_icon_' + icon">
|
|
172
|
+
<farm-icon>
|
|
173
|
+
{{ icon }}
|
|
174
|
+
</farm-icon>
|
|
175
|
+
<span>{{ icon }}</span>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
<br />
|
|
179
|
+
<h4>Color Examples</h4>
|
|
180
|
+
<div class="icons-container">
|
|
181
|
+
<farm-icon v-for="color of colors" :key="'currency_' + color" :color="color">
|
|
182
|
+
custom-currency-exchange
|
|
183
|
+
</farm-icon>
|
|
184
|
+
</div>
|
|
185
|
+
</div>`,
|
|
186
|
+
});
|
|
@@ -53,11 +53,16 @@ export default {
|
|
|
53
53
|
const el = ref(null);
|
|
54
54
|
|
|
55
55
|
const classes = computed(() => {
|
|
56
|
+
const isCustomIcon = icon.value.startsWith('custom-');
|
|
57
|
+
|
|
56
58
|
return {
|
|
57
59
|
'farm-icon': true,
|
|
58
60
|
['farm-icon--' + color.value]: true,
|
|
59
|
-
|
|
60
|
-
['mdi-' + icon.value]: true,
|
|
61
|
+
// Classes MDI para ícones padrão
|
|
62
|
+
...(isCustomIcon ? {} : { mdi: true, ['mdi-' + icon.value]: true }),
|
|
63
|
+
// Classe customizada para ícones personalizados
|
|
64
|
+
...(isCustomIcon ? { [icon.value]: true } : {}),
|
|
65
|
+
// Variações de cor
|
|
61
66
|
'farm-icon--lighten': variation.value === 'lighten',
|
|
62
67
|
'farm-icon--darken': variation.value === 'darken',
|
|
63
68
|
['farm-icon--black-' + variation.value]: color.value === 'black',
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* CSS simplificado para Tooltip - Abordagem simples e direta
|
|
3
|
-
* SEMPRE usa position: fixed via JavaScript
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/* Container principal */
|
|
7
1
|
.tooltip-container {
|
|
8
2
|
display: inline-block;
|
|
9
3
|
position: relative;
|
|
10
4
|
}
|
|
11
5
|
|
|
12
|
-
/* Activator */
|
|
13
6
|
.tooltip-activator {
|
|
14
7
|
display: inline-block;
|
|
15
8
|
}
|
|
16
9
|
|
|
17
|
-
/*
|
|
18
|
-
* COMPATIBILIDADE: Classes antigas mantidas para outros componentes
|
|
19
|
-
* que fazem @extend .farm-tooltip__popup
|
|
20
|
-
*/
|
|
21
10
|
.farm-tooltip {
|
|
22
11
|
display: inline-block;
|
|
23
12
|
position: relative;
|
|
@@ -28,7 +17,6 @@
|
|
|
28
17
|
}
|
|
29
18
|
|
|
30
19
|
.farm-tooltip__popup {
|
|
31
|
-
/* Estilos base mantidos para compatibilidade */
|
|
32
20
|
background-color: #333333;
|
|
33
21
|
color: #f5f5f5;
|
|
34
22
|
border-radius: 5px;
|
|
@@ -41,12 +29,10 @@
|
|
|
41
29
|
transform: translateZ(0);
|
|
42
30
|
pointer-events: auto;
|
|
43
31
|
|
|
44
|
-
/* Estados */
|
|
45
32
|
opacity: 0;
|
|
46
33
|
visibility: hidden;
|
|
47
34
|
transition: opacity 0.3s linear, visibility 0.3s linear;
|
|
48
35
|
|
|
49
|
-
/* Variantes */
|
|
50
36
|
&--visible {
|
|
51
37
|
opacity: 1;
|
|
52
38
|
visibility: visible;
|
|
@@ -57,7 +43,6 @@
|
|
|
57
43
|
max-width: 300px;
|
|
58
44
|
}
|
|
59
45
|
|
|
60
|
-
/* Header */
|
|
61
46
|
.farm-tooltip__header {
|
|
62
47
|
display: flex;
|
|
63
48
|
justify-content: space-between;
|
|
@@ -86,7 +71,6 @@
|
|
|
86
71
|
}
|
|
87
72
|
}
|
|
88
73
|
|
|
89
|
-
/* Estilos globais para tooltip criado dinamicamente */
|
|
90
74
|
.tooltip-popup {
|
|
91
75
|
background-color: #333333;
|
|
92
76
|
color: #f5f5f5;
|
|
@@ -100,7 +84,6 @@
|
|
|
100
84
|
transform: translateZ(0);
|
|
101
85
|
pointer-events: auto;
|
|
102
86
|
|
|
103
|
-
/* Estados */
|
|
104
87
|
opacity: 0;
|
|
105
88
|
visibility: hidden;
|
|
106
89
|
transition: opacity 0.3s linear, visibility 0.3s linear;
|
|
@@ -110,7 +93,6 @@
|
|
|
110
93
|
visibility: visible;
|
|
111
94
|
}
|
|
112
95
|
|
|
113
|
-
/* Variantes */
|
|
114
96
|
&--dark {
|
|
115
97
|
background-color: #333333;
|
|
116
98
|
color: #f5f5f5;
|
|
@@ -147,7 +129,6 @@
|
|
|
147
129
|
}
|
|
148
130
|
}
|
|
149
131
|
|
|
150
|
-
/* Tamanhos */
|
|
151
132
|
&--sm {
|
|
152
133
|
font-size: 11px;
|
|
153
134
|
padding: 12px;
|
|
@@ -163,7 +144,6 @@
|
|
|
163
144
|
padding: 20px;
|
|
164
145
|
}
|
|
165
146
|
|
|
166
|
-
/* Header */
|
|
167
147
|
.tooltip-header {
|
|
168
148
|
display: flex;
|
|
169
149
|
justify-content: space-between;
|
|
@@ -205,7 +185,6 @@
|
|
|
205
185
|
pointer-events: none;
|
|
206
186
|
}
|
|
207
187
|
|
|
208
|
-
/* Posicionamento específico */
|
|
209
188
|
&--has-title {
|
|
210
189
|
.tooltip-content {
|
|
211
190
|
margin-top: 4px;
|
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
docs: {
|
|
8
8
|
description: {
|
|
9
9
|
component: `Tooltip<br />
|
|
10
|
-
selector: <em>
|
|
10
|
+
selector: <em>farm-tooltip</em><br />
|
|
11
11
|
<span style="color: var(--farm-primary-base);">ready for use</span>
|
|
12
12
|
`,
|
|
13
13
|
},
|
|
@@ -43,17 +43,17 @@ export default {
|
|
|
43
43
|
|
|
44
44
|
export const Primary = {
|
|
45
45
|
render: () => ({
|
|
46
|
-
components: { Tooltip },
|
|
46
|
+
components: { 'farm-tooltip': Tooltip },
|
|
47
47
|
template: `
|
|
48
48
|
<div style="padding-left: 80px; padding-top: 80px;">
|
|
49
49
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
50
50
|
<span>Hover over the icon</span>
|
|
51
|
-
<
|
|
51
|
+
<farm-tooltip placement="top-center">
|
|
52
52
|
<template #activator>
|
|
53
53
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background: #666; color: white; border-radius: 50%; font-size: 10px; cursor: help;">?</span>
|
|
54
54
|
</template>
|
|
55
55
|
This is a simple tooltip
|
|
56
|
-
</
|
|
56
|
+
</farm-tooltip>
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
59
59
|
`,
|
|
@@ -62,70 +62,70 @@ export const Primary = {
|
|
|
62
62
|
|
|
63
63
|
export const AllPositions = {
|
|
64
64
|
render: () => ({
|
|
65
|
-
components: { Tooltip },
|
|
65
|
+
components: { 'farm-tooltip': Tooltip },
|
|
66
66
|
template: `
|
|
67
67
|
<div style="padding: 100px; display: flex; flex-direction: column; align-items: center; gap: 50px;">
|
|
68
68
|
<div style="display: flex; gap: 30px; margin-bottom: 50px;">
|
|
69
69
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
70
70
|
<p style="margin-bottom: 10px;">Top Left</p>
|
|
71
|
-
<
|
|
71
|
+
<farm-tooltip placement="top-left">
|
|
72
72
|
<template #activator>
|
|
73
73
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
74
74
|
</template>
|
|
75
75
|
Top-Left Position
|
|
76
|
-
</
|
|
76
|
+
</farm-tooltip>
|
|
77
77
|
</div>
|
|
78
78
|
|
|
79
79
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
80
80
|
<p style="margin-bottom: 10px;">Top Center</p>
|
|
81
|
-
<
|
|
81
|
+
<farm-tooltip placement="top-center">
|
|
82
82
|
<template #activator>
|
|
83
83
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
84
84
|
</template>
|
|
85
85
|
Top-Center Position (Default)
|
|
86
|
-
</
|
|
86
|
+
</farm-tooltip>
|
|
87
87
|
</div>
|
|
88
88
|
|
|
89
89
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
90
90
|
<p style="margin-bottom: 10px;">Top Right</p>
|
|
91
|
-
<
|
|
91
|
+
<farm-tooltip placement="top-right">
|
|
92
92
|
<template #activator>
|
|
93
93
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
94
94
|
</template>
|
|
95
95
|
Top-Right Position
|
|
96
|
-
</
|
|
96
|
+
</farm-tooltip>
|
|
97
97
|
</div>
|
|
98
98
|
</div>
|
|
99
99
|
|
|
100
100
|
<div style="display: flex; gap: 30px;">
|
|
101
101
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
102
102
|
<p style="margin-bottom: 10px;">Bottom Left</p>
|
|
103
|
-
<
|
|
103
|
+
<farm-tooltip placement="bottom-left">
|
|
104
104
|
<template #activator>
|
|
105
105
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
106
106
|
</template>
|
|
107
107
|
Bottom-Left Position
|
|
108
|
-
</
|
|
108
|
+
</farm-tooltip>
|
|
109
109
|
</div>
|
|
110
110
|
|
|
111
111
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
112
112
|
<p style="margin-bottom: 10px;">Bottom Center</p>
|
|
113
|
-
<
|
|
113
|
+
<farm-tooltip placement="bottom-center">
|
|
114
114
|
<template #activator>
|
|
115
115
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
116
116
|
</template>
|
|
117
117
|
Bottom-Center Position
|
|
118
|
-
</
|
|
118
|
+
</farm-tooltip>
|
|
119
119
|
</div>
|
|
120
120
|
|
|
121
121
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
122
122
|
<p style="margin-bottom: 10px;">Bottom Right</p>
|
|
123
|
-
<
|
|
123
|
+
<farm-tooltip placement="bottom-right">
|
|
124
124
|
<template #activator>
|
|
125
125
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
126
126
|
</template>
|
|
127
127
|
Bottom-Right Position
|
|
128
|
-
</
|
|
128
|
+
</farm-tooltip>
|
|
129
129
|
</div>
|
|
130
130
|
</div>
|
|
131
131
|
</div>
|
|
@@ -135,7 +135,7 @@ export const AllPositions = {
|
|
|
135
135
|
|
|
136
136
|
export const ControlledTooltip = {
|
|
137
137
|
render: () => ({
|
|
138
|
-
components: { Tooltip },
|
|
138
|
+
components: { 'farm-tooltip': Tooltip },
|
|
139
139
|
data() {
|
|
140
140
|
return {
|
|
141
141
|
showTooltip: false,
|
|
@@ -145,7 +145,7 @@ export const ControlledTooltip = {
|
|
|
145
145
|
<div style="padding: 80px;">
|
|
146
146
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
147
147
|
<span>Click to open:</span>
|
|
148
|
-
<
|
|
148
|
+
<farm-tooltip v-model="showTooltip" placement="top-right">
|
|
149
149
|
<template #activator>
|
|
150
150
|
<span
|
|
151
151
|
@click="showTooltip = !showTooltip"
|
|
@@ -154,7 +154,7 @@ export const ControlledTooltip = {
|
|
|
154
154
|
</template>
|
|
155
155
|
<template #title>Controlled Tooltip</template>
|
|
156
156
|
This tooltip is controlled by v-model
|
|
157
|
-
</
|
|
157
|
+
</farm-tooltip>
|
|
158
158
|
</div>
|
|
159
159
|
</div>
|
|
160
160
|
`,
|
|
@@ -163,18 +163,18 @@ export const ControlledTooltip = {
|
|
|
163
163
|
|
|
164
164
|
export const FluidTooltip = {
|
|
165
165
|
render: () => ({
|
|
166
|
-
components: { Tooltip },
|
|
166
|
+
components: { 'farm-tooltip': Tooltip },
|
|
167
167
|
template: `
|
|
168
168
|
<div style="padding-left: 80px; padding-top: 80px;">
|
|
169
169
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
170
170
|
<span>Fluid width tooltip</span>
|
|
171
|
-
<
|
|
171
|
+
<farm-tooltip placement="top-center" :fluid="true">
|
|
172
172
|
<template #activator>
|
|
173
173
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background: #666; color: white; border-radius: 50%; font-size: 10px; cursor: help;">?</span>
|
|
174
174
|
</template>
|
|
175
175
|
This is a fluid tooltip that will grow based on its content.
|
|
176
176
|
It contains a longer text to demonstrate how it expands horizontally.
|
|
177
|
-
</
|
|
177
|
+
</farm-tooltip>
|
|
178
178
|
</div>
|
|
179
179
|
</div>
|
|
180
180
|
`,
|
|
@@ -184,38 +184,38 @@ export const FluidTooltip = {
|
|
|
184
184
|
|
|
185
185
|
export const Sizes = {
|
|
186
186
|
render: () => ({
|
|
187
|
-
components: { Tooltip },
|
|
187
|
+
components: { 'farm-tooltip': Tooltip },
|
|
188
188
|
template: `
|
|
189
189
|
<div style="padding: 80px;">
|
|
190
190
|
<div style="display: flex; gap: 30px; align-items: center;">
|
|
191
191
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
192
192
|
<span>Small:</span>
|
|
193
|
-
<
|
|
193
|
+
<farm-tooltip placement="top-center" size="sm">
|
|
194
194
|
<template #activator>
|
|
195
195
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background: #666; color: white; border-radius: 50%; font-size: 10px; cursor: help;">?</span>
|
|
196
196
|
</template>
|
|
197
197
|
Small tooltip
|
|
198
|
-
</
|
|
198
|
+
</farm-tooltip>
|
|
199
199
|
</div>
|
|
200
200
|
|
|
201
201
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
202
202
|
<span>Medium:</span>
|
|
203
|
-
<
|
|
203
|
+
<farm-tooltip placement="top-center" size="md">
|
|
204
204
|
<template #activator>
|
|
205
205
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
206
206
|
</template>
|
|
207
207
|
Medium tooltip (default)
|
|
208
|
-
</
|
|
208
|
+
</farm-tooltip>
|
|
209
209
|
</div>
|
|
210
210
|
|
|
211
211
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
212
212
|
<span>Large:</span>
|
|
213
|
-
<
|
|
213
|
+
<farm-tooltip placement="top-center" size="lg">
|
|
214
214
|
<template #activator>
|
|
215
215
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background: #666; color: white; border-radius: 50%; font-size: 12px; cursor: help;">?</span>
|
|
216
216
|
</template>
|
|
217
217
|
Large tooltip
|
|
218
|
-
</
|
|
218
|
+
</farm-tooltip>
|
|
219
219
|
</div>
|
|
220
220
|
</div>
|
|
221
221
|
</div>
|
|
@@ -225,28 +225,28 @@ export const Sizes = {
|
|
|
225
225
|
|
|
226
226
|
export const WithCustomMaxWidth = {
|
|
227
227
|
render: () => ({
|
|
228
|
-
components: { Tooltip },
|
|
228
|
+
components: { 'farm-tooltip': Tooltip },
|
|
229
229
|
template: `
|
|
230
230
|
<div style="padding: 80px;">
|
|
231
231
|
<div style="display: flex; gap: 30px; align-items: center;">
|
|
232
232
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
233
233
|
<span>Default width:</span>
|
|
234
|
-
<
|
|
234
|
+
<farm-tooltip placement="top-center">
|
|
235
235
|
<template #activator>
|
|
236
236
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #666; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
237
237
|
</template>
|
|
238
238
|
This is a tooltip with default width that can be quite long and will wrap naturally
|
|
239
|
-
</
|
|
239
|
+
</farm-tooltip>
|
|
240
240
|
</div>
|
|
241
241
|
|
|
242
242
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
243
243
|
<span>Custom max-width (200px):</span>
|
|
244
|
-
<
|
|
244
|
+
<farm-tooltip placement="top-center" max-width="200px">
|
|
245
245
|
<template #activator>
|
|
246
246
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #007bff; color: white; border-radius: 50%; font-size: 11px; cursor: help;">?</span>
|
|
247
247
|
</template>
|
|
248
248
|
This is a tooltip with custom max-width of 200px that will wrap when it exceeds that width
|
|
249
|
-
</
|
|
249
|
+
</farm-tooltip>
|
|
250
250
|
</div>
|
|
251
251
|
</div>
|
|
252
252
|
</div>
|
|
@@ -256,12 +256,12 @@ export const WithCustomMaxWidth = {
|
|
|
256
256
|
|
|
257
257
|
export const ComplexContent = {
|
|
258
258
|
render: () => ({
|
|
259
|
-
components: { Tooltip },
|
|
259
|
+
components: { 'farm-tooltip': Tooltip },
|
|
260
260
|
template: `
|
|
261
261
|
<div style="padding: 80px;">
|
|
262
262
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
263
263
|
<span>Complex tooltip with title:</span>
|
|
264
|
-
<
|
|
264
|
+
<farm-tooltip placement="top-center" :fluid="true">
|
|
265
265
|
<template #activator>
|
|
266
266
|
<span style="display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: #28a745; color: white; border-radius: 50%; font-size: 11px; cursor: help;">i</span>
|
|
267
267
|
</template>
|
|
@@ -274,7 +274,7 @@ export const ComplexContent = {
|
|
|
274
274
|
<li>Processing time: 2-3 business days</li>
|
|
275
275
|
</ul>
|
|
276
276
|
</div>
|
|
277
|
-
</
|
|
277
|
+
</farm-tooltip>
|
|
278
278
|
</div>
|
|
279
279
|
</div>
|
|
280
280
|
`,
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
<script setup lang="ts">
|
|
53
53
|
import { ref, computed, onBeforeUnmount, nextTick, watch, useSlots } from 'vue';
|
|
54
54
|
|
|
55
|
+
defineOptions({
|
|
56
|
+
name: 'farm-tooltip',
|
|
57
|
+
});
|
|
58
|
+
|
|
55
59
|
export interface TooltipProps {
|
|
56
60
|
modelValue?: boolean;
|
|
57
61
|
trigger?: 'hover' | 'click' | 'manual';
|
|
@@ -69,7 +73,6 @@ export interface TooltipProps {
|
|
|
69
73
|
delay?: number | [number, number];
|
|
70
74
|
disabled?: boolean;
|
|
71
75
|
fluid?: boolean;
|
|
72
|
-
position?: string;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
const props = withDefaults(defineProps<TooltipProps>(), {
|
|
@@ -83,7 +86,6 @@ const props = withDefaults(defineProps<TooltipProps>(), {
|
|
|
83
86
|
delay: () => [100, 50],
|
|
84
87
|
disabled: false,
|
|
85
88
|
fluid: false,
|
|
86
|
-
position: undefined,
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
const emit = defineEmits<{
|
|
@@ -111,13 +113,6 @@ const isControlled = computed(() => props.modelValue !== undefined);
|
|
|
111
113
|
const hasTitle = computed(() => !!slots.title);
|
|
112
114
|
const showCloseButton = computed(() => isControlled.value && hasTitle.value);
|
|
113
115
|
|
|
114
|
-
const normalizedPlacement = computed(() => {
|
|
115
|
-
if (props.position) {
|
|
116
|
-
return props.position as typeof props.placement;
|
|
117
|
-
}
|
|
118
|
-
return props.placement;
|
|
119
|
-
});
|
|
120
|
-
|
|
121
116
|
const normalizedMaxWidth = computed(() => {
|
|
122
117
|
if (props.fluid) {
|
|
123
118
|
return '300px';
|
|
@@ -131,7 +126,7 @@ const tooltipClasses = computed(() => ({
|
|
|
131
126
|
[`tooltip-popup--${props.variant}`]: true,
|
|
132
127
|
[`tooltip-popup--${props.size}`]: true,
|
|
133
128
|
'tooltip-popup--has-title': hasTitle.value,
|
|
134
|
-
[`tooltip-popup--${
|
|
129
|
+
[`tooltip-popup--${props.placement}`]: true,
|
|
135
130
|
}));
|
|
136
131
|
|
|
137
132
|
const tooltipStyles = computed(() => {
|
|
@@ -152,7 +147,7 @@ const tooltipStyles = computed(() => {
|
|
|
152
147
|
});
|
|
153
148
|
|
|
154
149
|
const arrowStyles = computed(() => {
|
|
155
|
-
const [verticalPos] =
|
|
150
|
+
const [verticalPos] = props.placement.split('-');
|
|
156
151
|
const arrowColor = props.variant === 'light' ? '#ffffff' : '#333333';
|
|
157
152
|
|
|
158
153
|
const styles: Record<string, string> = {
|
|
@@ -315,7 +310,7 @@ const updatePosition = () => {
|
|
|
315
310
|
const position = calculateTooltipPosition(
|
|
316
311
|
activatorRect,
|
|
317
312
|
tooltipRect,
|
|
318
|
-
|
|
313
|
+
props.placement,
|
|
319
314
|
props.offset
|
|
320
315
|
);
|
|
321
316
|
|