diff --git a/packages/web/components/Quest/Skills.tsx b/packages/web/components/Quest/Skills.tsx index b575f4b9..a6a870a9 100644 --- a/packages/web/components/Quest/Skills.tsx +++ b/packages/web/components/Quest/Skills.tsx @@ -72,32 +72,52 @@ interface SkillsProps { export const SkillsTags: React.FC = ({ maxSkills = 6, skills, -}) => ( - - {skills.slice(0, maxSkills).map((skill) => ( - - {/* zIndex so the tooltip is lifted above the LinkOverlay that makes the whole tile a click target */} - - - {skill.name} - - - - ))} - {skills.length > maxSkills && ( - - - {`+${skills.length - maxSkills} more`} - - - )} - -); +}) => { + /** + * If there are more skills than maxSkills, collect the + * extra skills in a string to show in a tooltip + * moreSkills will be an empty string if skills.length is not greater than maxSkills + */ + const moreSkills: string = Array.from(skills.values()) + .slice(maxSkills) + .map((skill) => skill.name) + .join(', '); + + return ( + + {/* Print a limited number of skills as tags/chips */} + {skills.slice(0, maxSkills).map((skill) => ( + + {/* zIndex so the tooltip is lifted above the LinkOverlay that makes the whole tile a click target */} + + + {skill.name} + + + + ))} + {skills.length > maxSkills && ( + <> + {/** + * Print a tag/chip that shows how many more skills are associated with the quest, with a tooltip that shows those extra skill names on hover + */} + + + + {`+${skills.length - maxSkills} more`} + + + + + )} + + ); +}; export const SkillsTagsAll: React.FC = ({ skills }) => (