-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Migrate ChevronScroll Component from SCSS to Tailwind CSS #602
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ function ChevronScroll(props: React.PropsWithChildren<{}>) { | |
(e: React.UIEvent<HTMLDivElement>) => { | ||
const { scrollLeft, scrollWidth, clientWidth } = e.currentTarget; | ||
const maxScroll = scrollWidth - clientWidth - 1; | ||
// show left chevron if not at start of scrollable area | ||
// Show left chevron if not at the start of the scrollable area | ||
setShowLeftChevron(scrollLeft !== 0); | ||
//show right chevron if not at end of scrollable area | ||
// Show right chevron if not at the end of the scrollable area | ||
setShowRightChevron(scrollLeft < maxScroll); | ||
}, | ||
[] | ||
|
@@ -32,7 +32,7 @@ function ChevronScroll(props: React.PropsWithChildren<{}>) { | |
}); | ||
setChildIndex(childIndex + 1); | ||
} else if (direction === "left") { | ||
// if at end of scrollable area, don't want to skip over partially cut element | ||
// If at the end of the scrollable area, don't skip over a partially cut element | ||
if (!showRightChevron) { | ||
scrollRef.current.scrollBy({ | ||
left: -1, | ||
|
@@ -50,13 +50,10 @@ function ChevronScroll(props: React.PropsWithChildren<{}>) { | |
}; | ||
|
||
return ( | ||
<div className="chevron-scroll-outer-container"> | ||
<div className="whitespace-nowrap flex w-[1088px] h-[47px]"> | ||
<button | ||
className={combineClasses( | ||
"chevron-scroll-left-btn", | ||
"align-center", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should convert this CSS: |
||
"justify-center", | ||
"row", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also convert this |
||
"bg-white px-[32px] py-0 cursor-pointer border-none justify-center", | ||
showLeftChevron ? undefined : "hidden" | ||
)} | ||
onClick={() => scrollMove("left")} | ||
|
@@ -67,23 +64,21 @@ function ChevronScroll(props: React.PropsWithChildren<{}>) { | |
<div | ||
ref={scrollRef} | ||
onScroll={handleChevronVisibility} | ||
className="chevron-scroll-child-container" | ||
className="scroll-snap-x mandatory overflow-auto flex items-center gap-4 scrollbar-none" | ||
> | ||
{props.children} | ||
</div> | ||
<button | ||
className={combineClasses( | ||
"chevron-scroll-right-btn", | ||
"align-center", | ||
"row", | ||
"bg-white px-[32px] py-0 cursor-pointer border-none justify-center", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets also keep the CSS for the above |
||
showRightChevron ? undefined : "hidden" | ||
)} | ||
onClick={() => scrollMove("right")} | ||
aria-label="Scroll right" | ||
> | ||
<IconChevronRight /> | ||
</button> | ||
<button className="chevron-scroll-clear-btn">Clear all</button> | ||
<button className="flex items-center underline font-bold text-lg text-gray-700 ml-4 bg-transparent p-0 border-none cursor-pointer">Clear all</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is perfect, very nice 👌 |
||
</div> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react"; | ||
|
||
const ChevronScroll = () => { | ||
return ( | ||
<div className="whitespace-nowrap flex w-[1088px] h-[47px]"> | ||
<div className="scroll-snap-x mandatory overflow-auto flex items-center gap-4 scrollbar-none"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think these are valid tailwind classes |
||
{/* Chevron Scroll Left Button */} | ||
<button | ||
className="bg-white px-8 py-0 cursor-pointer border-none" | ||
aria-label="Scroll Left" | ||
> | ||
{/* Insert left chevron icon here */} | ||
</button> | ||
|
||
{/* Scrollable Content */} | ||
<div className="flex-1">Scrollable content goes here</div> | ||
|
||
{/* Chevron Scroll Right Button */} | ||
<button | ||
className="bg-white px-8 py-0 cursor-pointer border-none" | ||
aria-label="Scroll Right" | ||
> | ||
{/* Insert right chevron icon here */} | ||
</button> | ||
</div> | ||
|
||
{/* Clear Button */} | ||
<button className="flex items-center underline font-bold text-lg text-gray-700 ml-4 bg-transparent p-0 border-none cursor-pointer"> | ||
Clear | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChevronScroll; |
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.
Lets revert all the changes to the originalChevronScroll.tsx
file. I'd like for it to remain untouched so we have something to compare to, and other pages might still be using this component.Edit:
On second thought, after reviewing, I see how difficult this instruction realistically is. I didn't realize there would be so much Component functionality to migrate. Sorry about that. I am going to change the instructions so that we just modify the CSS classes directly in the original Component files.
For this PR, lets remove the
ChevronScrollTailwind.tsx
file and keep the changes withinChevronScroll.tsx
.Thank you for going with the original instruction anyway even though it was silly 😅