mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-06 02:15:35 +08:00
240210a281
* feat: qrcode * chore: code clean * feat: New Component Qr-Code (#38891) * feat: QrCode * fix * fix * fix: fix bug * fix: fix bug * fix * fix * fix * delete * delete * test case * fix lint * bundlesize * demo * fix: fix test * remove dep * update snap * en docs * refactor: rename tests dir * Update components/qr-code/demo/base.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/demo/base.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/demo/download.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/demo/download.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/demo/download.tsx Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/demo/logo.md Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qr-code/demo/logo.md Co-authored-by: MadCcc <1075746765@qq.com> * rename * fix * adjust text * rename * fix title * rename * rename * fix: snap * fix * bundlesize * update demo * update docs * add demo * add docs * add docs * test: add warning * update demo * bundlesize * update test case * update demo * feat: add onRefresh、add status * fix: fix demo * fix: fix demo * add locale * add locale * add test case * update snap * fix demo * update demo * update demo * update demo * Update components/qrcode/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qrcode/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qrcode/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qrcode/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qrcode/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qrcode/interface.ts Co-authored-by: MadCcc <1075746765@qq.com> * Update components/qrcode/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> * fix * Update components/qrcode/index.tsx Co-authored-by: MadCcc <1075746765@qq.com> * fix * fix * fix * add decs * fix * fix * fix type * fix * fix demo * fix lint * fix lint * add test case for bordered * prettier-ignore Co-authored-by: MadCcc <1075746765@qq.com> Co-authored-by: 栗嘉男 <lijianan@lijianandeMacBook-Pro.local>
250 lines
7.3 KiB
TypeScript
250 lines
7.3 KiB
TypeScript
import { TinyColor } from '@ctrl/tinycolor';
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
|
import { resetComponent } from '../../style';
|
|
import getArrowStyle, { MAX_VERTICAL_CONTENT_RADIUS } from '../../style/placementArrow';
|
|
|
|
export interface ComponentToken {}
|
|
|
|
interface TourToken extends FullToken<'Tour'> {
|
|
tourZIndexPopup: number;
|
|
sliderWidth: number;
|
|
sliderHeight: number;
|
|
tourBorderRadius: number;
|
|
tourCloseSize: number;
|
|
}
|
|
|
|
// =============================== Base ===============================
|
|
const genBaseStyle: GenerateStyle<TourToken> = (token) => {
|
|
const {
|
|
componentCls,
|
|
lineHeight,
|
|
padding,
|
|
paddingXS,
|
|
borderRadius,
|
|
borderRadiusXS,
|
|
colorPrimary,
|
|
colorText,
|
|
colorFill,
|
|
sliderHeight,
|
|
sliderWidth,
|
|
boxShadow,
|
|
tourZIndexPopup,
|
|
fontSize,
|
|
colorBgContainer,
|
|
fontWeightStrong,
|
|
marginXS,
|
|
colorTextLightSolid,
|
|
tourBorderRadius,
|
|
colorWhite,
|
|
colorBgTextHover,
|
|
tourCloseSize,
|
|
motionDurationSlow,
|
|
} = token;
|
|
|
|
return [
|
|
{
|
|
[componentCls]: {
|
|
...resetComponent(token),
|
|
|
|
color: colorText,
|
|
position: 'absolute',
|
|
zIndex: tourZIndexPopup,
|
|
display: 'block',
|
|
visibility: 'visible',
|
|
fontSize,
|
|
lineHeight,
|
|
width: 520,
|
|
'--antd-arrow-background-color': colorBgContainer,
|
|
|
|
'&-pure': {
|
|
maxWidth: '100%',
|
|
position: 'relative',
|
|
},
|
|
|
|
[`&${componentCls}-hidden`]: {
|
|
display: 'none',
|
|
},
|
|
|
|
// ============================= panel content ===========================
|
|
[`${componentCls}-content`]: {
|
|
position: 'relative',
|
|
},
|
|
[`${componentCls}-inner`]: {
|
|
textAlign: 'start',
|
|
textDecoration: 'none',
|
|
borderRadius: tourBorderRadius,
|
|
boxShadow,
|
|
position: 'relative',
|
|
backgroundColor: colorBgContainer,
|
|
border: 'none',
|
|
backgroundClip: 'padding-box',
|
|
|
|
[`${componentCls}-close`]: {
|
|
position: 'absolute',
|
|
top: padding,
|
|
insetInlineEnd: padding,
|
|
color: token.colorIcon,
|
|
outline: 'none',
|
|
width: tourCloseSize,
|
|
height: tourCloseSize,
|
|
borderRadius: token.borderRadiusSM,
|
|
transition: `background-color ${token.motionDurationMid}, color ${token.motionDurationMid}`,
|
|
display: 'flex',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
|
|
'&:hover': {
|
|
color: token.colorIconHover,
|
|
backgroundColor: token.wireframe ? 'transparent' : token.colorFillContent,
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-cover`]: {
|
|
textAlign: 'center',
|
|
padding: `${padding + tourCloseSize + paddingXS}px ${padding}px 0`,
|
|
img: {
|
|
width: '100%',
|
|
},
|
|
},
|
|
[`${componentCls}-header`]: {
|
|
padding: `${padding}px ${padding}px ${paddingXS}px`,
|
|
|
|
[`${componentCls}-title`]: {
|
|
lineHeight,
|
|
fontSize,
|
|
fontWeight: fontWeightStrong,
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-description`]: {
|
|
padding: `0 ${padding}px`,
|
|
lineHeight,
|
|
wordWrap: 'break-word',
|
|
},
|
|
|
|
[`${componentCls}-footer`]: {
|
|
padding: `${paddingXS}px ${padding}px ${padding}px`,
|
|
textAlign: 'end',
|
|
borderRadius: `0 0 ${borderRadiusXS}px ${borderRadiusXS}px`,
|
|
display: 'flex',
|
|
justifyContent: 'space-between',
|
|
|
|
[`${componentCls}-sliders`]: {
|
|
display: 'inline-block',
|
|
|
|
[`${componentCls}-slider`]: {
|
|
width: `${sliderWidth}px`,
|
|
height: `${sliderHeight}px`,
|
|
display: 'inline-block',
|
|
borderRadius: '50%',
|
|
background: colorFill,
|
|
marginInlineEnd: sliderHeight,
|
|
|
|
'&-active': {
|
|
background: colorPrimary,
|
|
},
|
|
},
|
|
},
|
|
[`${componentCls}-buttons button`]: {
|
|
marginInlineStart: marginXS,
|
|
},
|
|
},
|
|
},
|
|
|
|
// ============================= primary type ===========================
|
|
[`&${componentCls}-primary`]: {
|
|
'--antd-arrow-background-color': colorPrimary,
|
|
[`${componentCls}-inner`]: {
|
|
color: colorTextLightSolid,
|
|
textAlign: 'start',
|
|
textDecoration: 'none',
|
|
backgroundColor: colorPrimary,
|
|
borderRadius,
|
|
boxShadow,
|
|
|
|
[`${componentCls}-close`]: {
|
|
color: colorTextLightSolid,
|
|
},
|
|
|
|
[`${componentCls}-sliders`]: {
|
|
[`${componentCls}-slider`]: {
|
|
background: new TinyColor(colorTextLightSolid).setAlpha(0.15).toRgbString(),
|
|
|
|
'&-active': {
|
|
background: colorTextLightSolid,
|
|
},
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-prev-btn`]: {
|
|
color: colorTextLightSolid,
|
|
borderColor: new TinyColor(colorTextLightSolid).setAlpha(0.15).toRgbString(),
|
|
|
|
'&:hover': {
|
|
backgroundColor: new TinyColor(colorTextLightSolid).setAlpha(0.15).toRgbString(),
|
|
borderColor: 'transparent',
|
|
},
|
|
},
|
|
|
|
[`${componentCls}-next-btn`]: {
|
|
color: colorPrimary,
|
|
borderColor: 'transparent',
|
|
background: colorWhite,
|
|
|
|
'&:hover': {
|
|
background: new TinyColor(colorBgTextHover).onBackground(colorWhite).toRgbString(),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
// ============================= mask ===========================
|
|
[`${componentCls}-mask`]: {
|
|
[`${componentCls}-placeholder-animated`]: {
|
|
transition: `all ${motionDurationSlow}`,
|
|
},
|
|
},
|
|
|
|
// =========== Limit left and right placement radius ==============
|
|
[[
|
|
'&-placement-left',
|
|
'&-placement-leftTop',
|
|
'&-placement-leftBottom',
|
|
'&-placement-right',
|
|
'&-placement-rightTop',
|
|
'&-placement-rightBottom',
|
|
].join(',')]: {
|
|
[`${componentCls}-inner`]: {
|
|
borderRadius:
|
|
tourBorderRadius > MAX_VERTICAL_CONTENT_RADIUS
|
|
? MAX_VERTICAL_CONTENT_RADIUS
|
|
: tourBorderRadius,
|
|
},
|
|
},
|
|
},
|
|
|
|
// ============================= Arrow ===========================
|
|
getArrowStyle<TourToken>(token, {
|
|
colorBg: 'var(--antd-arrow-background-color)',
|
|
showArrowCls: '',
|
|
contentRadius: tourBorderRadius,
|
|
limitVerticalRadius: true,
|
|
}),
|
|
];
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export default genComponentStyleHook('Tour', (token) => {
|
|
const { borderRadiusLG, fontSize, lineHeight } = token;
|
|
const TourToken = mergeToken<TourToken>(token, {
|
|
tourZIndexPopup: token.zIndexPopupBase + 70,
|
|
sliderWidth: 6,
|
|
sliderHeight: 6,
|
|
tourBorderRadius: borderRadiusLG,
|
|
tourCloseSize: fontSize * lineHeight,
|
|
});
|
|
return [genBaseStyle(TourToken)];
|
|
});
|