Skip to content

Commit 1ca1d21

Browse files
committed
update tags feature in post creation view
1 parent ad7f7d9 commit 1ca1d21

File tree

1 file changed

+65
-17
lines changed

1 file changed

+65
-17
lines changed

apps/frontend/src/components/launches/tags.component.tsx

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,33 +170,80 @@ export const TagsComponent: FC<{
170170
selected={tagValue}
171171
onAdd={onAddition}
172172
onInput={setSuggestions}
173+
renderOption={(option) => {
174+
const findTag = data?.tags?.find(
175+
(f) => f.name === option.option.label
176+
);
177+
return (
178+
<div
179+
className="flex flex-row items-center gap-2 p-2 cursor-pointer hover:bg-customColor1 group max-w-72"
180+
{...option}
181+
>
182+
{findTag ? (
183+
<>
184+
<input
185+
type="checkbox"
186+
checked={
187+
tagValue.findIndex(
188+
(f) => f.label === option.option.label
189+
) > -1
190+
}
191+
readOnly
192+
/>
193+
<div
194+
className="size-3 rounded-full flex-shrink-0"
195+
style={{
196+
backgroundColor: findTag?.color || '#942828',
197+
}}
198+
/>
199+
</>
200+
) : (
201+
<div className="size-3 flex justify-center items-center">
202+
+
203+
</div>
204+
)}
205+
<div className="max-w-24 overflow-hidden overflow-ellipsis whitespace-nowrap">
206+
{option.option.label}
207+
</div>
208+
<div className="flex items-center flex-grow flex-row-reverse">
209+
{findTag && (
210+
<Button
211+
onClick={edit(findTag)}
212+
className="!h-6 !px-2 !rounded !text-xs !bg-third items-center !opacity-70 hover:!opacity-100 invisible group-hover:visible"
213+
>
214+
<svg
215+
xmlns="http://www.w3.org/2000/svg"
216+
fill="none"
217+
viewBox="0 0 24 24"
218+
strokeWidth={1.5}
219+
stroke="currentColor"
220+
className="w-3 h-3"
221+
>
222+
<path
223+
strokeLinecap="round"
224+
strokeLinejoin="round"
225+
d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125"
226+
/>
227+
</svg>
228+
{t('edit', 'Edit')}
229+
</Button>
230+
)}
231+
</div>
232+
</div>
233+
);
234+
}}
173235
onDelete={onDelete}
174236
renderTag={(tag) => {
175237
const findTag = data?.tags?.find((f) => f.name === tag.tag.label);
176-
const findIndex = tagValue.findIndex(
177-
(f) => f.label === tag.tag.label
178-
);
179238
return (
180239
<div
181-
className={`min-w-[50px] float-left ms-[4px] p-[3px] rounded-sm relative`}
240+
className={`min-w-[50px] float-left ms-[4px] p-[3px] rounded-lg relative cursor-pointer text-[12px] flex items-center justify-center tag-item`}
182241
style={{
183242
backgroundColor: findTag?.color,
184243
}}
185244
>
186-
<div
187-
className="absolute -top-[5px] start-[10px] text-[12px] text-red-600 bg-white px-[3px] rounded-full"
188-
onClick={edit(findTag)}
189-
>
190-
{t('edit', 'Edit')}
191-
</div>
192-
<div
193-
className="absolute -top-[5px] -start-[5px] text-[12px] text-red-600 bg-white px-[3px] rounded-full"
194-
onClick={() => onDelete(findIndex)}
195-
>
196-
X
197-
</div>
198245
<div className="text-white mix-blend-difference">
199-
{tag.tag.label}
246+
{findTag?.name}
200247
</div>
201248
</div>
202249
);
@@ -206,6 +253,7 @@ export const TagsComponent: FC<{
206253
</>
207254
);
208255
};
256+
209257
const ShowModal: FC<{
210258
tag: string;
211259
color?: string;

0 commit comments

Comments
 (0)