Skip to content

Commit 2a5fa40

Browse files
committed
fix: allow transparent background
1 parent 1ed51fa commit 2a5fa40

5 files changed

Lines changed: 12 additions & 14 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@lglab/react-qr-code': patch
3+
---
4+
5+
Allow transparent background

apps/playground/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function App() {
3131
value: 'https://github.com/LGLabGreg/react-qr-code.git',
3232
size: 500,
3333
marginSize: 3,
34-
background: '#f9f9f9',
34+
//background: '#f9f9f9',
3535
gradient: {
3636
type: 'linear',
3737
rotation: 0,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"url": "https://github.com/LGLabGreg/react-qr-code.git"
77
},
8-
"packageManager": "pnpm@10.2.0",
8+
"packageManager": "pnpm@10.2.1",
99
"type": "module",
1010
"scripts": {
1111
"dev": "pnpm concurrently --names packages,apps \"pnpm watch:packages\" \"pnpm watch:apps\"",

packages/react-qr-code/src/components/background.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BG_GRADIENT_ID, DEFAULT_BGCOLOR } from '../constants'
1+
import { BG_GRADIENT_ID } from '../constants'
22
import type { BackgroundSettings } from '../types/lib'
33
import { calculateGradientVectors } from '../utils/svg'
44

@@ -13,13 +13,7 @@ const testProps = {
1313

1414
export const Background = ({ background, numCells }: BackgroundProps) => {
1515
if (!background) {
16-
return (
17-
<path
18-
fill={DEFAULT_BGCOLOR}
19-
d={`M0,0 h${numCells}v${numCells}H0z`}
20-
{...testProps}
21-
/>
22-
)
16+
return null
2317
}
2418

2519
if (typeof background === 'string') {

packages/react-qr-code/src/react-qr-code.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { describe, expect, it, vi } from 'vitest'
44

55
import {
66
BG_GRADIENT_ID,
7-
DEFAULT_BGCOLOR,
87
DEFAULT_MARGIN_SIZE,
98
DEFAULT_SIZE,
109
GRADIENT_ID,
@@ -121,11 +120,11 @@ describe('ReactQRCode', () => {
121120
})
122121

123122
describe('Background', () => {
124-
it('renders with default background color', () => {
123+
it('renders without background if not provided', () => {
125124
render(<ReactQRCode value='test' />)
126125

127-
const background = screen.getByTestId('background')
128-
expect(background).toHaveAttribute('fill', DEFAULT_BGCOLOR)
126+
const background = screen.queryByTestId('background')
127+
expect(background).not.toBeInTheDocument()
129128
})
130129

131130
it('renders with custom background color', () => {

0 commit comments

Comments
 (0)