@datametria/vue-components 1.2.0 → 2.0.1
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 +548 -657
- package/dist/index.es.js +2353 -1364
- package/dist/index.umd.js +10 -10
- package/dist/vue-components.css +1 -1
- package/package.json +102 -98
- package/src/components/DatametriaAlert.vue +137 -137
- package/src/components/DatametriaAutocomplete.vue +184 -138
- package/src/components/DatametriaAvatar.vue +177 -33
- package/src/components/DatametriaBadge.vue +98 -98
- package/src/components/DatametriaBreadcrumb.vue +21 -21
- package/src/components/DatametriaButton.vue +177 -165
- package/src/components/DatametriaCard.vue +12 -12
- package/src/components/DatametriaCheckbox.vue +8 -8
- package/src/components/DatametriaChip.vue +145 -149
- package/src/components/DatametriaContainer.vue +4 -4
- package/src/components/DatametriaDatePicker.vue +686 -68
- package/src/components/DatametriaDivider.vue +13 -13
- package/src/components/DatametriaFileUpload.vue +272 -140
- package/src/components/DatametriaGrid.vue +3 -3
- package/src/components/DatametriaInput.vue +15 -15
- package/src/components/DatametriaMenu.vue +604 -619
- package/src/components/DatametriaModal.vue +16 -16
- package/src/components/DatametriaNavbar.vue +230 -252
- package/src/components/DatametriaPasswordInput.vue +430 -0
- package/src/components/DatametriaProgress.vue +18 -18
- package/src/components/DatametriaRadio.vue +20 -20
- package/src/components/DatametriaSelect.vue +15 -15
- package/src/components/DatametriaSkeleton.vue +243 -239
- package/src/components/DatametriaSlider.vue +395 -407
- package/src/components/DatametriaSortableTable.vue +585 -0
- package/src/components/DatametriaSpinner.vue +7 -7
- package/src/components/DatametriaSwitch.vue +16 -16
- package/src/components/DatametriaTable.vue +14 -14
- package/src/components/DatametriaTextarea.vue +28 -28
- package/src/components/DatametriaTimePicker.vue +285 -285
- package/src/components/DatametriaToast.vue +176 -176
- package/src/components/DatametriaTooltip.vue +408 -408
- package/src/components/__tests__/DatametriaAlert.test.js +35 -35
- package/src/components/__tests__/DatametriaAlert.test.ts +190 -0
- package/src/components/__tests__/DatametriaAutocomplete.test.ts +180 -0
- package/src/components/__tests__/DatametriaAvatar.test.ts +152 -0
- package/src/components/__tests__/DatametriaBadge.test.js +29 -29
- package/src/components/__tests__/DatametriaBadge.test.ts +167 -0
- package/src/components/__tests__/DatametriaBreadcrumb.test.ts +75 -0
- package/src/components/__tests__/DatametriaButton.test.js +30 -30
- package/src/components/__tests__/DatametriaButton.test.ts +283 -0
- package/src/components/__tests__/DatametriaCard.test.ts +201 -0
- package/src/components/__tests__/DatametriaCheckbox.test.ts +47 -0
- package/src/components/__tests__/DatametriaChip.test.js +38 -38
- package/src/components/__tests__/DatametriaContainer.test.ts +52 -0
- package/src/components/__tests__/DatametriaDatePicker.test.ts +234 -0
- package/src/components/__tests__/DatametriaDivider.test.ts +54 -0
- package/src/components/__tests__/DatametriaFileUpload.test.ts +291 -0
- package/src/components/__tests__/DatametriaGrid.test.ts +31 -0
- package/src/components/__tests__/DatametriaInput.test.ts +72 -0
- package/src/components/__tests__/DatametriaMenu.test.ts +366 -0
- package/src/components/__tests__/DatametriaModal.test.ts +86 -0
- package/src/components/__tests__/DatametriaNavbar.test.js +48 -48
- package/src/components/__tests__/DatametriaNavbar.test.ts +203 -0
- package/src/components/__tests__/DatametriaPasswordInput.test.js +305 -0
- package/src/components/__tests__/DatametriaProgress.test.ts +90 -0
- package/src/components/__tests__/DatametriaRadio.test.ts +77 -0
- package/src/components/__tests__/DatametriaSelect.test.ts +77 -0
- package/src/components/__tests__/DatametriaSlider.test.ts +261 -0
- package/src/components/__tests__/DatametriaSortableTable.test.js +168 -0
- package/src/components/__tests__/DatametriaSpinner.test.ts +156 -0
- package/src/components/__tests__/DatametriaSwitch.test.ts +64 -0
- package/src/components/__tests__/DatametriaTable.test.ts +97 -0
- package/src/components/__tests__/DatametriaTextarea.test.ts +66 -0
- package/src/components/__tests__/DatametriaToast.test.js +48 -48
- package/src/components/__tests__/DatametriaToast.test.ts +99 -0
- package/src/composables/useAccessibilityScale.ts +94 -94
- package/src/composables/useBreakpoints.ts +82 -82
- package/src/composables/useHapticFeedback.ts +439 -439
- package/src/composables/useRipple.ts +218 -218
- package/src/index.ts +68 -61
- package/src/stories/Variants.stories.js +95 -95
- package/src/styles/design-tokens.css +623 -623
- package/src/theme/ThemeProvider.vue +96 -0
- package/src/theme/__tests__/ThemeProvider.test.ts +208 -0
- package/src/theme/__tests__/constants.test.ts +31 -0
- package/src/theme/__tests__/presets.test.ts +166 -0
- package/src/theme/__tests__/tokens.test.ts +155 -0
- package/src/theme/__tests__/types.test.ts +153 -0
- package/src/theme/__tests__/useTheme.test.ts +146 -0
- package/src/theme/constants.ts +14 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/presets/datametria.ts +94 -0
- package/src/theme/presets/default.ts +94 -0
- package/src/theme/presets/index.ts +8 -0
- package/src/theme/tokens/colors.ts +28 -0
- package/src/theme/tokens/index.ts +47 -0
- package/src/theme/tokens/spacing.ts +21 -0
- package/src/theme/tokens/typography.ts +35 -0
- package/src/theme/types.ts +111 -0
- package/src/theme/useTheme.ts +28 -0
- package/src/types/index.ts +19 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Theme Provider Component
|
|
3
|
+
@author Vander Loto - CTO DATAMETRIA
|
|
4
|
+
@date 13/11/2025
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div :class="themeClass" :style="cssVariables">
|
|
9
|
+
<slot />
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { computed, provide } from 'vue'
|
|
15
|
+
import type { Theme } from './types'
|
|
16
|
+
import { THEME_INJECTION_KEY, DEFAULT_THEME_PREFIX, CSS_VARIABLE_PREFIX } from './constants'
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
theme: Theme
|
|
20
|
+
prefix?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
24
|
+
prefix: DEFAULT_THEME_PREFIX
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Provide theme to child components
|
|
28
|
+
const themeRef = computed(() => props.theme)
|
|
29
|
+
provide(THEME_INJECTION_KEY, themeRef)
|
|
30
|
+
|
|
31
|
+
const themeClass = computed(() => `${props.prefix}-theme`)
|
|
32
|
+
|
|
33
|
+
const cssVariables = computed(() => {
|
|
34
|
+
const vars: Record<string, string> = {}
|
|
35
|
+
const { tokens } = props.theme
|
|
36
|
+
const prefix = `${CSS_VARIABLE_PREFIX}${props.prefix}`
|
|
37
|
+
|
|
38
|
+
// Colors
|
|
39
|
+
vars[`${prefix}-primary`] = tokens.colors.primary
|
|
40
|
+
vars[`${prefix}-secondary`] = tokens.colors.secondary
|
|
41
|
+
vars[`${prefix}-success`] = tokens.colors.success
|
|
42
|
+
vars[`${prefix}-warning`] = tokens.colors.warning
|
|
43
|
+
vars[`${prefix}-error`] = tokens.colors.error
|
|
44
|
+
vars[`${prefix}-info`] = tokens.colors.info
|
|
45
|
+
|
|
46
|
+
// Neutral colors
|
|
47
|
+
Object.entries(tokens.colors.neutral).forEach(([key, value]) => {
|
|
48
|
+
vars[`${prefix}-neutral-${key}`] = value
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
// Typography - Font Family
|
|
52
|
+
vars[`${prefix}-font-sans`] = tokens.typography.fontFamily.sans
|
|
53
|
+
vars[`${prefix}-font-mono`] = tokens.typography.fontFamily.mono
|
|
54
|
+
|
|
55
|
+
// Typography - Font Size
|
|
56
|
+
Object.entries(tokens.typography.fontSize).forEach(([key, value]) => {
|
|
57
|
+
vars[`${prefix}-text-${key}`] = value
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
// Typography - Font Weight
|
|
61
|
+
Object.entries(tokens.typography.fontWeight).forEach(([key, value]) => {
|
|
62
|
+
vars[`${prefix}-font-${key}`] = value.toString()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
// Typography - Line Height
|
|
66
|
+
Object.entries(tokens.typography.lineHeight).forEach(([key, value]) => {
|
|
67
|
+
vars[`${prefix}-leading-${key}`] = value.toString()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
// Spacing
|
|
71
|
+
Object.entries(tokens.spacing).forEach(([key, value]) => {
|
|
72
|
+
vars[`${prefix}-space-${key}`] = value
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// Radius
|
|
76
|
+
Object.entries(tokens.radius).forEach(([key, value]) => {
|
|
77
|
+
vars[`${prefix}-radius-${key}`] = value
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Shadows
|
|
81
|
+
Object.entries(tokens.shadows).forEach(([key, value]) => {
|
|
82
|
+
vars[`${prefix}-shadow-${key}`] = value
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// Transitions
|
|
86
|
+
Object.entries(tokens.transitions).forEach(([key, value]) => {
|
|
87
|
+
vars[`${prefix}-transition-${key}`] = value
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
return vars
|
|
91
|
+
})
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<style scoped>
|
|
95
|
+
/* Theme container - no additional styles needed */
|
|
96
|
+
</style>
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThemeProvider Tests
|
|
3
|
+
* @author Vander Loto - CTO DATAMETRIA
|
|
4
|
+
* @date 13/11/2025
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, expect } from 'vitest'
|
|
8
|
+
import { mount } from '@vue/test-utils'
|
|
9
|
+
import { h } from 'vue'
|
|
10
|
+
import ThemeProvider from '../ThemeProvider.vue'
|
|
11
|
+
import { useTheme } from '../useTheme'
|
|
12
|
+
import { defaultTokens } from '../tokens'
|
|
13
|
+
import type { Theme } from '../types'
|
|
14
|
+
|
|
15
|
+
const testTheme: Theme = {
|
|
16
|
+
name: 'Test Theme',
|
|
17
|
+
tokens: defaultTokens
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const customTheme: Theme = {
|
|
21
|
+
name: 'Custom Theme',
|
|
22
|
+
tokens: {
|
|
23
|
+
...defaultTokens,
|
|
24
|
+
colors: {
|
|
25
|
+
...defaultTokens.colors,
|
|
26
|
+
primary: '#FF0000',
|
|
27
|
+
secondary: '#00FF00'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('ThemeProvider', () => {
|
|
33
|
+
it('should render children', () => {
|
|
34
|
+
const wrapper = mount(ThemeProvider, {
|
|
35
|
+
props: { theme: testTheme },
|
|
36
|
+
slots: {
|
|
37
|
+
default: '<div class="test-child">Child Content</div>'
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
expect(wrapper.text()).toContain('Child Content')
|
|
42
|
+
expect(wrapper.find('.test-child').exists()).toBe(true)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('should apply default theme class', () => {
|
|
46
|
+
const wrapper = mount(ThemeProvider, {
|
|
47
|
+
props: { theme: testTheme },
|
|
48
|
+
slots: { default: '<div>Content</div>' }
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
expect(wrapper.classes()).toContain('dm-theme')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('should apply custom prefix class', () => {
|
|
55
|
+
const wrapper = mount(ThemeProvider, {
|
|
56
|
+
props: { theme: testTheme, prefix: 'custom' },
|
|
57
|
+
slots: { default: '<div>Content</div>' }
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
expect(wrapper.classes()).toContain('custom-theme')
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('should generate CSS variables for colors', () => {
|
|
64
|
+
const wrapper = mount(ThemeProvider, {
|
|
65
|
+
props: { theme: testTheme },
|
|
66
|
+
slots: { default: '<div>Content</div>' }
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const style = wrapper.attributes('style')
|
|
70
|
+
expect(style).toContain('--dm-primary')
|
|
71
|
+
expect(style).toContain('#0072CE')
|
|
72
|
+
expect(style).toContain('--dm-secondary')
|
|
73
|
+
expect(style).toContain('#4B0078')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('should generate CSS variables for neutral colors', () => {
|
|
77
|
+
const wrapper = mount(ThemeProvider, {
|
|
78
|
+
props: { theme: testTheme },
|
|
79
|
+
slots: { default: '<div>Content</div>' }
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const style = wrapper.attributes('style')
|
|
83
|
+
expect(style).toContain('--dm-neutral-50')
|
|
84
|
+
expect(style).toContain('--dm-neutral-900')
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('should generate CSS variables for typography', () => {
|
|
88
|
+
const wrapper = mount(ThemeProvider, {
|
|
89
|
+
props: { theme: testTheme },
|
|
90
|
+
slots: { default: '<div>Content</div>' }
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const style = wrapper.attributes('style')
|
|
94
|
+
expect(style).toContain('--dm-font-sans')
|
|
95
|
+
expect(style).toContain('--dm-text-base')
|
|
96
|
+
expect(style).toContain('--dm-font-bold')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should generate CSS variables for spacing', () => {
|
|
100
|
+
const wrapper = mount(ThemeProvider, {
|
|
101
|
+
props: { theme: testTheme },
|
|
102
|
+
slots: { default: '<div>Content</div>' }
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const style = wrapper.attributes('style')
|
|
106
|
+
expect(style).toContain('--dm-space-4')
|
|
107
|
+
expect(style).toContain('1rem')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('should generate CSS variables for radius', () => {
|
|
111
|
+
const wrapper = mount(ThemeProvider, {
|
|
112
|
+
props: { theme: testTheme },
|
|
113
|
+
slots: { default: '<div>Content</div>' }
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const style = wrapper.attributes('style')
|
|
117
|
+
expect(style).toContain('--dm-radius-md')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('should generate CSS variables for shadows', () => {
|
|
121
|
+
const wrapper = mount(ThemeProvider, {
|
|
122
|
+
props: { theme: testTheme },
|
|
123
|
+
slots: { default: '<div>Content</div>' }
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
const style = wrapper.attributes('style')
|
|
127
|
+
expect(style).toContain('--dm-shadow-md')
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('should generate CSS variables for transitions', () => {
|
|
131
|
+
const wrapper = mount(ThemeProvider, {
|
|
132
|
+
props: { theme: testTheme },
|
|
133
|
+
slots: { default: '<div>Content</div>' }
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const style = wrapper.attributes('style')
|
|
137
|
+
expect(style).toContain('--dm-transition-base')
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('should use custom prefix for CSS variables', () => {
|
|
141
|
+
const wrapper = mount(ThemeProvider, {
|
|
142
|
+
props: { theme: testTheme, prefix: 'custom' },
|
|
143
|
+
slots: { default: '<div>Content</div>' }
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const style = wrapper.attributes('style')
|
|
147
|
+
expect(style).toContain('--custom-primary')
|
|
148
|
+
expect(style).not.toContain('--dm-primary')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('should update CSS variables when theme changes', async () => {
|
|
152
|
+
const wrapper = mount(ThemeProvider, {
|
|
153
|
+
props: { theme: testTheme },
|
|
154
|
+
slots: { default: '<div>Content</div>' }
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
let style = wrapper.attributes('style')
|
|
158
|
+
expect(style).toContain('#0072CE')
|
|
159
|
+
|
|
160
|
+
await wrapper.setProps({ theme: customTheme })
|
|
161
|
+
|
|
162
|
+
style = wrapper.attributes('style')
|
|
163
|
+
expect(style).toContain('#FF0000')
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('should provide theme to child components', () => {
|
|
167
|
+
const ChildComponent = {
|
|
168
|
+
setup() {
|
|
169
|
+
const theme = useTheme()
|
|
170
|
+
return () => h('div', { class: 'child' }, theme.value.name)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const wrapper = mount(ThemeProvider, {
|
|
175
|
+
props: { theme: testTheme },
|
|
176
|
+
slots: {
|
|
177
|
+
default: h(ChildComponent)
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
expect(wrapper.text()).toContain('Test Theme')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('should provide updated theme when changed', async () => {
|
|
185
|
+
const ChildComponent = {
|
|
186
|
+
setup() {
|
|
187
|
+
const theme = useTheme()
|
|
188
|
+
return () => h('div', { class: 'child' }, `${theme.value.name}-${theme.value.tokens.colors.primary}`)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const wrapper = mount(ThemeProvider, {
|
|
193
|
+
props: { theme: testTheme },
|
|
194
|
+
slots: {
|
|
195
|
+
default: h(ChildComponent)
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
expect(wrapper.text()).toContain('Test Theme')
|
|
200
|
+
expect(wrapper.text()).toContain('#0072CE')
|
|
201
|
+
|
|
202
|
+
await wrapper.setProps({ theme: customTheme })
|
|
203
|
+
await wrapper.vm.$nextTick()
|
|
204
|
+
|
|
205
|
+
expect(wrapper.text()).toContain('Custom Theme')
|
|
206
|
+
expect(wrapper.text()).toContain('#FF0000')
|
|
207
|
+
})
|
|
208
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Constants Tests
|
|
3
|
+
* @author Vander Loto - CTO DATAMETRIA
|
|
4
|
+
* @date 13/11/2025
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, expect } from 'vitest'
|
|
8
|
+
import { THEME_INJECTION_KEY, DEFAULT_THEME_PREFIX, CSS_VARIABLE_PREFIX } from '../constants'
|
|
9
|
+
|
|
10
|
+
describe('Theme Constants', () => {
|
|
11
|
+
it('should have THEME_INJECTION_KEY as Symbol', () => {
|
|
12
|
+
expect(typeof THEME_INJECTION_KEY).toBe('symbol')
|
|
13
|
+
expect(THEME_INJECTION_KEY.toString()).toContain('theme')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should have DEFAULT_THEME_PREFIX', () => {
|
|
17
|
+
expect(DEFAULT_THEME_PREFIX).toBe('dm')
|
|
18
|
+
expect(typeof DEFAULT_THEME_PREFIX).toBe('string')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should have CSS_VARIABLE_PREFIX', () => {
|
|
22
|
+
expect(CSS_VARIABLE_PREFIX).toBe('--')
|
|
23
|
+
expect(typeof CSS_VARIABLE_PREFIX).toBe('string')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should have unique injection key', () => {
|
|
27
|
+
const key1 = THEME_INJECTION_KEY
|
|
28
|
+
const key2 = Symbol('theme')
|
|
29
|
+
expect(key1).not.toBe(key2)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Presets Tests
|
|
3
|
+
* @author Vander Loto - CTO DATAMETRIA
|
|
4
|
+
* @date 13/11/2025
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, expect } from 'vitest'
|
|
8
|
+
import { datametriaTheme, defaultTheme } from '../presets'
|
|
9
|
+
|
|
10
|
+
describe('Theme Presets', () => {
|
|
11
|
+
describe('DATAMETRIA Theme', () => {
|
|
12
|
+
it('should have correct name', () => {
|
|
13
|
+
expect(datametriaTheme.name).toBe('DATAMETRIA')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should have DATAMETRIA brand colors', () => {
|
|
17
|
+
expect(datametriaTheme.tokens.colors.primary).toBe('#0072CE')
|
|
18
|
+
expect(datametriaTheme.tokens.colors.secondary).toBe('#4B0078')
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should have semantic colors', () => {
|
|
22
|
+
expect(datametriaTheme.tokens.colors.success).toBe('#10b981')
|
|
23
|
+
expect(datametriaTheme.tokens.colors.warning).toBe('#f59e0b')
|
|
24
|
+
expect(datametriaTheme.tokens.colors.error).toBe('#ef4444')
|
|
25
|
+
expect(datametriaTheme.tokens.colors.info).toBe('#06b6d4')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should have complete neutral scale', () => {
|
|
29
|
+
const neutralKeys = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900']
|
|
30
|
+
neutralKeys.forEach(key => {
|
|
31
|
+
expect(datametriaTheme.tokens.colors.neutral).toHaveProperty(key)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should have typography tokens', () => {
|
|
36
|
+
expect(datametriaTheme.tokens.typography.fontFamily.sans).toBeDefined()
|
|
37
|
+
expect(datametriaTheme.tokens.typography.fontSize.base).toBe('1rem')
|
|
38
|
+
expect(datametriaTheme.tokens.typography.fontWeight.bold).toBe(700)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should have spacing tokens', () => {
|
|
42
|
+
expect(datametriaTheme.tokens.spacing[0]).toBe('0')
|
|
43
|
+
expect(datametriaTheme.tokens.spacing[4]).toBe('1rem')
|
|
44
|
+
expect(datametriaTheme.tokens.spacing[8]).toBe('2rem')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('should have radius tokens', () => {
|
|
48
|
+
expect(datametriaTheme.tokens.radius.none).toBe('0')
|
|
49
|
+
expect(datametriaTheme.tokens.radius.md).toBe('0.375rem')
|
|
50
|
+
expect(datametriaTheme.tokens.radius.full).toBe('9999px')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('should have shadow tokens', () => {
|
|
54
|
+
expect(datametriaTheme.tokens.shadows.none).toBe('none')
|
|
55
|
+
expect(datametriaTheme.tokens.shadows.md).toContain('rgba')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should have transition tokens', () => {
|
|
59
|
+
expect(datametriaTheme.tokens.transitions.fast).toContain('150ms')
|
|
60
|
+
expect(datametriaTheme.tokens.transitions.base).toContain('200ms')
|
|
61
|
+
expect(datametriaTheme.tokens.transitions.slow).toContain('300ms')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should have all required token categories', () => {
|
|
65
|
+
expect(datametriaTheme.tokens).toHaveProperty('colors')
|
|
66
|
+
expect(datametriaTheme.tokens).toHaveProperty('typography')
|
|
67
|
+
expect(datametriaTheme.tokens).toHaveProperty('spacing')
|
|
68
|
+
expect(datametriaTheme.tokens).toHaveProperty('radius')
|
|
69
|
+
expect(datametriaTheme.tokens).toHaveProperty('shadows')
|
|
70
|
+
expect(datametriaTheme.tokens).toHaveProperty('transitions')
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
describe('Default Theme', () => {
|
|
75
|
+
it('should have correct name', () => {
|
|
76
|
+
expect(defaultTheme.name).toBe('Default')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('should have generic brand colors', () => {
|
|
80
|
+
expect(defaultTheme.tokens.colors.primary).toBe('#3b82f6')
|
|
81
|
+
expect(defaultTheme.tokens.colors.secondary).toBe('#8b5cf6')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should have semantic colors', () => {
|
|
85
|
+
expect(defaultTheme.tokens.colors.success).toBe('#10b981')
|
|
86
|
+
expect(defaultTheme.tokens.colors.warning).toBe('#f59e0b')
|
|
87
|
+
expect(defaultTheme.tokens.colors.error).toBe('#ef4444')
|
|
88
|
+
expect(defaultTheme.tokens.colors.info).toBe('#06b6d4')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should have complete neutral scale', () => {
|
|
92
|
+
const neutralKeys = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900']
|
|
93
|
+
neutralKeys.forEach(key => {
|
|
94
|
+
expect(defaultTheme.tokens.colors.neutral).toHaveProperty(key)
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('should have typography tokens', () => {
|
|
99
|
+
expect(defaultTheme.tokens.typography.fontFamily.sans).toBeDefined()
|
|
100
|
+
expect(defaultTheme.tokens.typography.fontSize.base).toBe('1rem')
|
|
101
|
+
expect(defaultTheme.tokens.typography.fontWeight.bold).toBe(700)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('should have all required token categories', () => {
|
|
105
|
+
expect(defaultTheme.tokens).toHaveProperty('colors')
|
|
106
|
+
expect(defaultTheme.tokens).toHaveProperty('typography')
|
|
107
|
+
expect(defaultTheme.tokens).toHaveProperty('spacing')
|
|
108
|
+
expect(defaultTheme.tokens).toHaveProperty('radius')
|
|
109
|
+
expect(defaultTheme.tokens).toHaveProperty('shadows')
|
|
110
|
+
expect(defaultTheme.tokens).toHaveProperty('transitions')
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
describe('Theme Comparison', () => {
|
|
115
|
+
it('should have different primary colors', () => {
|
|
116
|
+
expect(datametriaTheme.tokens.colors.primary).not.toBe(defaultTheme.tokens.colors.primary)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('should have different secondary colors', () => {
|
|
120
|
+
expect(datametriaTheme.tokens.colors.secondary).not.toBe(defaultTheme.tokens.colors.secondary)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('should have same semantic colors', () => {
|
|
124
|
+
expect(datametriaTheme.tokens.colors.success).toBe(defaultTheme.tokens.colors.success)
|
|
125
|
+
expect(datametriaTheme.tokens.colors.warning).toBe(defaultTheme.tokens.colors.warning)
|
|
126
|
+
expect(datametriaTheme.tokens.colors.error).toBe(defaultTheme.tokens.colors.error)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
it('should have same neutral scale', () => {
|
|
130
|
+
expect(datametriaTheme.tokens.colors.neutral).toEqual(defaultTheme.tokens.colors.neutral)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('should have same spacing scale', () => {
|
|
134
|
+
expect(datametriaTheme.tokens.spacing).toEqual(defaultTheme.tokens.spacing)
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should have same radius scale', () => {
|
|
138
|
+
expect(datametriaTheme.tokens.radius).toEqual(defaultTheme.tokens.radius)
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
describe('Theme Validation', () => {
|
|
143
|
+
it('DATAMETRIA theme should be valid', () => {
|
|
144
|
+
expect(datametriaTheme.name).toBeTruthy()
|
|
145
|
+
expect(datametriaTheme.tokens).toBeDefined()
|
|
146
|
+
expect(typeof datametriaTheme.tokens.colors.primary).toBe('string')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('Default theme should be valid', () => {
|
|
150
|
+
expect(defaultTheme.name).toBeTruthy()
|
|
151
|
+
expect(defaultTheme.tokens).toBeDefined()
|
|
152
|
+
expect(typeof defaultTheme.tokens.colors.primary).toBe('string')
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should have valid hex colors', () => {
|
|
156
|
+
const hexRegex = /^#[0-9A-Fa-f]{6}$/
|
|
157
|
+
expect(datametriaTheme.tokens.colors.primary).toMatch(hexRegex)
|
|
158
|
+
expect(defaultTheme.tokens.colors.primary).toMatch(hexRegex)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('should have valid rem values', () => {
|
|
162
|
+
expect(datametriaTheme.tokens.spacing[4]).toMatch(/rem$/)
|
|
163
|
+
expect(defaultTheme.tokens.spacing[4]).toMatch(/rem$/)
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
})
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Tokens Tests
|
|
3
|
+
* @author Vander Loto - CTO DATAMETRIA
|
|
4
|
+
* @date 13/11/2025
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, it, expect } from 'vitest'
|
|
8
|
+
import {
|
|
9
|
+
defaultColors,
|
|
10
|
+
defaultTypography,
|
|
11
|
+
defaultSpacing,
|
|
12
|
+
defaultRadius,
|
|
13
|
+
defaultShadows,
|
|
14
|
+
defaultTransitions,
|
|
15
|
+
defaultTokens
|
|
16
|
+
} from '../tokens'
|
|
17
|
+
|
|
18
|
+
describe('Default Tokens', () => {
|
|
19
|
+
describe('Colors', () => {
|
|
20
|
+
it('should have all required color properties', () => {
|
|
21
|
+
expect(defaultColors).toHaveProperty('primary')
|
|
22
|
+
expect(defaultColors).toHaveProperty('secondary')
|
|
23
|
+
expect(defaultColors).toHaveProperty('success')
|
|
24
|
+
expect(defaultColors).toHaveProperty('warning')
|
|
25
|
+
expect(defaultColors).toHaveProperty('error')
|
|
26
|
+
expect(defaultColors).toHaveProperty('info')
|
|
27
|
+
expect(defaultColors).toHaveProperty('neutral')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should have DATAMETRIA brand colors', () => {
|
|
31
|
+
expect(defaultColors.primary).toBe('#0072CE')
|
|
32
|
+
expect(defaultColors.secondary).toBe('#4B0078')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should have complete neutral scale', () => {
|
|
36
|
+
const neutralKeys = ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900']
|
|
37
|
+
neutralKeys.forEach(key => {
|
|
38
|
+
expect(defaultColors.neutral).toHaveProperty(key)
|
|
39
|
+
expect(typeof defaultColors.neutral[key as keyof typeof defaultColors.neutral]).toBe('string')
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('should have valid hex color format', () => {
|
|
44
|
+
const hexRegex = /^#[0-9A-Fa-f]{6}$/
|
|
45
|
+
expect(defaultColors.primary).toMatch(hexRegex)
|
|
46
|
+
expect(defaultColors.secondary).toMatch(hexRegex)
|
|
47
|
+
expect(defaultColors.success).toMatch(hexRegex)
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
describe('Typography', () => {
|
|
52
|
+
it('should have font families', () => {
|
|
53
|
+
expect(defaultTypography.fontFamily).toHaveProperty('sans')
|
|
54
|
+
expect(defaultTypography.fontFamily).toHaveProperty('mono')
|
|
55
|
+
expect(typeof defaultTypography.fontFamily.sans).toBe('string')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('should have complete font size scale', () => {
|
|
59
|
+
const sizeKeys = ['xs', 'sm', 'base', 'lg', 'xl', '2xl', '3xl', '4xl']
|
|
60
|
+
sizeKeys.forEach(key => {
|
|
61
|
+
expect(defaultTypography.fontSize).toHaveProperty(key)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should have font weights', () => {
|
|
66
|
+
expect(defaultTypography.fontWeight.normal).toBe(400)
|
|
67
|
+
expect(defaultTypography.fontWeight.medium).toBe(500)
|
|
68
|
+
expect(defaultTypography.fontWeight.semibold).toBe(600)
|
|
69
|
+
expect(defaultTypography.fontWeight.bold).toBe(700)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should have line heights', () => {
|
|
73
|
+
expect(defaultTypography.lineHeight.tight).toBe(1.25)
|
|
74
|
+
expect(defaultTypography.lineHeight.normal).toBe(1.5)
|
|
75
|
+
expect(defaultTypography.lineHeight.relaxed).toBe(1.75)
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
describe('Spacing', () => {
|
|
80
|
+
it('should have complete spacing scale', () => {
|
|
81
|
+
const spacingKeys = ['0', '1', '2', '3', '4', '6', '8', '12', '16', '20', '24']
|
|
82
|
+
spacingKeys.forEach(key => {
|
|
83
|
+
expect(defaultSpacing).toHaveProperty(key)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('should have valid rem values', () => {
|
|
88
|
+
expect(defaultSpacing[0]).toBe('0')
|
|
89
|
+
expect(defaultSpacing[4]).toBe('1rem')
|
|
90
|
+
expect(defaultSpacing[8]).toBe('2rem')
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
describe('Radius', () => {
|
|
95
|
+
it('should have all radius sizes', () => {
|
|
96
|
+
expect(defaultRadius).toHaveProperty('none')
|
|
97
|
+
expect(defaultRadius).toHaveProperty('sm')
|
|
98
|
+
expect(defaultRadius).toHaveProperty('md')
|
|
99
|
+
expect(defaultRadius).toHaveProperty('lg')
|
|
100
|
+
expect(defaultRadius).toHaveProperty('xl')
|
|
101
|
+
expect(defaultRadius).toHaveProperty('full')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('should have valid values', () => {
|
|
105
|
+
expect(defaultRadius.none).toBe('0')
|
|
106
|
+
expect(defaultRadius.full).toBe('9999px')
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
describe('Shadows', () => {
|
|
111
|
+
it('should have all shadow sizes', () => {
|
|
112
|
+
expect(defaultShadows).toHaveProperty('none')
|
|
113
|
+
expect(defaultShadows).toHaveProperty('sm')
|
|
114
|
+
expect(defaultShadows).toHaveProperty('md')
|
|
115
|
+
expect(defaultShadows).toHaveProperty('lg')
|
|
116
|
+
expect(defaultShadows).toHaveProperty('xl')
|
|
117
|
+
expect(defaultShadows).toHaveProperty('2xl')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('should have valid shadow values', () => {
|
|
121
|
+
expect(defaultShadows.none).toBe('none')
|
|
122
|
+
expect(defaultShadows.sm).toContain('rgba')
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
describe('Transitions', () => {
|
|
127
|
+
it('should have all transition speeds', () => {
|
|
128
|
+
expect(defaultTransitions).toHaveProperty('fast')
|
|
129
|
+
expect(defaultTransitions).toHaveProperty('base')
|
|
130
|
+
expect(defaultTransitions).toHaveProperty('slow')
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
it('should have valid timing values', () => {
|
|
134
|
+
expect(defaultTransitions.fast).toContain('ms')
|
|
135
|
+
expect(defaultTransitions.base).toContain('cubic-bezier')
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('Complete Token Set', () => {
|
|
140
|
+
it('should export complete default tokens', () => {
|
|
141
|
+
expect(defaultTokens).toHaveProperty('colors')
|
|
142
|
+
expect(defaultTokens).toHaveProperty('typography')
|
|
143
|
+
expect(defaultTokens).toHaveProperty('spacing')
|
|
144
|
+
expect(defaultTokens).toHaveProperty('radius')
|
|
145
|
+
expect(defaultTokens).toHaveProperty('shadows')
|
|
146
|
+
expect(defaultTokens).toHaveProperty('transitions')
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should have consistent structure', () => {
|
|
150
|
+
expect(defaultTokens.colors).toBe(defaultColors)
|
|
151
|
+
expect(defaultTokens.typography).toBe(defaultTypography)
|
|
152
|
+
expect(defaultTokens.spacing).toBe(defaultSpacing)
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
})
|