Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita64731e

Browse files
refactor: Add group badge to diff groups from users (#4478)
1 parent934777d commita64731e

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import{Story}from"@storybook/react"
2+
import{GroupAvatar,GroupAvatarProps}from"./GroupAvatar"
3+
4+
exportdefault{
5+
title:"components/GroupAvatar",
6+
component:GroupAvatar,
7+
}
8+
9+
constTemplate:Story<GroupAvatarProps>=(args)=><GroupAvatar{...args}/>
10+
11+
exportconstExample=Template.bind({})
12+
Example.args={
13+
name:"My Group",
14+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
importAvatarfrom"@material-ui/core/Avatar"
2+
importBadgefrom"@material-ui/core/Badge"
3+
import{withStyles}from"@material-ui/core/styles"
4+
importGroupfrom"@material-ui/icons/Group"
5+
import{FC}from"react"
6+
import{firstLetter}from"util/firstLetter"
7+
8+
constStyledBadge=withStyles((theme)=>({
9+
badge:{
10+
backgroundColor:theme.palette.background.paper,
11+
border:`1px solid${theme.palette.divider}`,
12+
borderRadius:"100%",
13+
width:24,
14+
height:24,
15+
display:"flex",
16+
alignItems:"center",
17+
justifyContent:"center",
18+
19+
"& svg":{
20+
width:14,
21+
height:14,
22+
},
23+
},
24+
}))(Badge)
25+
26+
exporttypeGroupAvatarProps={
27+
name:string
28+
}
29+
30+
exportconstGroupAvatar:FC<GroupAvatarProps>=({ name})=>{
31+
return(
32+
<StyledBadge
33+
overlap="circular"
34+
anchorOrigin={{
35+
vertical:"bottom",
36+
horizontal:"right",
37+
}}
38+
badgeContent={<Group/>}
39+
>
40+
<Avatar>{firstLetter(name)}</Avatar>
41+
</StyledBadge>
42+
)
43+
}

‎site/src/pages/GroupsPage/GroupsPageView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import React from "react"
2121
import{LinkasRouterLink,useNavigate}from"react-router-dom"
2222
import{Paywall}from"components/Paywall/Paywall"
2323
import{Group}from"api/typesGenerated"
24+
import{GroupAvatar}from"components/GroupAvatar/GroupAvatar"
2425

2526
exporttypeGroupsPageViewProps={
2627
groups:Group[]|undefined
@@ -135,6 +136,7 @@ export const GroupsPageView: React.FC<GroupsPageViewProps> = ({
135136
>
136137
<TableCell>
137138
<AvatarData
139+
avatar={<GroupAvatarname={group.name}/>}
138140
title={group.name}
139141
subtitle={`${group.members.length} members`}
140142
highlightTitle

‎site/src/pages/TemplatePage/TemplatePermissionsPage/TemplatePermissionsPageView.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
}from"components/UserOrGroupAutocomplete/UserOrGroupAutocomplete"
2929
import{FC,useState}from"react"
3030
import{Maybe}from"components/Conditionals/Maybe"
31+
import{GroupAvatar}from"components/GroupAvatar/GroupAvatar"
3132

3233
typeAddTemplateUserOrGroupProps={
3334
organizationId:string
@@ -208,6 +209,7 @@ export const TemplatePermissionsPageView: FC<
208209
<TableRowkey={group.id}>
209210
<TableCell>
210211
<AvatarData
212+
avatar={<GroupAvatarname={group.name}/>}
211213
title={group.name}
212214
subtitle={`${group.members.length} members`}
213215
highlightTitle

‎site/src/testHelpers/entities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const MockUser: TypesGen.User = {
7373
status:"active",
7474
organization_ids:["fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0"],
7575
roles:[MockOwnerRole],
76-
avatar_url:"https://github.com/coder.png",
76+
avatar_url:"https://avatars.githubusercontent.com/u/95932066?s=200&v=4",
7777
last_seen_at:"",
7878
}
7979

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp