Browse Source

Remove autofocus from tags. Refactoring.

master
Dejvino 11 months ago
parent
commit
08b182e1c5
4 changed files with 15 additions and 23 deletions
  1. +7
    -0
      src/app/components/Tag.tsx
  2. +3
    -10
      src/app/components/TagCloud.tsx
  3. +1
    -1
      src/app/components/job/JobCard.tsx
  4. +4
    -12
      src/app/components/job/JobTags.tsx

+ 7
- 0
src/app/components/Tag.tsx View File

@@ -0,0 +1,7 @@
import React from "react"

export default function Tag(props: {text: string}) {
return (
<span className='badge text-bg-light'>{props.text}</span>
)
}

+ 3
- 10
src/app/components/TagCloud.tsx View File

@@ -1,6 +1,7 @@
import React, { useEffect, useRef, useState } from 'react';
import React from 'react';
import Container from 'react-bootstrap/Container';
import { useAutoFocus, useFocusedElement } from '../hooks/FocusedElement';
import { useAutoFocus } from '../hooks/FocusedElement';
import Tag from './Tag';

export type Props = {
title: string,
@@ -9,14 +10,6 @@ export type Props = {
style?: 'primary' | 'light'
}

function Tag(props: {text: string}) {
const tagKey = 'tag ' + props.text;
const elementRef = useAutoFocus(tagKey)
return (
<span ref={elementRef} className='badge text-bg-light'>{props.text}</span>
)
}

export default function TagCloud(props: Props) {
const focusRef = useAutoFocus<HTMLDivElement>('tags ' + props.title)
const containerClasses = ['tag-cloud', 'cloud-' + (props.style || 'standard')]


+ 1
- 1
src/app/components/job/JobCard.tsx View File

@@ -2,7 +2,7 @@ import React from 'react';
import Card from 'react-bootstrap/Card';
import { useAutoFocus } from '../../hooks/FocusedElement';
import { Placeholder } from 'react-bootstrap';
import JobTags from './JobTags';
import JobTags, { focusKeyPlaceholder } from './JobTags';
import { Job } from '@/PersonalDataTypes';
import md from '../Markdown';



+ 4
- 12
src/app/components/job/JobTags.tsx View File

@@ -1,23 +1,15 @@
import { useAutoFocus } from "@/app/hooks/FocusedElement";
import React from "react";
import { Container } from "react-bootstrap";
import Tag from "../Tag";

export type Props = {
tags: string[]
}

export function JobTag(props: {text: string}) {
const tagKey = 'tag ' + props.text;
const elementRef = useAutoFocus(tagKey)
return (
<span ref={elementRef} className='badge text-bg-light'>{props.text}</span>
)
tags: string[],
}

export default function JobTags(props: Props) {
return (
<Container className='job-tags' fluid>
{props.tags.map((tag, index) => <JobTag key={index} text={tag} />)}
{props.tags.map((tag, index) => <Tag key={index} text={tag} />)}
</Container>
)
}
}

Loading…
Cancel
Save