Skip to content

Commit

Permalink
Upgrade to @primer/primitives@8.2.0 (#417)
Browse files Browse the repository at this point in the history
* Upgrade primitives@8.2.0

* Create gorgeous-moons-appear.md

* Fix for new spacer values
  • Loading branch information
jonrohan authored May 17, 2024
1 parent 86cf24f commit 3318d25
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-moons-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/stylelint-config": minor
---

Upgrade to @primer/primitives@8.2.0
50 changes: 29 additions & 21 deletions __tests__/spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ testRule({
],
reject: [
{
code: '.x { padding-bottom: 1px; }',
code: '.x { padding-bottom: 14px; }',
unfixable: true,
message: messages.rejected('1px'),
message: messages.rejected('14px'),
line: 1,
column: 22,
endColumn: 25,
endColumn: 26,
description: 'CSS > Errors on value not in spacer list',
},
{
Expand All @@ -77,8 +77,8 @@ testRule({
description: "CSS > Replaces '4px' with '--base-size-4'.",
},
{
code: '.x { padding: 3px; margin: 5px; }',
fixed: '.x { padding: var(--base-size-4); margin: var(--base-size-4); }',
code: '.x { padding: 3px; margin: 5px 7px; }',
fixed: '.x { padding: var(--base-size-4); margin: var(--base-size-4) var(--base-size-8); }',
description: "CSS > Replaces +- pixel values with closest variable '--base-size-4'.",
warnings: [
{
Expand All @@ -97,6 +97,14 @@ testRule({
rule: 'primer/spacing',
severity: 'error',
},
{
message: messages.rejected('7px', {name: '--base-size-8'}),
line: 1,
column: 32,
endColumn: 35,
rule: 'primer/spacing',
severity: 'error',
},
],
},
{
Expand Down Expand Up @@ -197,21 +205,21 @@ testRule({
],
},
{
code: '.x { padding: 2px 4px; }',
fixed: '.x { padding: 2px var(--base-size-4); }',
description: "CSS > Replaces '4px' with 'var(--base-size-4)' and errors on '2px'.",
code: '.x { padding: 14px 4px; }',
fixed: '.x { padding: 14px var(--base-size-4); }',
description: "CSS > Replaces '4px' with 'var(--base-size-4)' and errors on '14px'.",
warnings: [
{
endColumn: 18,
endColumn: 19,
column: 15,
line: 1,
rule: 'primer/spacing',
severity: 'error',
message: messages.rejected('2px'),
message: messages.rejected('14px'),
},
{
endColumn: 22,
column: 19,
endColumn: 23,
column: 20,
line: 1,
rule: 'primer/spacing',
severity: 'error',
Expand Down Expand Up @@ -266,33 +274,33 @@ testRule({
description: 'SCSS > Fails on negative SCSS variable.',
},
{
code: '.x { padding: 2px; .y { padding: 2px; .z { padding: 2px; } } }',
code: '.x { padding: 14px; .y { padding: 14px; .z { padding: 14px; } } }',
unfixable: true,
description: 'SCSS > Rejects nested CSS.',
warnings: [
{
column: 15,
endColumn: 18,
endColumn: 19,
line: 1,
rule: 'primer/spacing',
severity: 'error',
message: messages.rejected('2px'),
message: messages.rejected('14px'),
},
{
column: 34,
endColumn: 37,
column: 35,
endColumn: 39,
line: 1,
rule: 'primer/spacing',
severity: 'error',
message: messages.rejected('2px'),
message: messages.rejected('14px'),
},
{
column: 53,
endColumn: 56,
column: 55,
endColumn: 59,
line: 1,
rule: 'primer/spacing',
severity: 'error',
message: messages.rejected('2px'),
message: messages.rejected('14px'),
},
],
},
Expand Down
9 changes: 7 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"dependencies": {
"@github/browserslist-config": "^1.0.0",
"@primer/css": "^21.0.8",
"@primer/primitives": "^7.17.1",
"@primer/primitives": "^8.2.0",
"anymatch": "^3.1.1",
"postcss-scss": "^4.0.2",
"postcss-styled-syntax": "^0.6.4",
Expand Down
7 changes: 5 additions & 2 deletions plugins/lib/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ export async function primitivesVariables(type) {
for (const key of Object.keys(data)) {
const size = data[key]
const values = size['value']
values.push(`${parseInt(size['original']['value']) + 1}px`)
values.push(`${parseInt(size['original']['value']) - 1}px`)
const intValue = parseInt(size['original']['value'])
if (![2, 6].includes(intValue)) {
values.push(`${intValue + 1}px`)
values.push(`${intValue - 1}px`)
}

variables.push({
name: `--${size['name']}`,
Expand Down

0 comments on commit 3318d25

Please sign in to comment.