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

fix(progress): fix style & support icon demo #2729

Merged
merged 11 commits into from
Nov 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`should render progress when use props 1`] = `
>
<div
class="nut-progress-inner"
style="width: 100%; background-color: #FF0F23;"
style="width: 100%; background: #FF0F23;"
/>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions src/packages/progress/__tests__/progress.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ test('should render different height and color when use color height props', asy
<Progress percent={50} color="blue" strokeWidth="20" />
)
const inner = container.querySelector('.nut-progress-inner')
expect(inner?.getAttribute('style')).toBe(
'width: 50%; background-color: blue;'
)
expect(inner?.getAttribute('style')).toBe('width: 50%; background: blue;')
})

test('should show percent when use showText props', () => {
Expand Down
8 changes: 2 additions & 6 deletions src/packages/progress/demo.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@ const ProgressDemo = () => {
<Demo2 />
<View className="h2">{translated.noShowPercentage}</View>
<Demo3 />
{!harmonyAndRn() && (
<>
<View className="h2">{translated.customContent}</View>
<Demo4 />
</>
)}
<View className="h2">{translated.customContent}</View>
<Demo4 />
<View className="h2">{translated.customSize}</View>
<Demo5 />
<View className="h2">{translated.statusDisplay}</View>
Expand Down
6 changes: 3 additions & 3 deletions src/packages/progress/demos/h5/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const Demo4 = () => {
<Cell>
<Progress percent={60} showText>
<Image
width="30px"
height="30px"
src="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
width="20"
height="20"
src="https://img12.360buyimg.com/imagetools/jfs/t1/229362/18/22746/11607/669f8bfeF5fcbeaab/d4162bbf29bb1b00.png"
/>
</Progress>
</Cell>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/progress/demos/h5/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Demo6 = () => {
<Cell>
<Progress
percent={30}
color="linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)"
color="linear-gradient(270deg, rgb(18, 126, 255) 0%, rgb(32, 147, 255) 32.8156%, rgb(13, 242, 204) 100%)"
animated
/>
</Cell>
Expand Down
4 changes: 2 additions & 2 deletions src/packages/progress/demos/taro/demo4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const Demo4 = () => {
<Cell>
<Progress percent={60} showText>
<Image
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
width="30px"
height="30px"
width={20}
height={20}
Copy link
Collaborator

Choose a reason for hiding this comment

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

为什么改变了值?

src="https://img12.360buyimg.com/imagetools/jfs/t1/229362/18/22746/11607/669f8bfeF5fcbeaab/d4162bbf29bb1b00.png"
/>
</Progress>
Expand Down
34 changes: 14 additions & 20 deletions src/packages/progress/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
import React from 'react'
import { Progress, Cell } from '@nutui/nutui-react-taro'
import { Checked, Tips } from '@nutui/icons-react-taro'
import { harmonyAndRn } from '@/utils/platform-taro'
import pxTransform from '@/utils/px-transform'

const Demo6 = () => {
const iconStyle = {
marginTop: 0,
marginLeft: pxTransform(5),
marginRight: pxTransform(5),
}
return (
<>
<Cell>
<Progress
percent={30}
color={
harmonyAndRn()
? 'blue'
: 'linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)'
}
color="linear-gradient(270deg, rgba(18,126,255,1) 0%,rgba(32,147,255,1) 32.815625%,rgba(13,242,204,1) 100%)"
animated
/>
</Cell>
<Cell align="center">
<Progress percent={100} />
{!harmonyAndRn() && (
<Checked color="green" style={{ margin: '0 5px' }} />
)}
<Checked color="green" style={iconStyle} />
</Cell>
<Cell align="center">
<Progress percent={100} color="#AAFF00" strokeWidth="15" />
{!harmonyAndRn() && (
<Tips
color={
harmonyAndRn()
? 'red'
: 'linear-gradient(90deg, rgba(180,236,81,1) 0%,rgba(66,147,33,1) 100%)'
}
style={{ margin: '0 5px' }}
/>
)}
<Progress
percent={100}
color="linear-gradient(90deg, rgba(180,236,81,1) 0%,rgba(66,147,33,1) 100%)"
strokeWidth="15"
/>
<Tips color="#FF0000" style={iconStyle} />
</Cell>
</>
)
Expand Down
4 changes: 2 additions & 2 deletions src/packages/progress/progress.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
justify-content: center;
transition: all 0.4s;
border-radius: $progress-border-radius;
background-color: $progress-color;
background: $progress-color;
}

&-text {
Expand All @@ -39,7 +39,7 @@
top: $progress-text-position-top;
bottom: $progress-text-position-bottom;
transition: all 0.4s;
// transform: translate(-50%);
transform: translate(-50%);

&-inner {
display: flex;
Expand Down
5 changes: 2 additions & 3 deletions src/packages/progress/progress.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const Progress: FunctionComponent<

const stylesInner: React.CSSProperties = {
width: `${displayPercent}%`,
backgroundColor: color || '#FF0F23',
background: color || '#FF0F23',
}

if (strokeWidth) {
Expand Down Expand Up @@ -160,8 +160,7 @@ export const Progress: FunctionComponent<
}
}, [])
const getTextStyle = () => {
const value = harmony() ? '93%' : '99%'
return rtl ? { right: value } : { left: value }
return rtl ? { right: '100%' } : { left: '100%' }
Alex-huxiyang marked this conversation as resolved.
Show resolved Hide resolved
}
const computeRight = () => {
if (children) {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/progress/progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const Progress: FunctionComponent<

const stylesInner: React.CSSProperties = {
width: `${displayPercent}%`,
backgroundColor: color || '#FF0F23',
background: color || '#FF0F23',
}

useEffect(() => {
Expand Down
7 changes: 5 additions & 2 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,10 @@ $popover-menu-item-padding: var(

//progress(✅)
$progress-height: var(--nutui-progress-height, 10px) !default;
$progress-color: var(--nutui-progress-color, #ff0f23) !default;
$progress-color: var(
--nutui-progress-color,
$color-primary-gradient-1
) !default;
$progress-background: var(
--nutui-progress-background,
$color-background
Expand All @@ -1646,7 +1649,7 @@ $progress-text-color: var(
) !default;
$progress-text-background: var(
--nutui-progress-text-background,
#ff0f23
$color-primary-gradient-1
) !default;
$progress-text-padding: var(--nutui-progress-text-padding, 0 5px) !default;
$progress-text-font-size: var(--nutui-progress-text-font-size, 9px) !default;
Expand Down
Loading