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(avatar): rn 适配 #2343

Merged
merged 21 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
"feedback/pages/popover/index",
"feedback/pages/popup/index",
"feedback/pages/pulltorefresh/index",
"feedback/pages/resultpage/index",
"feedback/pages/skeleton/index",
"feedback/pages/swipe/index",
"feedback/pages/toast/index",
"feedback/pages/resultpage/index",
"exhibition/pages/animate/index",
"exhibition/pages/animatingnumbers/index",
"exhibition/pages/avatar/index",
Expand Down
2 changes: 2 additions & 0 deletions packages/nutui-taro-demo-rn/scripts/taro/adapted.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ exports = module.exports = [
'hoverbutton',
'safearea',
'hoverbuttonitem',
'avatar',
'avatargroup',
Comment on lines +29 to +30
Copy link

Choose a reason for hiding this comment

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

全局变量应避免重新赋值。

- exports = module.exports = [
+ const exports = module.exports = [
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'avatar',
'avatargroup',
const exports = module.exports = [
'avatar',
'avatargroup',

]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export default <>button</>;
import Demo from '@/packages/avatar/demo.taro'
export default Demo
11 changes: 8 additions & 3 deletions scripts/rn/copy-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ const copyFile = async (from, to, success, isSingle = false) => {
adapted.map((item) => {
if (item) {
if (
!['cellgroup', 'row', 'col', 'griditem', 'hoverbuttonitem'].includes(
item
)
![
'cellgroup',
'row',
'col',
'griditem',
'hoverbuttonitem',
'avatargroup',
].includes(item)
) {
modify(
`${targetBaseUrl}/packages/${item}/demo.taro.tsx`,
Expand Down
182 changes: 138 additions & 44 deletions src/packages/avatar/avatar.harmony.css
Copy link
Collaborator

Choose a reason for hiding this comment

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

需要删除 image 样式

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

web h5 还需要这个样式~

Original file line number Diff line number Diff line change
@@ -1,76 +1,170 @@
.nut-avatar {
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center center;
display: inline-block;
.nut-image {
display: block;
position: relative;
flex: 0 0 auto;
text-align: center;
}
.nut-avatar .avatar-img {
position: absolute;
.nut-image-default {
display: block;
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-image.nut-image-round {
border-radius: 50%;
overflow: hidden;
}
.nut-avatar .nut-icon-img {
.nut-image-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-avatar .text {
display: inline-block;
.nut-image-error {
width: 100%;
height: 100%;
text-align: center;
overflow: hidden;
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-avatar .avatar-img,
.nut-rtl .nut-avatar .avatar-img {
[dir=rtl] .nut-image .nut-img-loading,
.nut-rtl .nut-image .nut-img-loading {
left: auto;
right: 50%;
transform: translate(50%, -50%);
right: 0;
}
[dir=rtl] .nut-avatar .icon,
.nut-rtl .nut-avatar .icon {
[dir=rtl] .nut-image .nut-img-error,
.nut-rtl .nut-image .nut-img-error {
left: auto;
right: 50%;
transform: translate(50%, -50%);
right: 0;
}

.nut-avatar-group {
display: flex;
flex-direction: row;
flex: 0 0 auto;
}
.nut-avatar-group-avatar,
.nut-avatar-group .nut-avatar {
border: 1px solid #fff;
margin-left: -8px;
}
.nut-avatar-group-avatar:not(:first-of-type),
.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-avatar {
position: relative;
flex: 0 0 auto;
}
.nut-avatar-round {
border-radius: 999px;
overflow: hidden;
}
.nut-avatar-square {
border-radius: 5px;
}
.nut-avatar-first-child {
margin-left: 0;
margin-right: 0;
}
.nut-avatar-img {
width: 100%;
height: 100%;
flex-shrink: 0;
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center center;
}
.nut-avatar-icon {
background-size: 100% 100%;
}
.nut-avatar .nut-icon-img {
width: 100%;
height: 100%;
}
.nut-avatar-text {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.nut-avatar-large {
display: flex;
justify-content: center;
align-items: center;
width: 60px;
height: 60px;
}
.nut-avatar-large-img {
width: 60px;
height: 60px;
}
.nut-avatar-large-img-image {
width: 60px;
height: 60px;
}
.nut-avatar-large-icon {
width: 60px;
height: 60px;
}
.nut-avatar-large .nut-icon-img {
width: 100%;
height: 100%;
}
.nut-avatar-large-text {
width: 60px;
height: 60px;
line-height: 60px;
}

.nut-avatar-small {
display: flex;
justify-content: center;
align-items: center;
width: 32px;
height: 32px;
}
.nut-avatar-small-img-image {
width: 32px;
height: 32px;
}
.nut-avatar-small-text {
width: 32px;
height: 32px;
line-height: 32px;
}

.nut-avatar-normal {
display: flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
line-height: 40px;
}

.nut-avatar-round {
border-radius: 50%;
overflow: hidden;
.nut-avatar-normal-img-image {
width: 40px;
height: 40px;
}

.nut-avatar-square {
border-radius: 5px;
.nut-avatar-normal .nut-icon-img {
width: 100%;
height: 100%;
}
.nut-avatar-normal-text {
width: 40px;
height: 40px;
}
Loading