soapbox/app/soapbox/components/ui/tag-input/tag.tsx

29 wiersze
701 B
TypeScript
Czysty Zwykły widok Historia

2022-09-11 20:47:50 +00:00
import React from 'react';
import IconButton from '../icon-button/icon-button';
import Text from '../text/text';
interface ITag {
/** Name of the tag. */
tag: string
2022-09-11 20:47:50 +00:00
/** Callback when the X icon is pressed. */
onDelete: (tag: string) => void
2022-09-11 20:47:50 +00:00
}
/** A single editable Tag (used by TagInput). */
const Tag: React.FC<ITag> = ({ tag, onDelete }) => {
return (
2023-02-01 22:13:42 +00:00
<div className='inline-flex items-center whitespace-nowrap rounded bg-primary-500 p-1'>
2022-09-11 20:47:50 +00:00
<Text theme='white'>{tag}</Text>
<IconButton
iconClassName='h-4 w-4'
2022-09-11 20:47:50 +00:00
src={require('@tabler/icons/x.svg')}
onClick={() => onDelete(tag)}
transparent
/>
</div>
);
};
export default Tag;