Skip to content

Commit

Permalink
Merge pull request #103 from softeerbootcamp4th/refactor/optimization
Browse files Browse the repository at this point in the history
[Refactor] 최적화 및 오류 수정
  • Loading branch information
leve68 authored Aug 23, 2024
2 parents b460add + 1987a8b commit bf4ca53
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 41 deletions.
4 changes: 4 additions & 0 deletions public/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ body {
transition-duration: 300ms;
}

.whitespace-pre {
white-space: pre;
}

/* 특수 효과 */
.text-glow-white {
text-shadow:
Expand Down
19 changes: 11 additions & 8 deletions public/share.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@
</div>
</div>
<div
class="margin-top-2-25-rem flex-column gap-1-rem flex flex-center"
class="margin-top-2-25-rem flex-column gap-1-rem flex-center"
>
<p class="color-gray-200 font-kia-signature">
이벤트 응모하고<span
class="color-gray-50 font-kia-signature-bold"
>시그니엘 숙박권</span
>받자!!
</p>
<div
class="color-gray-200 whitespace-pre font-kia-signature flex-center"
>
<span>이벤트 응모하고</span
><span
class="color-gray-50 whitespace-pre font-kia-signature-bold"
>&nbsp시그니엘 숙박권</span
><span>&nbsp받자!!</span>
</div>
<button
class="position-relative height-6-25-rem width-94-rem border-radius-3xl background-primary color-gray-950 group overflow-hidden flex-center"
onclick="window.location.href='https://www.hyundaiseltos.site/event2/0';"
Expand Down Expand Up @@ -254,7 +257,7 @@

descriptionTextElement.innerHTML = descriptionList
.map((item) => {
return `<span class="${item.highlighted ? "color-gray-50" : "color-gray-400"}">${item.content} </span>`;
return `<span class="${item.highlighted ? "color-gray-50" : "color-gray-400"} whitespace-pre">${item.content} </span>`;
})
.join("");

Expand Down
1 change: 0 additions & 1 deletion src/client/api/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export const postEvent2Answers = async (
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: decodeURI(Cookies.get("auth") || ""),
},
body: JSON.stringify(answers),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ interface DriveDescriptionItemProps {
img: string;
tailwind?: string;
isSelected?: boolean;
noneSelected?: boolean;
}

const DriveDescriptionItem = ({
title,
description,
img,
tailwind,
isSelected,
noneSelected,
}: DriveDescriptionItemProps) => {
return (
<div
role="article"
className={`flex h-[20.875rem] w-[30rem] flex-col gap-700 flex-center ${tailwind}`}
>
const DriveDescriptionItem = React.memo(
({
title,
description,
img,
tailwind,
isSelected,
}: DriveDescriptionItemProps) => {
return (
<div
role="figure"
className={`flex h-full w-full justify-center break-keep bg-cover bg-center px-8 pt-8 font-kia-signature text-body-1-regular text-gray-50 ${noneSelected ? "text-opacity-0" : isSelected ? "text-opacity-100" : "text-opacity-0"} transition-all duration-200`}
style={{
backgroundImage: `${noneSelected ? `url(${img})` : isSelected ? `linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.8) 100%), url(${img})` : `url(${img})`}`,
}}
role="article"
className={`flex h-[20.875rem] w-[30rem] flex-col gap-700 flex-center ${tailwind}`}
>
{description}
<div
role="figure"
className={`flex h-full w-full justify-center break-keep bg-cover bg-center px-8 pt-8 font-kia-signature text-body-1-regular text-gray-50 ${isSelected ? "text-opacity-100" : "text-opacity-0"} transition-all duration-200`}
style={{
backgroundImage: `${isSelected ? `linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.8) 100%), url(${img})` : `url(${img})`}`,
}}
>
{description}
</div>
<div className="font-kia-signature-bold text-title-4 text-gray-950">
{title}
</div>
</div>
<div className="font-kia-signature-bold text-title-4 text-gray-950">
{title}
</div>
</div>
);
};
);
},
);

export default DriveDescriptionItem;
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const DriveSection = () => {
description={description}
img={image}
isSelected={index === selectedIndex}
noneSelected={selectedIndex === -1}
tailwind={`${isInView ? "opacity-100 scale-100" : "opacity-0 scale-90"} transition-all duration-[200ms] ease-[cubic-bezier(0.65, 0, 0.35, 1)] origin-bottom-right ${animationDelay[index as keyof typeof animationDelay]} `}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const RandomMainSection = ({
const getUniqueUrl = async () => {
if (isAuth)
try {
console.log("getURL");
const { result } = await postRandomResult(resultTypeId);
setShareUrl(result.uniqueLink);
} catch (error) {
Expand All @@ -57,11 +58,10 @@ const RandomMainSection = ({
const handleEventParticipation = async () => {
if (isAuth) {
getUniqueUrl();
setIsRandomEnd(true);
} else {
navigate("/auth-modal", { state: { background: location, event: 2 } });
}

setIsRandomEnd(true);
};

useEffect(() => {
Expand Down Expand Up @@ -91,12 +91,12 @@ const RandomMainSection = ({

<div className="flex font-kia-signature-bold text-title-3">
{description.map((item, index) => (
<span
<div
key={index}
className={`${item.highlighted ? "text-gray-50" : "text-gray-400"}`}
className={`${item.highlighted ? "text-gray-50" : "text-gray-400"} whitespace-pre`}
>
{item.content}
</span>
</div>
))}
</div>

Expand Down

0 comments on commit bf4ca53

Please sign in to comment.