refactor: extract Tag to its own component
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { AppState } from '@/ui_models/app_state';
|
import { AppState } from '@/ui_models/app_state';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
import { toDirective } from './utils';
|
import { toDirective } from './utils';
|
||||||
import { Icon } from './Icon';
|
import { Tag } from './Tag';
|
||||||
import { AutocompleteTagInput } from './AutocompleteTagInput';
|
import { AutocompleteTagInput } from './AutocompleteTagInput';
|
||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
|
|
||||||
@@ -14,10 +14,7 @@ const NoteTags = observer(({ application, appState }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap">
|
<div className="flex flex-wrap">
|
||||||
{appState.notes.activeNoteTags.map((tag) => (
|
{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">
|
<Tag key={tag.uuid} title={tag.title} className="mt-2 mr-2" />
|
||||||
<Icon type="hashtag" className="small color-neutral mr-1" />
|
|
||||||
{tag.title}
|
|
||||||
</span>
|
|
||||||
))}
|
))}
|
||||||
<AutocompleteTagInput application={application} appState={appState} />
|
<AutocompleteTagInput application={application} appState={appState} />
|
||||||
</div>
|
</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