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

Iconized/Collapsed variant of collaborators badges for mobile #3307

Merged
merged 5 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
25 changes: 22 additions & 3 deletions catalog/app/components/Collaborators/Avatars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const useStyles = M.makeStyles((t) => ({
position: 'relative',
transition: 'margin 0.3s ease',
},
moreIconized: {
marginLeft: '4px',
},
userpic: {
marginTop: '6px',
},
Expand All @@ -82,10 +85,16 @@ const useStyles = M.makeStyles((t) => ({
interface AvatarsProps {
className?: string
collaborators: Model.Collaborators
iconized?: boolean
onClick: () => void
}

export default function Avatars({ className, collaborators, onClick }: AvatarsProps) {
export default function Avatars({
className,
collaborators,
iconized,
onClick,
}: AvatarsProps) {
const knownCollaborators = collaborators.filter(
({ permissionLevel }) => !!permissionLevel,
)
Expand All @@ -94,9 +103,10 @@ export default function Avatars({ className, collaborators, onClick }: AvatarsPr
)

const avatars = React.useMemo(() => {
if (iconized) return []
if (!potentialCollaborators.length) return knownCollaborators.slice(0, 5)
return [potentialCollaborators[0], ...knownCollaborators.slice(0, 4)]
}, [knownCollaborators, potentialCollaborators])
}, [iconized, knownCollaborators, potentialCollaborators])

const classes = useStyles()
const moreNum = React.useMemo(
Expand All @@ -106,6 +116,13 @@ export default function Avatars({ className, collaborators, onClick }: AvatarsPr

return (
<div className={cx(classes.root, className)} onClick={onClick}>
{iconized && (
<div className={classes.avatarWrapper}>
<M.Icon className={classes.userpic} title="Collaborators">
people_outline
</M.Icon>
</div>
)}
{avatars.reduce(
(memo, { collaborator: { email }, permissionLevel }, index) => (
<div className={classes.avatarWrapper}>
Expand All @@ -122,7 +139,9 @@ export default function Avatars({ className, collaborators, onClick }: AvatarsPr
{moreNum > 0 && (
<div className={classes.avatarWrapper}>
<M.Tooltip title="Click to see more collaborators">
<span className={classes.more}>{moreNum}+</span>
<span className={cx(classes.more, { [classes.moreIconized]: iconized })}>
{moreNum}+
</span>
</M.Tooltip>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion catalog/app/components/FileEditor/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function Controls({
onEdit(types[0])
}
},
[onEdit, types],
[hasMultipleChoices, onEdit, types],
)
const handleTypeClick = React.useCallback(
(type) => {
Expand Down
3 changes: 3 additions & 0 deletions catalog/app/containers/NavBar/Collaborators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ interface CollaboratorsProps {

export default function Collaborators({ bucket, hidden }: CollaboratorsProps) {
const classes = useStyles()
const t = M.useTheme()
const sm = M.useMediaQuery(t.breakpoints.down('sm'))

const [{ data }] = urql.useQuery({
query: BUCKET_COLLABORATORS,
Expand Down Expand Up @@ -65,6 +67,7 @@ export default function Collaborators({ bucket, hidden }: CollaboratorsProps) {
<Avatars
className={cx(classes.avatars, { [classes.hidden]: hidden })}
collaborators={allCollaborators}
iconized={sm}
onClick={handleOpen}
/>
</M.MuiThemeProvider>
Expand Down
5 changes: 4 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Entries inside each section should be ordered by type:

## Catalog, Lambdas
!-->
## Catalog, Lambdas
* [Fixed] Fixed mobile layout for collaborators badges ([#3307](https://github.com/quiltdata/quilt/pull/3307))
* [Changed] Edit .quilt/config files with text editor ([#3306](https://github.com/quiltdata/quilt/pull/3306))

# 5.1.1 - 2023-01-25
## Python API
* [Fixed] Reduce backtracking during `pip install quilt3[catalog]` ([#3292](https://github.com/quiltdata/quilt/pull/3292))
Expand All @@ -33,7 +37,6 @@ Entries inside each section should be ordered by type:
* [Changed] Rename "Metadata" to "User metadata" ([#3255](https://github.com/quiltdata/quilt/pull/3255))
* [Changed] Show selective metadata for packages as JSON ([#3259](https://github.com/quiltdata/quilt/pull/3259))
* [Changed] Show selective metadata on one line and optionaly on multiple lines ([#3284](https://github.com/quiltdata/quilt/pull/3284))
* [Changed] Edit .quilt/config files with text editor ([#3306](https://github.com/quiltdata/quilt/pull/3306))

# 5.1.0 - 2022-12-09
## Python API
Expand Down