mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-30 12:52:43 +08:00
chore: create-cssr-scaffold script
This commit is contained in:
parent
3536e0fa03
commit
32c589a617
62
scripts/create-cssr-scaffold.js
Normal file
62
scripts/create-cssr-scaffold.js
Normal file
@ -0,0 +1,62 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const componentName = process.argv[2]
|
||||
|
||||
const componentPath = path.resolve(__dirname, '..', 'src', componentName)
|
||||
|
||||
if (!fs.existsSync(componentPath)) {
|
||||
console.log(componentPath + ' doesn\'t exists')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const themeStylesPath = path.resolve(componentPath, 'styles')
|
||||
if (!fs.existsSync(themeStylesPath)) {
|
||||
fs.mkdirSync(themeStylesPath)
|
||||
}
|
||||
fs.writeFileSync(path.resolve(themeStylesPath, 'light.js'), `import create from '../../styles/_utils/create-component-base'
|
||||
|
||||
export default create({
|
||||
theme: 'light',
|
||||
name: '',
|
||||
getDerivedVariables ({ base, derived }) {
|
||||
return {}
|
||||
}
|
||||
})
|
||||
`)
|
||||
fs.writeFileSync(path.resolve(themeStylesPath, 'dark.js'), `import create from '../../styles/_utils/create-component-base'
|
||||
|
||||
export default create({
|
||||
theme: 'dark',
|
||||
name: '',
|
||||
getDerivedVariables ({ base, derived }) {
|
||||
return {}
|
||||
}
|
||||
})
|
||||
`)
|
||||
|
||||
const cssrPath = path.resolve(componentPath, 'src', 'styles')
|
||||
if (!fs.existsSync(cssrPath)) {
|
||||
fs.mkdirSync(cssrPath)
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.resolve(cssrPath, 'themed-base.cssr.js'), `import { c, cTB, cB, cE, cM, cNotM } from '../../../_utils/cssr'
|
||||
|
||||
export default c([
|
||||
({ props }) => {
|
||||
}
|
||||
])
|
||||
`)
|
||||
|
||||
fs.writeFileSync(path.resolve(cssrPath, 'index.js'), `import baseStyle from './themed-base.cssr.js'
|
||||
|
||||
export default [
|
||||
{
|
||||
key: 'syntheticTheme',
|
||||
watch: [
|
||||
'syntheticTheme'
|
||||
],
|
||||
CNode: baseStyle
|
||||
}
|
||||
]
|
||||
`)
|
11
src/alert/src/styles/index.js
Normal file
11
src/alert/src/styles/index.js
Normal file
@ -0,0 +1,11 @@
|
||||
import baseStyle from './themed-base.cssr.js'
|
||||
|
||||
export default [
|
||||
{
|
||||
key: 'syntheticTheme',
|
||||
watch: [
|
||||
'syntheticTheme'
|
||||
],
|
||||
CNode: baseStyle
|
||||
}
|
||||
]
|
6
src/alert/src/styles/themed-base.cssr.js
Normal file
6
src/alert/src/styles/themed-base.cssr.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { c, cTB, cB, cE, cM, cNotM } from '../../../_utils/cssr'
|
||||
|
||||
export default c([
|
||||
({ props }) => {
|
||||
}
|
||||
])
|
9
src/alert/styles/dark.js
Normal file
9
src/alert/styles/dark.js
Normal file
@ -0,0 +1,9 @@
|
||||
import create from '../../styles/_utils/create-component-base'
|
||||
|
||||
export default create({
|
||||
theme: 'dark',
|
||||
name: '',
|
||||
getDerivedVariables ({ base, derived }) {
|
||||
return {}
|
||||
}
|
||||
})
|
9
src/alert/styles/light.js
Normal file
9
src/alert/styles/light.js
Normal file
@ -0,0 +1,9 @@
|
||||
import create from '../../styles/_utils/create-component-base'
|
||||
|
||||
export default create({
|
||||
theme: 'light',
|
||||
name: '',
|
||||
getDerivedVariables ({ base, derived }) {
|
||||
return {}
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user