import { splitByCase, upperFirst, camelCase, kebabCase } from 'scule'
const playground = ({ name }) => {
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
const kebabName = kebabCase(name)
return {
filename: `playground/pages/${kebabName}.vue`,
contents: `
`
}
}
const component = ({ name }) => {
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
const camelName = camelCase(name)
return {
filename: `src/runtime/components/${upperName}.vue`,
contents: `
`
}
}
const theme = ({ name }) => {
const camelName = camelCase(name)
return {
filename: `src/theme/${camelName}.ts`,
contents: `
export default {
slots: {
root: ''
},
variants: {
},
defaultVariants: {
}
}
`
}
}
const test = ({ name }) => {
const upperName = splitByCase(name).map(p => upperFirst(p)).join('')
return {
filename: `test/components/${upperName}.spec.ts`,
contents: `
import { describe, it, expect } from 'vitest'
import ${upperName}, { type ${upperName}Props } from '../../src/runtime/components/${upperName}.vue'
import ComponentRender from '../component-render'
describe('${upperName}', () => {
it.each([
['basic case', {}],
['with class', { props: { class: '' } }],
['with ui', { props: { ui: {} } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: ${upperName}Props, slots?: any }) => {
const html = await ComponentRender(nameOrHtml, options, ${upperName})
expect(html).toMatchSnapshot()
})
})
`
}
}
export default {
playground,
component,
theme,
test
}