-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add tag binding #90
Conversation
461452f
to
06986a5
Compare
d98311e
to
9bcb131
Compare
|
||
const colourPicker = (colour: string): string => { | ||
const blueStyle = "bg-theodo-turquoise hover:bg-omnilog-clear-blue"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this colourPicker specific to the button? If so, maybe include that in the name? Before I understood the function I thought if might be better living outside this folder, but actually it's looks specific to button? Probably good to make this clear in the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add it in the name, but this function is not exported so I thought it was clear that the scope was restrained to this file. I will rename it to buttonColourPicker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason that this component can't extend your non-icon button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style of both components are a bit different: this one has grey scale colours and is a circle.
<Button colour="blue" onClick={() => {}}> | ||
Useless Validation | ||
</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to prepare for the "Create New Tag" button, but since it would be pushed to prod before this feature appears, then I'll remove it. I'll also remove the "Cancel" button which is redundant with the top exit button of the Popup component
@@ -3,7 +3,7 @@ import { Button } from "@/components/atoms/Button"; | |||
import { CardAtom } from "@/components/atoms/CardAtom"; | |||
import { useNavigation } from "@/hooks/useNavigation"; | |||
import { LogData } from "@/types/logDisplayOptions"; | |||
import { ColumnContentTags } from "./components/ColumnContentTags"; | |||
import { ColumnContentTags } from "../components/ColumnContentTags"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why some of your imports are relative and others are absolute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the habit of writing the imports that are linked to the same feature as relative, and the ones which are not as absolute. Is this bad practice ?
import { MouseEventHandler } from "react"; | ||
|
||
type ButtonIconProps = { | ||
onClick: MouseEventHandler<HTMLButtonElement> | (() => void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need two types here? Why not just mouse event handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the two were too different, but you are right, casting () => void
to the event handler works great!
export const Popup = ({ children, open, setOpen }: PopupProps) => { | ||
return ( | ||
<Transition.Root show={open} as={Fragment}> | ||
<Dialog as="div" className="relative z-10" onClose={() => {}}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close is a different ticket im assuming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close
is a compulsory prop of the Dialog
component. It is called when clicking outside of the modal. I deactivated that behaviour to avoid a bug. The bug was that exiting with such a click navigated the user to the corresponding log. I suspect that the event that I had caught with e.stopPropagate
in openPopup
is freed and thus a click is made on the log's row, making the user navigate to it. I did not find a quick solution on the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do users close the dialog in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a button in the top right corner (see screenshot)
logId: string; | ||
}) => { | ||
const [tagArray, setTagArray] = useState<Tag[]>(tags); | ||
const addTag = (tag: Tag) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this is just setting it locally for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the idea is to update the database and the UI at the same time so that the user sees the new tag on his log without having to refresh the whole page. To do that I had to store the tags in this state.
}; | ||
|
||
export const TagPopup = ({ logId, addTagToDisplay }: TagPopupProps) => { | ||
const { isPopupOpen, openPopup, setIsPopupOpen, tags, selectTag } = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems odd. Wouldn't setIsPopUpOpen
be dependent on the openPopup
call? I don't think we need this much state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's needed but this seems a bit confusing to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The openPopup
is dependent on setIsOpenPopup
, but adds an event handler to prevent click propagation. I have replaced the function setIsOpenPopup
with closePopup
to stay consistent in the naming
}); | ||
}; | ||
|
||
const compareStrings = (stringA: string, stringB: string): number => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I thought sort basically did this by default, interesting you needed to define a sort function yourself since its a basic string sort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just do return newTagArray.sort(tagA.toLowerCase(), tagB.toLowerCase());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a little research and found a built-in function that compares string based on alphabetical order. New commit incoming!
setIsPopupOpen(true); | ||
}; | ||
|
||
return { isPopupOpen, openPopup, setIsPopupOpen, tags, selectTag }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I feel like you shouldn't need to expose setIsPopupOpen
outside fo this hook, like an openPopUp
and closePopUp
method shoudl only be exposed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I'll add a commit for this.
Waiting for TagsAPI routes to be functional.
Ticket for logs table
Ticket for details page