Skip to content

Commit 6ca0cae

Browse files
dchyunshleewhite
andauthored
Showcase: Update copilot instructions to follow gts structure (#3186)
Co-authored-by: Lee White <lee.white@hashicorp.com>
1 parent 1040393 commit 6ca0cae

File tree

1 file changed

+64
-11
lines changed

1 file changed

+64
-11
lines changed

.github/copilot-instructions.md

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,78 @@ applyTo: "showcase/app/**"
117117
description: "Instructions for how components should be displayed in the showcase application"
118118
---
119119

120-
### File structure
121-
- Define a folder for every component under `showcase/app`.
122-
123-
#### Required files
124-
- `comtrollers/page-components/<component-name>.js` - Controller for the component's showcase page.
125-
- `routes/page-components/<component-name>.js` - Route for the component's showcase page
126-
- `templates/page-components/<component-name>.hbs` - Handlebars template for the component's showcase page.
120+
### Required files
121+
- `components/page-components/<component-name>/index.gts` - Main component for component's showcase page which contains references to sub-section components.
122+
- `routes/page-components/<component-name>.ts` - Route for the component's showcase page.
123+
- `templates/page-components/<component-name>.gts` - Page template which contains a component's index component.
127124

128125
Compare a component's showcase against its corresponding component in the `packages/components/src/components/hds` folder.
129126

130-
### Showcase template
131-
For a given component, make the showcase template file include:
127+
### Showcase components
128+
The purpose of a Showcase page for an HDS component is to showcase possible combinations and edge cases of the component, for different formats and combinations of its content.
129+
130+
For a given component, the following items should be shown on its showcase page:
132131
- Instances of all available arguments, and all available values for the component.
133132
- Example: An `@isActive` boolean argument should be demonstrated with both `true` and `false` values.
134133
- Example: A `@color` argument should be demonstrated with all available color values.
135134
- Instances of all available blocks for the component.
136135

137-
### Component routes
138-
- Include all pages under the `showcase/app/templates/page-components` folder in the `showcase/app/router.ts` file.
136+
For each HDS component, follow the following structure for showcase component files.
137+
- `components/page-components/<component-name>/index.gts` - Index file for the component's showcase page.
138+
- `components/page-components/<component-name>/code-fragments/<code-fragment-name>.gts` - Reusable examples of the main HDS component. Used multiple tiomes within the component's page.
139+
- `components/page-components/<component-name>/sub-sections/<sub-section-name>.gts` - Sub-sections of the main component's showcase page. They should contains examples of the main HDS component's attributes, properties, interactive states, and other use cases. Each major section of the showcase should be broken into its own sub-section component. What constitutes a section can be flexible, but generally its each `ShwTextH2` plus the content below it.
140+
141+
#### Best practices
142+
- Use arrow functions instead of `@action` for event handlers.
143+
- For interactive components, document all interactive states for hover, focus, active, disabled, etc.
144+
145+
Examples:
146+
```javascript
147+
// Good: Arrow function
148+
onClickToggleSingle = () => {
149+
150+
};
151+
152+
// Bad: Action decorator
153+
@action
154+
onClickToggleSingle {
155+
156+
};
157+
```
158+
159+
### Routes
160+
Each component should have a route file under the `routes/page-components/<component-name>.ts` path. This file should define the route for the component's showcase page.
161+
162+
Example file:
163+
```ts
164+
import Route from '@ember/routing/route';
165+
166+
import type { ModelFrom } from 'showcase/utils/ModelFromRoute';
167+
168+
export type PageComponentsAccordionModel =
169+
ModelFrom<PageComponentsAccordionRoute>;
170+
171+
export default class PageComponentsAccordionRoute extends Route {}
172+
```
173+
174+
### Templates
175+
Each component should have a template file under the `templates/page-components/<component-name>.gts` path. This template should contain the component's index component.
176+
177+
Example file:
178+
```gts
179+
import type { TemplateOnlyComponent } from '@ember/component/template-only';
180+
181+
import AccordionIndex from 'showcase/components/page-components/accordion';
182+
183+
const PageComponentsAccordion: TemplateOnlyComponent = <template>
184+
<AccordionIndex />
185+
</template>;
186+
187+
export default PageComponentsAccordion;
188+
```
189+
190+
### App router
191+
- Include all pages under the `showcase/app/templates/page-components` folder in the `router.ts` file.
139192
- Define a route with the format `this.route('component-name');` for each component.
140193

141194
## Testing

0 commit comments

Comments
 (0)