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(lottie): new component #2867

Merged
merged 16 commits into from
Dec 27, 2024
Merged
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
"classnames": "^2.5.1",
"lodash.isequal": "^4.5.0",
"lodash.kebabcase": "^4.1.1",
"lottie-miniprogram": "^1.0.12",
"lottie-react": "^2.4.0",
"react-transition-group": "^4.4.5"
},
"devDependencies": {
Expand All @@ -131,8 +133,8 @@
"@swc/core": "^1.4.8",
"@tarojs/components": "4.0.8-beta.1",
"@tarojs/plugin-platform-alipay": "4.0.8-beta.1",
"@tarojs/plugin-platform-weapp": "4.0.8-beta.1",
"@tarojs/plugin-platform-jd": "4.0.8-beta.1",
"@tarojs/plugin-platform-weapp": "4.0.8-beta.1",
"@tarojs/react": "4.0.8-beta.1",
"@tarojs/taro": "4.0.8-beta.1",
"@testing-library/jest-dom": "^6.4.2",
Expand Down Expand Up @@ -228,6 +230,9 @@
},
"resolutions": {
"@types/react": "^18.2.57",
"@types/react-dom": "^18.2.19"
"@types/react-dom": "^18.2.19",
"sass": "1.77.6",
"@tarojs/api": "4.0.8-beta.1",
"@tarojs/components": "4.0.8-beta.1"
}
}
5 changes: 0 additions & 5 deletions packages/nutui-taro-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,5 @@
"postcss": "^8.4.35",
"stylelint": "^16.7.0",
"typescript": "^5.3.3"
},
"resolutions": {
"sass": "1.77.6",
"@tarojs/api": "4.0.8-beta.1",
"@tarojs/components": "4.0.8-beta.1"
}
}
600 changes: 479 additions & 121 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@
"sort": 15,
"show": true,
"taro": true,
"v14":true,
"author": "mike8625"
},
{
Expand Down Expand Up @@ -1041,6 +1042,17 @@
"taro": true,
"author": "liukun"
},
{
"version": "3.0.0",
"name": "Lottie",
"type": "component",
"cName": "动画/动效",
"desc": "给子元素添加动画效果",
"sort": 27,
"show": true,
"taro": true,
"author": "swag~jun"
},
{
"version": "3.0.0",
"name": "Pagination",
Expand Down
6 changes: 4 additions & 2 deletions src/packages/configprovider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type NutCSSVariables =
| 'nutuiColorPrimaryLightPressed'
| 'nutuiRed6'
| 'nutuiGray8'
| 'nutuiColorPrimarySpecialdisabled'
| 'nutuiColorDefault'
| 'nutuiColorDefaultPressed'
| 'nutuiColorDefaultLight'
Expand Down Expand Up @@ -217,7 +218,6 @@ export type NutCSSVariables =
| 'nutuiInputnumberInputMargin'
| 'nutuiInputnumberButtonWidth'
| 'nutuiInputnumberButtonHeight'
| 'nutuiInputnumberButtonBorderRadius'
| 'nutuiInputnumberButtonBackgroundColor'
| 'nutuiInputnumberIconColor'
| 'nutuiInputnumberIconSize'
Expand Down Expand Up @@ -541,15 +541,16 @@ export type NutCSSVariables =
| 'nutuiBadgeDotWidth'
| 'nutuiBadgeDotBorder'
| 'nutuiPopoverBorderRadius'
| 'nutuiPopoverFontSize'
| 'nutuiPopoverBorderColor'
| 'nutuiPopoverFontSize'
| 'nutuiPopoverContentBackgroundColor'
| 'nutuiPopoverTextColor'
| 'nutuiPopoverHoverBackgroundColor'
| 'nutuiPopoverHoverTextColor'
| 'nutuiPopoverDisableColor'
| 'nutuiPopoverDividerColor'
| 'nutuiPopoverMenuItemPadding'
| 'nutuiPopoverMenuItemWidth'
| 'nutuiProgressHeight'
| 'nutuiProgressColor'
| 'nutuiProgressBackground'
Expand Down Expand Up @@ -813,6 +814,7 @@ export type NutCSSVariables =
| 'nutuiLoadingIconSize'
| 'nutuiLoadingColor'
| 'nutuiLoadingFontSize'
| 'nutuiLoadingLottieBackground'
| 'nutuiResultpageWidth'
| 'nutuiResultpageIconSize'
| 'nutuiResultpageIconMarginBottom'
Expand Down
18 changes: 17 additions & 1 deletion src/packages/loading/__test__/loading.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as React from 'react'

import { render } from '@testing-library/react'
import '@testing-library/jest-dom'

import { Star } from '@nutui/icons-react'
import { Loading } from '../loading'
import data from '@/packages/lottie/animation/light/loading.json'

test('type test', () => {
const { container } = render(<Loading type="circular" />)
Expand All @@ -30,3 +30,19 @@ test('custom icon test', () => {
)
expect(container.querySelector('svg')).toHaveClass('nut-icon-Star')
})

test('use lottie', () => {
const { container } = render(
<Loading
direction="vertical"
type="lottie"
jsonData={data}
lottieProps={{ autoplay: false, loop: false }}
>
正在奋力加载中,感谢您的等待
</Loading>
)
expect(container.querySelectorAll('g')[0].getAttribute('id')).toContain(
'lottie'
)
})
oasis-cloud marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 23 additions & 5 deletions src/packages/loading/demos/h5/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import React from 'react'
import { Loading, Cell } from '@nutui/nutui-react'
import { Cell, Loading } from '@nutui/nutui-react'
import data from '../../../lottie/animation/light/loading.json'

const Demo1 = () => {
return (
<Cell>
<Loading type="circular" />
<Loading type="spinner" />
</Cell>
<>
<Cell>
<Loading type="circular" />
</Cell>
<Cell>
<Loading type="spinner" />
</Cell>
<Cell>
<Loading direction="vertical" type="lottie" jsonData={data} />
</Cell>
<Cell>
<Loading
direction="vertical"
type="lottie"
jsonData={data}
lottieProps={{ autoplay: false, loop: false }}
>
正在奋力加载中,感谢您的等待
</Loading>
</Cell>
</>
)
}
export default Demo1
37 changes: 32 additions & 5 deletions src/packages/loading/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
import React from 'react'
import { Loading, Cell } from '@nutui/nutui-react-taro'
import { Cell, Loading } from '@nutui/nutui-react-taro'
import data from '@/packages/lottie/animation/light/loading.json'

const Demo1 = () => {
return (
<Cell>
<Loading type="circular" />
<Loading type="spinner" />
</Cell>
<>
<Cell>
<Loading type="circular" />
</Cell>
<Cell>
<Loading type="spinner" />
</Cell>
<Cell>
<Loading
direction="vertical"
type="lottie"
jsonData={data}
lottieProps={{ style: { width: 56, height: 56 } }}
/>
</Cell>
<Cell>
<Loading
direction="vertical"
type="lottie"
jsonData={data}
lottieProps={{
autoplay: false,
loop: false,
style: { width: 56, height: 56 },
}}
>
正在奋力加载中,感谢您的等待
</Loading>
</Cell>
</>
)
}
export default Demo1
7 changes: 4 additions & 3 deletions src/packages/loading/demos/taro/demo8.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react'
import { Loading, Cell, Button, Overlay } from '@nutui/nutui-react-taro'
import { View } from '@tarojs/components'
import { Button, Cell, Loading, Overlay } from '@nutui/nutui-react-taro'

const Demo8 = () => {
const [visible, setVisible] = useState(false)
Expand All @@ -26,9 +27,9 @@ const Demo8 = () => {
</Button>
</Cell>
<Overlay visible={visible}>
<div className="wrapper" style={WrapperStyle}>
<View className="wrapper" style={WrapperStyle}>
<Loading direction="vertical">加载中</Loading>
</div>
</View>
</Overlay>
</>
)
Expand Down
2 changes: 0 additions & 2 deletions src/packages/loading/doc.en-US.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Loading

#

A loading icon, Used to show the loading state

### Import
Expand Down
2 changes: 0 additions & 2 deletions src/packages/loading/doc.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Loading 加载中

#

加载图标,用于显示正在加载中的状态

### 引入
Expand Down
2 changes: 0 additions & 2 deletions src/packages/loading/doc.taro.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Loading 加载中

#

加载图标,用于显示正在加载中的状态

### 引入
Expand Down
4 changes: 1 addition & 3 deletions src/packages/loading/doc.zh-TW.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Loading 加載中

#

加載圖標,用於顯示正在加載中的狀態

### 引入
Expand Down Expand Up @@ -80,7 +78,7 @@ import { Loading } from '@nutui/nutui-react'

### Props

| 属性 | 说明 | 类型 | 默认值 |
| 屬性 | 說明 | 類型 | 默認值 |
| --- | --- | --- | --- |
| type | loading图标的样式 | `circular \| spinner` | `circular` |
| direction | loading图标和文字的排列方式 | `horizontal \| vertical` | `horizontal` |
Expand Down
6 changes: 1 addition & 5 deletions src/packages/loading/index.taro.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { Loading } from './loading.taro'

export type {
LoadingProps,
LoadingType,
LoadingDirection,
} from './loading.taro'
export type { LoadingProps, LoadingType, LoadingDirection } from './types'
export default Loading
2 changes: 1 addition & 1 deletion src/packages/loading/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Loading } from './loading'

export type { LoadingProps, LoadingType, LoadingDirection } from './loading'
export type { LoadingProps, LoadingType, LoadingDirection } from './types'
export default Loading
8 changes: 7 additions & 1 deletion src/packages/loading/loading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
font-size: $loading-icon-size;
}
}
.nut-loading-lottie-box {
width: 56px;
height: 56px;
border-radius: $radius-base;
background: $loading-lottie-background;
}

.nut-loading-text {
padding: 8px;
padding-top: $spacing-base;
color: $loading-color;
font-size: $loading-font-size;
}
Expand Down
Loading
Loading