Skip to content

Commit

Permalink
Refactor the primer/colors variable (#491)
Browse files Browse the repository at this point in the history
* Refactor the primer/colors variable

Co-authored-by: Katie Langerman <[email protected]>

* Test fixes

* Create four-eyes-compete.md

* Remove primer/css dependency

* Add 0

* Some refactoring and fixes

* Fail on sass variables

* Add tests for sass vars

* Some updates for edge cases

* Ignore old color vars

* Use regex for more cases

* Refining

* Fix code scanning alert no. 33: Inefficient regular expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Katie Langerman <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 6ab6f69 commit a615645
Show file tree
Hide file tree
Showing 14 changed files with 431 additions and 2,689 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-eyes-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/stylelint-config": minor
---

Refactor the primer/colors variable to use primitives values match up props
5 changes: 2 additions & 3 deletions __tests__/__fixtures__/good/example.pcss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* stylelint-disable primer/borders */
/* stylelint-disable primer/spacing */

/* CSS for Button */
Expand All @@ -24,7 +23,7 @@
flex-direction: row;
user-select: none;
background-color: transparent;
border: var(--borderWidth-thin) $border-style;
border: var(--borderWidth-thin) solid;
border-color: transparent;
border-radius: var(--borderRadius-medium);
transition: var(--duration-fast) var(--easing-easeInOut);
Expand Down Expand Up @@ -423,4 +422,4 @@
cursor: default;
background-color: var(--button-inactive-bgColor);
border: 0;
}
}
9 changes: 9 additions & 0 deletions __tests__/borders.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ testRule({
endColumn: 24,
description: 'CSS > Does not autofix 1px to borderWidth-thin variable.',
},
{
code: '.x { border: 1px solid var(--borderColor-default); }',
fixed: '.x { border: var(--borderWidth-thin) solid var(--borderColor-default); }',
message: messages.rejected('1px', {name: '--borderWidth-thin'}),
line: 1,
column: 14,
endColumn: 17,
description: 'CSS > Places error border on 1px for shorthand border.',
},
],
})

Expand Down
Loading

0 comments on commit a615645

Please sign in to comment.