@mozaic-ds/vue 2.1.0 → 2.2.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/README.md +2 -2
- package/dist/mozaic-vue.css +1 -1
- package/dist/mozaic-vue.d.ts +57 -3
- package/dist/mozaic-vue.js +142 -114
- package/dist/mozaic-vue.js.map +1 -1
- package/dist/mozaic-vue.umd.cjs +1 -1
- package/dist/mozaic-vue.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/components/Contributing.mdx +1 -1
- package/src/components/Introduction.mdx +1 -1
- package/src/components/tooltip/MTooltip.spec.ts +47 -0
- package/src/components/tooltip/MTooltip.stories.ts +59 -0
- package/src/components/tooltip/MTooltip.vue +59 -0
- package/src/main.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mozaic-ds/vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Mozaic-Vue is the Vue.js implementation of ADEO Design system",
|
|
6
6
|
"author": "ADEO - ADEO Design system",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@commitlint/cli": "^19.8.0",
|
|
50
50
|
"@commitlint/config-conventional": "^19.8.0",
|
|
51
51
|
"@mozaic-ds/css-dev-tools": "1.75.0",
|
|
52
|
-
"@mozaic-ds/icons-vue": "^
|
|
52
|
+
"@mozaic-ds/icons-vue": "^1.0.0",
|
|
53
53
|
"@release-it/conventional-changelog": "^8.0.2",
|
|
54
54
|
"@storybook/addon-a11y": "^9.0.18",
|
|
55
55
|
"@storybook/addon-themes": "^9.0.18",
|
|
@@ -38,7 +38,7 @@ import vue from '../../.storybook/assets/vue.svg';
|
|
|
38
38
|
alt="npm version"
|
|
39
39
|
/>
|
|
40
40
|
</a>
|
|
41
|
-
<a href="https://github.com/adeo/mozaic-vue/blob/
|
|
41
|
+
<a href="https://github.com/adeo/mozaic-vue/blob/main/CONTRIBUTING.md">
|
|
42
42
|
<img
|
|
43
43
|
src="https://img.shields.io/badge/PRs-welcome-blue.svg?logo=github"
|
|
44
44
|
alt="PRs welcome"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils';
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import MTooltip from './MTooltip.vue';
|
|
4
|
+
|
|
5
|
+
describe('MTooltip.vue', () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
id: 'tooltip-1',
|
|
8
|
+
text: 'Tooltip content',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
it('renders tooltip text', () => {
|
|
12
|
+
const wrapper = mount(MTooltip, {
|
|
13
|
+
props: { ...defaultProps },
|
|
14
|
+
slots: { default: 'Hover me' }
|
|
15
|
+
});
|
|
16
|
+
expect(wrapper.text()).toContain(defaultProps.text);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('sets aria-describedby attribute correctly', () => {
|
|
20
|
+
const wrapper = mount(MTooltip, {
|
|
21
|
+
props: { ...defaultProps }
|
|
22
|
+
});
|
|
23
|
+
const tooltipDiv = wrapper.find('.mc-tooltip');
|
|
24
|
+
expect(tooltipDiv.attributes('aria-describedby')).toBe(defaultProps.id);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('applies position class based on prop', () => {
|
|
28
|
+
const wrapper = mount(MTooltip, {
|
|
29
|
+
props: { ...defaultProps, position: 'bottom' }
|
|
30
|
+
});
|
|
31
|
+
expect(wrapper.find('.mc-tooltip').classes()).toContain('mc-tooltip--bottom');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('applies no-pointer class when pointer is false', () => {
|
|
35
|
+
const wrapper = mount(MTooltip, {
|
|
36
|
+
props: { ...defaultProps, pointer: false }
|
|
37
|
+
});
|
|
38
|
+
expect(wrapper.find('.mc-tooltip').classes()).toContain('mc-tooltip--no-pointer');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('does not apply no-pointer class when pointer is true', () => {
|
|
42
|
+
const wrapper = mount(MTooltip, {
|
|
43
|
+
props: { ...defaultProps, pointer: true }
|
|
44
|
+
});
|
|
45
|
+
expect(wrapper.find('.mc-tooltip').classes()).not.toContain('mc-tooltip--no-pointer');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import MTooltip from './MTooltip.vue';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof MTooltip> = {
|
|
5
|
+
title: 'Overlay/Tooltip',
|
|
6
|
+
component: MTooltip,
|
|
7
|
+
parameters: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component:
|
|
11
|
+
'A tooltip is a small, contextual message that appears when users hover over, focus on, or tap an element, providing additional information or guidance without cluttering the interface. Tooltips are commonly used to explain icons, abbreviations, or complex actions. They typically disappear automatically when the user moves away from the trigger element.',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
id: 'tooltipId',
|
|
17
|
+
text: 'Keep the tooltip text concise.',
|
|
18
|
+
default: 'Tooltip on the top',
|
|
19
|
+
},
|
|
20
|
+
render: (args) => ({
|
|
21
|
+
components: { MTooltip },
|
|
22
|
+
setup() {
|
|
23
|
+
return { args };
|
|
24
|
+
},
|
|
25
|
+
template: `
|
|
26
|
+
<MTooltip v-bind="args">
|
|
27
|
+
${args.default}
|
|
28
|
+
</MTooltip>
|
|
29
|
+
`,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
export default meta;
|
|
33
|
+
type Story = StoryObj<typeof MTooltip>;
|
|
34
|
+
|
|
35
|
+
export const Default: Story = {};
|
|
36
|
+
|
|
37
|
+
export const Pointer: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
pointer: false
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Right: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
position: 'right'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Left: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
position: 'left'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Bottom: Story = {
|
|
56
|
+
args: {
|
|
57
|
+
position: 'bottom'
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="tooltip-story-wrapper">
|
|
3
|
+
<div class="mc-tooltip" :class="classObject" :aria-describedby="id">
|
|
4
|
+
<slot/>
|
|
5
|
+
<span :id="id" class="mc-tooltip__content" role="tooltip">
|
|
6
|
+
{{ text }}
|
|
7
|
+
</span>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
/**
|
|
15
|
+
* A tooltip is a small, contextual message that appears when users hover over, focus on, or tap an element, providing additional information or guidance without cluttering the interface. Tooltips are commonly used to explain icons, abbreviations, or complex actions. They typically disappear automatically when the user moves away from the trigger element.
|
|
16
|
+
*/
|
|
17
|
+
const props = withDefaults(
|
|
18
|
+
defineProps<{
|
|
19
|
+
/**
|
|
20
|
+
* A unique identifier for the tooltip, used to describe the tooltip.
|
|
21
|
+
*/
|
|
22
|
+
id: string;
|
|
23
|
+
/**
|
|
24
|
+
* Content of the tooltip
|
|
25
|
+
*/
|
|
26
|
+
text: string;
|
|
27
|
+
/**
|
|
28
|
+
* Determines the position of the tooltip
|
|
29
|
+
*/
|
|
30
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
31
|
+
/**
|
|
32
|
+
* if `true`, the tooltip display a pointer.
|
|
33
|
+
*/
|
|
34
|
+
pointer?: boolean;
|
|
35
|
+
}>(),
|
|
36
|
+
{
|
|
37
|
+
position: 'top',
|
|
38
|
+
pointer: true
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
defineSlots<{
|
|
43
|
+
/**
|
|
44
|
+
* The tooltip will point to the content of the slot.
|
|
45
|
+
*/
|
|
46
|
+
default: string;
|
|
47
|
+
}>();
|
|
48
|
+
|
|
49
|
+
const classObject = computed(() => {
|
|
50
|
+
return {
|
|
51
|
+
[`mc-tooltip--${props.position}`]: props.position,
|
|
52
|
+
'mc-tooltip--no-pointer': !props.pointer,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<style lang="scss" scoped>
|
|
58
|
+
@use '@mozaic-ds/styles/components/tooltip';
|
|
59
|
+
</style>
|
package/src/main.ts
CHANGED
|
@@ -29,4 +29,5 @@ export { default as MTag } from './components/tag/MTag.vue';
|
|
|
29
29
|
export { default as MTextArea } from './components/textarea/MTextArea.vue';
|
|
30
30
|
export { default as MTextInput } from './components/textinput/MTextInput.vue';
|
|
31
31
|
export { default as MToggle } from './components/toggle/MToggle.vue';
|
|
32
|
+
export { default as MTooltip } from './components/tooltip/MTooltip.vue';
|
|
32
33
|
export { default as MToggleGroup } from './components/togglegroup/MToggleGroup.vue';
|