Skip to content

Commit 86aa054

Browse files
committed
feat: able checkicon color
1 parent 7fa9797 commit 86aa054

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

packages/components/src/components/Checkbox/__tests__/index.browser.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ describe('Checkbox', () => {
256256
border: '#00ff00',
257257
text: '#0000ff',
258258
inputBg: '#ffff00',
259+
checkIcon: '#000000',
259260
}
260261

261262
const { container } = render(
@@ -273,6 +274,7 @@ describe('Checkbox', () => {
273274
border: '#00ff00',
274275
text: '#0000ff',
275276
inputBg: '#ffff00',
277+
checkIcon: '#000000',
276278
}
277279

278280
const { container } = render(
@@ -344,12 +346,28 @@ describe('Checkbox', () => {
344346
})
345347
})
346348

349+
it('should apply checkIcon color to CSS variables', () => {
350+
const customColors = {
351+
checkIcon: '#checkIcon-custom',
352+
}
353+
354+
const { container } = render(
355+
<Checkbox colors={customColors}>Test Checkbox</Checkbox>,
356+
)
357+
358+
const input = container.querySelector('input')
359+
expect(input).toHaveStyle({
360+
'--checkIcon': '#checkIcon-custom',
361+
})
362+
})
363+
347364
it('should apply all custom colors to CSS variables', () => {
348365
const customColors = {
349366
primary: '#primary-custom',
350367
border: '#border-custom',
351368
text: '#text-custom',
352369
inputBg: '#inputBg-custom',
370+
checkIcon: '#checkIcon-custom',
353371
}
354372

355373
const { container } = render(
@@ -362,6 +380,7 @@ describe('Checkbox', () => {
362380
'--border': '#border-custom',
363381
'--text': '#text-custom',
364382
'--inputBg': '#inputBg-custom',
383+
'--checkIcon': '#checkIcon-custom',
365384
})
366385
})
367386

@@ -374,6 +393,7 @@ describe('Checkbox', () => {
374393
expect(input?.style.getPropertyValue('--border')).toBe('')
375394
expect(input?.style.getPropertyValue('--text')).toBe('')
376395
expect(input?.style.getPropertyValue('--inputBg')).toBe('')
396+
expect(input?.style.getPropertyValue('--checkIcon')).toBe('')
377397
})
378398

379399
it('should work properly with onChange when colors are applied', async () => {
@@ -383,6 +403,7 @@ describe('Checkbox', () => {
383403
border: '#00ff00',
384404
text: '#0000ff',
385405
inputBg: '#ffff00',
406+
checkIcon: '#000000',
386407
}
387408

388409
const { container } = render(

packages/components/src/components/Checkbox/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface CheckboxProps
1212
border?: string
1313
text?: string
1414
inputBg?: string
15+
checkIcon?: string
1516
}
1617
}
1718

@@ -75,6 +76,7 @@ export function Checkbox({
7576
border: colors?.border,
7677
text: colors?.text,
7778
inputBg: colors?.inputBg,
79+
checkIcon: colors?.checkIcon,
7880
}}
7981
type="checkbox"
8082
{...props}
@@ -83,12 +85,14 @@ export function Checkbox({
8385
<Box
8486
as={CheckIcon}
8587
props={{
86-
color: disabled ? 'light-dark(#D6D7DE, #373737)' : '#FFF',
88+
color: disabled
89+
? 'light-dark(#D6D7DE, #373737)'
90+
: 'var(--checkIcon, #FFF)',
8791
className: css({
8892
left: '50%',
8993
pointerEvents: 'none',
9094
pos: 'absolute',
91-
top: '8px',
95+
top: '60%',
9296
transform: 'translate(-50%, -50%)',
9397
}),
9498
}}

0 commit comments

Comments
 (0)