From c3cb26bf2ea84c501e2916fd893af7140885b91b Mon Sep 17 00:00:00 2001 From: oasis <12181600+oasis-cloud@users.noreply.github.com> Date: Fri, 27 Dec 2024 11:52:38 +0800 Subject: [PATCH 1/2] feat(v15): indicator adaptation (#2746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(v14): indicator adaptation * feat(v14): indicator adaptation * feat: 增加视觉限制最大宽度 * fix: review * fix: update test * fix: 覆盖率 * fix: review * fix: review --------- Co-authored-by: xiaoyatong <84436086+xiaoyatong@users.noreply.github.com> --- migrate-from-v2.md | 8 +- src/config.json | 1 + .../__snapshots__/indicator.spec.tsx.snap | 6 +- .../indicator/__test__/indicator.spec.tsx | 15 +- src/packages/indicator/demo.taro.tsx | 14 ++ src/packages/indicator/demo.tsx | 14 ++ src/packages/indicator/demos/h5/demo1.tsx | 9 +- src/packages/indicator/demos/h5/demo4.tsx | 81 ++++++---- src/packages/indicator/demos/h5/demo5.tsx | 13 ++ src/packages/indicator/demos/h5/demo6.tsx | 16 ++ src/packages/indicator/demos/taro/demo1.tsx | 9 +- src/packages/indicator/demos/taro/demo4.tsx | 135 ++++++++++------- src/packages/indicator/demos/taro/demo5.tsx | 13 ++ src/packages/indicator/demos/taro/demo6.tsx | 16 ++ src/packages/indicator/doc.en-US.md | 26 +++- src/packages/indicator/doc.md | 32 +++- src/packages/indicator/doc.taro.md | 32 +++- src/packages/indicator/doc.zh-TW.md | 32 +++- src/packages/indicator/indicator.scss | 141 ++++++++++++++++-- src/packages/indicator/indicator.taro.tsx | 77 ++++++++-- src/packages/indicator/indicator.tsx | 71 +++++++-- src/styles/variables.scss | 19 ++- 22 files changed, 606 insertions(+), 174 deletions(-) create mode 100644 src/packages/indicator/demos/h5/demo5.tsx create mode 100644 src/packages/indicator/demos/h5/demo6.tsx create mode 100644 src/packages/indicator/demos/taro/demo5.tsx create mode 100644 src/packages/indicator/demos/taro/demo6.tsx diff --git a/migrate-from-v2.md b/migrate-from-v2.md index 5dfba737d2..de7987c625 100644 --- a/migrate-from-v2.md +++ b/migrate-from-v2.md @@ -255,12 +255,8 @@ plugins: [ #### Indicator -- 移除 `block`,暴露自定义节点 -- 移除 `align`,暴露自定义节点 -- `vertical` 重命名为`direction`,默认值为 `horizontal`,可选 `vertical` -- 移除 `fillZero`,暴露自定义节点 -- `size` 重命名为 `total` -- 增加非数字展示,并设置为默认状态 +- type 属性的值调整为 `'anchor'` 或 `'slide'` +- color 属性的值增加 `'white'` #### Menu diff --git a/src/config.json b/src/config.json index 8e6b4cf7f5..3b5b447e8b 100644 --- a/src/config.json +++ b/src/config.json @@ -1048,6 +1048,7 @@ "sort": 16, "show": true, "taro": true, + "v15": true, "author": "liukun" }, { diff --git a/src/packages/indicator/__test__/__snapshots__/indicator.spec.tsx.snap b/src/packages/indicator/__test__/__snapshots__/indicator.spec.tsx.snap index 6aef6f06d8..d2f9346040 100644 --- a/src/packages/indicator/__test__/__snapshots__/indicator.spec.tsx.snap +++ b/src/packages/indicator/__test__/__snapshots__/indicator.spec.tsx.snap @@ -6,13 +6,13 @@ exports[`should match snapshot 1`] = ` class="nut-indicator" >
diff --git a/src/packages/indicator/__test__/indicator.spec.tsx b/src/packages/indicator/__test__/indicator.spec.tsx index 341aaef23c..b0d76e67e6 100644 --- a/src/packages/indicator/__test__/indicator.spec.tsx +++ b/src/packages/indicator/__test__/indicator.spec.tsx @@ -17,7 +17,9 @@ test('should be shown when passing size and current', () => { ) expect(container.querySelectorAll('.nut-indicator-dot')).toHaveLength(3) - expect(container.querySelectorAll('.nut-indicator-active')).toHaveLength(1) + expect(container.querySelectorAll('.nut-indicator-dot-active')).toHaveLength( + 1 + ) }) test('should be shown when custom node', () => { @@ -41,3 +43,14 @@ test('should be shown when custom node', () => { ) expect(container.querySelectorAll('.nut-indicator-dot')).toHaveLength(5) }) + +test('should be shown when slide', () => { + const { container } = render( + + + + ) + expect(container.querySelectorAll('.nut-indicator-line-active')).toHaveLength( + 1 + ) +}) diff --git a/src/packages/indicator/demo.taro.tsx b/src/packages/indicator/demo.taro.tsx index ee3bb5a491..184068c77b 100644 --- a/src/packages/indicator/demo.taro.tsx +++ b/src/packages/indicator/demo.taro.tsx @@ -7,23 +7,31 @@ import Demo1 from './demos/taro/demo1' import Demo2 from './demos/taro/demo2' import Demo3 from './demos/taro/demo3' import Demo4 from './demos/taro/demo4' +import Demo5 from './demos/taro/demo5' +import Demo6 from './demos/taro/demo6' const IndicatorDemo = () => { const [translated] = useTranslate({ 'zh-CN': { basic: '基础用法', + white: '白色', + type: '类型', customNode: '自定义节点', custom: '自定义', vertical: '竖向展示', }, 'zh-TW': { basic: '基礎用法', + white: '白色', + type: '类型', customNode: '自定义节点', custom: '自定义', vertical: '豎向展示', }, 'en-US': { basic: 'Basic usage', + white: 'White', + type: 'Type', customNode: 'Custom Node', custom: 'Custom', vertical: 'Vertical display', @@ -37,6 +45,12 @@ const IndicatorDemo = () => { {translated.basic} + {translated.white} + + + {translated.type} + + {translated.customNode} diff --git a/src/packages/indicator/demo.tsx b/src/packages/indicator/demo.tsx index 3e772985ac..1f2695c0af 100644 --- a/src/packages/indicator/demo.tsx +++ b/src/packages/indicator/demo.tsx @@ -4,23 +4,31 @@ import Demo1 from './demos/h5/demo1' import Demo2 from './demos/h5/demo2' import Demo3 from './demos/h5/demo3' import Demo4 from './demos/h5/demo4' +import Demo5 from './demos/h5/demo5' +import Demo6 from './demos/h5/demo6' const IndicatorDemo = () => { const [translated] = useTranslate({ 'zh-CN': { basic: '基础用法', + white: '白色', + type: '类型', customNode: '自定义节点', custom: '自定义', vertical: '竖向展示', }, 'zh-TW': { basic: '基礎用法', + white: '白色', + type: '类型', customNode: '自定义节点', custom: '自定义', vertical: '豎向展示', }, 'en-US': { basic: 'Basic usage', + white: 'White', + type: 'Type', customNode: 'Custom Node', custom: 'Custom', vertical: 'Vertical display', @@ -33,6 +41,12 @@ const IndicatorDemo = () => {

{translated.basic}

+

{translated.white}

+ + +

{translated.type}

+ +

{translated.customNode}

diff --git a/src/packages/indicator/demos/h5/demo1.tsx b/src/packages/indicator/demos/h5/demo1.tsx index 0cedc6cd59..5ba63d1e3c 100644 --- a/src/packages/indicator/demos/h5/demo1.tsx +++ b/src/packages/indicator/demos/h5/demo1.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { Indicator, Cell } from '@nutui/nutui-react' +import { Cell, Indicator } from '@nutui/nutui-react' const Demo1 = () => { return ( @@ -8,10 +8,13 @@ const Demo1 = () => { - + - + + + + ) diff --git a/src/packages/indicator/demos/h5/demo4.tsx b/src/packages/indicator/demos/h5/demo4.tsx index 66977d59a2..788f2ef46e 100644 --- a/src/packages/indicator/demos/h5/demo4.tsx +++ b/src/packages/indicator/demos/h5/demo4.tsx @@ -1,38 +1,61 @@ import React from 'react' -import { Indicator, Cell } from '@nutui/nutui-react' +import { Cell, Indicator } from '@nutui/nutui-react' const Demo4 = () => { return ( - - -
+ + +
+ {5} +
+
+ - {5} -
-
- -
+ /> + + + + + + + ) } export default Demo4 diff --git a/src/packages/indicator/demos/h5/demo5.tsx b/src/packages/indicator/demos/h5/demo5.tsx new file mode 100644 index 0000000000..b4595b4fd0 --- /dev/null +++ b/src/packages/indicator/demos/h5/demo5.tsx @@ -0,0 +1,13 @@ +import React from 'react' +import { Cell, Indicator } from '@nutui/nutui-react' + +const Demo5 = () => { + return ( + <> + + + + + ) +} +export default Demo5 diff --git a/src/packages/indicator/demos/h5/demo6.tsx b/src/packages/indicator/demos/h5/demo6.tsx new file mode 100644 index 0000000000..2fe8b28862 --- /dev/null +++ b/src/packages/indicator/demos/h5/demo6.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import { Cell, Indicator } from '@nutui/nutui-react' + +const Demo6 = () => { + return ( + <> + + + + + + + + ) +} +export default Demo6 diff --git a/src/packages/indicator/demos/taro/demo1.tsx b/src/packages/indicator/demos/taro/demo1.tsx index bcfa4b0d21..4dfb8e95c0 100644 --- a/src/packages/indicator/demos/taro/demo1.tsx +++ b/src/packages/indicator/demos/taro/demo1.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { Indicator, Cell } from '@nutui/nutui-react-taro' +import { Cell, Indicator } from '@nutui/nutui-react-taro' const Demo1 = () => { return ( @@ -8,10 +8,13 @@ const Demo1 = () => { - + - + + + + ) diff --git a/src/packages/indicator/demos/taro/demo4.tsx b/src/packages/indicator/demos/taro/demo4.tsx index 1527d78be1..250e4f4d85 100644 --- a/src/packages/indicator/demos/taro/demo4.tsx +++ b/src/packages/indicator/demos/taro/demo4.tsx @@ -1,66 +1,89 @@ import React from 'react' -import { Indicator, Cell } from '@nutui/nutui-react-taro' +import { Cell, Indicator } from '@nutui/nutui-react-taro' import { View } from '@tarojs/components' import { harmonyAndRn } from '@/utils/platform-taro' import pxTransform from '@/utils/px-transform' const Demo4 = () => { return ( - - - - {5} - - - - + <> + + + + {5} + + + + + + + + + + ) } export default Demo4 diff --git a/src/packages/indicator/demos/taro/demo5.tsx b/src/packages/indicator/demos/taro/demo5.tsx new file mode 100644 index 0000000000..a7d213f591 --- /dev/null +++ b/src/packages/indicator/demos/taro/demo5.tsx @@ -0,0 +1,13 @@ +import React from 'react' +import { Cell, Indicator } from '@nutui/nutui-react-taro' + +const Demo5 = () => { + return ( + <> + + + + + ) +} +export default Demo5 diff --git a/src/packages/indicator/demos/taro/demo6.tsx b/src/packages/indicator/demos/taro/demo6.tsx new file mode 100644 index 0000000000..7f282ea05c --- /dev/null +++ b/src/packages/indicator/demos/taro/demo6.tsx @@ -0,0 +1,16 @@ +import React from 'react' +import { Cell, Indicator } from '@nutui/nutui-react-taro' + +const Demo6 = () => { + return ( + <> + + + + + + + + ) +} +export default Demo6 diff --git a/src/packages/indicator/doc.en-US.md b/src/packages/indicator/doc.en-US.md index 283cd508be..feb5f3d144 100644 --- a/src/packages/indicator/doc.en-US.md +++ b/src/packages/indicator/doc.en-US.md @@ -18,6 +18,22 @@ import { Indicator } from '@nutui/nutui-react' ::: +### White + +:::demo + + + +::: + +### Type + +:::demo + + + +::: + ### Custom Node :::demo @@ -51,6 +67,8 @@ import { Indicator } from '@nutui/nutui-react' | current | current step | `number` | `0` | | total | step total size | `number` | `3` | | direction | display directory,default is horizontal | `horizontal` \| `vertical` | `horizontal` | +| color | color | `primary` \| `white` | `primary` | +| type | interactivity Type | `anchor` \| `slide` | `anchor` | ## Theming @@ -62,7 +80,7 @@ The component provides the following CSS variables, which can be used to customi | --- | --- | --- | | \--nutui-indicator-color | indicator active color | `$color-primary` | | \--nutui-indicator-dot-color | indicator default color | `$color-text-disabled` | -| \--nutui-indicator-dot-size | indicator dot size | `5px` | -| \--nutui-indicator-dot-active-size | indicator dot active size | `15px` | -| \--nutui-indicator-border-radius | indicator active border size | `3px` | -| \--nutui-indicator-dot-margin | when horizontal, indicator margin | `4px` | +| \--nutui-indicator-dot-size | indicator dot size | `3px` | +| \--nutui-indicator-dot-active-size | indicator dot active size | `6px` | +| \--nutui-indicator-border-radius | indicator active border size | `$radius-xxs` | +| \--nutui-indicator-dot-margin | when horizontal, indicator margin | `$spacing-xxxs` | diff --git a/src/packages/indicator/doc.md b/src/packages/indicator/doc.md index c255a685b8..16ce2c1dbe 100644 --- a/src/packages/indicator/doc.md +++ b/src/packages/indicator/doc.md @@ -18,6 +18,22 @@ import { Indicator } from '@nutui/nutui-react' ::: +### 白色 + +:::demo + + + +::: + +### 类型 + +:::demo + + + +::: + ### 自定义节点 :::demo @@ -48,9 +64,11 @@ import { Indicator } from '@nutui/nutui-react' | 属性 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| current | 当前步骤 | `number` | `0` | -| total | 步骤长度 | `number` | `3` | -| direction | 展示方向,默认为水平方向 | `horizontal` \| `vertical` | `horizontal` | +| current | 当前页 | `number` | `0` | +| total | 总页数 | `number` | `2` | +| direction | 方向,默认为水平方向 | `horizontal` \| `vertical` | `horizontal` | +| color | 颜色 | `primary` \| `white` | `primary` | +| type | 交互类型 | `anchor` \| `slide` | `anchor` | ## 主题定制 @@ -62,7 +80,7 @@ import { Indicator } from '@nutui/nutui-react' | --- | --- | --- | | \--nutui-indicator-color | 指示器焦点时色值 | `$color-primary` | | \--nutui-indicator-dot-color | 指示器默认色值 | `$color-text-disabled` | -| \--nutui-indicator-dot-size | 指示器尺寸 | `5px` | -| \--nutui-indicator-dot-active-size | 指示器焦点时尺寸 | `15px` | -| \--nutui-indicator-border-radius | 指示器焦点时的border值 | `3px` | -| \--nutui-indicator-dot-margin | 指示器横向时的margin值 | `4px` | +| \--nutui-indicator-dot-size | 指示器尺寸 | `3px` | +| \--nutui-indicator-dot-active-size | 指示器焦点时尺寸 | `6px` | +| \--nutui-indicator-border-radius | 指示器焦点时的border值 | `$radius-xxs` | +| \--nutui-indicator-dot-margin | 指示器横向时的margin值 | `$spacing-xxxs` | diff --git a/src/packages/indicator/doc.taro.md b/src/packages/indicator/doc.taro.md index 46d29ed51e..7b0331f69b 100644 --- a/src/packages/indicator/doc.taro.md +++ b/src/packages/indicator/doc.taro.md @@ -18,6 +18,22 @@ import { Indicator } from '@nutui/nutui-react-taro' ::: +### 白色 + +:::demo + + + +::: + +### 类型 + +:::demo + + + +::: + ### 自定义节点 :::demo @@ -48,9 +64,11 @@ import { Indicator } from '@nutui/nutui-react-taro' | 属性 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| current | 当前步骤 | `number` | `0` | -| total | 步骤长度 | `number` | `3` | -| direction | 展示方向,默认为水平方向 | `horizontal` \| `vertical` | `horizontal` | +| current | 当前页 | `number` | `0` | +| total | 总页数 | `number` | `2` | +| direction | 方向,默认为水平方向 | `horizontal` \| `vertical` | `horizontal` | +| color | 颜色 | `primary` \| `white` | `primary` | +| type | 交互类型 | `anchor` \| `slide` | `anchor` | ## 主题定制 @@ -62,7 +80,7 @@ import { Indicator } from '@nutui/nutui-react-taro' | --- | --- | --- | | \--nutui-indicator-color | 指示器焦点时色值 | `$color-primary` | | \--nutui-indicator-dot-color | 指示器默认色值 | `$color-text-disabled` | -| \--nutui-indicator-dot-size | 指示器尺寸 | `5px` | -| \--nutui-indicator-dot-active-size | 指示器焦点时尺寸 | `15px` | -| \--nutui-indicator-border-radius | 指示器焦点时的border值 | `3px` | -| \--nutui-indicator-dot-margin | 指示器横向时的margin值 | `4px` | +| \--nutui-indicator-dot-size | 指示器尺寸 | `3px` | +| \--nutui-indicator-dot-active-size | 指示器焦点时尺寸 | `6px` | +| \--nutui-indicator-border-radius | 指示器焦点时的border值 | `$radius-xxs` | +| \--nutui-indicator-dot-margin | 指示器横向时的margin值 | `$spacing-xxxs` | diff --git a/src/packages/indicator/doc.zh-TW.md b/src/packages/indicator/doc.zh-TW.md index 65ef6fe486..0d170f68a4 100644 --- a/src/packages/indicator/doc.zh-TW.md +++ b/src/packages/indicator/doc.zh-TW.md @@ -18,6 +18,22 @@ import { Indicator } from '@nutui/nutui-react' ::: +### 白色 + +:::demo + + + +::: + +### 类型 + +:::demo + + + +::: + ### 自定義節點 :::demo @@ -48,9 +64,11 @@ import { Indicator } from '@nutui/nutui-react' | 屬性 | 說明 | 類型 | 默認值 | | --- | --- | --- | --- | -| current | 當前步驟 | `number` | `0` | -| total | 步驟長度 | `number` | `3` | -| direction | 展示方向,默認為水平方向 | `horizontal` \| `vertical` | `horizontal` | +| current | 目前頁 | `number` | `0` | +| total | 總頁數 | `number` | `2` | +| direction | 方向,預設為水平方向 | `horizontal` \| `vertical` | `horizontal` | +| color | 顏色 | `primary` \| `white` | `primary` | +| type | 互動類型 | `anchor` \| `slide` | `anchor` | ## 主題定製 @@ -62,7 +80,7 @@ import { Indicator } from '@nutui/nutui-react' | --- | --- | --- | | \--nutui-indicator-color | 指示器焦點時色值 | `$color-primary` | | \--nutui-indicator-dot-color | 指示器默認色值 | `$color-text-disabled` | -| \--nutui-indicator-dot-size | 指示器尺寸 | `5px` | -| \--nutui-indicator-dot-active-size | 指示器焦點時尺寸 | `15px` | -| \--nutui-indicator-border-radius | 指示器焦點時的border值 | `3px` | -| \--nutui-indicator-dot-margin | 指示器橫向時的margin值 | `4px` | +| \--nutui-indicator-dot-size | 指示器尺寸 | `3px` | +| \--nutui-indicator-dot-active-size | 指示器焦點時尺寸 | `6px` | +| \--nutui-indicator-border-radius | 指示器焦點時的border值 | `$radius-xxs` | +| \--nutui-indicator-dot-margin | 指示器橫向時的margin值 | `$spacing-xxxs` | diff --git a/src/packages/indicator/indicator.scss b/src/packages/indicator/indicator.scss index 6b66b4d9a4..6272f82c1b 100644 --- a/src/packages/indicator/indicator.scss +++ b/src/packages/indicator/indicator.scss @@ -1,19 +1,24 @@ .nut-indicator { display: flex; - flex-direction: row; width: auto; + flex-direction: row; flex-wrap: nowrap; align-items: center; - justify-content: center; - &-dot { + &-fixed-width { + width: 21px; + } + + &-dot, + &-line { display: inline-block; vertical-align: middle; width: $indicator-dot-size; height: $indicator-dot-size; border-radius: 50%; - background-color: $indicator-dot-color; + background-color: $color-border-disabled; margin: 0 $indicator-dot-margin; + opacity: 0.4; &:first-child { margin-left: 0px; @@ -22,20 +27,119 @@ &:last-child { margin-right: 0px; } + + &-active { + width: $indicator-dot-active-size; + border-radius: $indicator-border-radius; + background: $indicator-color; + opacity: 1; + } + } + + // 固定宽度 + &-fixed-width { + // 两个页码的时候 + .nut-indicator-dot { + width: 12px; + border-radius: $indicator-border-radius; + + &-active { + width: 6px; + } + } } - &-active { + &-vertical { + // 竖向固定高度 + &.nut-indicator-fixed-width { + justify-content: flex-start; + height: 21px; + width: auto; + + // 竖向两个页码 + .nut-indicator-dot { + width: 3px; + height: 12px; + border-radius: $indicator-border-radius; + + &-active { + height: 6px; + } + } + } + } + + &-line { width: $indicator-dot-active-size; + margin: 0; + border-radius: $indicator-border-radius; - background: $indicator-color; + background-color: transparent; + + &-active { + transition: transform 0.3s ease-in-out; + background: $indicator-color; + } } +} - &-vertical { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; +.nut-indicator-track { + position: relative; + &:after { + display: block; + content: ' '; + position: absolute; + width: 100%; + height: 100%; + box-sizing: border-box; + border-radius: $indicator-border-radius; + background-color: $color-border-disabled; + opacity: 0.4; + } +} + +.nut-indicator-white { + .nut-indicator { + &-dot, + &-line { + position: relative; + box-sizing: content-box; + background: rgba(255, 255, 255, 0.4); + border: 1px solid rgba(0, 0, 0, 0.06); + opacity: 1; + } + + &-line { + opacity: 0; + + &-active { + opacity: 1; + background: rgba(255, 255, 255, 1); + } + } + &-dot { + &-active { + background: rgba(255, 255, 255, 1); + } + } + } +} + +.nut-indicator-track.nut-indicator-white { + &:after { + border: 1px solid rgba(0, 0, 0, 0.06); + background: rgba(255, 255, 255, 0.4); + } +} + +.nut-indicator-vertical { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + + .nut-indicator { &-dot { margin: $indicator-dot-margin 0; @@ -46,11 +150,20 @@ &:last-child { margin-bottom: 0px; } + + &-active { + width: $indicator-dot-size; + height: $indicator-dot-active-size; + } } + } - &-active { - width: $indicator-dot-size; - height: $indicator-dot-active-size; + &.nut-indicator-track { + .nut-indicator { + &-line { + width: $indicator-dot-size; + height: $indicator-dot-active-size; + } } } } diff --git a/src/packages/indicator/indicator.taro.tsx b/src/packages/indicator/indicator.taro.tsx index 521e21bfb9..87b192b78f 100644 --- a/src/packages/indicator/indicator.taro.tsx +++ b/src/packages/indicator/indicator.taro.tsx @@ -1,31 +1,51 @@ import React, { FunctionComponent, ReactNode } from 'react' import classNames from 'classnames' -import { View } from '@tarojs/components' +import { View, ViewProps } from '@tarojs/components' + +export type IndicatorType = 'anchor' | 'slide' +export type IndicatorColor = 'primary' | 'white' export interface IndicatorProps { total: number current: number direction: string + color: IndicatorColor + type: IndicatorType } + const defaultProps = { - total: 3, + total: 2, current: 0, direction: 'horizontal', + color: 'primary', + type: 'anchor', } as IndicatorProps + const classPrefix = `nut-indicator` + export const Indicator: FunctionComponent< - Partial & React.HTMLAttributes + Partial & ViewProps > = (props) => { - const { total, current, children, className, direction, style } = { + const { + color, + type, + total, + current, + children, + className, + direction, + ...rest + } = { ...defaultProps, ...props, } const classes = classNames({ [`${classPrefix}-vertical`]: direction === 'vertical', + [`${classPrefix}-white`]: color === 'white', + [`${classPrefix}-track`]: type === 'slide', }) - const classPrefixV = - direction === 'vertical' ? `${classPrefix}-vertical` : classPrefix - const renderElement = () => { + + const renderDotElement = () => { const childs: ReactNode[] = [] for (let item = 0; item < total; item++) { childs.push( @@ -33,22 +53,51 @@ export const Indicator: FunctionComponent< children || ( ) ) : ( - + ) ) } return childs } + const renderLineElement = () => { + const trackWidth: number = 21 + const sliderWidth: number = 6 + const stride = (trackWidth - sliderWidth) / (total - 1) + return ( + + ) + } + const renderByType = (type: IndicatorType) => { + switch (type) { + case 'slide': + return renderLineElement() + default: + return renderDotElement() + } + } + + function maybeFixedWidth() { + if (total === 2 || type === 'slide') { + return `${classPrefix}-fixed-width` + } + return '' + } + return ( - - {renderElement()} + + {renderByType(type)} ) } diff --git a/src/packages/indicator/indicator.tsx b/src/packages/indicator/indicator.tsx index 75160d621b..eba34461ca 100644 --- a/src/packages/indicator/indicator.tsx +++ b/src/packages/indicator/indicator.tsx @@ -1,15 +1,23 @@ import React, { FunctionComponent, ReactNode } from 'react' import classNames from 'classnames' +export type IndicatorType = 'anchor' | 'slide' +export type IndicatorColor = 'primary' | 'white' + export interface IndicatorProps { total: number current: number direction: string + color: IndicatorColor + type: IndicatorType } + const defaultProps = { - total: 3, + total: 2, current: 0, direction: 'horizontal', + color: 'primary', + type: 'anchor', } as IndicatorProps const classPrefix = `nut-indicator` @@ -17,16 +25,26 @@ const classPrefix = `nut-indicator` export const Indicator: FunctionComponent< Partial & React.HTMLAttributes > = (props) => { - const { total, current, children, className, direction, ...rest } = { + const { + color, + type, + total, + current, + children, + className, + direction, + ...rest + } = { ...defaultProps, ...props, } const classes = classNames({ [`${classPrefix}-vertical`]: direction === 'vertical', + [`${classPrefix}-white`]: color === 'white', + [`${classPrefix}-track`]: type === 'slide', }) - const classPrefixV = - direction === 'vertical' ? `${classPrefix}-vertical` : classPrefix - const renderElement = () => { + + const renderDotElement = () => { const childs: ReactNode[] = [] for (let item = 0; item < total; item++) { childs.push( @@ -34,22 +52,51 @@ export const Indicator: FunctionComponent< children || (
) ) : ( -
+
) ) } return childs } + const renderLineElement = () => { + const trackWidth: number = 21 + const sliderWidth: number = 6 + const stride = (trackWidth - sliderWidth) / (total - 1) + return ( +
+ ) + } + const renderByType = (type: IndicatorType) => { + switch (type) { + case 'slide': + return renderLineElement() + default: + return renderDotElement() + } + } + + function maybeFixedWidth() { + if (total === 2 || type === 'slide') { + return `${classPrefix}-fixed-width` + } + return '' + } + return ( -
- {renderElement()} +
+ {renderByType(type)}
) } diff --git a/src/styles/variables.scss b/src/styles/variables.scss index cf19277565..cb41db5bed 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -1781,17 +1781,20 @@ $tabs-tabpane-backgroundColor: var( ) !default; // indicator(✅) $indicator-color: var(--nutui-indicator-color, $color-primary) !default; -$indicator-dot-color: var( - --nutui-indicator-dot-color, - $color-text-disabled -) !default; -$indicator-dot-size: var(--nutui-indicator-dot-size, 4px) !default; +$indicator-dot-color: var(--nutui-indicator-dot-color, $color-border) !default; +$indicator-dot-size: var(--nutui-indicator-dot-size, 3px) !default; $indicator-dot-active-size: var( --nutui-indicator-dot-active-size, - 8px + 6px +) !default; +$indicator-border-radius: var( + --nutui-indicator-border-radius, + $radius-xxs +) !default; +$indicator-dot-margin: var( + --nutui-indicator-dot-margin, + $spacing-xxxs ) !default; -$indicator-border-radius: var(--nutui-indicator-border-radius, 2px) !default; -$indicator-dot-margin: var(--nutui-indicator-dot-margin, 2px) !default; // menu(✅) $menu-scroll-fixed-top: var(--nutui-menu-scroll-fixed-top, 0) !default; From a91e0e241d06cb673a06be514c7d41d84f2f35af Mon Sep 17 00:00:00 2001 From: songsong <353833373@qq.com> Date: Fri, 27 Dec 2024 14:48:33 +0800 Subject: [PATCH 2/2] feat(price): v15 (#2885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 解决微信小程序滚动报错问题 * fix(countup): 分隔符文字颜色支持css变量修改 * feat(price): v15 * fix: demo和文档更新 * fix: update test * fix: update type * fix: update test * chore: update sologn * fix: update doc * fix: update test * fix: update card test * fix: props type修改为color --- migrate-from-v2.md | 5 +- src/config.json | 1 + .../__test__/__snapshots__/card.spec.tsx.snap | 18 +-- src/packages/cell/cell.taro.tsx | 18 +-- src/packages/cell/cell.tsx | 16 +-- src/packages/cell/index.taro.ts | 2 +- src/packages/cell/index.ts | 2 +- src/packages/cell/types.ts | 14 +++ .../__snapshots__/price.spec.tsx.snap | 110 +++++++++++++++--- src/packages/price/__test__/price.spec.tsx | 12 ++ src/packages/price/demo.taro.tsx | 12 +- src/packages/price/demo.tsx | 12 +- src/packages/price/demos/h5/demo1.tsx | 15 ++- src/packages/price/demos/h5/demo2.tsx | 2 +- src/packages/price/demos/h5/demo3.tsx | 2 +- src/packages/price/demos/h5/demo4.tsx | 2 +- src/packages/price/demos/h5/demo5.tsx | 8 +- src/packages/price/demos/h5/demo6.tsx | 2 +- src/packages/price/demos/h5/demo7.tsx | 2 +- src/packages/price/demos/h5/demo8.tsx | 6 +- src/packages/price/demos/h5/demo9.tsx | 42 +++++++ src/packages/price/demos/taro/demo1.tsx | 15 ++- src/packages/price/demos/taro/demo2.tsx | 2 +- src/packages/price/demos/taro/demo3.tsx | 2 +- src/packages/price/demos/taro/demo4.tsx | 2 +- src/packages/price/demos/taro/demo5.tsx | 8 +- src/packages/price/demos/taro/demo6.tsx | 2 +- src/packages/price/demos/taro/demo7.tsx | 2 +- src/packages/price/demos/taro/demo8.tsx | 6 +- src/packages/price/demos/taro/demo9.tsx | 46 ++++++++ src/packages/price/doc.en-US.md | 42 ++++--- src/packages/price/doc.md | 40 ++++--- src/packages/price/doc.taro.md | 41 ++++--- src/packages/price/doc.zh-TW.md | 50 +++++--- src/packages/price/index.taro.ts | 2 +- src/packages/price/index.ts | 2 +- src/packages/price/price.scss | 58 +++++++-- src/packages/price/price.taro.tsx | 101 +++++++++------- src/packages/price/price.tsx | 57 ++++----- src/packages/price/types.ts | 14 +++ src/styles/jd-font.scss | 10 +- src/styles/variables.scss | 51 +++++--- 42 files changed, 588 insertions(+), 268 deletions(-) create mode 100644 src/packages/cell/types.ts create mode 100644 src/packages/price/demos/h5/demo9.tsx create mode 100644 src/packages/price/demos/taro/demo9.tsx create mode 100644 src/packages/price/types.ts diff --git a/migrate-from-v2.md b/migrate-from-v2.md index de7987c625..cb1ec0b797 100644 --- a/migrate-from-v2.md +++ b/migrate-from-v2.md @@ -729,9 +729,8 @@ plugins: [ #### Price -- `decimalDigits` 重命名为 `digits` -- 移除 `needSymbol`,通过 `symbol` 判断是否需要加上 symbol 符号 -- 新增 `line`,是否展示划线价 +- 修改 `size`,增加 'xlarge' 尺寸 +- 新增 `color`, 价格类型 #### Progress diff --git a/src/config.json b/src/config.json index 3b5b447e8b..9767d8cab4 100644 --- a/src/config.json +++ b/src/config.json @@ -1084,6 +1084,7 @@ "sort": 4, "show": true, "taro": true, + "v15": true, "author": "songsong" }, { diff --git a/src/packages/card/__test__/__snapshots__/card.spec.tsx.snap b/src/packages/card/__test__/__snapshots__/card.spec.tsx.snap index 393ccf15cd..8617abeeef 100644 --- a/src/packages/card/__test__/__snapshots__/card.spec.tsx.snap +++ b/src/packages/card/__test__/__snapshots__/card.spec.tsx.snap @@ -44,7 +44,7 @@ exports[`description slot test 1`] = ` class="nut-card-right-price" >
| ITouchEvent ) => void @@ -32,12 +26,12 @@ const defaultProps = { onClick: ( event: React.MouseEvent | ITouchEvent ) => {}, -} as CellProps +} as CellTaroProps const classPrefix = 'nut-cell' export const Cell: FunctionComponent< - Partial & Omit, 'title'> + Partial & Omit, 'title'> > & { Group: typeof CellGroup } = (props) => { const ctx = useContext(CellGroupContext) const { diff --git a/src/packages/cell/cell.tsx b/src/packages/cell/cell.tsx index 9281ee7a42..e63023173a 100644 --- a/src/packages/cell/cell.tsx +++ b/src/packages/cell/cell.tsx @@ -1,20 +1,10 @@ -import React, { FunctionComponent, ReactNode, useContext } from 'react' +import React, { FunctionComponent, useContext } from 'react' import classNames from 'classnames' -import { BasicComponent, ComponentDefaults } from '@/utils/typings' +import { ComponentDefaults } from '@/utils/typings' import CellGroup from '@/packages/cellgroup' import CellGroupContext from '@/packages/cellgroup/context' import { useRtl } from '@/packages/configprovider' - -export interface CellProps extends BasicComponent { - title: ReactNode - description: ReactNode - extra: ReactNode - radius: string | number - align: 'flex-start' | 'center' | 'flex-end' - clickable: boolean - isLast: boolean - onClick: (event: React.MouseEvent) => void -} +import { CellProps } from './types' const defaultProps = { ...ComponentDefaults, diff --git a/src/packages/cell/index.taro.ts b/src/packages/cell/index.taro.ts index 81c3a8f8db..0fd6bf07a4 100644 --- a/src/packages/cell/index.taro.ts +++ b/src/packages/cell/index.taro.ts @@ -1,4 +1,4 @@ import { Cell } from './cell.taro' -export type { CellProps } from './cell.taro' +export type { CellProps, CellAlign } from './types' export default Cell diff --git a/src/packages/cell/index.ts b/src/packages/cell/index.ts index 99f19d22a0..9f302af797 100644 --- a/src/packages/cell/index.ts +++ b/src/packages/cell/index.ts @@ -1,4 +1,4 @@ import { Cell } from './cell' -export type { CellProps } from './cell' +export type { CellProps, CellAlign } from './types' export default Cell diff --git a/src/packages/cell/types.ts b/src/packages/cell/types.ts new file mode 100644 index 0000000000..5c098df2a8 --- /dev/null +++ b/src/packages/cell/types.ts @@ -0,0 +1,14 @@ +import { BasicComponent } from '@/utils/typings' + +export type CellAlign = 'flex-start' | 'center' | 'flex-end' | 'baseline' + +export interface CellProps extends BasicComponent { + title: React.ReactNode + description: React.ReactNode + extra: React.ReactNode + radius: string | number + align: CellAlign + clickable: boolean + isLast: boolean + onClick: (event: React.MouseEvent) => void +} diff --git a/src/packages/price/__test__/__snapshots__/price.spec.tsx.snap b/src/packages/price/__test__/__snapshots__/price.spec.tsx.snap index 7b7e51561f..05f4ca4e8f 100644 --- a/src/packages/price/__test__/__snapshots__/price.spec.tsx.snap +++ b/src/packages/price/__test__/__snapshots__/price.spec.tsx.snap @@ -3,25 +3,25 @@ exports[`props digits test 1`] = `
¥
15213
.
122
@@ -32,25 +32,25 @@ exports[`props digits test 1`] = ` exports[`props symbol test 1`] = `
$
10010
.
00
@@ -61,20 +61,68 @@ exports[`props symbol test 1`] = ` exports[`props test 1`] = `
1,010
.
+ 00 +
+
+
+`; + +exports[`props test 2`] = ` +
+
+
+ 1,010 +
+
+ . +
+
+ 00 +
+
+
+`; + +exports[`props test 3`] = ` +
+
+
+ 1,010 +
+
+ . +
+
00
@@ -85,28 +133,52 @@ exports[`props test 1`] = ` exports[`props thousands test 1`] = `
$
10010
.
01
`; + +exports[`props type 1`] = ` +
+
+
+ 1,010 +
+
+ . +
+
+ 00 +
+
+
+`; diff --git a/src/packages/price/__test__/price.spec.tsx b/src/packages/price/__test__/price.spec.tsx index 9b16a75cc8..2eaed3259a 100644 --- a/src/packages/price/__test__/price.spec.tsx +++ b/src/packages/price/__test__/price.spec.tsx @@ -39,3 +39,15 @@ test('props digits test', () => { ) expect(container).toMatchSnapshot() }) + +test('props size', () => { + const { container } = render() + expect(container.querySelector('.nut-price-integer')).toHaveClass( + 'nut-price-integer-large' + ) +}) + +test('props color', () => { + const { container } = render() + expect(container.querySelector('.nut-price')).toHaveClass('nut-price-primary') +}) diff --git a/src/packages/price/demo.taro.tsx b/src/packages/price/demo.taro.tsx index 6a3eec9f03..e3e92ebfcd 100644 --- a/src/packages/price/demo.taro.tsx +++ b/src/packages/price/demo.taro.tsx @@ -11,11 +11,12 @@ import Demo5 from './demos/taro/demo5' import Demo6 from './demos/taro/demo6' import Demo7 from './demos/taro/demo7' import Demo8 from './demos/taro/demo8' +import Demo9 from './demos/taro/demo9' const PriceDemo = () => { const [translated] = useTranslate({ 'zh-CN': { - title1: '支持三种尺寸:small、normal、large', + title1: '支持尺寸:small、normal、large、xlarge', title2: '不保留小数', title3: '有人民币符号,无千位分隔', title4: '有人民币符号,有千位分隔,保留小数点后三位', @@ -23,9 +24,10 @@ const PriceDemo = () => { title6: '异步随机变更', title7: '不展示 symbol 符号', title8: '划线价', + title9: '场域分类:原子级、模块级、列表级、页面级', }, 'zh-TW': { - title1: '支持三種尺寸:small、normal、large', + title1: '支持尺寸:small、normal、large、xlarge', title2: '不保留小數', title3: '有人民幣符號,無千位分隔', title4: '有人民幣符號,有千位分隔,保留小數點後三位', @@ -33,9 +35,10 @@ const PriceDemo = () => { title6: '異步隨機變更', title7: '不展示 symbol 符號', title8: '劃線價', + title9: '場域分類:原子級、模塊級、列表級、頁面級', }, 'en-US': { - title1: 'Support three sizes:small、normal、large', + title1: 'Support sizes:small、normal、large、xlarge', title2: 'No decimals', title3: 'With RMB symbol, no thousands separator', title4: @@ -44,6 +47,7 @@ const PriceDemo = () => { title6: 'Asynchronous random changes', title7: 'Do not display symbol', title8: 'Line-through price', + title9: 'Field classification: atomic, module, list, page', }, }) return ( @@ -52,6 +56,8 @@ const PriceDemo = () => { {translated.title1} + {translated.title9} + {translated.title2} {translated.title3} diff --git a/src/packages/price/demo.tsx b/src/packages/price/demo.tsx index 28db3583b3..4b4f672e29 100644 --- a/src/packages/price/demo.tsx +++ b/src/packages/price/demo.tsx @@ -8,11 +8,12 @@ import Demo5 from './demos/h5/demo5' import Demo6 from './demos/h5/demo6' import Demo7 from './demos/h5/demo7' import Demo8 from './demos/h5/demo8' +import Demo9 from './demos/h5/demo9' const PriceDemo = () => { const [translated] = useTranslate({ 'zh-CN': { - title1: '支持三种尺寸:small、normal、large', + title1: '支持尺寸:small、normal、large、xlarge', title2: '不保留小数', title3: '有人民币符号,无千位分隔', title4: '有人民币符号,有千位分隔,保留小数点后三位', @@ -20,9 +21,10 @@ const PriceDemo = () => { title6: '异步随机变更', title7: '不展示 symbol 符号', title8: '划线价', + title9: '场域分类:原子级、模块级、列表级、页面级', }, 'zh-TW': { - title1: '支持三種尺寸:small、normal、large', + title1: '支持尺寸:small、normal、large、xlarge', title2: '不保留小數', title3: '有人民幣符號,無千位分隔', title4: '有人民幣符號,有千位分隔,保留小數點後三位', @@ -30,9 +32,10 @@ const PriceDemo = () => { title6: '異步隨機變更', title7: '不展示 symbol 符號', title8: '劃線價', + title9: '場域分類:原子級、模塊級、列表級、頁面級', }, 'en-US': { - title1: 'Support three sizes:small、normal、large', + title1: 'Support sizes:small、normal、large、xlarge', title2: 'No decimals', title3: 'With RMB symbol, no thousands separator', title4: @@ -41,6 +44,7 @@ const PriceDemo = () => { title6: 'Asynchronous random changes', title7: 'Do not display symbol', title8: 'Line-through price', + title9: 'Field classification: atomic, module, list, page', }, }) @@ -48,6 +52,8 @@ const PriceDemo = () => {

{translated.title1}

+

{translated.title9}

+

{translated.title2}

{translated.title3}

diff --git a/src/packages/price/demos/h5/demo1.tsx b/src/packages/price/demos/h5/demo1.tsx index c6f8175387..2c1df37ef5 100644 --- a/src/packages/price/demos/h5/demo1.tsx +++ b/src/packages/price/demos/h5/demo1.tsx @@ -1,19 +1,22 @@ import React from 'react' -import { Price, Cell } from '@nutui/nutui-react' +import { Price, Cell, CellGroup } from '@nutui/nutui-react' const Demo1 = () => { return ( - <> + - + - + - + - + + + + ) } export default Demo1 diff --git a/src/packages/price/demos/h5/demo2.tsx b/src/packages/price/demos/h5/demo2.tsx index fa16698314..77782262ee 100644 --- a/src/packages/price/demos/h5/demo2.tsx +++ b/src/packages/price/demos/h5/demo2.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react' const Demo2 = () => { return ( - + ) } diff --git a/src/packages/price/demos/h5/demo3.tsx b/src/packages/price/demos/h5/demo3.tsx index 60b46ccf9f..492739b3ea 100644 --- a/src/packages/price/demos/h5/demo3.tsx +++ b/src/packages/price/demos/h5/demo3.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react' const Demo3 = () => { return ( - + ) } diff --git a/src/packages/price/demos/h5/demo4.tsx b/src/packages/price/demos/h5/demo4.tsx index 34904db1d3..84f6c4c721 100644 --- a/src/packages/price/demos/h5/demo4.tsx +++ b/src/packages/price/demos/h5/demo4.tsx @@ -4,7 +4,7 @@ import { Price, Cell } from '@nutui/nutui-react' const Demo4 = () => { return ( - + ) } diff --git a/src/packages/price/demos/h5/demo5.tsx b/src/packages/price/demos/h5/demo5.tsx index efda097104..0e267ca7b6 100644 --- a/src/packages/price/demos/h5/demo5.tsx +++ b/src/packages/price/demos/h5/demo5.tsx @@ -4,13 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react' const Demo5 = () => { return ( - + ) } diff --git a/src/packages/price/demos/h5/demo6.tsx b/src/packages/price/demos/h5/demo6.tsx index 914071c963..bf0e9441be 100644 --- a/src/packages/price/demos/h5/demo6.tsx +++ b/src/packages/price/demos/h5/demo6.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react' const Demo6 = () => { return ( - + ) } diff --git a/src/packages/price/demos/h5/demo7.tsx b/src/packages/price/demos/h5/demo7.tsx index 8c6bca6e44..3f1bd0c639 100644 --- a/src/packages/price/demos/h5/demo7.tsx +++ b/src/packages/price/demos/h5/demo7.tsx @@ -14,7 +14,7 @@ const Demo7 = () => { }, []) return ( - + ) } diff --git a/src/packages/price/demos/h5/demo8.tsx b/src/packages/price/demos/h5/demo8.tsx index b7f0c82e8d..73b8a33812 100644 --- a/src/packages/price/demos/h5/demo8.tsx +++ b/src/packages/price/demos/h5/demo8.tsx @@ -3,10 +3,10 @@ import { Cell, Price } from '@nutui/nutui-react' const Demo8 = () => { return ( - - + +   - + ) } diff --git a/src/packages/price/demos/h5/demo9.tsx b/src/packages/price/demos/h5/demo9.tsx new file mode 100644 index 0000000000..c2e60a009b --- /dev/null +++ b/src/packages/price/demos/h5/demo9.tsx @@ -0,0 +1,42 @@ +import React from 'react' +import { Cell, CellGroup, Price } from '@nutui/nutui-react' + +const Demo9 = () => { + const colorStyles = { + color: 'var(--nutui-color-primary)', + fontSize: '12px', + lineHeight: 1, + } + const exclusivePriceStyles = { + margin: '0 8px 0 4px', + } + const priceStyles = { + margin: '0 4px 0 2px', + } + + return ( + + + + 专享价 + + + + + 粉丝到手价 + + + + + 秒杀价 + + + + + 专享价 + + + + ) +} +export default Demo9 diff --git a/src/packages/price/demos/taro/demo1.tsx b/src/packages/price/demos/taro/demo1.tsx index 8ad987499a..1ac546bffb 100644 --- a/src/packages/price/demos/taro/demo1.tsx +++ b/src/packages/price/demos/taro/demo1.tsx @@ -1,19 +1,22 @@ import React from 'react' -import { Price, Cell } from '@nutui/nutui-react-taro' +import { Price, Cell, CellGroup } from '@nutui/nutui-react-taro' const Demo1 = () => { return ( - <> + - + - + - + - + + + + ) } export default Demo1 diff --git a/src/packages/price/demos/taro/demo2.tsx b/src/packages/price/demos/taro/demo2.tsx index ad47a89ec3..03fdf3def3 100644 --- a/src/packages/price/demos/taro/demo2.tsx +++ b/src/packages/price/demos/taro/demo2.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react-taro' const Demo2 = () => { return ( - + ) } diff --git a/src/packages/price/demos/taro/demo3.tsx b/src/packages/price/demos/taro/demo3.tsx index 7a60184001..9505f09abe 100644 --- a/src/packages/price/demos/taro/demo3.tsx +++ b/src/packages/price/demos/taro/demo3.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react-taro' const Demo3 = () => { return ( - + ) } diff --git a/src/packages/price/demos/taro/demo4.tsx b/src/packages/price/demos/taro/demo4.tsx index 12bba9ecdf..658567849a 100644 --- a/src/packages/price/demos/taro/demo4.tsx +++ b/src/packages/price/demos/taro/demo4.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react-taro' const Demo4 = () => { return ( - + ) } diff --git a/src/packages/price/demos/taro/demo5.tsx b/src/packages/price/demos/taro/demo5.tsx index 99d7d22d9a..cc23abd5f8 100644 --- a/src/packages/price/demos/taro/demo5.tsx +++ b/src/packages/price/demos/taro/demo5.tsx @@ -4,13 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react-taro' const Demo5 = () => { return ( - + ) } diff --git a/src/packages/price/demos/taro/demo6.tsx b/src/packages/price/demos/taro/demo6.tsx index 00fa1639c6..d1755c9480 100644 --- a/src/packages/price/demos/taro/demo6.tsx +++ b/src/packages/price/demos/taro/demo6.tsx @@ -4,7 +4,7 @@ import { Cell, Price } from '@nutui/nutui-react-taro' const Demo6 = () => { return ( - + ) } diff --git a/src/packages/price/demos/taro/demo7.tsx b/src/packages/price/demos/taro/demo7.tsx index eb423cc18f..99fbf41da6 100644 --- a/src/packages/price/demos/taro/demo7.tsx +++ b/src/packages/price/demos/taro/demo7.tsx @@ -14,7 +14,7 @@ const Demo7 = () => { }, []) return ( - + ) } diff --git a/src/packages/price/demos/taro/demo8.tsx b/src/packages/price/demos/taro/demo8.tsx index 706db12db0..212a776e4c 100644 --- a/src/packages/price/demos/taro/demo8.tsx +++ b/src/packages/price/demos/taro/demo8.tsx @@ -4,10 +4,10 @@ import { Text } from '@tarojs/components' const Demo8 = () => { return ( - - + +   - + ) } diff --git a/src/packages/price/demos/taro/demo9.tsx b/src/packages/price/demos/taro/demo9.tsx new file mode 100644 index 0000000000..cd7b102f31 --- /dev/null +++ b/src/packages/price/demos/taro/demo9.tsx @@ -0,0 +1,46 @@ +import React from 'react' +import { Cell, CellGroup, Price } from '@nutui/nutui-react-taro' +import { Text } from '@tarojs/components' +import { harmony } from '@/utils/platform-taro' + +const Demo9 = () => { + const colorStyles = { + color: harmony() ? '#ff0f23' : 'var(--nutui-color-primary)', + fontSize: 12, + lineHeight: 1, + } + const exclusivePriceStyles = { + marginLeft: 4, + marginRight: 8, + } + const priceStyles = { + marginLeft: 2, + marginRight: 4, + } + + return ( + + + + 专享价 + + + + + 粉丝到手价 + + + + + 秒杀价 + + + + + 专享价 + + + + ) +} +export default Demo9 diff --git a/src/packages/price/doc.en-US.md b/src/packages/price/doc.en-US.md index ce88f8f5f3..6efc166c41 100644 --- a/src/packages/price/doc.en-US.md +++ b/src/packages/price/doc.en-US.md @@ -10,7 +10,7 @@ import { Price } from '@nutui/nutui-react' ## Demo -### Support three sizes:small、normal、large +### Support sizes:small、normal、large、xlarge :::demo @@ -18,6 +18,14 @@ import { Price } from '@nutui/nutui-react' ::: +### Field classification: atomic, module, list, page + +:::demo + + + +::: + ### No decimals :::demo @@ -80,12 +88,13 @@ import { Price } from '@nutui/nutui-react' | Property | Description | Type | Default | | --- | --- | --- | --- | +| color | Price type | `primary` \| `gray` \| `darkgray` | `primary` | | price | Price | `number` | `0` | | symbol | Symbol type | `string` | `¥` | | digits | Decimal digits | `number` | `2` | | thousands | Thousands separation | `boolean` | `false` | | position | The symbol appear before or after the price,`before`、`after` | `string` | `before` | -| size | Size,`large`、`normal`、`small` | `string` | `large` | +| size | Size,`xlarge` \| `large` \| `normal` \| `small` | `string` | `large` | | line | Line-through price | `boolean` | `false` | ## Theming @@ -96,15 +105,20 @@ The component provides the following CSS variables, which can be used to customi | Name | Description | Default | | --- | --- | --- | -| \--nutui-price-symbol-big-size | large Size Symbol font size | `18px` | -| \--nutui-price-integer-big-size | large Size Integer partial font size | `24px` | -| \--nutui-price-decimal-big-size | large Size Size of the decimal part of the font | `18px` | -| \--nutui-price-symbol-medium-size | normal Size Symbol font size | `14px` | -| \--nutui-price-integer-medium-size | normal Size Integer partial font size | `16px` | -| \--nutui-price-decimal-medium-size | normal Size Size of the decimal part of the font | `14px` | -| \--nutui-price-symbol-small-size | small Size Symbol font size | `10px` | -| \--nutui-price-integer-small-size | small Size Integer partial font size | `12px` | -| \--nutui-price-decimal-small-size | small Size Size of the decimal part of the font | `10px` | -| \--nutui-price-line-font-size | Line-through price Font size | `10px` | -| \--nutui-price-line-color | Line through price color | `#757575` | -| \--nutui-price-symbol-padding-right | Symbol padding right | `1px` | +| \--nutui-price-primary-color | Text color when type is primary | `#ff0f23` | +| \--nutui-price-color | Text color when type is gray | `#888b94` | +| \--nutui-price-darkgray-color | Text color when type is darkgray | `#1a1a1a` | +| \--nutui-price-line-color | Underline price color | `#888b94` | +| \--nutui-price-symbol-padding-right | Right padding of symbol | `0px` | +| \--nutui-price-symbol-xlarge-size | xlarge size symbol font size | `12px` | +| \--nutui-price-integer-xlarge-size | xlarge size integer part font size | `24px` | +| \--nutui-price-decimal-xlarge-size | xlarge size decimal part font size | `12px` | +| \--nutui-price-symbol-large-size | large size symbol font size | `12px` | +| \--nutui-price-integer-large-size | large size integer part font size | `18px` | +| \--nutui-price-decimal-large-size | large size decimal part font size | `12px` | +| \--nutui-price-symbol-normal-size | normal size symbol font size | `12px` | +| \--nutui-price-integer-normal-size | normal size integer part font size | `16px` | +| \--nutui-price-decimal-normal-size | normal size decimal part font size | `12px` | +| \--nutui-price-symbol-small-size | small size symbol font size | `12px` | +| \--nutui-price-integer-small-size | small Size integer part font size | `12px` | +| \--nutui-price-decimal-small-size | small Size decimal part font size | `12px` | diff --git a/src/packages/price/doc.md b/src/packages/price/doc.md index 5ba4f1f1b9..f19ad0b34f 100644 --- a/src/packages/price/doc.md +++ b/src/packages/price/doc.md @@ -10,7 +10,7 @@ import { Price } from '@nutui/nutui-react' ## 示例代码 -### 基础用法 small normal large +### 支持尺寸:small、normal、large、xlarge :::demo @@ -18,6 +18,14 @@ import { Price } from '@nutui/nutui-react' ::: +### 场域分类:原子级、模块级、列表级、页面级 + +:::demo + + + +::: + ### 不保留小数 :::demo @@ -80,12 +88,13 @@ import { Price } from '@nutui/nutui-react' | 属性 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | +| color | 价格类型 | `primary` \| `gray` \| `darkgray` | `primary` | | price | 价格数量 | `number` | `0` | | symbol | 符号类型 | `string` | `¥` | | digits | 小数位位数 | `number` | `2` | | thousands | 是否按照千分号形式显示 | `boolean` | `false` | | position | 符号显示在价格前或者后,`before`、`after` | `string` | `before` | -| size | 价格尺寸,`large`、`normal`、`small` | `string` | `large` | +| size | 价格尺寸,`xlarge` \| `large` \| `normal` \| `small` | `string` | `normal` | | line | 是否划线价 | `boolean` | `false` | ## 主题定制 @@ -96,15 +105,20 @@ import { Price } from '@nutui/nutui-react' | 名称 | 说明 | 默认值 | | --- | --- | --- | -| \--nutui-price-symbol-big-size | large 尺寸符号字体大小 | `18px` | -| \--nutui-price-integer-big-size | large 尺寸整数部分字体大小 | `24px` | -| \--nutui-price-decimal-big-size | large 尺寸小数部分字体大小 | `18px` | -| \--nutui-price-symbol-medium-size | normal 尺寸符号字体大小 | `14px` | -| \--nutui-price-integer-medium-size | normal 尺寸整数部分字体大小 | `16px` | -| \--nutui-price-decimal-medium-size | normal 尺寸小数部分字体大小 | `14px` | -| \--nutui-price-symbol-small-size | small 尺寸符号字体大小 | `10px` | +| \--nutui-price-primary-color | type为primary时文字颜色 | `#ff0f23` | +| \--nutui-price-color | type为gray时文字颜色 | `#888b94` | +| \--nutui-price-darkgray-color | type为darkgray时文字颜色 | `#1a1a1a` | +| \--nutui-price-line-color | 划线价颜色 | `#888b94` | +| \--nutui-price-symbol-padding-right | 符号的右内边距 | `0px` | +| \--nutui-price-symbol-xlarge-size | xlarge 尺寸符号字体大小 | `12px` | +| \--nutui-price-integer-xlarge-size | xlarge 尺寸整数部分字体大小 | `24px` | +| \--nutui-price-decimal-xlarge-size | xlarge 尺寸小数部分字体大小 | `12px` | +| \--nutui-price-symbol-large-size | large 尺寸符号字体大小 | `12px` | +| \--nutui-price-integer-large-size | large 尺寸整数部分字体大小 | `18px` | +| \--nutui-price-decimal-large-size | large 尺寸小数部分字体大小 | `12px` | +| \--nutui-price-symbol-normal-size | normal 尺寸符号字体大小 | `12px` | +| \--nutui-price-integer-normal-size | normal 尺寸整数部分字体大小 | `16px` | +| \--nutui-price-decimal-normal-size | normal 尺寸小数部分字体大小 | `12px` | +| \--nutui-price-symbol-small-size | small 尺寸符号字体大小 | `12px` | | \--nutui-price-integer-small-size | small 尺寸整数部分字体大小 | `12px` | -| \--nutui-price-decimal-small-size | small 尺寸小数部分字体大小 | `10px` | -| \--nutui-price-line-font-size | 划线价字体大小 | `10px` | -| \--nutui-price-line-color | 划线价颜色 | `#757575` | -| \--nutui-price-symbol-padding-right | 符号的右内边距 | `1px` | +| \--nutui-price-decimal-small-size | small 尺寸小数部分字体大小 | `12px` | diff --git a/src/packages/price/doc.taro.md b/src/packages/price/doc.taro.md index c80ccdccef..2ca6dc6736 100644 --- a/src/packages/price/doc.taro.md +++ b/src/packages/price/doc.taro.md @@ -10,7 +10,7 @@ import { Price } from '@nutui/nutui-react-taro' ## 示例代码 -### 基础用法 small normal large +### 支持尺寸:small、normal、large、xlarge :::demo @@ -18,6 +18,14 @@ import { Price } from '@nutui/nutui-react-taro' ::: +### 场域分类:原子级、模块级、列表级、页面级 + +:::demo + + + +::: + ### 不保留小数 :::demo @@ -80,12 +88,12 @@ import { Price } from '@nutui/nutui-react-taro' | 属性 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | -| price | 价格数量 | `number` | `0` | +| type | 价格类型 | `primary` \| `gray` \| `darkgray` | `primary` | | symbol | 符号类型 | `string` | `¥` | | digits | 小数位位数 | `number` | `2` | | thousands | 是否按照千分号形式显示 | `boolean` | `false` | | position | 符号显示在价格前或者后,`before`、`after` | `string` | `before` | -| size | 价格尺寸,`large`、`normal`、`small` | `string` | `large` | +| size | 价格尺寸,`xlarge` \| `large` \| `normal` \| `small` | `string` | `normal` | | line | 是否划线价 | `boolean` | `false` | ## 主题定制 @@ -96,15 +104,20 @@ import { Price } from '@nutui/nutui-react-taro' | 名称 | 说明 | 默认值 | | --- | --- | --- | -| \--nutui-price-symbol-big-size | large 尺寸符号字体大小 | `18px` | -| \--nutui-price-integer-big-size | large 尺寸整数部分字体大小 | `24px` | -| \--nutui-price-decimal-big-size | large 尺寸小数部分字体大小 | `18px` | -| \--nutui-price-symbol-medium-size | normal 尺寸符号字体大小 | `14px` | -| \--nutui-price-integer-medium-size | normal 尺寸整数部分字体大小 | `16px` | -| \--nutui-price-decimal-medium-size | normal 尺寸小数部分字体大小 | `14px` | -| \--nutui-price-symbol-small-size | small 尺寸符号字体大小 | `10px` | +| \--nutui-price-primary-color | type为primary时文字颜色 | `#ff0f23` | +| \--nutui-price-color | type为gray时文字颜色 | `#888b94` | +| \--nutui-price-darkgray-color | type为darkgray时文字颜色 | `#1a1a1a` | +| \--nutui-price-line-color | 划线价颜色 | `#888b94` | +| \--nutui-price-symbol-padding-right | 符号的右内边距 | `0px` | +| \--nutui-price-symbol-xlarge-size | xlarge 尺寸符号字体大小 | `12px` | +| \--nutui-price-integer-xlarge-size | xlarge 尺寸整数部分字体大小 | `24px` | +| \--nutui-price-decimal-xlarge-size | xlarge 尺寸小数部分字体大小 | `12px` | +| \--nutui-price-symbol-large-size | large 尺寸符号字体大小 | `12px` | +| \--nutui-price-integer-large-size | large 尺寸整数部分字体大小 | `18px` | +| \--nutui-price-decimal-large-size | large 尺寸小数部分字体大小 | `12px` | +| \--nutui-price-symbol-normal-size | normal 尺寸符号字体大小 | `12px` | +| \--nutui-price-integer-normal-size | normal 尺寸整数部分字体大小 | `16px` | +| \--nutui-price-decimal-normal-size | normal 尺寸小数部分字体大小 | `12px` | +| \--nutui-price-symbol-small-size | small 尺寸符号字体大小 | `12px` | | \--nutui-price-integer-small-size | small 尺寸整数部分字体大小 | `12px` | -| \--nutui-price-decimal-small-size | small 尺寸小数部分字体大小 | `10px` | -| \--nutui-price-line-font-size | 划线价字体大小 | `10px` | -| \--nutui-price-line-color | 划线价颜色 | `#757575` | -| \--nutui-price-symbol-padding-right | 符号的右内边距 | `1px` | +| \--nutui-price-decimal-small-size | small 尺寸小数部分字体大小 | `12px` | diff --git a/src/packages/price/doc.zh-TW.md b/src/packages/price/doc.zh-TW.md index a795260050..6d27fe12a8 100644 --- a/src/packages/price/doc.zh-TW.md +++ b/src/packages/price/doc.zh-TW.md @@ -1,6 +1,6 @@ # Price 價格 -用來對商品價格數值的小數點前後部分應用不同樣式,還支持人民幣符號、仟位分隔符、設置小數點位數等功能。 +用來對商品價格數值的小數點前後部分應用不同樣式,還支持人民幣符號、千位分隔符、設置小數點位數等功能。 ## 引入 @@ -10,7 +10,7 @@ import { Price } from '@nutui/nutui-react' ## 示例代碼 -### 基礎用法 small normal large +### 支持尺寸:small、normal、large、xlarge :::demo @@ -18,6 +18,14 @@ import { Price } from '@nutui/nutui-react' ::: +### 場域分類:原子級、模塊級、列表級、頁面級 + +:::demo + + + +::: + ### 不保留小數 :::demo @@ -26,7 +34,7 @@ import { Price } from '@nutui/nutui-react' ::: -### 有人民幣符號,無仟位分隔 +### 有人民幣符號,無千位分隔 :::demo @@ -34,7 +42,7 @@ import { Price } from '@nutui/nutui-react' ::: -### 帶人民幣符號,有仟位分隔,保留小數點後三位 +### 帶人民幣符號,有千位分隔,保留小數點後三位 :::demo @@ -80,15 +88,16 @@ import { Price } from '@nutui/nutui-react' | 屬性 | 說明 | 類型 | 默認值 | | --- | --- | --- | --- | +| color | 價格類型 | `primary` \| `gray` \| `darkgray` | `primary` | | price | 價格數量 | `number` | `0` | | symbol | 符號類型 | `string` | `¥` | | digits | 小數位位數 | `number` | `2` | -| thousands | 是否按照仟分號形式顯示 | `boolean` | `false` | +| thousands | 是否按照千分號形式顯示 | `boolean` | `false` | | position | 符號顯示在價格前或者後,`before`、`after` | `string` | `before` | -| size | 價格尺寸,`large`、`normal`、`small` | `string` | `large` | +| size | 價格尺寸,`xlarge` \| `large` \| `normal` \| `small` | `string` | `normal` | | line | 是否劃線價 | `boolean` | `false` | -## 主題定制 +## 主題定製 ### 樣式變量 @@ -96,15 +105,20 @@ import { Price } from '@nutui/nutui-react' | 名稱 | 說明 | 默認值 | | --- | --- | --- | -| \--nutui-price-symbol-big-size | large 尺寸符號字體大小 | `18px` | -| \--nutui-price-integer-big-size | large 尺寸整數部分字體大小 | `24px` | -| \--nutui-price-decimal-big-size | large 尺寸小數部分字體大小 | `18px` | -| \--nutui-price-symbol-medium-size | normal 尺寸符號字體大小 | `14px` | -| \--nutui-price-integer-medium-size | normal 尺寸整數部分字體大小 | `16px` | -| \--nutui-price-decimal-medium-size | normal 尺寸小數部分字體大小 | `14px` | -| \--nutui-price-symbol-small-size | small 尺寸符號字體大小 | `10px` | +| \--nutui-price-primary-color | type為primary時文字顏色 | `#ff0f23` | +| \--nutui-price-color | type為gray時文字顏色 | `#888b94` | +| \--nutui-price-darkgray-color | type為darkgray時文字顏色 | `#1a1a1a` | +| \--nutui-price-line-color | 劃線價顏色 | `#888b94` | +| \--nutui-price-symbol-padding-right | 符號的右內邊距 | `0px` | +| \--nutui-price-symbol-xlarge-size | xlarge 尺寸符號字體大小 | `12px` | +| \--nutui-price-integer-xlarge-size | xlarge 尺寸整數部分字體大小 | `24px` | +| \--nutui-price-decimal-xlarge-size | xlarge 尺寸小數部分字體大小 | `12px` | +| \--nutui-price-symbol-large-size | large 尺寸符號字體大小 | `12px` | +| \--nutui-price-integer-large-size | large 尺寸整數部分字體大小 | `18px` | +| \--nutui-price-decimal-large-size | large 尺寸小數部分字體大小 | `12px` | +| \--nutui-price-symbol-normal-size | normal 尺寸符號字體大小 | `12px` | +| \--nutui-price-integer-normal-size | normal 尺寸整數部分字體大小 | `16px` | +| \--nutui-price-decimal-normal-size | normal 尺寸小數部分字體大小 | `12px` | +| \--nutui-price-symbol-small-size | small 尺寸符號字體大小 | `12px` | | \--nutui-price-integer-small-size | small 尺寸整數部分字體大小 | `12px` | -| \--nutui-price-decimal-small-size | small 尺寸小數部分字體大小 | `10px` | -| \--nutui-price-line-font-size | 劃線價字體大小 | `10px` | -| \--nutui-price-line-color | 劃線價顏色 | `#757575` | -| \--nutui-price-symbol-padding-right | 符號的右內邊距 | `1px` | +| \--nutui-price-decimal-small-size | small 尺寸小數部分字體大小 | `12px` | diff --git a/src/packages/price/index.taro.ts b/src/packages/price/index.taro.ts index 647e5ce6ad..379abb8c0a 100644 --- a/src/packages/price/index.taro.ts +++ b/src/packages/price/index.taro.ts @@ -1,4 +1,4 @@ import { Price } from './price.taro' -export type { PriceProps } from './price.taro' +export type { PriceProps, PriceSize, PriceColor } from './types' export default Price diff --git a/src/packages/price/index.ts b/src/packages/price/index.ts index c9b2829a34..3a4847c6df 100644 --- a/src/packages/price/index.ts +++ b/src/packages/price/index.ts @@ -1,4 +1,4 @@ import { Price } from './price' -export type { PriceProps } from './price' +export type { PriceProps, PriceSize, PriceColor } from './types' export default Price diff --git a/src/packages/price/price.scss b/src/packages/price/price.scss index 8d600e0312..cdfa63ba19 100644 --- a/src/packages/price/price.scss +++ b/src/packages/price/price.scss @@ -8,15 +8,45 @@ &-symbol, &-integer, &-decimal { - color: $color-primary; + color: $price-color; + font-family: 'JD'; + line-height: 1; + } + + &-darkgray { + .nut-price { + &-symbol, + &-integer, + &-decimal { + font-family: 'JD-Bold'; + color: $price-darkgray-color; + } + } + } + + &-primary { + .nut-price { + &-symbol, + &-integer, + &-decimal { + font-family: 'JD-Bold'; + color: $price-primary-color; + } + } } &-symbol { - font-size: $price-symbol-medium-size; padding-right: $price-symbol-padding-right; + &-xlarge { + font-size: $price-symbol-xlarge-size; + } &-large { - font-size: $price-symbol-big-size; + font-size: $price-symbol-large-size; + } + + &-normal { + font-size: $price-symbol-normal-size; } &-small { @@ -30,10 +60,16 @@ } &-integer { - font-size: $price-integer-medium-size; + &-xlarge { + font-size: $price-integer-xlarge-size; + } &-large { - font-size: $price-integer-big-size; + font-size: $price-integer-large-size; + } + + &-normal { + font-size: $price-integer-normal-size; } &-small { @@ -42,10 +78,16 @@ } &-decimal { - font-size: $price-decimal-medium-size; + &-xlarge { + font-size: $price-decimal-xlarge-size; + } &-large { - font-size: $price-decimal-big-size; + font-size: $price-decimal-large-size; + } + + &-normal { + font-size: $price-decimal-normal-size; } &-small { @@ -55,7 +97,5 @@ &-line { text-decoration: line-through $price-line-color; - font-size: $price-line-font-size; - color: $price-line-color; } } diff --git a/src/packages/price/price.taro.tsx b/src/packages/price/price.taro.tsx index 91484281ce..3585c83782 100644 --- a/src/packages/price/price.taro.tsx +++ b/src/packages/price/price.taro.tsx @@ -1,30 +1,25 @@ import React, { FunctionComponent } from 'react' -import { Text } from '@tarojs/components' +import { Text, View } from '@tarojs/components' import classNames from 'classnames' -import { BasicComponent, ComponentDefaults } from '@/utils/typings' +import { ComponentDefaults } from '@/utils/typings' import { useRtl } from '@/packages/configprovider/index.taro' +import { PriceProps } from './types' +import { harmony } from '@/utils/platform-taro' -export interface PriceProps extends BasicComponent { - price: number | string - symbol: string - digits: number - thousands: boolean - position: string - size: string - line: boolean -} const defaultProps = { ...ComponentDefaults, + color: 'primary', price: 0, symbol: '¥', digits: 2, thousands: false, position: 'before', - size: 'large', + size: 'normal', line: false, } as PriceProps export const Price: FunctionComponent> = (props) => { const { + color, price, symbol, digits, @@ -61,12 +56,11 @@ export const Price: FunctionComponent> = (props) => { if (Number(num) === 0) { num = 0 } + num = num.toString() + if (checkPoint(num)) { - num = Number(num).toFixed(digits) num = typeof num.split('.') === 'string' ? num.split('.') : num.split('.')[0] - } else { - num = num.toString() } if (thousands) { return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') @@ -109,40 +103,59 @@ export const Price: FunctionComponent> = (props) => { ) } - - return ( - - {symbol && position === 'before' ? renderSymbol() : null} - - {formatThousands(price)} - - {digits !== 0 ? ( + const renderInner = () => { + return ( + <> + {symbol && position === 'before' ? renderSymbol() : null} - . + {formatThousands(price)} - ) : null} - - {formatDecimal(price)} - - {symbol && position === 'after' ? renderSymbol() : null} - + {digits ? ( + <> + + . + + + {formatDecimal(price)} + + + ) : null} + + {symbol && position === 'after' ? renderSymbol() : null} + + ) + } + + return ( + <> + {harmony() ? ( + + {renderInner()} + + ) : ( + + {renderInner()} + + )} + ) } diff --git a/src/packages/price/price.tsx b/src/packages/price/price.tsx index a6bbdabd6b..fbc68af7bb 100644 --- a/src/packages/price/price.tsx +++ b/src/packages/price/price.tsx @@ -1,29 +1,23 @@ import React, { FunctionComponent } from 'react' import classNames from 'classnames' -import { BasicComponent, ComponentDefaults } from '@/utils/typings' +import { ComponentDefaults } from '@/utils/typings' import { useRtl } from '@/packages/configprovider/index' +import { PriceProps } from './types' -export interface PriceProps extends BasicComponent { - price: number | string - symbol: string - digits: number - thousands: boolean - position: string - size: string - line: boolean -} const defaultProps = { ...ComponentDefaults, + color: 'primary', price: 0, symbol: '¥', digits: 2, thousands: false, position: 'before', - size: 'large', + size: 'normal', line: false, } as PriceProps export const Price: FunctionComponent> = (props) => { const { + color, price, symbol, digits, @@ -52,11 +46,9 @@ export const Price: FunctionComponent> = (props) => { num = 0 } if (checkPoint(num)) { - num = Number(num).toFixed(digits) + num = num.toString() num = typeof num.split('.') === 'string' ? num.split('.') : num.split('.')[0] - } else { - num = num.toString() } if (thousands) { return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') @@ -101,9 +93,7 @@ export const Price: FunctionComponent> = (props) => { return (
@@ -115,22 +105,25 @@ export const Price: FunctionComponent> = (props) => { > {formatThousands(price)}
- {digits !== 0 ? ( -
- . -
+ {digits ? ( + <> +
+ . +
+
+ {formatDecimal(price)} +
+ ) : null} -
- {formatDecimal(price)} -
+ {symbol && position === 'after' ? renderSymbol() : null}
) diff --git a/src/packages/price/types.ts b/src/packages/price/types.ts new file mode 100644 index 0000000000..4d8eea1a7c --- /dev/null +++ b/src/packages/price/types.ts @@ -0,0 +1,14 @@ +import { BasicComponent } from '@/utils/typings' + +export type PriceSize = 'xlarge' | 'large' | 'normal' | 'small' +export type PriceColor = 'primary' | 'gray' | 'darkgray' +export interface PriceProps extends BasicComponent { + color: PriceColor + price: number | string + symbol: string + digits: number + thousands: boolean + position: string + size: PriceSize + line: boolean +} diff --git a/src/styles/jd-font.scss b/src/styles/jd-font.scss index bb20c0c72a..616644161b 100644 --- a/src/styles/jd-font.scss +++ b/src/styles/jd-font.scss @@ -1,8 +1,16 @@ @font-face { font-family: 'JD'; - src: url('data:font/ttf;charset=utf-8;base64,AAEAAAAMAIAAAwBAR0RFRgATAA4AAAtkAAAAFk9TLzJvL3A9AAAGLAAAAGBjbWFwAF0AbwAABowAAAA8Z2FzcP//AAMAAAtcAAAACGdseWarNFnTAAAAzAAABJhoZWFkLNdRDQAABaQAAAA2aGhlYQ47BogAAAYIAAAAJGh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AG4AZwBIAGUAaQAgAFYAMgAuADAAIABSAGUAZwB1AGwAYQByAFYAZQByAHMAaQBvAG4AIAAyAC4AMAAwADAAOwBHAGwAeQBwAGgAcwAgADMALgAxAC4AMQAgACgAMwAxADMANQApAEoARABaAGgAZQBuAGcASABlAGkAVgAyAC4AMAAtAFIAZQBnAHUAbABhAHIATgBlAHcAIABWAGEAbAB1AGWWdnQ8AEoARABaAGgAZQBuAGcASABlAGkAIABWADIALgAwAEIAeQAgAEIARQBJAEoASQBOAEcAIABKAEkATgBHAEQATwBOAEcAIABUAEUAQwBIAE4ATwBMAE8ARwBZACAAQwBPAC4ALAAgAEwAVABEAAAAAAIAAAAAAAD/NABmAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAEAAgADABMAFAAVABYAFwAYABkAGgAbABwAAAAAAAH//wACAAEAAAAMAAAAAAAAAAIAAQADAA0AAQAA') + src: url('data:font/ttf;charset=utf-8;base64,AAEAAAANAIAAAwBQRkZUTamiMnsAAA7YAAAAHEdERUYAKQAYAAAOuAAAAB5PUy8yeoF5HQAAAVgAAABgY21hcGtpMjEAAAIAAAABcmdhc3D//wADAAAOsAAAAAhnbHlmcqvHpQAAA5wAAAXcaGVhZC36UY0AAADcAAAANmhoZWERxQaTAAABFAAAACRobXR4S/MGzQAAAbgAAABIbG9jYQ1iC/QAAAN0AAAAJm1heHAAXgBMAAABOAAAACBuYW1lrP1qywAACXgAAATecG9zdFeSjFQAAA5YAAAAVgABAAAAAgAAb+Mu6l8PPPUACwgAAAAAAONzNPoAAAAA44/SOgA9/mYHmgb2AAAACAACAAAAAAAAAAEAAAb2/mYDMwgaAAAAAAeaAAEAAAAAAAAAAAAAAAAAAAASAAEAAAASAEkACgAAAAAAAgAAAAEAAQAAAEAAAAAAAAAABASZAZAABQAABTMEzQAAAJoFMwTNAAACzQBmAo8AAAAAAAAAAAAAAAAAAAADCAAAAAAAABAAAAAAVUtXTgDAACD/5Qb2/mYDMwiPAZoAAAABAAAAAATNBfYA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AAAAAIAAAAAAAD/NABmAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAEAAgADABEAEwAUABUAFgAXABgAGQAaABsAHACWAQIBAwd1bmk1MTQzB3VuaUZGRTUAAAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQADABEAAQAEAAAAAgAAAAAAAAABAAAAAOKfK0YAAAAA43M0+gAAAADjj9I6') format('truetype'); font-weight: 400; font-style: normal; font-display: swap; } +@font-face { + font-family: 'JD-Bold'; + src: url('data:font/ttf;charset=utf-8;base64,AAEAAAANAIAAAwBQRkZUTamiRLQAAA6cAAAAHEdERUYAKQAYAAAOfAAAAB5PUy8ye615eQAAAVgAAABgY21hcGtpMjEAAAIAAAABcmdhc3D//wADAAAOdAAAAAhnbHlmaUqojwAAA5wAAAYAaGVhZC4LY8YAAADcAAAANmhoZWER0QaTAAABFAAAACRobXR4UVAG5wAAAbgAAABIbG9jYQ1+DAwAAAN0AAAAJm1heHAAXgBMAAABOAAAACBuYW1ld67D0QAACZwAAASAcG9zdFeSjFQAAA4cAAAAVgABAAAAAgAA375yEF8PPPUACwgAAAAAAONzNLcAAAAA44/ktgBC/mYHpgb2AAAACAACAAAAAAAAAAEAAAb2/mYDMwgaAAAAAAemAAEAAAAAAAAAAAAAAAAAAAASAAEAAAASAEkACgAAAAAAAgAAAAEAAQAAAEAAAAAAAAAABAT1ArwABQAABTMEzQAAAJoFMwTNAAACzQBmAo8AAAAAAAAAAAAAAAAAAAADCAAAAAAAABAAAAAAVUtXTgDAACD/5Qb2/mYDMwiPAZoAAAABAAAAAATNBfYAAAAgAAEERwDNAAAAAAKqAAABmQAAAc4AQgU3AFgDhQBCBTcAiwU3AIMFNwBGBTcAgwU3AGoFNwCRBTcAWgU3AGoGNQCmCBoAXAY1AKYAAAADAAAAAwAAABwAAQAAAAAAbAADAAEAAAAcAAQAUAAAABAAEAADAAAAIAAuADkAoAClUUP/5f//AAAAIAAuADAAoAClUUP/5f///+P/1v/V/2P/aq7NACwAAQAAA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GgAZQBuAGcASABlAGkAMgAuADEALQBCAG8AbABkAAAyLjAwMDtVS1dOO0pEWmhlbmdIZWkyLjEtQm9sZABOrE4ca2Oe0QBWADIALgAxfJdPUwAAVjIuMQAAVgBlAHIAcwBpAG8AbgAgADIALgAwADAAMAA7AEcAbAB5AHAAaABzACAAMwAuADEALgAxACAAKAAzADEAMwA1ACkAAFZlcnNpb24gMi4wMDA7R2x5cGhzIDMuMS4xICgzMTM1KQAASgBEAFoAaABlAG4AZwBIAGUAaQAyAC4AMQAtAEIAbwBsAGQAAEpEWmhlbmdIZWkyLjEtQm9sZACWdnQ8AAAATqxOHGtjntEAIABWADIALgAxAAAgVjIuMQAAQgBvAGwAZAAAQm9sZAAAQwBvAHAAeQByAGkAZwBoAHQAKABjACkAIAAgAEIARQBJAEoASQBOAEcAIABKAEkATgBHAEQATwBOAEcAIABUAEUAQwBIAE4ATwBMAE8ARwBZACAAQwBPAC4ALAAgAEwAVABEAABOrE4ca2Oe0QAgAFYAMgAuADEAIABCAG8AbABkAAAAUgBlAGcAdQBsAGEAcgAATqxOHGtjntEAVgAyAC4AMXyXT1MAAABCAHkAIABCAEUASQBKAEkATgBHACAASgBJAE4ARwBEAE8ATgBHACAAVABFAEMASABOAE8ATABPAEcAWQAgAEMATwAuACwAIABMAFQARAAATqxOHGtjntEAIABWADIALgAxAAAAQgBvAGwAZAAAAAIAAAAAAAD/NABmAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAEAAgADABEAEwAUABUAFgAXABgAGQAaABsAHACWAQIBAwd1bmk1MTQzB3VuaUZGRTUAAAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQADABEAAQAEAAAAAgAAAAAAAAABAAAAAOKfK0YAAAAA43M0twAAAADjj+S2') + format('truetype'); + font-weight: 700; + font-style: normal; + font-display: swap; +} diff --git a/src/styles/variables.scss b/src/styles/variables.scss index cb41db5bed..2050922e65 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -773,32 +773,53 @@ $countdown-number-primary-border-color: var( $color-primary ) !default; -//large price(✅) +//price(✅) +$price-primary-color: var(--nutui-price-color, $color-primary) !default; +$price-color: var(--nutui-price-color, var(--nutui-color-text-help)) !default; +$price-darkgray-color: var( + --nutui-price-darkgray-color, + var(--nutui-gray-7) +) !default; +$price-line-color: var( + --nutui-price-line-color, + var(--nutui-color-text-help) +) !default; $price-symbol-padding-right: var( --nutui-price-symbol-padding-right, - 1px + 0px +) !default; + +//xlarge price(✅) +$price-symbol-xlarge-size: var(--nutui-price-symbol-xlarge-size, 12px) !default; +$price-integer-xlarge-size: var( + --nutui-price-integer-xlarge-size, + 24px +) !default; +$price-decimal-xlarge-size: var( + --nutui-price-decimal-xlarge-size, + 12px ) !default; -$price-symbol-big-size: var(--nutui-price-symbol-big-size, 18px) !default; -$price-integer-big-size: var(--nutui-price-integer-big-size, 24px) !default; -$price-decimal-big-size: var(--nutui-price-decimal-big-size, 18px) !default; + +//large price(✅) +$price-symbol-large-size: var(--nutui-price-symbol-large-size, 12px) !default; +$price-integer-large-size: var(--nutui-price-integer-large-size, 18px) !default; +$price-decimal-large-size: var(--nutui-price-decimal-large-size, 12px) !default; //normal price(✅) -$price-line-color: var(--nutui-price-line-color, $color-border) !default; -$price-line-font-size: var(--nutui-price-line-font-size, 12px) !default; -$price-symbol-medium-size: var(--nutui-price-symbol-medium-size, 14px) !default; -$price-integer-medium-size: var( - --nutui-price-integer-medium-size, +$price-symbol-normal-size: var(--nutui-price-symbol-normal-size, 12px) !default; +$price-integer-normal-size: var( + --nutui-price-integer-normal-size, 16px ) !default; -$price-decimal-medium-size: var( - --nutui-price-decimal-medium-size, - 14px +$price-decimal-normal-size: var( + --nutui-price-decimal-normal-size, + 12px ) !default; // small price(✅) -$price-symbol-small-size: var(--nutui-price-symbol-small-size, 10px) !default; +$price-symbol-small-size: var(--nutui-price-symbol-small-size, 12px) !default; $price-integer-small-size: var(--nutui-price-integer-small-size, 12px) !default; -$price-decimal-small-size: var(--nutui-price-decimal-small-size, 10px) !default; +$price-decimal-small-size: var(--nutui-price-decimal-small-size, 12px) !default; //avatar(✅) $avatar-square: var(--nutui-avatar-square, 5px) !default;