Skip to content

Commit e4fab1d

Browse files
Copilotmyabc
andcommitted
Update copilot instructions based on code review feedback
Co-authored-by: myabc <755+myabc@users.noreply.github.com>
1 parent c2c56f2 commit e4fab1d

1 file changed

Lines changed: 13 additions & 34 deletions

File tree

.github/copilot-instructions.md

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ When suggesting components, prefer stable components unless specifically asked f
5050
- **Ruby**: 3.2.0+
5151
- **Rails**: 7.2.0+
5252
- **ViewComponent**: 3.1+ to 5.0
53-
- **JavaScript/TypeScript**: Component behaviors using Catalyst controllers
53+
- **JavaScript/TypeScript**: Component behaviors using custom elements (often via Catalyst controllers)
5454
- **PostCSS**: Component styling
5555
- **Lookbook**: Component development and documentation tool
5656
- **Playwright**: Visual regression testing
@@ -143,14 +143,9 @@ class MyComponentElement extends HTMLElement {
143143
// Initialize
144144
}
145145
}
146-
147-
if (!window.customElements.get('my-component')) {
148-
window.MyComponentElement = MyComponentElement
149-
window.customElements.define('my-component', MyComponentElement)
150-
}
151146
```
152147

153-
**Remember:** Catalyst controllers require a custom element in the component template.
148+
**Note:** Catalyst automatically handles custom element registration, so the boilerplate `window.customElements.define()` code is not necessary. The custom element must be present in the component template.
154149

155150
#### Styling (PostCSS)
156151

@@ -218,28 +213,14 @@ end
218213

219214
### Playwright Visual Regression Tests
220215

221-
Add component previews to `static/previews.json`:
222-
223-
```json
224-
{
225-
"name": "my_component",
226-
"component": "MyComponent",
227-
"status": "openproject",
228-
"lookup_path": "primer/open_project/my_component",
229-
"examples": [
230-
{
231-
"preview_path": "primer/open_project/my_component/default",
232-
"name": "default",
233-
"snapshot": "true",
234-
"skip_rules": {
235-
"wont_fix": ["region"],
236-
"will_fix": ["color-contrast"]
237-
}
238-
}
239-
]
240-
}
216+
The `static/previews.json` file is auto-generated by running:
217+
218+
```bash
219+
bundle exec rake static:dump
241220
```
242221

222+
This task is automatically run by the `.github/workflows/static-files.yml` workflow on every push to main. The file contains component preview configurations used for visual regression testing.
223+
243224
Run tests:
244225
```bash
245226
./script/test # All tests
@@ -313,12 +294,11 @@ We periodically sync with GitHub's Primer repository. The process:
313294
- Use `status :open_project` for OpenProject components
314295
- Document all public APIs with YARD
315296
- Restrict HTML tags appropriately
316-
- Use `system_arguments` for HTML attributes
297+
- Use `system_arguments` for HTML attributes and styling (via utility classes). Full reference: https://primer.style/view-components/lookbook/pages/system_arguments/
317298
- Follow ViewComponent best practices
318299

319300
### JavaScript/TypeScript
320-
- Use Catalyst for interactive components
321-
- Export custom elements properly
301+
- Use Web Components for interactive components (consider using Catalyst to DRY up boilerplate involved in creating custom elements)
322302
- Follow GitHub's JavaScript style guide
323303
- Use TypeScript for type safety
324304

@@ -339,10 +319,9 @@ We periodically sync with GitHub's Primer repository. The process:
339319
2. **Add changeset** for user-facing changes: `npx changeset`
340320
3. **Write YARD docs** for new components/public methods
341321
4. **Add Lookbook previews** to demonstrate usage
342-
5. **Update `static/previews.json`** for visual regression tests
343-
6. **Ensure linters pass**: `npm run lint && ./script/rubocop`
344-
7. **Keep changes focused** - one feature/fix per PR
345-
8. **Update documentation** if API changes
322+
5. **Ensure linters pass**: `npm run lint && ./script/rubocop`
323+
6. **Keep changes focused** - one feature/fix per PR
324+
7. **Update documentation** if API changes
346325

347326
## Common Tasks
348327

0 commit comments

Comments
 (0)