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

Create/Update Dogs Owner #65

Merged
merged 16 commits into from
Mar 3, 2025
4 changes: 4 additions & 0 deletions client/src/assets/icons/upload.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions client/src/components/TestFileUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { useState } from "react";
import { useMutation } from "@apollo/client";
import { DOG_PROFIL_PICTURE } from "@/graphQL/mutations/dogs";
import { useFileUpload } from "@/hooks/useFileUpload";

function TestFileUpload() {
const [uploadDogPicture] = useMutation(DOG_PROFIL_PICTURE);
const [selectedFile, setSelectedFile] = useState<File | null>(null);

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target.files?.[0]) {
setSelectedFile(event.target.files[0]);
}
};
const { selectedFile, handleChange } = useFileUpload();

const handleSend = async () => {
if (!selectedFile) {
Expand Down
194 changes: 107 additions & 87 deletions client/src/components/_atoms/Button/Button.scss
Original file line number Diff line number Diff line change
@@ -1,87 +1,107 @@
@import "@style";

$btn-types: (
"submit",
"dark",
"light",
"invite",
"role-select-left",
"role-select-right"
);

.button {
all: inherit;
min-height: $btn-height;
color: $primary-light;
font-weight: $semiBold;
border-radius: $atoms-radius;
padding: 1.25rem;
padding-inline: 3.5rem;
margin: 0.2rem;
font-size: $s;
background-color: $blue-200;
text-align: center;
cursor: pointer;
border: none;
display: inline-block;

@each $btn-type in $btn-types {
&.btn-#{$btn-type} {
color: $font-light;
}
}

&.btn-submit {
$background-color: $blue-200;
background-color: $background-color;

&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-dark {
$background-color: $blue-500;
background-color: $background-color;

&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-light {
$background-color: $blue-200;
background-color: $background-color;

&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-invite {
$background-color: $blue-500;
background-color: $background-color;

&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-role-select-left {
$background-color: $green-400;
background-color: $background-color;

&:hover {
background-color: $green-300;
}
}

&.btn-role-select-right {
$background-color: $orange-500;
background-color: $background-color;

&:hover {
background-color: $orange-400;
}
}
}
@import "@style";

$btn-types: (
"submit",
"dark",
"light",
"invite",
"role-select-left",
"role-select-right",
"thin-btn-light"
);

$colors: (
"orange": $orange-400,
"blue": $blue-100,
"green": $green-400,
);

.button {
all: inherit;
min-height: $btn-height;
color: $primary-light;
font-weight: $semiBold;
border-radius: $atoms-radius;
padding: 1.25rem;
padding-inline: 3.5rem;
margin: 0.2rem;
font-size: $s;
background-color: $blue-200;
text-align: center;
cursor: pointer;
border: none;
display: inline-block;

@each $btn-type in $btn-types {
&.btn-#{$btn-type} {
color: $font-light;
}
}

&.btn-submit {
$background-color: $blue-200;
background-color: $background-color;
&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-dark {
$background-color: $blue-500;
background-color: $background-color;
&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-light {
$background-color: $blue-200;
background-color: $background-color;
&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-invite {
$background-color: $blue-500;
background-color: $background-color;
&:hover {
background-color: lighten($background-color, 10%);
}
}

&.btn-role-select-left {
$background-color: $green-400;
background-color: $background-color;
&:hover {
background-color: $green-300;
}
}

&.btn-role-select-right {
$background-color: $orange-500;
background-color: $background-color;

&:hover {
background-color: $orange-400;
}
}

&.thin-btn-light {
padding: 0.8rem;
padding-inline: min(5rem, 10vw);
border-radius: 5px;
box-shadow: 0 3px 5px 5px rgba($beige-500, 0.2);

@each $color, $base-color in $colors {
&.thin-btn-#{$color} {
background-color: $base-color;

&:hover {
background-color: lighten($base-color, 5%);
color: $font-light;
}
}
}
}
}
56 changes: 36 additions & 20 deletions client/src/components/_atoms/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useNavigate } from "react-router-dom";
import "./Button.scss";

type ThinButtonColor = "orange" | "blue" | "green";

type ButtonStyles =
| "submit"
| "btn-dark"
Expand All @@ -9,7 +11,26 @@ type ButtonStyles =
| "event"
| "button"
| "role-select-left"
| "role-select-right";
| "role-select-right"
| { type: "thin-btn-light"; color: ThinButtonColor };

interface BaseButtonProps {
type?: "submit" | "button" | "reset";
children?: string;
href?: string;
className?: string;
onClick?: () => void;
}

interface RegularButtonProps extends BaseButtonProps {
style: Exclude<ButtonStyles, { type: "thin-btn-light" }>;
}

interface ThinButtonProps extends BaseButtonProps {
style: { type: "thin-btn-light"; color: ThinButtonColor };
}

type ButtonProps = RegularButtonProps | ThinButtonProps;
/** To add a new type:
* 1. Add the type in ButtonStyles up above
* 2. Add the type in Button.scss (list $btn-types)
Expand All @@ -24,27 +45,22 @@ export default function Button({
href,
className,
onClick,
}: {
style: ButtonStyles;
type?: "submit" | "button" | "reset" | undefined;
children?: string;
href?: string;
className?: string;
onClick?: () => void;
}) {
}: ButtonProps) {
const buttonType = style === "submit" ? "submit" : "button";
const buttonClassName =
style === "submit"
? "btn-submit"
: style === "btn-dark"
? "btn-dark"
: style === "invite" || style === "event"
? "btn-invite"
: style === "role-select-left"
? "btn-role-select-left"
: style === "role-select-right"
? "btn-role-select-right"
: "btn-light";
typeof style === "object"
? `thin-btn-light thin-btn-${style.color}`
: style === "submit"
? "btn-submit"
: style === "btn-dark"
? "btn-dark"
: style === "invite" || style === "event"
? "btn-invite"
: style === "role-select-left"
? "btn-role-select-left"
: style === "role-select-right"
? "btn-role-select-right"
: "btn-light";
const navigate = useNavigate();

if (href) {
Expand Down
6 changes: 6 additions & 0 deletions client/src/components/_atoms/Inputs/TextInput/TextInput.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
}

&__light {

label {
font-weight: $bold;
color: $blue-400;
}

input,
textarea {
border: 2px solid $beige-300;
Expand Down
34 changes: 31 additions & 3 deletions client/src/components/_atoms/Inputs/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ type TextInputTypes =
| "SIRET"
| "company_name"
| "telephone"
| "description";
| "description"
| "name"
| "birthDate"
| "breed"
| "info";

interface TextInputProps {
type?: TextInputTypes;
required?: boolean;
passwordRef?: React.RefObject<HTMLInputElement>;
isLogin?: boolean;
inputType?: "input" | "textarea";
inputType?: "input" | "textarea" | "date";
style?: "dark" | "light";
label?: string;
placeholder?: string;
Expand Down Expand Up @@ -76,6 +80,22 @@ const TEXT_INPUT_CONFIG: Record<
mappedLabel: "Description",
mappedPlaceholder: "Entrez votre description",
},
name: {
mappedLabel: "Nom de mon chien",
mappedPlaceholder: "Entrez le nom de votre chien",
},
birthDate: {
mappedLabel: "Date de naissance de mon chien",
mappedPlaceholder: "Sélectionnez la date de naissance",
},
breed: {
mappedLabel: "Race de mon chien",
mappedPlaceholder: "Entrez la race de votre chien",
},
info: {
mappedLabel: "Informations complémentaires",
mappedPlaceholder: "Entrez un commentaire sur votre chien",
},
};

// forwardRef allows us to use useRef in the component calling this one
Expand Down Expand Up @@ -155,7 +175,15 @@ const TextInput = React.forwardRef<
<input
id={inputId}
ref={inputRef as React.RefObject<HTMLInputElement>}
type={isPasswordField ? (showPassword ? "text" : "password") : type}
type={
isPasswordField
? showPassword
? "text"
: "password"
: inputType === "date"
? "date"
: "text"
}
placeholder={mappedPlaceholder}
required={required}
onBlur={validateInput}
Expand Down
Loading