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

fix: popover trigger placement and list of members sorted #112

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions src/common/utils/parser/groupParticipantsByRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import { User } from '../../types';
}
*/

export function groupParticipantsByRole(membersObj: User[], administrator: User) {
const grouped = membersObj.concat(administrator).reduce(
export function groupParticipantsByRole(membersObj: User[], administratorObj: User) {
const grouped = [administratorObj].concat(membersObj).reduce(
// thanks Marcos <3!
(acc, obj) => {
if (!acc[obj.role]) {
acc[obj.role] = [];
Expand Down
13 changes: 7 additions & 6 deletions src/components/Cards/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const ProjectCard = ({
list: cn('flex flex-wrap gap-4 mt-4 text-3.5'),
popoverTrigger: cn(
'bg-gradient-to-rb from-primary-600 to-secondary-500 w-5 h-5 rounded-full text-xs flex items-center justify-center cursor-pointer select-none'
)
),
adminBadge: cn('text-xs bg-gradient-to-rb from-primary-600 to-secondary-500 text-transparent bg-clip-text rounded-full')
};

const handleDescription = () => {
Expand All @@ -60,19 +61,19 @@ export const ProjectCard = ({
const participantList = participantsByRole[role].map((participant, idx) => {
const isAdmin = Object.values(administrator).includes(participant.name);
return (
<li className="text-cWhite capitalize px-1 py-0.5 flex gap-1" key={participant.name + idx}>
<li className="text-cWhite capitalize px-1 py-0.5 flex items-center gap-1.5" key={participant.name + idx}>
{participant.name}
{isAdmin && <span className="text-secondary-600">{'(Adm)'}</span>}
{isAdmin && <span className={classes.adminBadge}>{'(admin)'}</span>}
</li>
);
});

return (
<li key={role + idx}>
{/** TODO: change key later πŸ˜’ Why later?*/}
<Tag>
<div className="flex items-center gap-2">
{role}
<Tag className="relative capitalize">
<span>{role}</span>
<div className="absolute -right-2 -top-2">
<Popover content={<ul>{participantList}</ul>}>
<span className={classes.popoverTrigger}>{groupLength}</span>
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface TagProps {
export const Tag = ({ children, variant = TagVariant.primary, size = TagSize.sm, className, borderSize = TagSize.xs }: TagProps) => {
const classes = {
container: cn('flex items-center justify-center rounded-full w-fit', TagContainerVariants[variant], BorderSizes[borderSize], className),
tag: cn('rounded-full py-px px-2', TagVariants[variant], Sizes[size])
tag: cn('rounded-full py-0.5 px-3', TagVariants[variant], Sizes[size])
};

return (
Expand Down
Loading