-
Notifications
You must be signed in to change notification settings - Fork 0
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
ToggleButtonGroup and Carousel components created for Sections filters feature #66
Conversation
@@ -36,6 +36,7 @@ exports[`Modal matches snapshot 1`] = ` | |||
<section | |||
aria-labelledby="react-aria-2" | |||
class="sc-eCYdqJ iasutB" | |||
data-rac="" |
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.
Updates coming from react-aria-components v1.6.0
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 is looking really good, I'm mainly wondering about responsiveness and some minor things.
src/components/Carousel/styles.ts
Outdated
|
||
export const CarouselContainer = styled.div<{customWidth?: string}>` | ||
position: relative; | ||
width: ${({customWidth}) => customWidth ? customWidth : '30rem'}; |
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.
We need this to be responsive, does it still work if the default was 100%?
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 will leave it as 100%. Still working, I attach a video . Let me know if something is wrong
Screen.Recording.2025-01-22.at.3.09.21.PM.mov
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 wasn't paying attention to the wrapper when testing this... I think we can default to not defining the width and let the block rendering do what we want. Otherwise the wrapping container will need to add some styles to contain it - at least on Firefox, 100% causes overflow: https://openstax.github.io/ui-components/refs/heads/CORE-675-filter-sections-component/c27809ccad34b4b7353423157e55a57d9578bef2/?mode=preview&story=carousel--default
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 should I remove the customWidth as well ? Or keep it and have a width: auto as default ?
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 think so, we can always let the consuming app define it by overriding the styled component
src/components/Carousel/styles.ts
Outdated
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)}; | ||
`; | ||
|
||
export const StyledRightArrow = styled(RightArrow)<{ disabled: boolean }>` |
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 we add padding or width/height to these arrows so the tap target is bigger?
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.
When you convert these to buttons that contain the svg, if you put 100% height on the button, but constrain the height on the svg, we should be able to match the container height without the svg size getting too big.
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 right arrow is initializing correctly now, but I think we need to listen for resize, because it doesn't update from disabled to enabled if you collapse the window enough to hide items. Random thought, but I wonder if using normal scroll overflow and a mutation observer that checks for it would simplify the arrow implementation 🤔
src/components/Carousel/index.tsx
Outdated
|
||
} | ||
}, [currentIndex, wrapperRef]); | ||
|
||
}, [currentIndex, wrapperRef]); |
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.
Looks like this repo don't fail the build if the linter doesn't pass, oops. Anyway it wants checkIfRightArrowShouldBeDisabled in the dependency array
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.
My bad, didn't run the linter this time
src/components/Carousel/index.tsx
Outdated
setIsRightArrowDisabled(isDisabled); | ||
setIsLeftArrowDisabled((currentIndex) === 0); | ||
checkIfRightArrowShouldBeDisabled() | ||
window.addEventListener('resize', checkIfRightArrowShouldBeDisabled); |
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 effect needs to run removeEventListenter on return
src/components/Carousel/index.tsx
Outdated
})} | ||
</CarouselWrapper> | ||
</CarouselOverflow> | ||
<StyledRightArrow |
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 didn't notice it before, but these need to be real button elements that can be focused
src/components/Carousel/styles.ts
Outdated
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)}; | ||
`; | ||
|
||
export const StyledRightArrow = styled(RightArrow)<{ disabled: boolean }>` |
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.
When you convert these to buttons that contain the svg, if you put 100% height on the button, but constrain the height on the svg, we should be able to match the container height without the svg size getting too big.
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 is basically good to go I just have some tiny tweaks
height: 3.6rem; | ||
padding: 0.8rem; | ||
background-color: ${colors.palette.white}; | ||
border: solid 0.1rem ${colors.palette.pale}; |
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.
Tiny thing I didn't notice before: can we do a & + &
rule here to remove the left border?
src/components/Carousel/styles.ts
Outdated
background: transparent; | ||
|
||
&:hover { | ||
box-shadow: 0rem 0.2rem 0.4rem rgba(0, 0, 0, 0.2); |
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.
We don't have designs for this in Figma, but to fit into the overall flat design, can you remove this and make it a solid border?
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, add a solid border in buttons ?
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 just for the hover
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.
Meaning, not for all buttons but just this rule right here
src/components/Carousel/styles.ts
Outdated
|
||
svg { | ||
position: relative; | ||
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')}; |
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 you move this to the 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.
For this one, if we move it up one level, it'll look a little nicer if it activates on the button mouse over not the svg
…tax/ui-components into CORE-675-filter-sections-component
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.
Left a comment about the border shifting and the color, feel free to merge if you change those and it looks good to you.
src/components/Carousel/styles.ts
Outdated
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)}; | ||
|
||
&:hover { | ||
border: 0.1rem solid ${palette.black}; |
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.
We use pale
more often for borders
src/components/Carousel/styles.ts
Outdated
position: absolute; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
border: none; |
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 think you want a transparent border here so the svg doesn't shift on hover
@jomcarvajal Oh yeah before you merge, can you also bump the package version? Then we can make a build off main once it's in. |
Ticket: https://openstax.atlassian.net/browse/CORE-675
Design: https://www.figma.com/design/9xbDQWGZuE4vdYb8kqsyvj/instructor-side?node-id=3994-4223&t=BBN1G7YWDrkB6v2J-4
Storybook screenshots
Carousel:
Screen.Recording.2025-01-21.at.9.03.57.AM.mov
ToggleButtonGroup:
Carousel + ToggleButtonGroup:
Resize example:
https://github.com/user-attachments/assets/9110a109-94df-410f-bf51-ef1564662220