+
+
NutUI-React
+
一套京东风格的轻量级移动端React组件库,提供丰富的基础组件和业务组件,帮助开发者快速搭建移动应用。
diff --git a/src/packages/skeleton/demos/taro/demo5.tsx b/src/packages/skeleton/demos/taro/demo5.tsx
index a4d15b1216..85be784261 100644
--- a/src/packages/skeleton/demos/taro/demo5.tsx
+++ b/src/packages/skeleton/demos/taro/demo5.tsx
@@ -1,6 +1,7 @@
import { Avatar, Image, Skeleton, Switch } from '@nutui/nutui-react-taro'
import React, { useState } from 'react'
import { View, Text } from '@tarojs/components'
+import pxTransform from '@/utils/px-transform'
const Demo5 = () => {
const [checked, setChecked] = useState(false)
@@ -12,11 +13,19 @@ const Demo5 = () => {
setChecked(value)
}
return (
-
- changeStatus(value, event)} />
+
+ changeStatus(value, event)}
+ style={{ display: 'flex', marginBottom: pxTransform(8) }}
+ />
-
+
{
/>
}
/>
-
- NutUI-React
+
+ NutUI-React
一套京东风格的轻量级移动端React组件库,提供丰富的基础组件和业务组件,帮助开发者快速搭建移动应用。
diff --git a/src/packages/skeleton/skeleton.harmony.css b/src/packages/skeleton/skeleton.harmony.css
index a00db0f425..34bf352a46 100644
--- a/src/packages/skeleton/skeleton.harmony.css
+++ b/src/packages/skeleton/skeleton.harmony.css
@@ -1,3 +1,152 @@
+.nut-avatar-group {
+ background-size: 100% 100%;
+ background-repeat: no-repeat;
+ background-position: center center;
+ display: inline-block;
+ position: relative;
+ flex: 0 0 auto;
+}
+.nut-avatar-group .nut-avatar {
+ border: 1px solid #fff;
+}
+.nut-avatar-group .nut-avatar:not(:first-of-type) {
+ margin-left: -8px;
+}
+
+[dir=rtl] .nut-avatar-group .nut-avatar:not(:first-of-type),
+.nut-rtl .nut-avatar-group .nut-avatar:not(:first-of-type) {
+ margin-left: 0;
+ margin-right: -8px;
+}
+
+.nut-image {
+ display: block;
+ position: relative;
+}
+.nut-image .nut-img {
+ display: block;
+ width: 100%;
+ height: 100%;
+}
+.nut-image.nut-image-round {
+ border-radius: 50%;
+ overflow: hidden;
+}
+.nut-image .nut-img-loading {
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ background: #f5f6fa;
+ background-size: 100% 100%;
+}
+.nut-image .nut-img-error {
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ background: #f5f6fa;
+ background-size: 100% 100%;
+}
+
+[dir=rtl] .nut-image .nut-img-loading,
+.nut-rtl .nut-image .nut-img-loading {
+ left: auto;
+ right: 0;
+}
+[dir=rtl] .nut-image .nut-img-error,
+.nut-rtl .nut-image .nut-img-error {
+ left: auto;
+ right: 0;
+}
+
+.nut-avatar {
+ background-size: 100% 100%;
+ background-repeat: no-repeat;
+ background-position: center center;
+ display: inline-block;
+ position: relative;
+ flex: 0 0 auto;
+ text-align: center;
+}
+.nut-avatar .avatar-img {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ flex-shrink: 0;
+}
+.nut-avatar .icon {
+ background-size: 100% 100%;
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+}
+.nut-avatar .nut-icon-img {
+ width: 100%;
+ height: 100%;
+}
+.nut-avatar .text {
+ display: inline-block;
+ width: 100%;
+ height: 100%;
+ text-align: center;
+ overflow: hidden;
+}
+
+[dir=rtl] .nut-avatar .avatar-img,
+.nut-rtl .nut-avatar .avatar-img {
+ left: auto;
+ right: 50%;
+ transform: translate(50%, -50%);
+}
+[dir=rtl] .nut-avatar .icon,
+.nut-rtl .nut-avatar .icon {
+ left: auto;
+ right: 50%;
+ transform: translate(50%, -50%);
+}
+
+.nut-avatar-large {
+ width: 60px;
+ height: 60px;
+ line-height: 60px;
+}
+
+.nut-avatar-small {
+ width: 32px;
+ height: 32px;
+ line-height: 32px;
+}
+
+.nut-avatar-normal {
+ width: 40px;
+ height: 40px;
+ line-height: 40px;
+}
+
+.nut-avatar-round {
+ border-radius: 50%;
+ overflow: hidden;
+}
+
+.nut-avatar-square {
+ border-radius: 5px;
+}
+
.nut-skeleton {
display: inline-block;
position: relative;
@@ -7,15 +156,16 @@
}
.nut-skeleton-content {
display: flex;
+ flex-direction: row;
}
-.nut-skeleton-content .nut-avatar {
+.nut-skeleton-content-avatar {
margin-right: 20px;
- background: #F7F8FC !important;
+ background: #f5f6fa !important;
}
-.nut-skeleton-content .nut-skeleton-block {
+.nut-skeleton-content-block {
width: 100%;
height: 15px;
- background: #F7F8FC;
+ background: #f5f6fa;
margin-top: 10px;
border-radius: 0;
}
@@ -24,13 +174,16 @@
display: flex;
flex-direction: column;
}
-.nut-skeleton-content-line .nut-skeleton-title {
+.nut-skeleton-content-line .nut-skeleton-content-block:last-child {
+ width: 70%;
+}
+.nut-skeleton-content-title {
width: 30%;
height: 15px;
- background: #F7F8FC;
+ background: #f5f6fa;
}
-.nut-skeleton-content-line .nut-skeleton-block:last-child {
- width: 70%;
+.nut-skeleton-content-block-last-child {
+ width: 55%;
}
.nut-skeleton-animation {
position: absolute;
@@ -39,7 +192,9 @@
width: 100%;
height: 100%;
z-index: 1;
+ /* #ifndef rn */
background: linear-gradient(90deg, hsla(0, 0%, 100%, 0), hsla(0, 0%, 100%, 0.5) 50%, hsla(0, 0%, 100%, 0) 80%);
+ /* #endif */
animation: nut-skeleton 2s ease-in-out 0s infinite;
}
@keyframes nut-skeleton {
@@ -60,7 +215,9 @@
.nut-rtl .nut-skeleton-animation {
left: auto;
right: 0;
+ /* #ifndef rn */
background: linear-gradient(-90deg, hsla(0, 0%, 100%, 0), hsla(0, 0%, 100%, 0.5) 50%, hsla(0, 0%, 100%, 0) 80%);
+ /* #endif */
animation: nut-skeleton-rtl 2s ease-in-out 0s infinite;
}
@keyframes nut-skeleton-rtl {
diff --git a/src/packages/skeleton/skeleton.scss b/src/packages/skeleton/skeleton.scss
index 4394b47e28..74730e6aca 100644
--- a/src/packages/skeleton/skeleton.scss
+++ b/src/packages/skeleton/skeleton.scss
@@ -9,13 +9,14 @@
&-content {
display: flex;
+ flex-direction: row;
- .nut-avatar {
+ &-avatar {
margin-right: 20px;
background: $skeleton-background !important;
}
- .nut-skeleton-block {
+ &-block {
width: $skeleton-line-width;
height: $skeleton-line-height;
background: $skeleton-background;
@@ -27,17 +28,20 @@
width: 100%;
display: flex;
flex-direction: column;
-
- .nut-skeleton-title {
- width: 30%;
- height: $skeleton-line-height;
- background: $skeleton-background;
- }
-
- .nut-skeleton-block:last-child {
+ .nut-skeleton-content-block:last-child {
width: 70%;
}
}
+
+ &-title {
+ width: 30%;
+ height: $skeleton-line-height;
+ background: $skeleton-background;
+ }
+
+ &-block-last-child {
+ width: 55%;
+ }
}
&-animation {
@@ -47,12 +51,15 @@
width: 100%;
height: 100%;
z-index: 1;
+
+ /* #ifndef rn */
background: linear-gradient(
90deg,
hsla(0, 0%, 100%, 0),
hsla(0, 0%, 100%, 0.5) 50%,
hsla(0, 0%, 100%, 0) 80%
);
+ /* #endif */
animation: nut-skeleton 2s ease-in-out 0s infinite;
}
@@ -78,12 +85,15 @@
&-animation {
left: auto;
right: 0;
+
+ /* #ifndef rn */
background: linear-gradient(
-90deg,
hsla(0, 0%, 100%, 0),
hsla(0, 0%, 100%, 0.5) 50%,
hsla(0, 0%, 100%, 0) 80%
);
+ /* #endif */
animation: nut-skeleton-rtl 2s ease-in-out 0s infinite;
}
diff --git a/src/packages/skeleton/skeleton.taro.tsx b/src/packages/skeleton/skeleton.taro.tsx
index fd69c374d5..7bd6e14e5e 100644
--- a/src/packages/skeleton/skeleton.taro.tsx
+++ b/src/packages/skeleton/skeleton.taro.tsx
@@ -1,7 +1,9 @@
import React, { FunctionComponent } from 'react'
+import { View } from '@tarojs/components'
import classNames from 'classnames'
import Avatar from '@/packages/avatar/index.taro'
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
+import pxTransform from '@/utils/px-transform'
type avatarShape = 'round' | 'square'
@@ -46,6 +48,7 @@ export const Skeleton: FunctionComponent> = (props) => {
const classes = classNames(classPrefix, className)
const avatarClass = classNames({
[`nut-avatar`]: true,
+ [`nut-skeleton-content-avatar`]: true,
[`avatar-${avatarShape}`]: avatarShape,
})
@@ -56,13 +59,13 @@ export const Skeleton: FunctionComponent> = (props) => {
const getStyle = () => {
if (avatarSize) {
return {
- width: avatarSize,
- height: avatarSize,
+ width: pxTransform(parseInt(avatarSize)),
+ height: pxTransform(parseInt(avatarSize)),
}
}
return {
- width: '50px',
- height: '50px',
+ width: pxTransform(50),
+ height: pxTransform(50),
}
}
@@ -71,9 +74,9 @@ export const Skeleton: FunctionComponent> = (props) => {
{visible ? (
<>{children}>
) : (
-
- {animated &&
}
-
+
+ {animated && }
+
{avatar && (
> = (props) => {
/>
)}
{rows === 1 ? (
-
+
) : (
-
- {title &&
}
+
+ {title && }
{repeatLines(rows).map((item, index) => {
- return
+ return (
+
+ )
})}
-
+
)}
-
-
+
+
)}
>
)
diff --git a/src/packages/skeleton/skeleton.tsx b/src/packages/skeleton/skeleton.tsx
index 03dc00b257..09cf9c6abb 100644
--- a/src/packages/skeleton/skeleton.tsx
+++ b/src/packages/skeleton/skeleton.tsx
@@ -46,6 +46,7 @@ export const Skeleton: FunctionComponent> = (props) => {
const classes = classNames(classPrefix, className)
const avatarClass = classNames({
[`nut-avatar`]: true,
+ [`nut-skeleton-content-avatar`]: true,
[`avatar-${avatarShape}`]: avatarShape,
})
@@ -83,12 +84,17 @@ export const Skeleton: FunctionComponent> = (props) => {
/>
)}
{rows === 1 ? (
-
+
) : (
- {title &&
}
+ {title &&
}
{repeatLines(rows).map((item, index) => {
- return
+ return (
+
+ )
})}
)}