Skip to content

Commit

Permalink
Fixed class creation being skipped when property values are zero (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyesong committed Dec 6, 2022
1 parent 705422f commit 19bd82c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-olives-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rainbow-sprinkles': patch
---

Fixed classes not being created when property value is 0
23 changes: 23 additions & 0 deletions packages/rainbow-sprinkles/src/__tests__/assignClasses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,26 @@ test('supports number values', () => {

expect(assignClasses(config, 'foo')).toBe('a');
});

test('supports 0 values', () => {
const config: CreateStylesOutput = {
dynamic: {
default: 'a',
conditions: { mobile: 'a', tablet: 'b', desktop: 'c' },
},
name: 'flexShrink',
vars: {
conditions: { mobile: 'a', tablet: 'b', desktop: 'c' },
default: 'a',
},
};

expect(
assignClasses(config, {
mobile: 0,
tablet: 1,
}),
).toBe('a b');

expect(assignClasses(config, 0)).toBe('a');
});
2 changes: 1 addition & 1 deletion packages/rainbow-sprinkles/src/assignClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function assignClasses(
propertyConfig: CreateStylesOutput,
propValue: unknown,
): string {
if (!propValue) {
if (!propValue && propValue !== 0) {
return '';
}

Expand Down

0 comments on commit 19bd82c

Please sign in to comment.