Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
feat: re-ordering tags (#9823)
Browse files Browse the repository at this point in the history
* fix: Re-ordering tags with Drag-and-Drop

* Added on Hover cursor change

* Added setTags for events
  • Loading branch information
Abhishek-90 authored Dec 1, 2023
1 parent 7e2b9ff commit 8e3abe6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/tag/TagsInput.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import XMarkIcon from "@heroicons/react/20/solid/XMarkIcon";
import Input from "../form/Input";
import { ReactSortable } from "react-sortablejs";
import Notification from "@components/Notification";

export default function TagsInput({
tags,
onTagAdd,
onTagRemove,
inputRef,
setTags,
showNotification,
setShowNotification,
}) {
Expand Down Expand Up @@ -49,7 +51,7 @@ export default function TagsInput({
const tagItems = tags.map((tag, i) => (
<li
key={i}
className="flex items-center gap-x-1 text-sm p-1 font-mono border rounded-md line-clamp-1"
className="flex items-center gap-x-1 text-sm p-1 font-mono border rounded-md line-clamp-1 hover:cursor-move"
>
<span>{tag}</span>
<button
Expand Down Expand Up @@ -78,7 +80,11 @@ export default function TagsInput({
additionalMessage={showNotification.additionalMessage}
/>
<label htmlFor="tags">Tags</label>
<ul
<ReactSortable
tag="ul"
list={tags}
setList={setTags}
swap
role="list"
className="flex flex-wrap items-center gap-x-4 gap-y-2 border-primary-medium-low mt-3 border-2 transition-all duration-250 ease-linear rounded px-6 py-2 mb-2 w-full dark:bg-primary-high focus-within:border-tertiary-medium hover:border-tertiary-medium"
>
Expand All @@ -94,7 +100,7 @@ export default function TagsInput({
onKeyDown={handleKeyDown}
/>
</li>
</ul>
</ReactSortable>
</>
);
}
1 change: 1 addition & 0 deletions pages/account/manage/event/[[...data]].js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export default function ManageEvent({ BASE_URL, event }) {
onTagAdd={handleTagAdd}
onTagRemove={handleTagRemove}
tags={tags}
setTags={setTags}
inputRef={tagInputRef}
showNotification={showNotification}
setShowNotification={setShowNotification}
Expand Down
1 change: 1 addition & 0 deletions pages/account/manage/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export default function Profile({ BASE_URL, profile, fileExists }) {
onTagRemove={handleTagRemove}
tags={tags}
inputRef={tagInputRef}
setTags={setTags}
showNotification={showNotification}
setShowNotification={setShowNotification}
/>
Expand Down

0 comments on commit 8e3abe6

Please sign in to comment.