Repository: ant-design/ant-design-mobile
Pull request #6691 (2024-08-01 07:14:56)

feat(notice-bar): shape and bordered prop
增加 success 配色，shape 和 bordered 属性。







github-actions[bot]: **Size Change:** +170 B (+0.05%) 

**Total Size:** 358 kB

| Filename | Size | Change |
| :--- | :---: | :---: |
| `./lib/bundle/antd-mobile.compatible.umd.js` | 192 kB | +76 B (+0.04%) |
| `./lib/bundle/antd-mobile.umd.js` | 147 kB | +11 B (+0.01%) |
| `./lib/bundle/style.css` | 18.1 kB | +83 B (+0.46%) |

<details><summary>ℹ️ <strong>View Unchanged</strong></summary>

| Filename | Size |
| :--- | :---: |
| `./lib/bundle/css-vars-patch.css` | 1.42 kB |

</details>



<a href="https://github.com/preactjs/compressed-size-action"><sub>compressed-size-action</sub></a>
github-actions[bot]: ## size-limit report 📦 
| Path                             | Size                 | Loading time (3g) | Running time (snapdragon) | Total time |
| -------------------------------- | -------------------- | ----------------- | ------------------------- | ---------- |
| `./lib/bundle/antd-mobile.es.js` | 103.6 KB (+100 B 🔺) | 2.1 s (+0.1% 🔺)  | 916 ms (-2.06% 🔽)        | 3 s        |
github-actions[bot]: PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6691.surge.sh

Patch:
diff --git a/src/components/notice-bar/demos/demo1.tsx b/src/components/notice-bar/demos/demo1.tsx
index 40601a539..df1fa518a 100644
--- a/src/components/notice-bar/demos/demo1.tsx
+++ b/src/components/notice-bar/demos/demo1.tsx
@@ -1,7 +1,7 @@
-import React from 'react'
 import { NoticeBar, Space } from 'antd-mobile'
+import { CloseCircleOutline, CompassOutline } from 'antd-mobile-icons'
 import { DemoBlock, lorem } from 'demos'
-import { CompassOutline, CloseCircleOutline } from 'antd-mobile-icons'
+import React from 'react'
 
 const demoLongText = lorem.generateWords(20)
 
