Skip to content

Feat v4 floatbutton #6294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export type { EmptyProps } from './empty';
export { default as Empty } from './empty';

export type { FloatButtonProps, FloatButtonGroupProps } from './float-button/interface';
export { default as FloatButton } from './float-button';
export { default as FloatButton, FloatButtonGroup } from './float-button';

export type { FormProps, FormItemProps, FormInstance, FormItemInstance } from './form';
export { default as Form, FormItem, FormItemRest } from './form';
Expand Down
4 changes: 0 additions & 4 deletions components/float-button/BackTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,4 @@ const BackTop = defineComponent({
},
});

if (process.env.NODE_ENV !== 'production') {
BackTop.displayName = 'BackTop';
}

export default BackTop;
32 changes: 13 additions & 19 deletions components/float-button/FloatButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ const FloatButton = defineComponent({
return groupShape || props.shape;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

groupShape.value ?

});

const classString = computed(() => {
return classNames(
hashId.value,
prefixCls.value,
attrs.class,
`${prefixCls.value}-${props.type}`,
`${prefixCls.value}-${mergeShape.value}`,
{
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
},
);
});

expose({
floatButtonEl: floatButtonRef,
});
Expand All @@ -63,6 +50,17 @@ const FloatButton = defineComponent({
description,
};

const classString = classNames(
prefixCls.value,
`${prefixCls.value}-${props.type}`,
`${prefixCls.value}-${mergeShape.value}`,
{
[`${prefixCls.value}-rtl`]: direction.value === 'rtl',
},
attrs.class,
hashId.value,
);

const buttonNode = (
<Tooltip placement="left">
{{
Expand Down Expand Up @@ -98,7 +96,7 @@ const FloatButton = defineComponent({
ref={floatButtonRef}
{...attrs}
{...(restProps as any)}
class={classString.value}
class={classString}
style={attrs.style as CSSProperties}
>
{buttonNode}
Expand All @@ -108,7 +106,7 @@ const FloatButton = defineComponent({
ref={floatButtonRef}
{...attrs}
{...restProps}
class={classString.value}
class={classString}
style={attrs.style as CSSProperties}
type="button"
>
Expand All @@ -120,8 +118,4 @@ const FloatButton = defineComponent({
},
});

if (process.env.NODE_ENV !== 'production') {
FloatButton.displayName = 'FloatButton';
}

export default FloatButton;
3 changes: 1 addition & 2 deletions components/float-button/FloatButtonContent.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { defineComponent } from 'vue';
import FileTextOutlined from '@ant-design/icons-vue/FileTextOutlined';
import classNames from '../_util/classNames';
import { initDefaultProps } from '../_util/props-util';
import { floatButtonContentProps } from './interface';

const FloatButtonContent = defineComponent({
compatConfig: { MODE: 3 },
name: 'AFloatButtonContent',
inheritAttrs: false,
props: initDefaultProps(floatButtonContentProps(), {}),
props: floatButtonContentProps(),
setup(props, { attrs, slots }) {
return () => {
const { description, prefixCls } = props;
Expand Down
2 changes: 1 addition & 1 deletion components/float-button/FloatButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const FloatButtonGroup = defineComponent({
const floatButtonRef = ref<HTMLButtonElement | HTMLAnchorElement>(null);

FloatButtonGroupContext.useProvide({
shape: computed(() => props.shape),
shape: props.shape,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成这样就丢失响应式了吧

});

const hoverAction = computed(() => {
Expand Down
5 changes: 1 addition & 4 deletions components/float-button/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import type { Ref } from 'vue';
import createContext from '../_util/createContext';

import type { FloatButtonShape } from './interface';

const FloatButtonGroupContext = createContext<{ shape: Ref<FloatButtonShape> } | undefined>(
undefined,
);
const FloatButtonGroupContext = createContext<{ shape: FloatButtonShape } | undefined>(undefined);

export default FloatButtonGroupContext;
6 changes: 3 additions & 3 deletions components/float-button/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { CSSObject } from '../../_util/cssinjs';
import { Keyframes } from '../../_util/cssinjs';
import type { FullToken, GenerateStyle } from '../../theme/internal';
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
import { initFadeMotion } from '../../_style/motion/fade';
import { resetComponent } from '../../_style';
import { initMotion } from '../../_style/motion/motion';
import { initFadeMotion } from '../../style/motion/fade';
import { resetComponent } from '../../style';
import { initMotion } from '../../style/motion/motion';

/** Component only token. Which will handle additional calculation of alias token */
export interface ComponentToken {
Expand Down