|
| 1 | +# Spectrum 2 migration roadmap |
| 2 | + |
| 3 | +This directory contains comprehensive migration documentation for 2nd generation Spectrum Web Components based on the implementation of Spectrum 2 components that were previously migrated in [Spectrum CSS](https://github.com/adobe/spectrum-css/tree/spectrum-two). It helps engineers understand what needs to be implemented, updated, or aligned between the two systems to guide development of 2nd generation web components. |
| 4 | + |
| 5 | +## Purpose |
| 6 | + |
| 7 | +### Why we do this analysis |
| 8 | + |
| 9 | +The migration roadmap facilitates development of 2nd generation, full-fidelity Spectrum 2 web components by providing: |
| 10 | + |
| 11 | +- **Feature gap analysis**: Identifies new features and capabilities needed to match Spectrum 2 design specifications |
| 12 | +- **Implementation comparison**: Maps CSS selectors to existing SWC properties and notes markup differences between systems |
| 13 | +- **Deprecation tracking**: Documents features or variants being removed in Spectrum 2 |
| 14 | +- **Planning guidance**: High-level overview of changes to assist with estimating migration effort |
| 15 | + |
| 16 | +### The bigger picture |
| 17 | + |
| 18 | +When engineers begin 2nd generation Spectrum 2 implementation work, this documentation provides: |
| 19 | + |
| 20 | +- **Clear starting point**: Entry point for development work that identifies specific areas needing adjustment |
| 21 | +- **Gap analysis**: Differences that would prevent Spectrum 2 CSS from working in SWC |
| 22 | +- **Reference materials**: Links to CSS and React implementations, and previous migration work |
| 23 | + |
| 24 | +## What we analyze |
| 25 | + |
| 26 | +### Component specifications |
| 27 | + |
| 28 | +We extract and document: |
| 29 | + |
| 30 | +- **CSS selectors**: All selectors from `metadata.json` in the spectrum-css `spectrum-two` branch |
| 31 | +- **Passthroughs**: CSS passthrough custom properties |
| 32 | +- **Modifiers**: CSS modifier custom properties (note that `--mod` properties will be deprecated in the 2nd-gen implementation) |
| 33 | +- **SWC attributes**: Properties with `@property` decorators (which use getter/setter patterns) in TypeScript |
| 34 | +- **SWC slots**: Slot patterns from render methods |
| 35 | +- **Nested components**: Child components used within the component |
| 36 | + |
| 37 | +### DOM structure comparison |
| 38 | + |
| 39 | +We analyze markup from three sources: |
| 40 | + |
| 41 | +1. **Spectrum Web Components**: Current HTML structure from web component `render()` method |
| 42 | +2. **Legacy CSS**: HTML structure from spectrum-css `main` branch template files |
| 43 | +3. **Spectrum 2 CSS**: HTML structure from spectrum-css `spectrum-two` branch template files |
| 44 | + |
| 45 | +This three-way comparison reveals: |
| 46 | + |
| 47 | +- DOM changes specific to Spectrum 2 features (Legacy → Spectrum 2) |
| 48 | +- Structural differences between CSS and SWC implementations |
| 49 | +- Additional work needed for SWC render methods beyond new features |
| 50 | + |
| 51 | +### CSS to SWC mapping |
| 52 | + |
| 53 | +We create mapping tables that connect: |
| 54 | + |
| 55 | +- **CSS selectors** to **SWC attributes or slots** |
| 56 | +- **Variants** (CSS selectors with `--` notation) typically map to component attributes |
| 57 | +- **Base elements** (selectors with single `-`) typically map to slots |
| 58 | +- **Status tracking** for implementation gaps |
| 59 | + |
| 60 | +### Implementation gaps |
| 61 | + |
| 62 | +The analysis surfaces: |
| 63 | + |
| 64 | +- **Missing from SWC**: CSS features without web component equivalents |
| 65 | +- **Missing from CSS**: Web component features without CSS support |
| 66 | +- **New for Spectrum 2**: Features that need to be added for 2nd generation |
| 67 | +- **Deprecated**: Features being removed in Spectrum 2 |
| 68 | + |
| 69 | +## Documentation structure |
| 70 | + |
| 71 | +Each component follows this format: |
| 72 | + |
| 73 | +```markdown |
| 74 | +# [Component name] migration roadmap |
| 75 | + |
| 76 | +## Component specifications |
| 77 | + |
| 78 | +**Note**: CSS selectors and attributes/slots are often grouped by elements, states, variants, or other logical categories to improve readability. |
| 79 | + |
| 80 | +### CSS |
| 81 | + |
| 82 | +- CSS selectors (collapsible) |
| 83 | +- Passthroughs (collapsible) |
| 84 | +- Modifiers (deprecated) (collapsible) |
| 85 | + |
| 86 | +### SWC |
| 87 | + |
| 88 | +- Attributes (collapsible) |
| 89 | +- Slots (collapsible) |
| 90 | + |
| 91 | +## Comparison |
| 92 | + |
| 93 | +### DOM structure changes |
| 94 | + |
| 95 | +- Spectrum Web Components (collapsible) |
| 96 | +- Legacy CSS main branch (collapsible) |
| 97 | +- Spectrum 2 CSS spectrum-two branch (collapsible) |
| 98 | +- Diff: Legacy → Spectrum 2, based on changes made to template in CSS migration work (collapsible, if changes exist) |
| 99 | + |
| 100 | +### CSS => SWC mapping |
| 101 | + |
| 102 | +| CSS selector | Attribute or slot | Status | |
| 103 | +| ------------ | ----------------- | ------------------------------------------------------- | |
| 104 | +| ... | ... | Implemented/Missing from WC/Missing from CSS/Deprecated | |
| 105 | + |
| 106 | +## Summary of changes |
| 107 | + |
| 108 | +### CSS => SWC implementation gaps |
| 109 | + |
| 110 | +### CSS Spectrum 2 changes |
| 111 | + |
| 112 | +**Note**: Some of this information may be summarized in the component's changelog in the spectrum-two branch. |
| 113 | + |
| 114 | +## Resources |
| 115 | + |
| 116 | +- [CSS migration]() |
| 117 | +- [Spectrum 2 preview]() |
| 118 | +- [React]() |
| 119 | +``` |
| 120 | + |
| 121 | +## How to generate documentation |
| 122 | + |
| 123 | +### Prerequisites |
| 124 | + |
| 125 | +Set up a Cursor workspace with both repositories: |
| 126 | + |
| 127 | +- `spectrum-css` (primarily `spectrum-two` branch, with comparisons to `main`) |
| 128 | +- `spectrum-web-components` (`main` branch) |
| 129 | + |
| 130 | +### Using the cursor prompt |
| 131 | + |
| 132 | +**Model recommendation**: This type of detailed migration analysis is better handled by slower but more advanced thinking models like Claude or GPT-5, which can provide more thorough analysis and better understand complex component relationships. |
| 133 | + |
| 134 | +1. **Load the prompt**: Reference `migration-roadmap/cursor_prompt.md` |
| 135 | +2. **Specify component**: Replace `[COMPONENT_NAME]` with the target component |
| 136 | +3. **Branch verification**: Ensure correct branches are checked out: |
| 137 | + - `spectrum-css`: `spectrum-two` for specifications, both `main` and `spectrum-two` for comparisons |
| 138 | + - `spectrum-web-components`: `main` branch |
| 139 | +4. **Generate documentation**: Follow the structured prompt to create component markdown files |
| 140 | + |
| 141 | +### Quality assurance |
| 142 | + |
| 143 | +**Human review is required** for all generated documentation: |
| 144 | + |
| 145 | +- **Verify data accuracy**: Check extracted information against source repositories/branches |
| 146 | +- **Validate mappings**: Ensure CSS selector to SWC feature mappings are correct |
| 147 | +- **Review summaries**: Confirm summaries provide clear, actionable guidance |
| 148 | +- **Check DOM structures**: Verify HTML snippets match actual template/render method output |
| 149 | +- **Audit diffs**: Ensure branch comparisons are accurate and meaningful |
| 150 | + |
| 151 | +### Common issues to watch for |
| 152 | + |
| 153 | +- **Branch confusion**: AI may analyze wrong branches or mix up repositories |
| 154 | +- **Incomplete mappings**: AI may incorrectly mark implemented states or variants as missing in mapping tables |
| 155 | +- **Verbose summaries**: Trim AI-generated text to focus on actionable changes and human readability |
| 156 | +- **DOM accuracy**: Verify render method HTML matches documented structure |
| 157 | +- **Missing components**: Note when components don't exist in one system or the other |
| 158 | + |
| 159 | +## Contributing |
| 160 | + |
| 161 | +### Modifying the cursor prompt |
| 162 | + |
| 163 | +The cursor prompt template (`cursor_prompt.md`) can be modified to improve AI performance. Consider updates for: |
| 164 | + |
| 165 | +- Better mapping accuracy |
| 166 | +- Clearer summary generation |
| 167 | +- Additional analysis sections |
| 168 | +- Improved error handling |
| 169 | + |
| 170 | +### Adding new components |
| 171 | + |
| 172 | +1. Use the cursor prompt with the target component name |
| 173 | +2. Generate the markdown file in `migration-roadmap/[component-name].md` |
| 174 | +3. Review and validate all sections for accuracy |
| 175 | +4. Submit a PR to the `2nd-gen-component-analysis` branch |
| 176 | + |
| 177 | +## Resources |
| 178 | + |
| 179 | +- [Cursor prompt template](cursor_prompt.md) |
| 180 | +- [Spectrum CSS repository](https://github.com/adobe/spectrum-css) |
| 181 | +- [Spectrum Web Components repository](https://github.com/adobe/spectrum-web-components) |
0 commit comments