-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib-user: Refactor MyGroups with GroupCards (#5989)
* Refactor mock panoptes resources * Move GroupCard * Refactor MyGroups with GroupCardList, add GroupCardContainer * Add MyGroup story * Fix GroupStats propType * Init MyGroups grid refactor for small screens * Refactor text color for dark theme in GroupCard group displayName and TitledStat * Fix hover effect and spacing issue * Fix GroupCardContainer import
- Loading branch information
Showing
24 changed files
with
505 additions
and
169 deletions.
There are no files selected for viewing
This file contains 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
38 changes: 38 additions & 0 deletions
38
packages/lib-user/src/components/MyGroups/MyGroups.stories.js
This file contains 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,38 @@ | ||
import MyGroups from './MyGroups' | ||
|
||
import GroupCard from './components/GroupCard/GroupCard' | ||
|
||
import { getActiveGroupsWithRoles } from './helpers/getActiveGroupsWithRoles' | ||
import { MEMBERSHIPS, USER_GROUPS } from '../../../test/mocks/panoptes' | ||
|
||
const MEMBERSHIPS_WITH_GROUPS = { | ||
linked: { | ||
user_groups: USER_GROUPS | ||
}, | ||
memberships: MEMBERSHIPS | ||
} | ||
const groups = getActiveGroupsWithRoles(MEMBERSHIPS_WITH_GROUPS) | ||
|
||
export default { | ||
title: 'Components/MyGroups', | ||
component: MyGroups | ||
} | ||
|
||
export const Default = { | ||
render: () => ( | ||
<MyGroups> | ||
{groups.map(group => ( | ||
<GroupCard | ||
key={group.id} | ||
classifications={Math.floor(Math.random() * 1000)} | ||
contributors={Math.floor(Math.random() * 10)} | ||
displayName={group.display_name} | ||
hours={Math.floor(Math.random() * 50)} | ||
id={group.id} | ||
projects={Math.floor(Math.random() * 10)} | ||
role={group.roles[0]} | ||
/> | ||
))} | ||
</MyGroups> | ||
) | ||
} |
This file contains 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
96 changes: 0 additions & 96 deletions
96
packages/lib-user/src/components/MyGroups/components/GroupCard.js
This file was deleted.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
packages/lib-user/src/components/MyGroups/components/GroupCard/GroupCard.js
This file contains 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,113 @@ | ||
import { SpacedHeading } from '@zooniverse/react-components' | ||
import { Anchor, Box } from 'grommet' | ||
import { number, string } from 'prop-types' | ||
import styled, { css } from 'styled-components' | ||
|
||
import { TitledStat } from '@components/shared' | ||
|
||
const StyledListItem = styled.li` | ||
border-radius: 8px; | ||
list-style: none; | ||
&:hover, &:focus-within { | ||
box-shadow: 1px 2px 6px 0px rgba(0, 0, 0, 0.25); | ||
} | ||
` | ||
|
||
const StyledAnchor = styled(Anchor)` | ||
&:hover, &:focus { | ||
text-decoration: none; | ||
outline: none; | ||
box-shadow: none; | ||
} | ||
` | ||
|
||
const StyledRole = styled(Box)` | ||
font-size: 9px; | ||
letter-spacing: 0.9px; | ||
display: flex; | ||
align-items: center; | ||
width: 90px; | ||
line-height: normal; | ||
padding: 5px 0; | ||
text-transform: uppercase; | ||
font-weight: bold; | ||
${props => | ||
css` | ||
color: ${props.theme.global.colors.black}; | ||
`} | ||
` | ||
|
||
function GroupCard({ | ||
classifications = 0, | ||
contributors = 0, // members | ||
displayName = '', | ||
hours = 0, | ||
id = '', | ||
projects = 0, | ||
role = '' | ||
}) { | ||
return ( | ||
<StyledListItem> | ||
<StyledAnchor | ||
href={`https://local.zooniverse.org:8080/?groups=${id}`} | ||
> | ||
<Box | ||
pad='20px' | ||
> | ||
<Box | ||
align='center' | ||
direction='row' | ||
gap='small' | ||
> | ||
<SpacedHeading | ||
color={{ light: 'neutral-1', dark: 'accent-1' }} | ||
size='16px' | ||
> | ||
{displayName} | ||
</SpacedHeading> | ||
<StyledRole | ||
round='xsmall' | ||
background={role === 'group_admin' ? 'neutral-2' : 'accent-1'} | ||
> | ||
{role === 'group_admin' ? 'Admin' : 'Member'} | ||
</StyledRole> | ||
</Box> | ||
<Box | ||
direction='row' | ||
justify='between' | ||
> | ||
<TitledStat | ||
title='Classifications' | ||
value={classifications} | ||
/> | ||
<TitledStat | ||
title='Hours' | ||
value={hours} | ||
/> | ||
<TitledStat | ||
title='Contributors' | ||
value={contributors} | ||
/> | ||
<TitledStat | ||
title='Projects' | ||
value={projects} | ||
/> | ||
</Box> | ||
</Box> | ||
</StyledAnchor> | ||
</StyledListItem> | ||
) | ||
} | ||
|
||
GroupCard.propTypes = { | ||
classifications: number, | ||
contributors: number, | ||
displayName: string, | ||
hours: number, | ||
id: string, | ||
projects: number, | ||
role: string | ||
} | ||
|
||
export default GroupCard |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...nts/MyGroups/components/GroupCard.spec.js → ...ps/components/GroupCard/GroupCard.spec.js
This file contains 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
4 changes: 2 additions & 2 deletions
4
.../MyGroups/components/GroupCard.stories.js → ...components/GroupCard/GroupCard.stories.js
This file contains 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
Oops, something went wrong.