Dejvino's Curriculum Vitae
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
1.1 KiB

  1. import React, { useEffect, useRef, useState } from 'react';
  2. import Container from 'react-bootstrap/Container';
  3. import { useFocusedElement } from '../FocusedElement';
  4. export type Props = {
  5. title: string,
  6. icon?: string,
  7. tags: string[],
  8. style?: 'primary' | 'light'
  9. }
  10. function Tag(props: {text: string}) {
  11. const tagKey = 'tag_' + props.text;
  12. const {elementRef, focusedClass, focusElement} = useFocusedElement(tagKey)
  13. return (
  14. <span ref={elementRef}
  15. onClick={focusElement}
  16. className={`badge text-bg-light ${focusedClass}`}>{props.text}</span>
  17. )
  18. }
  19. export default function TagCloud(props: Props) {
  20. const containerClasses = ['tag-cloud', 'cloud-' + (props.style || 'standard')]
  21. return (
  22. <Container className={containerClasses.join(' ')}>
  23. <h4>{props.icon && (<i className={'bi-' + props.icon}> </i>)}{props.title}</h4>
  24. <Container className='tag-badges'>
  25. {props.tags.map((tag: string) => (<Tag key={tag} text={tag} />) )}
  26. </Container>
  27. </Container>
  28. )
  29. }