ant-design / ant-design/x

为 Bubble 和 BubbleList 组件的 footer 属性增加可控的 hover 样式

Open
#489 6 comments 0 reactions 1 assignee Claimed by @chenluda View on GitHub
enhancement
Dominant language
TypeScript
Stars
4.8k
Forks
1.2k
Avg merge
3d 3h
Merged PRs (30d)
2

Description

### 需求动机

### 问题描述

1. 在 `Bubble` 组件中实现 `footer` 的 hover 效果。虽然可以直接使用 CSS 样式来实现,但在 `BubbleList` 组件中,使用 CSS 样式可能会导致**样式污染**。因此,希望在 `Bubble` 和 `BubbleList` 组件中增加一个属性,以便能够更灵活地控制 `footer` 的 hover 样式;
2. `Bubble` 组件中 `footer` 建议默认在 `typeing` 和 `loading` 完后再加载。

### 解决方案

建议在 `Bubble` 和 `BubbleList` 组件中增加属性,允许自定义 `footer` 的 hover 样式。

### 预期效果

- 在 `Bubble` 组件中,`footer` 部分能够根据 `footerDisplayMode` 属性设置显示 hover 效果。
- 在 `BubbleList` 组件中,可以根据 `hoverableBubbleFooter` 属性设置符合条件的 `Bubble`,其 `footer` 部分的 hover 效果。

![Image](https://github.com/user-attachments/assets/3aeea5bb-3fdb-4a9e-bf51-2a5106e7374f)

### 提议的 API 是什么样的?

### Bubble:
属性 | 说明 | 类型 | 默认值
-- | -- | -- | --
footerDisplayMode | 设置气泡 footer hover 属性 | `always`/`hover` | always

- `bubble/Bubble.js`
``` js
const footerClassName = classnames(`${prefixCls}-footer`, contextConfig.classNames.footer, classNames.footer, {
[`${prefixCls}-footer-hover`]: footerDisplayMode === 'hover',
});
```
- `bubble/style/index.js`
``` js
[`& ${componentCls}-footer-hover`]: {
opacity: 0,
transition: 'opacity 0.3s ease',
},
[`&:hover ${componentCls}-footer-hover`]: {
opacity: 1,
},
```

### Bubble.List:
属性 | 说明 | 类型 | 默认值
-- | -- | -- | --
hoverableBubbleFooter | 设置对话列表中气泡 hover 属性 | `latest`/`all`/`none`/`与 role 匹配` | none

- `bubble/BubbleList.js`
``` js
const getFooterDisplayMode = (index, role) => {
if (hoverableBubbleFooter === 'latest') {
return index === displayData.length - 1 ? 'always' : 'hover';
} else if (hoverableBubbleFooter === 'all') {
return 'hover';
}

if (roles && roles[hoverableBubbleFooter]) {
return role === hoverableBubbleFooter ? 'hover' : 'always';
}

return 'always';
};
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.