Skip to content
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

feat(n-card): adds content-class footer-class header-class ..... #5262

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
- `n-message` adds `container-class` prop.
- `n-loading-bar` adds `container-class` prop.
- `n-thing` adds `content-class` and `description-class` props.

- `n-card` adds `content-class`, `footer-class`, `header-class` and `header-extra-class` props.
-
## 2.35.0

### Breaking Changes
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- `n-message` 新增 `container-class` 属性
- `n-loading-bar` 新增 `container-class` 属性
- `n-thing` 新增 `content-class` 和 `description-class` 属性
- `n-card` 新增 `content-class`、`footer-class`、`header-class` 和 `header-extra-class` 属性

## 2.35.0

Expand Down
4 changes: 4 additions & 0 deletions src/card/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ embedded.vue
| --- | --- | --- | --- | --- |
| bordered | `boolean` | `true` | Whether to show the card border. | |
| closable | `boolean` | `false` | Is it allowed to close. | |
| content-class | `string` | `undefined` | The class of the card content area. | NEXT_VERSION |
| content-style | `Object \| string` | `undefined` | The style of the card content area. | |
| embedded | `boolean` | `false` | Use a darker background color to show the embedding effect (only for bright themes) | |
| footer-class | `string` | `undefined` | The class of the bottom area of the card. | NEXT_VERSION |
| footer-style | `Object \| string` | `undefined` | The style of the bottom area of the card. | |
| header-class | `string` | `undefined` | The class of the card head area. | NEXT_VERSION |
| header-style | `Object \| string` | `undefined` | The style of the card head area. | |
| header-extra-class | `string` | `undefined` | The class of the card head extra area. | NEXT_VERSION |
| header-extra-style | `Object \| string` | `undefined` | The style of the card head extra area. | 2.25.0 |
| hoverable | `boolean` | `false` | Whether to show shadow when hovering on the card. | |
| segmented | `boolean \| { [part in 'content' \| 'footer' \| 'action']?: boolean \| 'soft' }` | `false` | Segment divider settings of the card. | |
Expand Down
4 changes: 4 additions & 0 deletions src/card/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ embedded-debug.vue
| --- | --- | --- | --- | --- |
| bordered | `boolean` | `true` | 是否显示卡片边框 | |
| closable | `boolean` | `false` | 是否允许关闭 | |
| content-class | `string` | `undefined` | 卡片内容区域的类名 | NEXT_VERSION |
| content-style | `Object \| string` | `undefined` | 卡片内容区域的样式 | |
| embedded | `boolean` | `false` | 使用更深的背景色展现嵌入效果,只对亮色主题生效 | |
| footer-class | `string` | `undefined` | 卡片底部区域的类名 | NEXT_VERSION |
| footer-style | `Object \| string` | `undefined` | 卡片底部区域的样式 | |
| header-class | `string` | `undefined` | 卡片头部区域的类名 | NEXT_VERSION |
| header-style | `Object \| string` | `undefined` | 卡片头部区域的样式 | |
| header-extra-class | `string` | `undefined` | 卡片头部额外内容的类名 | NEXT_VERSION |
| header-extra-style | `Object \| string` | `undefined` | 卡片头部额外内容的样式 | 2.25.0 |
| hoverable | `boolean` | `false` | 卡片是否可悬浮 | |
| segmented | `boolean \| { [part in 'content' \| 'footer' \| 'action']?: boolean \| 'soft' }` | `false` | 卡片的分段区域设置 | |
Expand Down
19 changes: 15 additions & 4 deletions src/card/src/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ export interface CardSegmented {

export const cardBaseProps = {
title: String,
contentClass: String,
contentStyle: [Object, String] as PropType<CSSProperties | string>,
headerClass: String,
headerStyle: [Object, String] as PropType<CSSProperties | string>,
headerExtraClass: String,
headerExtraStyle: [Object, String] as PropType<CSSProperties | string>,
footerClass: String,
footerStyle: [Object, String] as PropType<CSSProperties | string>,
embedded: Boolean,
segmented: {
Expand Down Expand Up @@ -172,6 +176,10 @@ export default defineComponent({
},
render () {
const {
footerStyle,
headerExtraClass,
headerClass,
contentClass,
segmented,
bordered,
hoverable,
Expand Down Expand Up @@ -224,7 +232,7 @@ export default defineComponent({
{resolveWrappedSlot($slots.header, (children) => {
return children || this.title || this.closable ? (
<div
class={`${mergedClsPrefix}-card-header`}
class={[`${mergedClsPrefix}-card-header`, headerClass]}
style={this.headerStyle}
>
<div
Expand All @@ -238,7 +246,10 @@ export default defineComponent({
(children) =>
children && (
<div
class={`${mergedClsPrefix}-card-header__extra`}
class={[
`${mergedClsPrefix}-card-header__extra`,
headerExtraClass
]}
style={this.headerExtraStyle}
>
{children}
Expand All @@ -261,7 +272,7 @@ export default defineComponent({
(children) =>
children && (
<div
class={`${mergedClsPrefix}-card__content`}
class={[`${mergedClsPrefix}-card__content`, contentClass]}
style={this.contentStyle}
role="none"
>
Expand All @@ -274,7 +285,7 @@ export default defineComponent({
(children) =>
children && [
<div
class={`${mergedClsPrefix}-card__footer`}
class={[`${mergedClsPrefix}-card__footer`, footerStyle]}
style={this.footerStyle}
role="none"
>
Expand Down
Loading