Skip to content

Commit

Permalink
fix: fix QRCode style (#39849)
Browse files Browse the repository at this point in the history
* fix: fix style

* snap

* Update components/qrcode/style/index.ts

Co-authored-by: afc163 <afc163@gmail.com>

* rename className

* use token

Co-authored-by: afc163 <afc163@gmail.com>
  • Loading branch information
li-jia-nan and afc163 committed Dec 27, 2022
1 parent 01b5660 commit 0a0291b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Expand Up @@ -361,7 +361,9 @@ exports[`renders ./components/qrcode/demo/status.tsx extend context correctly 1`
<div
class="ant-qrcode-mask"
>
<p>
<p
class="ant-qrcode-expired"
>
QR code expired
</p>
<button
Expand Down
4 changes: 3 additions & 1 deletion components/qrcode/__tests__/__snapshots__/demo.test.ts.snap
Expand Up @@ -321,7 +321,9 @@ exports[`renders ./components/qrcode/demo/status.tsx correctly 1`] = `
<div
class="ant-qrcode-mask"
>
<p>
<p
class="ant-qrcode-expired"
>
QR code expired
</p>
<button
Expand Down
2 changes: 1 addition & 1 deletion components/qrcode/index.tsx
Expand Up @@ -80,7 +80,7 @@ const QRCode: React.FC<QRCodeProps> = (props) => {
{status === 'loading' && <Spin />}
{status === 'expired' && (
<>
<p>{locale.expired}</p>
<p className={`${prefixCls}-expired`}>{locale.expired}</p>
{typeof onRefresh === 'function' && (
<Button type="link" icon={<ReloadOutlined />} onClick={onRefresh}>
{locale.refresh}
Expand Down
6 changes: 6 additions & 0 deletions components/qrcode/style/index.ts
Expand Up @@ -5,6 +5,7 @@ import { resetComponent } from '../../style';
export interface ComponentToken {}

interface QRCodeToken extends FullToken<'QRCode'> {
QRCodeExpiredTextColor: string;
QRCodeMaskBackgroundColor: string;
}

Expand All @@ -17,6 +18,7 @@ const genQRCodeStyle: GenerateStyle<QRCodeToken> = (token) => {
justifyContent: 'center',
alignItems: 'center',
padding: token.paddingSM,
backgroundColor: token.colorWhite,
borderRadius: token.borderRadiusLG,
border: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
position: 'relative',
Expand All @@ -38,6 +40,9 @@ const genQRCodeStyle: GenerateStyle<QRCodeToken> = (token) => {
lineHeight: token.lineHeight,
background: token.QRCodeMaskBackgroundColor,
textAlign: 'center',
[`& > ${componentCls}-expired`]: {
color: token.QRCodeExpiredTextColor,
},
},
'&-icon': {
marginBlockEnd: token.marginXS,
Expand All @@ -53,6 +58,7 @@ const genQRCodeStyle: GenerateStyle<QRCodeToken> = (token) => {
export default genComponentStyleHook<'QRCode'>('QRCode', (token) =>
genQRCodeStyle(
mergeToken<QRCodeToken>(token, {
QRCodeExpiredTextColor: 'rgba(0, 0, 0, 0.88)',
QRCodeMaskBackgroundColor: 'rgba(255, 255, 255, 0.96)',
}),
),
Expand Down

0 comments on commit 0a0291b

Please sign in to comment.