chromatic modes

This commit is contained in:
Gauthier Roebroeck 2025-08-11 14:02:29 +08:00
parent 432e933e01
commit 5d49e41370
4 changed files with 32 additions and 11 deletions

View file

@ -0,0 +1,19 @@
const themes = ['light', 'dark']
const viewports = [
{ name: 'mobile', value: 'xs' },
{ name: 'desktop', value: 'md' },
]
const allModes: Record<string, object> = {}
// viewport / theme combinations
viewports.forEach((vp) => {
themes.forEach((t) => {
allModes[`${t} ${vp.name}`] = {
viewport: vp.value,
theme: t,
}
})
})
export { allModes }

View file

@ -12,7 +12,8 @@ import { vueIntl } from '@/plugins/vue-intl'
import 'virtual:uno.css'
import { availableLocales } from '@/utils/i18n/locale-helper'
import { localeDecorator } from './locale.decorator'
import { viewports } from './viewport'
import { vuetifyViewports } from './viewport'
import { allModes } from './modes'
initialize(
{
@ -31,6 +32,9 @@ Object.entries(availableLocales).forEach(([code, name]) => {
const preview: Preview = {
parameters: {
chromatic: {
modes: allModes,
},
controls: {
matchers: {
color: /(background|color)$/i,
@ -38,7 +42,7 @@ const preview: Preview = {
},
},
viewport: {
options: [...viewports],
options: { ...vuetifyViewports },
},
a11y: {
// 'todo' - show a11y violations in the test UI only

View file

@ -1,37 +1,37 @@
export const viewports = [
{
export const vuetifyViewports = {
xs: {
name: 'xs',
styles: {
width: '400px',
height: '963px',
},
},
{
sm: {
name: 'sm',
styles: {
width: '950px',
height: '963px',
},
},
{
md: {
name: 'md',
styles: {
width: '1200px',
height: '963px',
},
},
{
lg: {
name: 'lg',
styles: {
width: '1900px',
height: '963px',
},
},
{
xl: {
name: 'xl',
styles: {
width: '2550px',
height: '963px',
},
},
]
}

View file

@ -22,12 +22,10 @@ declare module 'vue' {
FragmentBuildVersion: typeof import('./fragments/fragment/BuildVersion.vue')['default']
FragmentDialogConfirm: typeof import('./fragments/fragment/dialog/Confirm.vue')['default']
FragmentDialogConfirmEdit: typeof import('./fragments/fragment/dialog/ConfirmEdit.vue')['default']
FragmentHistoryBookFileDeleted: typeof import('./fragments/fragment/history/BookFileDeleted.vue')['default']
FragmentHistoryExpandBookConverted: typeof import('./fragments/fragment/history/expand/BookConverted.vue')['default']
FragmentHistoryExpandBookFileDeleted: typeof import('./fragments/fragment/history/expand/BookFileDeleted.vue')['default']
FragmentHistoryExpandBookImported: typeof import('./fragments/fragment/history/expand/BookImported.vue')['default']
FragmentHistoryExpandDuplicatePageDeleted: typeof import('./fragments/fragment/history/expand/DuplicatePageDeleted.vue')['default']
FragmentHistoryExpandFileDeleted: typeof import('./fragments/fragment/history/ExpandFileDeleted.vue')['default']
FragmentHistoryExpandSeriesFolderDeleted: typeof import('./fragments/fragment/history/expand/SeriesFolderDeleted.vue')['default']
FragmentHistoryExpandTable: typeof import('./fragments/fragment/history/expand/Table.vue')['default']
FragmentHistoryTable: typeof import('./fragments/fragment/history/Table.vue')['default']