Skip to content

Commit

Permalink
Merge 54b3666 into ca772f7
Browse files Browse the repository at this point in the history
  • Loading branch information
weareoutman authored Aug 2, 2024
2 parents ca772f7 + 54b3666 commit 518d7fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
22 changes: 13 additions & 9 deletions packages/yo/src/plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ export default function (
"libDevDependencies",
getObjectPartialInPackageJson(libDevDependencies)
);
plop.setHelper("getTagName", (brickType, pkgName, brickName, lastNameOnly) =>
brickType === "common"
? `eo-${brickName}`
: lastNameOnly
? brickName
: `${pkgName}.${brickName}`
plop.setHelper(
"getTagName",
(brickType, pkgName, brickName, lastNameOnly, stripEo) =>
brickType === "common"
? stripEo
? brickName
: `eo-${brickName}`
: lastNameOnly
? brickName
: `${pkgName}.${brickName}`
);
plop.setHelper("getDirectory", (type, pkgName, libName) =>
type === "bricks"
Expand All @@ -83,15 +87,15 @@ export default function (
);
plop.setPartial(
"tagName",
"{{getTagName brickType pkgName brickName false}}"
"{{getTagName brickType pkgName brickName false false}}"
);
plop.setPartial(
"lastTagName",
"{{getTagName brickType pkgName brickName true}}"
"{{getTagName brickType pkgName brickName true false}}"
);
plop.setPartial(
"className",
"{{pascalCase (getTagName brickType pkgName brickName true)}}"
"{{pascalCase (getTagName brickType pkgName brickName true true)}}"
);

// create your generators here
Expand Down
14 changes: 9 additions & 5 deletions packages/yo/src/templates/brick/index.tsx.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,34 @@ import styleText from "./styles.shadow.css";

{{#if useI18n}}
initializeReactI18n(NS, locales);
{{/if}}

{{/if}}
const { defineElement, property } = createDecorators();

export interface {{>className}}Props {
// Define props here.
}

/**
* 构件 `{{>tagName}}`
*/
export
@defineElement("{{>tagName}}", {
styleTexts: [styleText],
})
class {{>className}} extends ReactNextElement {
class {{>className}} extends ReactNextElement implements {{>className}}Props {
render() {
return (
<{{>className}}Component />
);
}
}

export interface {{>className}}Props {
// Define props here.
export interface {{>className}}ComponentProps extends {{>className}}Props {
// Define event handlers here.
}

export function {{>className}}Component(props: {{>className}}Props) {
export function {{>className}}Component(props: {{>className}}ComponentProps) {
{{#if useI18n}}
const { t } = useTranslation(NS);
const hello = t(K.HELLO);
Expand Down

0 comments on commit 518d7fc

Please sign in to comment.