-
-
Notifications
You must be signed in to change notification settings - Fork 0
Improve Button styling contract and recipe parity #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Button State Verification</title> | ||
| <link rel="stylesheet" href="../dist/index.css"> | ||
| <style> | ||
| body { | ||
| padding: 2rem; | ||
| font-family: sans-serif; | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 2rem; | ||
| } | ||
| section { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 1rem; | ||
| border: 1px solid #ccc; | ||
| padding: 1rem; | ||
| border-radius: 8px; | ||
| } | ||
| .row { | ||
| display: flex; | ||
| gap: 1rem; | ||
| align-items: center; | ||
| flex-wrap: wrap; | ||
| } | ||
| h2 { | ||
| margin: 0; | ||
| font-size: 1.2rem; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h1>Button State Verification</h1> | ||
|
|
||
| <section> | ||
| <h2>Aria-Busy (Loading) State</h2> | ||
| <div class="row"> | ||
| <button class="sp-btn sp-btn--primary" aria-busy="true">Primary Loading (Aria)</button> | ||
| <button class="sp-btn sp-btn--secondary" aria-busy="true">Secondary Loading (Aria)</button> | ||
| <button class="sp-btn sp-btn--ghost" aria-busy="true">Ghost Loading (Aria)</button> | ||
| <button class="sp-btn sp-btn--danger" aria-busy="true">Danger Loading (Aria)</button> | ||
| </div> | ||
| </section> | ||
|
|
||
| <section> | ||
| <h2>Aria-Disabled State</h2> | ||
| <div class="row"> | ||
| <button class="sp-btn sp-btn--primary" aria-disabled="true">Primary Disabled (Aria)</button> | ||
| <button class="sp-btn sp-btn--secondary" aria-disabled="true">Secondary Disabled (Aria)</button> | ||
| <button class="sp-btn sp-btn--ghost" aria-disabled="true">Ghost Disabled (Aria)</button> | ||
| <button class="sp-btn sp-btn--cta" aria-disabled="true">CTA Disabled (Aria)</button> | ||
| <button class="sp-btn sp-btn--accent" aria-disabled="true">Accent Disabled (Aria)</button> | ||
| </div> | ||
| </section> | ||
|
|
||
| <section> | ||
| <h2>Forced States (Recipe Output Verification)</h2> | ||
| <div class="row"> | ||
| <button class="sp-btn sp-btn--primary is-hover">Primary Hovered</button> | ||
| <button class="sp-btn sp-btn--secondary is-focus">Secondary Focused</button> | ||
| <button class="sp-btn sp-btn--danger is-active">Danger Active</button> | ||
| </div> | ||
| </section> | ||
|
|
||
| </body> | ||
| </html> | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -61,9 +61,9 @@ describe('getButtonClasses', () => { | |||||||||||||||||||||
| expect(result).toContain('sp-btn--full'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--loading'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--disabled'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--hover'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--focus'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--active'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--hover is-hover'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--focus is-focus'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--active is-active'); | ||||||||||||||||||||||
|
Comment on lines
+64
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assert state tokens individually instead of combined substrings. These checks can false-pass on partial matches. Split by whitespace and assert exact token membership for both Suggested test hardening- expect(result).toContain('sp-btn--hover is-hover');
- expect(result).toContain('sp-btn--focus is-focus');
- expect(result).toContain('sp-btn--active is-active');
+ const tokens = result.split(/\s+/)
+ expect(tokens).toContain('sp-btn--hover')
+ expect(tokens).toContain('is-hover')
+ expect(tokens).toContain('sp-btn--focus')
+ expect(tokens).toContain('is-focus')
+ expect(tokens).toContain('sp-btn--active')
+ expect(tokens).toContain('is-active')As per coding guidelines, "tests/**: Verify tests cover recipe output correctness, class name generation, and variant exhaustiveness." 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| expect(result).toContain('sp-btn--icon'); | ||||||||||||||||||||||
| expect(result).toContain('sp-btn--pill'); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add explicit
type="button"on all demo buttons.Without explicit type, buttons default to
submitin form contexts and can create misleading verification behavior.Suggested fix
Apply the same to each
<button>in this file.Also applies to: 52-56, 63-65
🧰 Tools
🪛 HTMLHint (1.9.2)
[warning] 42-42: The type attribute must be present on elements.
(button-type-require)
[warning] 43-43: The type attribute must be present on
elements.(button-type-require)
[warning] 44-44: The type attribute must be present on
elements.(button-type-require)
[warning] 45-45: The type attribute must be present on
elements.(button-type-require)
🤖 Prompt for AI Agents