Skip to content
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

Merged
merged 24 commits into from
Oct 11, 2023
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b3e7ca6
feat(front): create calls from services to tag api
Lerri-Cofannos Oct 6, 2023
e46f575
feat(front): add red option in button atom
Lerri-Cofannos Oct 6, 2023
29d497b
feat(front): create button atom with icon
Lerri-Cofannos Oct 6, 2023
bb7717c
feat(front): create popup atom
Lerri-Cofannos Oct 6, 2023
1d49193
feat(front): safe cast response from tagsAPI
Lerri-Cofannos Oct 6, 2023
bbdd338
feat(front): create tag popup
Lerri-Cofannos Oct 6, 2023
d09e3a9
refactor(front): move tables to views subdirectory
Lerri-Cofannos Oct 6, 2023
f2a7b30
fix(front): adjust getTags to server response
Lerri-Cofannos Oct 6, 2023
20a1eff
style(front): improve popup UI
Lerri-Cofannos Oct 6, 2023
9bcb131
refactor(front): move LogsData to prisma folder
Lerri-Cofannos Oct 10, 2023
2b55f4a
fix(front): update path to LogsData in page test
Lerri-Cofannos Oct 10, 2023
e19a887
style(front): change ButtonIcon outline colour
Lerri-Cofannos Oct 10, 2023
0b3c3c6
feat(front): improve UX speed when adding tags
Lerri-Cofannos Oct 10, 2023
b9af47d
refactor(front): move the propagation prevention to useTagPopup
Lerri-Cofannos Oct 10, 2023
5e4824f
refactor(front): move connectTagToLog to relevant file
Lerri-Cofannos Oct 10, 2023
72f975e
refactor(front): group tag helper functions
Lerri-Cofannos Oct 10, 2023
c64b9ee
feat(front): handle errors while connecting log and tag
Lerri-Cofannos Oct 10, 2023
39034c6
fix(front): prevent adding existing tag to array
Lerri-Cofannos Oct 10, 2023
4a22a4e
refactor(front): rename colour picker function
Lerri-Cofannos Oct 10, 2023
e800c1b
fix(front): remove unused buttons on popup
Lerri-Cofannos Oct 10, 2023
badbd1d
refactor(front): create closePopup func in tag hook
Lerri-Cofannos Oct 11, 2023
56006ed
refactor(front): use built-in string comparison
Lerri-Cofannos Oct 11, 2023
dec6e0e
refactor(front): clean className string format
Lerri-Cofannos Oct 11, 2023
8de6f1a
refactor(front): remove unused type option for button
Lerri-Cofannos Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions front/src/components/atoms/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ type ButtonProps = {
children: React.ReactNode;
onClick: () => void;
className?: string;
colour?: "blue" | "grey" | "green";
colour?: "blue" | "grey" | "green" | "red";
};

export const Button = ({ children, onClick, className, colour = "blue", ...props }: ButtonProps) => {
const blueStyle = "bg-theodo-turquoise hover:bg-omnilog-clear-blue";
const greyStyle = "bg-theodo-grey-regular hover:bg-theodo-turquoise";
const greenStyle = "bg-theodo-green-dark hover:bg-theodo-green-regular";
const bgColour = colour === "blue" ? blueStyle : colour === "grey" ? greyStyle : greenStyle;
export const Button = ({
children,
onClick,
className,
colour = "blue",
...props
}: ButtonProps) => {
const bgColour = colourPicker(colour);
return (
<button
className={` ${bgColour} text-white font-bold py-2 px-4 rounded ${className} transition-colors duration-100`}
Expand All @@ -19,4 +22,23 @@ export const Button = ({ children, onClick, className, colour = "blue", ...props
{children}
</button>
);
}
};

const colourPicker = (colour: string): string => {
const blueStyle = "bg-theodo-turquoise hover:bg-omnilog-clear-blue";
Copy link
Contributor

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

Copy link
Collaborator Author

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.

const greyStyle = "bg-theodo-grey-regular hover:bg-theodo-turquoise";
const greenStyle = "bg-theodo-green-dark hover:bg-theodo-green-regular";
const redStyle = "bg-red-600 hover:bg-red-500";
switch (colour) {
case "blue":
return blueStyle;
case "grey":
return greyStyle;
case "green":
return greenStyle;
case "red":
return redStyle;
default:
return blueStyle;
}
};