| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
- var _cssinjs = require("../../_util/cssinjs");
- var _internal = require("../../theme/internal");
- var _fade = require("../../style/motion/fade");
- var _style = require("../../style");
- var _motion = require("../../style/motion/motion");
- var _util = _interopRequireDefault(require("../util"));
- const initFloatButtonGroupMotion = token => {
- const {
- componentCls,
- floatButtonSize,
- motionDurationSlow,
- motionEaseInOutCirc
- } = token;
- const groupPrefixCls = `${componentCls}-group`;
- const moveDownIn = new _cssinjs.Keyframes('antFloatButtonMoveDownIn', {
- '0%': {
- transform: `translate3d(0, ${floatButtonSize}px, 0)`,
- transformOrigin: '0 0',
- opacity: 0
- },
- '100%': {
- transform: 'translate3d(0, 0, 0)',
- transformOrigin: '0 0',
- opacity: 1
- }
- });
- const moveDownOut = new _cssinjs.Keyframes('antFloatButtonMoveDownOut', {
- '0%': {
- transform: 'translate3d(0, 0, 0)',
- transformOrigin: '0 0',
- opacity: 1
- },
- '100%': {
- transform: `translate3d(0, ${floatButtonSize}px, 0)`,
- transformOrigin: '0 0',
- opacity: 0
- }
- });
- return [{
- [`${groupPrefixCls}-wrap`]: (0, _extends2.default)({}, (0, _motion.initMotion)(`${groupPrefixCls}-wrap`, moveDownIn, moveDownOut, motionDurationSlow, true))
- }, {
- [`${groupPrefixCls}-wrap`]: {
- [`
- &${groupPrefixCls}-wrap-enter,
- &${groupPrefixCls}-wrap-appear
- `]: {
- opacity: 0,
- animationTimingFunction: motionEaseInOutCirc
- },
- [`&${groupPrefixCls}-wrap-leave`]: {
- animationTimingFunction: motionEaseInOutCirc
- }
- }
- }];
- };
- // ============================== Group ==============================
- const floatButtonGroupStyle = token => {
- const {
- antCls,
- componentCls,
- floatButtonSize,
- margin,
- borderRadiusLG,
- borderRadiusSM,
- badgeOffset,
- floatButtonBodyPadding
- } = token;
- const groupPrefixCls = `${componentCls}-group`;
- return {
- [groupPrefixCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
- zIndex: 99,
- display: 'block',
- border: 'none',
- position: 'fixed',
- width: floatButtonSize,
- height: 'auto',
- boxShadow: 'none',
- minHeight: floatButtonSize,
- insetInlineEnd: token.floatButtonInsetInlineEnd,
- insetBlockEnd: token.floatButtonInsetBlockEnd,
- borderRadius: borderRadiusLG,
- [`${groupPrefixCls}-wrap`]: {
- zIndex: -1,
- display: 'block',
- position: 'relative',
- marginBottom: margin
- },
- [`&${groupPrefixCls}-rtl`]: {
- direction: 'rtl'
- },
- [componentCls]: {
- position: 'static'
- }
- }),
- [`${groupPrefixCls}-circle`]: {
- [`${componentCls}-circle:not(:last-child)`]: {
- marginBottom: token.margin,
- [`${componentCls}-body`]: {
- width: floatButtonSize,
- height: floatButtonSize,
- borderRadius: '50%'
- }
- }
- },
- [`${groupPrefixCls}-square`]: {
- [`${componentCls}-square`]: {
- borderRadius: 0,
- padding: 0,
- '&:first-child': {
- borderStartStartRadius: borderRadiusLG,
- borderStartEndRadius: borderRadiusLG
- },
- '&:last-child': {
- borderEndStartRadius: borderRadiusLG,
- borderEndEndRadius: borderRadiusLG
- },
- '&:not(:last-child)': {
- borderBottom: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`
- },
- [`${antCls}-badge`]: {
- [`${antCls}-badge-count`]: {
- top: -(floatButtonBodyPadding + badgeOffset),
- insetInlineEnd: -(floatButtonBodyPadding + badgeOffset)
- }
- }
- },
- [`${groupPrefixCls}-wrap`]: {
- display: 'block',
- borderRadius: borderRadiusLG,
- boxShadow: token.boxShadowSecondary,
- [`${componentCls}-square`]: {
- boxShadow: 'none',
- marginTop: 0,
- borderRadius: 0,
- padding: floatButtonBodyPadding,
- '&:first-child': {
- borderStartStartRadius: borderRadiusLG,
- borderStartEndRadius: borderRadiusLG
- },
- '&:last-child': {
- borderEndStartRadius: borderRadiusLG,
- borderEndEndRadius: borderRadiusLG
- },
- '&:not(:last-child)': {
- borderBottom: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`
- },
- [`${componentCls}-body`]: {
- width: token.floatButtonBodySize,
- height: token.floatButtonBodySize
- }
- }
- }
- },
- [`${groupPrefixCls}-circle-shadow`]: {
- boxShadow: 'none'
- },
- [`${groupPrefixCls}-square-shadow`]: {
- boxShadow: token.boxShadowSecondary,
- [`${componentCls}-square`]: {
- boxShadow: 'none',
- padding: floatButtonBodyPadding,
- [`${componentCls}-body`]: {
- width: token.floatButtonBodySize,
- height: token.floatButtonBodySize,
- borderRadius: borderRadiusSM
- }
- }
- }
- };
- };
- // ============================== Shared ==============================
- const sharedFloatButtonStyle = token => {
- const {
- antCls,
- componentCls,
- floatButtonBodyPadding,
- floatButtonIconSize,
- floatButtonSize,
- borderRadiusLG,
- badgeOffset,
- dotOffsetInSquare,
- dotOffsetInCircle
- } = token;
- return {
- [componentCls]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
- border: 'none',
- position: 'fixed',
- cursor: 'pointer',
- zIndex: 99,
- display: 'block',
- justifyContent: 'center',
- alignItems: 'center',
- width: floatButtonSize,
- height: floatButtonSize,
- insetInlineEnd: token.floatButtonInsetInlineEnd,
- insetBlockEnd: token.floatButtonInsetBlockEnd,
- boxShadow: token.boxShadowSecondary,
- // Pure Panel
- '&-pure': {
- position: 'relative',
- inset: 'auto'
- },
- '&:empty': {
- display: 'none'
- },
- [`${antCls}-badge`]: {
- width: '100%',
- height: '100%',
- [`${antCls}-badge-count`]: {
- transform: 'translate(0, 0)',
- transformOrigin: 'center',
- top: -badgeOffset,
- insetInlineEnd: -badgeOffset
- }
- },
- [`${componentCls}-body`]: {
- width: '100%',
- height: '100%',
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- transition: `all ${token.motionDurationMid}`,
- [`${componentCls}-content`]: {
- overflow: 'hidden',
- textAlign: 'center',
- minHeight: floatButtonSize,
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'center',
- padding: `${floatButtonBodyPadding / 2}px ${floatButtonBodyPadding}px`,
- [`${componentCls}-icon`]: {
- textAlign: 'center',
- margin: 'auto',
- width: floatButtonIconSize,
- fontSize: floatButtonIconSize,
- lineHeight: 1
- }
- }
- }
- }),
- [`${componentCls}-rtl`]: {
- direction: 'rtl'
- },
- [`${componentCls}-circle`]: {
- height: floatButtonSize,
- borderRadius: '50%',
- [`${antCls}-badge`]: {
- [`${antCls}-badge-dot`]: {
- top: dotOffsetInCircle,
- insetInlineEnd: dotOffsetInCircle
- }
- },
- [`${componentCls}-body`]: {
- borderRadius: '50%'
- }
- },
- [`${componentCls}-square`]: {
- height: 'auto',
- minHeight: floatButtonSize,
- borderRadius: borderRadiusLG,
- [`${antCls}-badge`]: {
- [`${antCls}-badge-dot`]: {
- top: dotOffsetInSquare,
- insetInlineEnd: dotOffsetInSquare
- }
- },
- [`${componentCls}-body`]: {
- height: 'auto',
- borderRadius: borderRadiusLG
- }
- },
- [`${componentCls}-default`]: {
- backgroundColor: token.floatButtonBackgroundColor,
- transition: `background-color ${token.motionDurationMid}`,
- [`${componentCls}-body`]: {
- backgroundColor: token.floatButtonBackgroundColor,
- transition: `background-color ${token.motionDurationMid}`,
- '&:hover': {
- backgroundColor: token.colorFillContent
- },
- [`${componentCls}-content`]: {
- [`${componentCls}-icon`]: {
- color: token.colorText
- },
- [`${componentCls}-description`]: {
- display: 'flex',
- alignItems: 'center',
- lineHeight: `${token.fontSizeLG}px`,
- color: token.colorText,
- fontSize: token.fontSizeSM
- }
- }
- }
- },
- [`${componentCls}-primary`]: {
- backgroundColor: token.colorPrimary,
- [`${componentCls}-body`]: {
- backgroundColor: token.colorPrimary,
- transition: `background-color ${token.motionDurationMid}`,
- '&:hover': {
- backgroundColor: token.colorPrimaryHover
- },
- [`${componentCls}-content`]: {
- [`${componentCls}-icon`]: {
- color: token.colorTextLightSolid
- },
- [`${componentCls}-description`]: {
- display: 'flex',
- alignItems: 'center',
- lineHeight: `${token.fontSizeLG}px`,
- color: token.colorTextLightSolid,
- fontSize: token.fontSizeSM
- }
- }
- }
- }
- };
- };
- // ============================== Export ==============================
- var _default = exports.default = (0, _internal.genComponentStyleHook)('FloatButton', token => {
- const {
- colorTextLightSolid,
- colorBgElevated,
- controlHeightLG,
- marginXXL,
- marginLG,
- fontSize,
- fontSizeIcon,
- controlItemBgHover,
- paddingXXS,
- borderRadiusLG
- } = token;
- const floatButtonToken = (0, _internal.mergeToken)(token, {
- floatButtonBackgroundColor: colorBgElevated,
- floatButtonColor: colorTextLightSolid,
- floatButtonHoverBackgroundColor: controlItemBgHover,
- floatButtonFontSize: fontSize,
- floatButtonIconSize: fontSizeIcon * 1.5,
- floatButtonSize: controlHeightLG,
- floatButtonInsetBlockEnd: marginXXL,
- floatButtonInsetInlineEnd: marginLG,
- floatButtonBodySize: controlHeightLG - paddingXXS * 2,
- // 这里的 paddingXXS 是简写,完整逻辑是 (controlHeightLG - (controlHeightLG - paddingXXS * 2)) / 2,
- floatButtonBodyPadding: paddingXXS,
- badgeOffset: paddingXXS * 1.5,
- dotOffsetInCircle: (0, _util.default)(controlHeightLG / 2),
- dotOffsetInSquare: (0, _util.default)(borderRadiusLG)
- });
- return [floatButtonGroupStyle(floatButtonToken), sharedFloatButtonStyle(floatButtonToken), (0, _fade.initFadeMotion)(token), initFloatButtonGroupMotion(floatButtonToken)];
- });
|