refactor: extract Tag to its own component
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { AppState } from '@/ui_models/app_state';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { toDirective } from './utils';
|
||||
import { Icon } from './Icon';
|
||||
import { Tag } from './Tag';
|
||||
import { AutocompleteTagInput } from './AutocompleteTagInput';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
|
||||
@@ -14,10 +14,7 @@ const NoteTags = observer(({ application, appState }: Props) => {
|
||||
return (
|
||||
<div className="flex flex-wrap">
|
||||
{appState.notes.activeNoteTags.map((tag) => (
|
||||
<span key={tag.uuid} className="bg-contrast rounded text-xs color-text p-1 flex items-center mt-2 mr-2">
|
||||
<Icon type="hashtag" className="small color-neutral mr-1" />
|
||||
{tag.title}
|
||||
</span>
|
||||
<Tag key={tag.uuid} title={tag.title} className="mt-2 mr-2" />
|
||||
))}
|
||||
<AutocompleteTagInput application={application} appState={appState} />
|
||||
</div>
|
||||
|
||||
16
app/assets/javascripts/components/Tag.tsx
Normal file
16
app/assets/javascripts/components/Tag.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { FunctionalComponent } from 'preact';
|
||||
import { Icon } from './Icon';
|
||||
|
||||
type TagProps = {
|
||||
title: string;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export const Tag: FunctionalComponent<TagProps> = ({ title, className }) => (
|
||||
<span
|
||||
className={`bg-contrast rounded text-xs color-text p-1 flex items-center ${className ?? ''}`}
|
||||
>
|
||||
<Icon type="hashtag" className="small color-neutral mr-1" />
|
||||
{title}
|
||||
</span>
|
||||
);
|
||||
Reference in New Issue
Block a user