This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork37
feat: User list with setter, UI/UX#1139
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
a12e7fc
feat(user-list): basic UI
mydearxymac3392c
refactor(user-list): ui wip
mydearxym7c8b974
refactor(user-list): basic search view UX
mydearxymce8b090
refactor(user-list): basic list UX
mydearxymaf82958
refactor(user-list): basic list UX
mydearxym47b71e3
refactor(user-list): basic list UX
mydearxymFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionspublic/icons/static/article/export.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/article/import.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/delete-solid.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/ear.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletionspublic/icons/static/shape/settings.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletionssrc/components/UserList/List/CreateWorksLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* UserList | ||
* | ||
*/ | ||
import { FC, memo } from 'react' | ||
import type { TUser } from '@/spec' | ||
import { ICON } from '@/config' | ||
import { buildLog } from '@/utils/logger' | ||
// import Setter from './Setter' | ||
import { | ||
Wrapper, | ||
Avatar, | ||
SettingWrapper, | ||
SettingIcon, | ||
} from '../styles/list/create_works_layout' | ||
/* eslint-disable-next-line */ | ||
const log = buildLog('c:UserList:index') | ||
type TProps = { | ||
users: TUser[] | ||
withSetter?: boolean | ||
onSetting: () => void | ||
} | ||
const CreateWorksLayout: FC<TProps> = ({ | ||
users, | ||
withSetter = false, | ||
onSetting, | ||
}) => { | ||
return ( | ||
<Wrapper> | ||
{users.map((user) => ( | ||
<Avatar key={user.id} src={user.avatar} /> | ||
))} | ||
{withSetter && ( | ||
<SettingWrapper onClick={onSetting}> | ||
<SettingIcon src={`${ICON}/shape/settings.svg`} /> | ||
</SettingWrapper> | ||
)} | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(CreateWorksLayout) |
49 changes: 49 additions & 0 deletionssrc/components/UserList/List/WorksLayout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* | ||
* UserList | ||
* | ||
*/ | ||
import { FC, memo } from 'react' | ||
import type { TUser } from '@/spec' | ||
import { ICON } from '@/config' | ||
import { buildLog } from '@/utils/logger' | ||
import Button from '@/components/Buttons/Button' | ||
import UserItem from '../UserItem' | ||
import { | ||
Wrapper, | ||
SettingWrapper, | ||
SettingIcon, | ||
} from '../styles/list/works_layout' | ||
/* eslint-disable-next-line */ | ||
const log = buildLog('c:UserList:index') | ||
type TProps = { | ||
users: TUser[] | ||
withSetter?: boolean | ||
onSetting: () => void | ||
} | ||
const WorksLayout: FC<TProps> = ({ users, withSetter = false, onSetting }) => { | ||
return ( | ||
<Wrapper> | ||
{users.map((user) => ( | ||
<UserItem key={user.id} user={user} /> | ||
))} | ||
{withSetter && ( | ||
<SettingWrapper onClick={onSetting}> | ||
<Button size="small" ghost noBorder> | ||
管理 | ||
<SettingIcon src={`${ICON}/shape/settings.svg`} /> | ||
</Button> | ||
</SettingWrapper> | ||
)} | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(WorksLayout) |
41 changes: 41 additions & 0 deletionssrc/components/UserList/List/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { FC } from 'react' | ||
import type { TUser } from '@/spec' | ||
import type { TLayout } from '../spec' | ||
import CreateWorksLayout from './CreateWorksLayout' | ||
import WorksLayout from './WorksLayout' | ||
// create-works, works, guide-contribute | ||
type TProps = { | ||
layout: TLayout | ||
users: TUser[] | ||
withSetter?: boolean | ||
onSetting: () => void | ||
} | ||
const Layout: FC<TProps> = ({ layout, users, withSetter, onSetting }) => { | ||
switch (layout) { | ||
case 'works': { | ||
return ( | ||
<WorksLayout | ||
users={users} | ||
withSetter={withSetter} | ||
onSetting={onSetting} | ||
/> | ||
) | ||
} | ||
default: { | ||
return ( | ||
<CreateWorksLayout | ||
users={users} | ||
withSetter={withSetter} | ||
onSetting={onSetting} | ||
/> | ||
) | ||
} | ||
} | ||
} | ||
export default Layout |
46 changes: 46 additions & 0 deletionssrc/components/UserList/Setter/Header.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FC, Fragment, memo } from 'react' | ||
import { ICON } from '@/config' | ||
import { Wrapper, BackWrapper, PlusIcon } from '../styles/setter/header' | ||
import Button from '@/components/Buttons/Button' | ||
import ArrowButton from '@/components/Buttons/ArrowButton' | ||
import LavaLampLoading from '@/components/Loading/LavaLampLoading' | ||
import type { TView } from '../spec' | ||
type TProps = { | ||
view: TView | ||
goBack: () => void | ||
goSearch: () => void | ||
} | ||
const Header: FC<TProps> = ({ view, goBack, goSearch }) => { | ||
return ( | ||
<Wrapper> | ||
{view === 'list' && ( | ||
<Fragment> | ||
<div>管理团队成员</div> | ||
<Button size="small" onClick={goSearch} ghost noBorder> | ||
<PlusIcon src={`${ICON}/shape/plus.svg`} /> | ||
添加新成员 | ||
</Button> | ||
</Fragment> | ||
)} | ||
{view === 'search' && ( | ||
<BackWrapper> | ||
<Button size="small" onClick={goBack} ghost noBorder> | ||
<ArrowButton size="medium" direction="left" arrowStyle="simple"> | ||
返回 | ||
</ArrowButton> | ||
</Button> | ||
<LavaLampLoading size="small" /> | ||
</BackWrapper> | ||
)} | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(Header) |
66 changes: 66 additions & 0 deletionssrc/components/UserList/Setter/List.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { FC, memo } from 'react' | ||
import type { TUser } from '@/spec' | ||
import { ICON } from '@/config' | ||
import { SpaceGrow } from '@/components/Common' | ||
import Tooltip from '@/components/Tooltip' | ||
import Checker from '@/components/Checker' | ||
import { | ||
Wrapper, | ||
UserWrapper, | ||
Avatar, | ||
Intro, | ||
Name, | ||
Bio, | ||
CheckWrapper, | ||
RemoveIcon, | ||
} from '../styles/setter/list' | ||
type TProps = { | ||
users: TUser[] | ||
withDelete: boolean | ||
withSelect: boolean | ||
} | ||
const List: FC<TProps> = ({ | ||
users, | ||
withDelete = false, | ||
withSelect = false, | ||
}) => { | ||
return ( | ||
<Wrapper> | ||
{users.map((user) => ( | ||
<UserWrapper key={user.id}> | ||
<Avatar src={user.avatar} /> | ||
<Intro> | ||
<Name> | ||
{user.nickname} | ||
<SpaceGrow /> | ||
{withSelect && ( | ||
<CheckWrapper> | ||
<Checker size="small" /> | ||
</CheckWrapper> | ||
)} | ||
{withDelete && ( | ||
<Tooltip | ||
trigger="click" | ||
content="请确认是否继续?" | ||
placement="left" | ||
behavior="delete-confirm" | ||
> | ||
<RemoveIcon src={`${ICON}/shape/delete-solid.svg`} /> | ||
</Tooltip> | ||
)} | ||
</Name> | ||
<Bio>{user.bio}</Bio> | ||
</Intro> | ||
</UserWrapper> | ||
))} | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(List) |
13 changes: 13 additions & 0 deletionssrc/components/UserList/Setter/SearchBox.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { FC, memo } from 'react' | ||
import { Wrapper, SearchInput } from '../styles/setter/search_box' | ||
const SearchBox: FC = () => { | ||
return ( | ||
<Wrapper> | ||
<SearchInput placeholder="// 输入用户名查找用户" /> | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(SearchBox) |
55 changes: 55 additions & 0 deletionssrc/components/UserList/Setter/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* | ||
* UserList | ||
* | ||
*/ | ||
import { FC, memo, useState } from 'react' | ||
import type { TUser } from '@/spec' | ||
import { buildLog } from '@/utils/logger' | ||
import Modal from '@/components/Modal' | ||
import Header from './Header' | ||
import SearchBox from './SearchBox' | ||
import List from './List' | ||
import type { TView } from '../spec' | ||
import { Wrapper } from '../styles/setter' | ||
/* eslint-disable-next-line */ | ||
const log = buildLog('c:UserList:index') | ||
export type TProps = { | ||
testid?: string | ||
show: boolean | ||
users: TUser[] | ||
withSetter?: boolean | ||
onClose: () => void | ||
} | ||
const Setter: FC<TProps> = ({ show, users, onClose }) => { | ||
const [view, setView] = useState('list') // list or search | ||
return ( | ||
<> | ||
<Modal width="400px" show={show} showCloseBtn onClose={onClose}> | ||
<Wrapper> | ||
<Header | ||
view={view as TView} | ||
goBack={() => setView('list')} | ||
goSearch={() => setView('search')} | ||
/> | ||
{view === 'search' && <SearchBox />} | ||
<List | ||
users={users} | ||
withDelete={view === 'list'} | ||
withSelect={view === 'search'} | ||
/> | ||
</Wrapper> | ||
</Modal> | ||
</> | ||
) | ||
} | ||
export default memo(Setter) |
36 changes: 36 additions & 0 deletionssrc/components/UserList/UserItem.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FC, memo } from 'react' | ||
import type { TUser } from '@/spec' | ||
import { ICON } from '@/config' | ||
import { SpaceGrow } from '@/components/Common' | ||
import Tooltip from '@/components/Tooltip' | ||
import Checker from '@/components/Checker' | ||
import { | ||
Wrapper, | ||
Avatar, | ||
Intro, | ||
Name, | ||
Bio, | ||
CheckWrapper, | ||
RemoveIcon, | ||
} from './styles/user_item' | ||
type TProps = { | ||
user: TUser | ||
} | ||
const List: FC<TProps> = ({ user }) => { | ||
return ( | ||
<Wrapper key={user.id}> | ||
<Avatar src={user.avatar} /> | ||
<Intro> | ||
<Name>{user.nickname}</Name> | ||
<Bio>{user.bio}</Bio> | ||
</Intro> | ||
</Wrapper> | ||
) | ||
} | ||
export default memo(List) |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.