Skip to content

Commit be03c01

Browse files
committed
refactor(script): update component generation script with latest doc changes
1 parent 8a1fa7a commit be03c01

File tree

8 files changed

+85
-61
lines changed

8 files changed

+85
-61
lines changed

scripts/component-generator/templates/component/src/components/ods-{{>component-name}}/ods-{{>component-name}}.tsx.hbs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { FunctionalComponent } from '@stencil/core';
2-
import { Component, Host, Prop, h } from '@stencil/core';
1+
import { Component, type FunctionalComponent, Host, Prop, h } from '@stencil/core';
32

43
@Component({
54
shadow: true,
@@ -12,7 +11,7 @@ export class Ods{{> ComponentName }} {
1211
render(): FunctionalComponent {
1312
return (
1413
<Host
15-
class='ods-{{> component-name }}'
14+
class="ods-{{> component-name }}"
1615
role="article">
1716
<p>
1817
ODS Template Component: { this.dummy }

scripts/component-generator/templates/component/tests/accessibility/ods-{{>component-name}}.e2e.ts.hbs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { E2EElement, E2EPage } from '@stencil/core/testing';
2-
import { newE2EPage } from '@stencil/core/testing';
1+
import { type E2EElement, type E2EPage, newE2EPage } from '@stencil/core/testing';
32

43
describe('ods-{{> component-name }} accessibility', () => {
54
let el: E2EElement;
@@ -9,7 +8,7 @@ describe('ods-{{> component-name }} accessibility', () => {
98
page = await newE2EPage();
109

1110
await page.setContent(content);
12-
await page.evaluate(() => document.body.style.setProperty('margin', '0px'));
11+
await page.evaluate(() => document.body.style.setProperty('margin', '0'));
1312

1413
el = await page.find('ods-{{> component-name }}');
1514
}

scripts/component-generator/templates/component/tests/rendering/ods-{{>component-name}}.e2e.ts.hbs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { E2EElement, E2EPage } from '@stencil/core/testing';
2-
import { newE2EPage } from '@stencil/core/testing';
1+
import { type E2EElement, type E2EPage, newE2EPage } from '@stencil/core/testing';
32

43
describe('ods-{{> component-name }} rendering', () => {
54
let el: E2EElement;
@@ -9,7 +8,7 @@ describe('ods-{{> component-name }} rendering', () => {
98
page = await newE2EPage();
109

1110
await page.setContent(content);
12-
await page.evaluate(() => document.body.style.setProperty('margin', '0px'));
11+
await page.evaluate(() => document.body.style.setProperty('margin', '0'));
1312

1413
if (customStyle) {
1514
await page.addStyleTag({ content: customStyle });

scripts/component-generator/templates/component/tests/rendering/ods-{{>component-name}}.spec.ts.hbs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { SpecPage } from '@stencil/core/testing';
2-
import { newSpecPage } from '@stencil/core/testing';
1+
import { type SpecPage, newSpecPage } from '@stencil/core/testing';
32
import { Ods{{> ComponentName }} } from '../../src';
43

54
describe('ods-{{> component-name }} rendering', () => {
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,61 @@
1-
import { Canvas, Meta, Markdown } from '@storybook/blocks';
2-
import Specifications{{> ComponentName }} from '@ovhcloud/ods-{{> component-dir}}/src/components/{{> component-name }}/documentation/spec.md?raw';
3-
import { Banner } from '../../banner';
4-
import { DocNavigator } from '../../doc-navigator';
1+
import { Canvas, Meta } from '@storybook/blocks';
52
import * as {{> ComponentName }}Stories from './{{> component-name }}.stories';
6-
import { LINK_ID } from '../../zeroheight';
3+
import { Banner } from '../../../src/components/banner/Banner';
4+
import { BestPractices } from '../../../src/components/bestPractices/BestPractices';
5+
import { Heading } from '../../../src/components/heading/Heading';
6+
import { IdentityCard } from '../../../src/components/identityCard/IdentityCard';
7+
import { StorybookLink } from '../../../src/components/storybookLink/StorybookLink';
8+
import { ATOMIC_TYPE } from '../../../src/constants/atomicDesign';
9+
import { ODS_COMPONENTS_TITLE, STORY } from '../../../src/constants/meta';
710

811
<Meta of={ {{> ComponentName }}Stories } name='Documentation' />
912

1013
<Banner of={ {{> ComponentName }}Stories } />
1114

12-
# Overview
13-
14-
TODO Some text about the component
15+
_**{{> ComponentName }}** TODO some text about the component_
1516

1617
<Canvas of={ {{> ComponentName }}Stories.Default } sourceState='none' />
1718

18-
<DocNavigator of={ {{> ComponentName }}Stories } linkId={ LINK_ID.{{> COMPONENT_NAME }} } />
19+
<Heading label="Overview" level={ 2 } />
20+
21+
<IdentityCard aliases={ [] }
22+
atomicType={ ATOMIC_TYPE.TODO }
23+
figmaLink="TODO"
24+
githubUrl="https://github.com/ovh/design-system/tree/master/packages/ods/src/components/{{> component-name }}"
25+
name="{{> ComponentName }}"
26+
relatedComponents={ [] }>
27+
TODO some text about the component.
28+
</IdentityCard>
29+
30+
<Heading label="Anatomy" level={ 2 } />
31+
32+
TODO picture
33+
34+
<Heading label="Usage" level={ 2 } />
35+
36+
TODO if relevant
37+
38+
<Heading label="Dos & Don'ts" level={ 3 } />
1939

20-
<Markdown>{ Specifications{{> ComponentName }} }</Markdown>
40+
<BestPractices
41+
donts={[]}
42+
dos={[]}
43+
/>
2144

22-
# Style customization [IF RELEVANT]
45+
<Heading label="Placement" level={ 2 } />
2346

24-
You can add your own style on the {{> component-name }} element using the part `{{> component-name }}`.
47+
TODO if relevant
2548

26-
Custom {{> component-name }} css:
49+
<Heading label="Behavior" level={ 2 } />
2750

28-
<Canvas of={ {{> ComponentName }}Stories.CustomCSS } sourceState='shown'/>
51+
TODO if relevant
2952

30-
# Examples
53+
<Heading label="Variation" level={ 2 } />
3154

32-
## Default
55+
<Heading label="Variant" level={ 3 } />
3356

34-
<Canvas of={ {{> ComponentName }}Stories.Default } sourceState='shown' />
57+
TODO if relevant
3558

36-
## [Other attribute]
37-
<Canvas of={ {{> ComponentName }}Stories.Default } sourceState='shown' />
59+
<Heading label="Accessibility" level={ 2 } />
3860

39-
...
61+
TODO if relevant

scripts/component-generator/templates/storybook/migration.from.17.x.mdx.hbs

-26
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Canvas, Meta } from '@storybook/blocks';
2+
import Specifications{{> ComponentName }} from '@ovhcloud/ods-components/src/components/{{> component-name }}/documentation/custom-elements.json';
3+
import { Banner } from '../../../src/components/banner/Banner';
4+
import { Heading } from '../../../src/components/heading/Heading';
5+
import { TechnicalSpecification } from '../../../src/components/technicalSpecification/TechnicalSpecification';
6+
import * as {{> ComponentName }}Stories from './{{> component-name }}.stories';
7+
8+
<Meta of={ {{> ComponentName }}Stories } name="Technical information" />
9+
10+
<Banner of={ {{> ComponentName }}Stories } />
11+
12+
<Heading label="Overview" level={ 2 } />
13+
14+
<Canvas of={ {{> ComponentName }}Stories.Overview } sourceState="'none' "/>
15+
16+
<TechnicalSpecification data={ Specifications{{> ComponentName }} } />
17+
18+
<Heading label="Style customization" level={ 2 } />
19+
20+
TODO if relevant
21+
22+
You can add your own style on the {{> component-name }} element using the part `...`.
23+
24+
Custom CSS:
25+
26+
<Canvas of={ {{> ComponentName }}Stories.CustomCSS } sourceState="shown" />
27+
28+
<Heading label="Examples" level={ 2 } />
29+
30+
<Heading label="Default" level={ 3 } />
31+
32+
<Canvas of={ {{> ComponentName }}Stories.Default } sourceState="shown" />
33+
34+
...

scripts/component-generator/templates/storybook/{{> component-name }}.stories.ts.hbs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { Meta, StoryObj } from '@storybook/web-components';
2-
import { defineCustomElement } from '@ovhcloud/ods-components/dist/components/ods-{{> component-name }}';
32
import { html } from 'lit-html';
4-
import { CONTROL_CATEGORY, orderControls } from '../../control';
5-
6-
defineCustomElement();
3+
import { CONTROL_CATEGORY } from '../../../src/constants/controls';
4+
import { orderControls } from '../../../src/helpers/controls';
75

86
const meta: Meta = {
97
title: 'ODS Components/TODO/{{> ComponentName }}',

0 commit comments

Comments
 (0)