Skip to content

Commit

Permalink
build: expand templating to support #1822 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed May 23, 2024
1 parent 5d189c2 commit a2f82a7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
3 changes: 3 additions & 0 deletions projects/templates/plop-templates/args.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const argTypes = {

}
10 changes: 5 additions & 5 deletions projects/templates/plop-templates/stories.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { html, TemplateResult } from '@spectrum-web-components/base';
import { TemplateResult } from '@spectrum-web-components/base';

import '../{{> tagnamePartial }}.js';
import { Template } from './template.js';
import { argTypes } from './args.js';

export default {
title: '{{displayName name}}',
component: '{{> tagnamePartial}}',
argTypes,
};

export const Default = (): TemplateResult => {
return html`<{{> tagnamePartial}}></{{> tagnamePartial}}>`;
};
export const Default = (): TemplateResult => Template({});
13 changes: 13 additions & 0 deletions projects/templates/plop-templates/template.ts.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { html, TemplateResult } from '@spectrum-web-components/base';

import '@spectrum-web-components/{{ name }}/{{> tagnamePartial }}.js';

export interface Properties {
}

export const Template = (props: Properties): TemplateResult => {
// Remove the console.log() when you're ready to consume `props` in the element below.
// eslint-disable-next-line no-console
console.log('template properties', props);
return html`<{{> tagnamePartial}}></{{> tagnamePartial}}>`;
};
4 changes: 2 additions & 2 deletions projects/templates/plop-templates/test.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fixture, elementUpdated, expect, html } from '@open-wc/testing';

import '../{{> tagnamePartial }}.js';
import { {{className name}} } from '..';
import '@spectrum-web-components/{{name}}/{{> tagnamePartial }}.js';
import { {{className name}} } from '@spectrum-web-components/{{name}}';
import { testForLitDevWarnings } from '../../../test/testing-helpers.js';

describe('{{className name}}', () => {
Expand Down
12 changes: 11 additions & 1 deletion projects/templates/plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = function (plop) {

plop.setActionType('format files', function (answers) {
execSync(
`cd ../../ && yarn prettier --write packages/${answers.name} && eslint --fix -f pretty packages/${answers.name} && stylelint --fix packages/${answers.name}`
`cd ../../ && yarn prettier --write packages/${answers.name} && yarn eslint --fix -f pretty packages/${answers.name} && yarn stylelint --fix packages/${answers.name}`
);
});

Expand Down Expand Up @@ -126,6 +126,16 @@ module.exports = function (plop) {
path: '../../packages/{{name}}/stories/{{name}}.stories.ts',
templateFile: 'plop-templates/stories.ts.hbs',
},
{
type: 'add',
path: '../../packages/{{name}}/stories/args.ts',
templateFile: 'plop-templates/args.ts.hbs',
},
{
type: 'add',
path: '../../packages/{{name}}/stories/template.ts',
templateFile: 'plop-templates/template.ts.hbs',
},
{
type: 'add',
path: '../../packages/{{name}}/README.md',
Expand Down

0 comments on commit a2f82a7

Please sign in to comment.