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.
 
 
 

32 lines
1.1 KiB

  1. import React, { useEffect, useRef, useState } from 'react';
  2. import Container from 'react-bootstrap/Container';
  3. import { useAutoFocus, useFocusedElement } from '../hooks/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 = useAutoFocus(tagKey)
  13. return (
  14. <span ref={elementRef} className='badge text-bg-light'>{props.text}</span>
  15. )
  16. }
  17. export default function TagCloud(props: Props) {
  18. const focusRef = useAutoFocus<HTMLDivElement>('tags ' + props.title)
  19. const containerClasses = ['tag-cloud', 'cloud-' + (props.style || 'standard')]
  20. return (
  21. <Container ref={focusRef} className={containerClasses.join(' ')}>
  22. <h4>{props.icon && (<i className={'bi-' + props.icon}> </i>)}{props.title}</h4>
  23. <Container className='tag-badges'>
  24. {props.tags.map((tag: string) => (<Tag key={tag} text={tag} />) )}
  25. </Container>
  26. </Container>
  27. )
  28. }