@@ -11,6 +11,7 @@ export default () => {
       <DemoBlock title='通告栏语义' padding='0' background='transparent'>
         <Space block direction='vertical'>
           <NoticeBar content='默认' color='default' />
+          <NoticeBar content='成功' color='success' />
           <NoticeBar content='警告' color='alert' />
           <NoticeBar content='错误' color='error' />
           <NoticeBar content='信息' color='info' />
@@ -50,6 +51,22 @@ export default () => {
             content={'自定义右侧功能区'}
             color='alert'
           />
+          <div style={{ paddingInline: 12 }}>
+            <NoticeBar
+              color='info'
+              shape='neutral'
+              bordered
+              content={'圆角+全边框'}
+            />
+          </div>
+          <div style={{ paddingInline: 12 }}>
+            <NoticeBar
+              color='success'
+              shape='rounded'
+              bordered={false}
+              content={'圆形+无边框'}
+            />
+          </div>
         </Space>
       </DemoBlock>
     </>
diff --git a/src/components/notice-bar/index.en.md b/src/components/notice-bar/index.en.md
index 4149d5487..a4ba78416 100644
--- a/src/components/notice-bar/index.en.md
+++ b/src/components/notice-bar/index.en.md
@@ -14,11 +14,11 @@ It is applicable to the notification of information in the current page, which i
 
 ### Props
 
-| Name | Description | Type | Default |
-| --- | --- | --- | --- |
+| Name | Description | Type | Default | Version |
+| --- | --- | --- | --- | --- |
 | closeable | Whether it can be closed | `boolean` | `false` |
 | closeIcon | Custom close button icon | `ReactNode` | `<CloseOutline />` |
-| color | The type of the NoticeBar | `'default' \| 'alert' \| 'error' \| 'info'` | `'default'` |
+| color | The type of the NoticeBar | `'default' \| 'alert' \| 'error' \| 'info' \| 'success'` | `'default'` |
 | content | The content of the NoticeBar | `React.ReactNode` | - |
 | delay | Delay to start scrolling, unit `ms` | `number` | `2000` |
 | extra | Additional operating area, displayed to the left of the close button | `React.ReactNode` | - |
@@ -27,14 +27,18 @@ It is applicable to the notification of information in the current page, which i
 | onClick | Click event | `() => void` | - |
 | speed | Scroll speed, unit `px/s` | `number` | `50` |
 | wrap | Whether to display multiple lines | `boolean` | `false` |
+| shape | Shape of the NoticeBar (rectangular: sharp; neutral: round corner; rounded: circle/pill shape) | `'rectangular' \| 'neutral' \| 'rounded'` | `'rectangular'` | 5.38.0 |
+| bordered | Border visibility of the NoticeBar (`block`: top and bottom border; `true`: full border; `false`: no border) | `'block' \| boolean` | `'block'` | 5.38.0 |
 
 ### CSS Variables
 
-| Name | Description | Default |
-| --- | --- | --- |
+| Name | Description | Default | Global | Version |
+| --- | --- | --- | --- | --- |
 | --background-color | background color | `var(--adm-color-weak)` |
 | --border-color | border color | `var(--adm-color-weak)` |
 | --font-size | Font size of notice text content. | `15px` |
 | --height | Height of the whole element. | `40px` |
 | --icon-font-size | Font size of left icon. | `18px` |
 | --text-color | text color | `#ffffff` |
+| `--adm-notice-bar-border-radius` | Border radius of neutral shape NoticeBar | `4px` | `--adm-notice-bar-border-radius` | 5.38.0 |
+| `--adm-notice-bar-border-width` | Border width of bordered NoticeBar | `1px` | `--adm-notice-bar-border-width` | 5.38.0 |
diff --git a/src/components/notice-bar/index.zh.md b/src/components/notice-bar/index.zh.md
index 14d5407e4..d617f7eb0 100644
--- a/src/components/notice-bar/index.zh.md
+++ b/src/components/notice-bar/index.zh.md
@@ -14,11 +14,11 @@
 
 ### 属性
 
-| 属性 | 说明 | 类型 | 默认值 |
-| --- | --- | --- | --- |
+| 属性 | 说明 | 类型 | 默认值 | 版本 |
+| --- | --- | --- | --- | --- |
 | closeable | 是否可关闭 | `boolean` | `false` |
 | closeIcon | 自定义关闭按钮图标 | `ReactNode` | `<CloseOutline />` |
-| color | 通告栏的类型 | `'default' \| 'alert' \| 'error' \| 'info'` | `'default'` |
+| color | 通告栏的类型 | `'default' \| 'alert' \| 'error' \| 'info' \| 'success'` | `'default'` |
 | content | 公告内容 | `React.ReactNode` | - |
 | delay | 开始滚动的延迟，单位 `ms` | `number` | `2000` |
 | extra | 额外操作区域，显示在关闭按钮左侧 | `React.ReactNode` | - |
@@ -27,14 +27,18 @@
 | onClick | 点击事件 | `() => void` | - |
 | speed | 滚动速度，单位 `px/s` | `number` | `50` |
 | wrap | 是否多行展示 | `boolean` | `false` |
+| shape | 形状 (rectangular: 直角; neutral: 圆角; rounded: 圆形) | `'rectangular' \| 'neutral' \| 'rounded'` | `'rectangular'` | 5.38.0 |
+| bordered | 边框可见性 (`block`: 上下边框; `true`: 全边框; `false`: 无边框) | `'block' \| boolean` | `'block'` | 5.38.0 |
 
 ### CSS 变量
 
-| 属性               | 说明           | 默认值                  |
-| ------------------ | -------------- | ----------------------- |
-| --background-color | 背景色         | `var(--adm-color-weak)` |
-| --border-color     | 边框颜色       | `var(--adm-color-weak)` |
-| --font-size        | 文字字号       | `15px`                  |
-| --height           | 整体高度       | `40px`                  |
-| --icon-font-size   | 左侧图标的字号 | `18px`                  |
-| --text-color       | 文字颜色       | `#ffffff`               |
+| 属性 | 说明 | 默认值 | 全局变量 | 版本 |
+| --- | --- | --- | --- | --- |
+| `--background-color` | 背景色 | `var(--adm-color-weak)` |
+| `--border-color` | 边框颜色 | `var(--adm-color-weak)` |
+| `--font-size` | 文字字号 | `15px` |
+| `--height` | 整体高度 | `40px` |
+| `--icon-font-size` | 左侧图标的字号 | `18px` |
+| `--text-color` | 文字颜色 | `#ffffff` |
+| `--adm-notice-bar-border-radius` | 圆角形状(neutral)的圆角大小 | `4px` | `--adm-notice-bar-border-radius` | 5.38.0 |
+| `--adm-notice-bar-border-width` | 边框粗细 | `1px` | `--adm-notice-bar-border-width` | 5.38.0 |
diff --git a/src/components/notice-bar/notice-bar.less b/src/components/notice-bar/notice-bar.less
index 13ef66513..0dbcf159c 100644
--- a/src/components/notice-bar/notice-bar.less
+++ b/src/components/notice-bar/notice-bar.less
@@ -7,6 +7,8 @@
   --font-size: var(--adm-font-size-7);
   --icon-font-size: var(--adm-font-size-10);
   --height: 40px;
+  --adm-notice-bar-border-radius: 4px;
+  --adm-notice-bar-border-width: 1px;
 
   height: var(--height);
   box-sizing: border-box;
@@ -16,9 +18,9 @@
   align-items: center;
   justify-content: space-between;
 
-  border: solid 1px var(--border-color);
-  border-left: none;
-  border-right: none;
+  border: solid var(--adm-notice-bar-border-width) var(--border-color);
+  border-left-width: 0;
+  border-right-width: 0;
   background-color: var(--background-color);
   color: var(--text-color);
   & > span[role='img'] {
@@ -33,13 +35,18 @@
   &.@{class-prefix-notice-bar}-error {
     --background-color: var(--adm-color-danger);
     --border-color: #d9281e;
-    --text-color: #ffffff;
+    --text-color: #fff;
   }
   &.@{class-prefix-notice-bar}-info {
     --background-color: #d0e4ff;
     --border-color: #bcd8ff;
     --text-color: var(--adm-color-primary);
   }
+  &.@{class-prefix-notice-bar}-success {
+    --background-color: #d1fff0;
+    --border-color: #a8f0d8;
+    --text-color: var(--adm-color-success);
+  }
 
   & .@{class-prefix-notice-bar}-left {
     flex-shrink: 0;
@@ -89,4 +96,22 @@
     padding-bottom: 8px;
     line-height: 22px;
   }
+
+  &-neutral {
+    border-radius: var(--adm-notice-bar-border-radius);
+  }
+
+  &-rounded {
+    border-radius: 1000px;
+  }
+
+  &-bordered {
+    border-left-width: var(--adm-notice-bar-border-width);
+    border-right-width: var(--adm-notice-bar-border-width);
+  }
+
+  &-without-border {
+    border-top-width: 0;
+    border-bottom-width: 0;
+  }
 }
diff --git a/src/components/notice-bar/notice-bar.tsx b/src/components/notice-bar/notice-bar.tsx
index b2a858a3e..f3780e746 100644
--- a/src/components/notice-bar/notice-bar.tsx
+++ b/src/components/notice-bar/notice-bar.tsx
@@ -13,7 +13,7 @@ const classPrefix = `adm-notice-bar`
 
 export type NoticeBarProps = {
   /** The type of the NoticeBar */
-  color?: 'default' | 'alert' | 'error' | 'info'
+  color?: 'default' | 'alert' | 'error' | 'success' | 'info'
   /** TDelay to start scrolling, unit ms */
   delay?: number
   /** Scroll speed, unit px/s */
@@ -34,6 +34,10 @@ export type NoticeBarProps = {
   icon?: ReactNode
   /** Whether to display multiple lines */
   wrap?: boolean
+  /** Block shape */
+  shape?: 'rectangular' | 'neutral' | 'rounded'
+  /** Border visibility */
+  bordered?: 'block' | boolean
 } & NativeProps<
   | '--background-color'
   | '--border-color'
@@ -49,6 +53,8 @@ const defaultProps = {
   speed: 50,
   icon: <SoundOutline />,
   wrap: false,
+  shape: 'rectangular',
+  bordered: 'block' as 'block' | boolean,
 }
 
 export const NoticeBar = memo<NoticeBarProps>(props => {
@@ -130,8 +136,11 @@ export const NoticeBar = memo<NoticeBarProps>(props => {
       className={classNames(
         classPrefix,
         `${classPrefix}-${mergedProps.color}`,
+        `${classPrefix}-${mergedProps.shape}`,
         {
           [`${classPrefix}-wrap`]: mergedProps.wrap,
+          [`${classPrefix}-bordered`]: mergedProps.bordered === true,
+          [`${classPrefix}-without-border`]: mergedProps.bordered === false,
         }
       )}
       onClick={mergedProps.onClick}


Test patch:
diff --git a/src/components/notice-bar/tests/__snapshots__/notice-bar.test.tsx.snap b/src/components/notice-bar/tests/__snapshots__/notice-bar.test.tsx.snap
index d6c6d47a0..e5580e361 100644
--- a/src/components/notice-bar/tests/__snapshots__/notice-bar.test.tsx.snap
+++ b/src/components/notice-bar/tests/__snapshots__/notice-bar.test.tsx.snap
@@ -3,7 +3,7 @@
 exports[`NoticeBar long content 1`] = `
 <div>
   <div
-    class="adm-notice-bar adm-notice-bar-default"
+    class="adm-notice-bar adm-notice-bar-default adm-notice-bar-rectangular"
   >
     <span
       class="adm-notice-bar-left"