Skip to content

Commit

Permalink
feat(cli): improve scaffold props
Browse files Browse the repository at this point in the history
  • Loading branch information
asgorobets committed Nov 7, 2024
1 parent b2e969f commit 72c1936
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cli/prompts.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const prompts = {
promptContentType: {
name: 'promptContentType',
type: 'rawlist',
type: 'list',
message: 'Please choose a CTF content type to generate the component for:',
choices: ['---No content type yet---'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export const {{pascalCase name}}Client: React.FC<{
const { data: originalData } = props;
const { data, addAttributes } = useComponentPreview<typeof originalData>(originalData);

return <{{pascalCase name}} data={data} addAttributes={addAttributes} />;
return <{{pascalCase name}} id={data.sys.id} addAttributes={addAttributes} />;
};
8 changes: 2 additions & 6 deletions cli/scaffolds/ui/{{hyphenCase name}}.stories.{{ext}}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const meta = {
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
data: {},
id: {},
},
} satisfies Meta<typeof {{pascalCase name}}>;

Expand All @@ -24,10 +24,6 @@ type Story = StoryObj<typeof meta>;
// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const Default: Story = {
args: {
data: {
sys: {
id: '{{ snakeCase name }}_id',
},
},
id: '{{ snakeCase name }}_id',
},
};
6 changes: 3 additions & 3 deletions cli/scaffolds/ui/{{hyphenCase name}}.{{ext}}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export interface {{pascalCase name}}Props {
data: { sys: { id: string } };
id: string;
addAttributes?: (name: string) => object | null;
}

export const {{pascalCase name}} = ({ data, addAttributes = () => ({}) }: {{pascalCase name}}Props) => {
export const {{pascalCase name}} = ({ id, addAttributes = () => ({}) }: {{pascalCase name}}Props) => {
return (
<div {...addAttributes('attributes')}>
<div>{{pascalCase name}}</div>
<div>{data.sys.id}</div>
<div>{id}</div>
</div>
);
};

0 comments on commit 72c1936

Please sign in to comment.