Skip to content

Commit

Permalink
chore: create-cssr-scaffold script
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed Jul 21, 2020
1 parent 3536e0f commit 32c589a
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
62 changes: 62 additions & 0 deletions scripts/create-cssr-scaffold.js
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions src/alert/src/styles/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import baseStyle from './themed-base.cssr.js'

export default [
{
key: 'syntheticTheme',
watch: [
'syntheticTheme'
],
CNode: baseStyle
}
]
6 changes: 6 additions & 0 deletions src/alert/src/styles/themed-base.cssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { c, cTB, cB, cE, cM, cNotM } from '../../../_utils/cssr'

export default c([
({ props }) => {
}
])
9 changes: 9 additions & 0 deletions src/alert/styles/dark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import create from '../../styles/_utils/create-component-base'

export default create({
theme: 'dark',
name: '',
getDerivedVariables ({ base, derived }) {
return {}
}
})
9 changes: 9 additions & 0 deletions src/alert/styles/light.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import create from '../../styles/_utils/create-component-base'

export default create({
theme: 'light',
name: '',
getDerivedVariables ({ base, derived }) {
return {}
}
})

0 comments on commit 32c589a

Please sign in to comment.