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

ToggleButtonGroup and Carousel components created for Sections filters feature #66

Merged
merged 12 commits into from
Jan 30, 2025

Conversation

jomcarvajal
Copy link
Contributor

@jomcarvajal jomcarvajal commented Jan 22, 2025

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:
Screenshot 2025-01-22 at 10 37 05 AM

Carousel + ToggleButtonGroup:
Screenshot 2025-01-22 at 10 37 17 AM

Resize example:
https://github.com/user-attachments/assets/9110a109-94df-410f-bf51-ef1564662220

@@ -36,6 +36,7 @@ exports[`Modal matches snapshot 1`] = `
<section
aria-labelledby="react-aria-2"
class="sc-eCYdqJ iasutB"
data-rac=""
Copy link
Contributor Author

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

@jomcarvajal jomcarvajal requested a review from jivey January 22, 2025 18:26
Copy link
Member

@jivey jivey left a 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.


export const CarouselContainer = styled.div<{customWidth?: string}>`
position: relative;
width: ${({customWidth}) => customWidth ? customWidth : '30rem'};
Copy link
Member

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%?

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor Author

@jomcarvajal jomcarvajal Jan 23, 2025

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 ?

Copy link
Member

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/index.tsx Outdated Show resolved Hide resolved
opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
`;

export const StyledRightArrow = styled(RightArrow)<{ disabled: boolean }>`
Copy link
Member

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?

Copy link
Member

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.

src/components/ToggleButtonGroup.stories.tsx Show resolved Hide resolved
src/components/ToggleButtonGroup/index.tsx Outdated Show resolved Hide resolved
Copy link
Member

@jivey jivey left a 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 🤔


}
}, [currentIndex, wrapperRef]);

}, [currentIndex, wrapperRef]);
Copy link
Member

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

Copy link
Contributor Author

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

setIsRightArrowDisabled(isDisabled);
setIsLeftArrowDisabled((currentIndex) === 0);
checkIfRightArrowShouldBeDisabled()
window.addEventListener('resize', checkIfRightArrowShouldBeDisabled);
Copy link
Member

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

})}
</CarouselWrapper>
</CarouselOverflow>
<StyledRightArrow
Copy link
Member

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

opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};
`;

export const StyledRightArrow = styled(RightArrow)<{ disabled: boolean }>`
Copy link
Member

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.

Copy link
Member

@jivey jivey left a 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};
Copy link
Member

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?

background: transparent;

&:hover {
box-shadow: 0rem 0.2rem 0.4rem rgba(0, 0, 0, 0.2);
Copy link
Member

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?

Copy link
Contributor Author

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 ?

Copy link
Member

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

Copy link
Member

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


svg {
position: relative;
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
Copy link
Member

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?

Copy link
Member

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

Copy link
Member

@jivey jivey left a 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.

opacity: ${({ disabled }) => (disabled ? 0.5 : 1)};

&:hover {
border: 0.1rem solid ${palette.black};
Copy link
Member

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

position: absolute;
top: 50%;
transform: translateY(-50%);
border: none;
Copy link
Member

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

@jivey
Copy link
Member

jivey commented Jan 30, 2025

@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.

@jomcarvajal jomcarvajal merged commit fc9ecbb into main Jan 30, 2025
3 checks passed
@jomcarvajal jomcarvajal deleted the CORE-675-filter-sections-component branch January 30, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants