Skip to content

Instantly share code, notes, and snippets.

@qfox
Created August 29, 2019 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qfox/764e5ad976ee2e0b1f98240b9e79b9e1 to your computer and use it in GitHub Desktop.
Save qfox/764e5ad976ee2e0b1f98240b9e79b9e1 to your computer and use it in GitHub Desktop.
const args = process.argv.slice(2);
const cell = {
block: args[0],
mod: {
name: args[1],
val: args[2],
}
};
// cell
const ModVal = args[3] || `${PascalCase(cell.mod.name)}${PascalCase(cell.mod.val)}`;
const BlockModVal = args[4] || `${cell.block}${ModVal}`;
function PascalCase(s) { return s[0].toUpperCase() + s.slice(1); }
console.log(`import { withBemMod } from '@bem-react/core';
import { cn${cell.block} } from '../${cell.block}';
import './${cell.block}_${cell.mod.name}_${cell.mod.val}.css';
export interface I${BlockModVal}Props {
/**
* Внешний вид кнопки.
*/
${cell.mod.name}?: '${cell.mod.val}';
}
/**
* Модификатор, отвечающий за внешний вид.
* @param {I${BlockModVal}Props} props
*/
export const with${ModVal} = withBemMod<I${BlockModVal}Props>(cn${cell.block}(), { ${cell.mod.name}: '${cell.mod.val}' });`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment