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

Activities bar - added carousel #287

Merged
merged 20 commits into from
Apr 9, 2024
Merged

Activities bar - added carousel #287

merged 20 commits into from
Apr 9, 2024

Conversation

ioay
Copy link
Contributor

@ioay ioay commented Mar 3, 2024

Closes: #225


Implement a carousel component


What was done:


Preview:

activities-carousel

Additional info:

  • If there are fewer cards, the carousel arrows are hidden.
  • If the user removes a card, the carousel component is refreshed in the background for correct width conversion.
  • If the last element is removed, the carousel is moved to the previous element to improve user experience.
  • The activity details page will be changed in another story, according to the design we are waiting for.

Copy link

netlify bot commented Mar 3, 2024

Deploy Preview for acre-dapp-testnet ready!

Name Link
🔨 Latest commit a6ba5d6
🔍 Latest deploy log https://app.netlify.com/sites/acre-dapp-testnet/deploys/6615449c905b6b0008a95e79
😎 Deploy Preview https://deploy-preview-287--acre-dapp-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ioay ioay force-pushed the carousel-component-activities branch 14 times, most recently from dda8a04 to e174e27 Compare March 4, 2024 10:45
@ioay ioay self-assigned this Mar 4, 2024
@ioay ioay force-pushed the carousel-component-activities branch 4 times, most recently from 50df52a to 5044090 Compare March 4, 2024 16:36
@ioay ioay force-pushed the carousel-component-activities branch from 7a5df5f to 389b9e2 Compare March 4, 2024 16:50
@ioay ioay marked this pull request as ready for review March 4, 2024 17:08
@ioay ioay requested a review from kkosiorowska March 4, 2024 17:08
@ioay ioay force-pushed the carousel-component-activities branch from f86bc1d to c7e0dfc Compare March 8, 2024 10:57
dapp/src/components/GlobalStyles/index.tsx Outdated Show resolved Hide resolved
dapp/src/components/GlobalStyles/index.tsx Outdated Show resolved Hide resolved
dapp/src/components/shared/Activities/ActivityBar.tsx Outdated Show resolved Hide resolved
Comment on lines 12 to 28
export function ActivityCardLinkWrapper({
activity,
children,
...props
}: ActivityCardLinkWrapperProps) {
return (
<ChakraLink
as={ReactRouterLink}
to="/activity-details"
state={{ activity }}
key={activity.txHash}
{...props}
>
{children}
</ChakraLink>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should use special compnent for that case from chakra - LinkOverlay, because:

According to the specification](https://www.w3.org/TR/html5/text-level-semantics.html#the-a-element), an <a> element’s content model specifically states that an cannot contain any interactive descendants (button, anchors, input, etc.).

Copy link
Contributor Author

@ioay ioay Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely convinced about this solution, since we end up using it anyway prop as={ReactRouterLink} which generates <a> element (no matter if we use LinkOverlay/LinkBox). I'm wondering how we can get around this to meet the semantic assumptions 🤔

UPDATE:
Added click handler instead of using ChakraLink.: ba6d8ee

dapp/src/pages/OverviewPage/index.tsx Outdated Show resolved Hide resolved
@@ -29,7 +29,7 @@ export default function ActivityPage() {
/>
</ChakraLink>
<Flex gap={10}>
<ActivityBar flexDirection="column" />
<ActivityBar />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. I think we can keep the ActivityBar under pages/AcrtivityPage. Unless we update the ActivityBar that can handle horizontal and vertical positions so we can use ActivityBar inside the ActivityCarousel but with horizontal position.

dapp/src/pages/OverviewPage/DocsCard.tsx Outdated Show resolved Hide resolved
dapp/src/pages/OverviewPage/DocsCard.tsx Outdated Show resolved Hide resolved
@ioay ioay force-pushed the carousel-component-activities branch from e0c9ce4 to 61c0943 Compare March 21, 2024 22:33
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments after the tests:

  • Not able to remove activity card when it is at the end of the carousel.
Screen.Recording.2024-03-22.at.14.06.01.mov
  • Currently, when we have a lot of activity it doesn't look good.
Screen.Recording.2024-03-22.at.14.08.50.mov

dapp/src/pages/ActivityPage/ActivityBar.tsx Outdated Show resolved Hide resolved
dapp/src/pages/ActivityPage/ActivityBar.tsx Outdated Show resolved Hide resolved
dapp/src/pages/ActivityPage/index.tsx Outdated Show resolved Hide resolved
Comment on lines 44 to 48
// React-slick package: Chakra-ui with react-slick package doesn't
// generate flex style for auto-generated slick-track wrapper.
.slick-track {
display: flex;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that this is not a problem related to Chakra but to the fact that we have not imported styles.

Copy link
Contributor Author

@ioay ioay Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if importing additional styles and then overriding the imported styles is needed. To add this kind of style with a lot of we have to install the additional package: slick-carousel or import them from cdn, another option is to add all these styles into the global styles file which leads to the same thing, only with more styles to remove/overwrite.

We just need to add display: flex to the slick-track class (this class is generated under the hood of react-slick, so we can't style it directly in the Carousel component). I'd leave it as it is if you don't mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this approach, let's add a right description of why we do this. Let's document this decision.

@ioay
Copy link
Contributor Author

ioay commented Mar 22, 2024

Some comments after the tests:

  • Not able to remove activity card when it is at the end of the carousel.

Screen.Recording.2024-03-22.at.14.06.01.mov

  • Currently, when we have a lot of activity it doesn't look good.

Screen.Recording.2024-03-22.at.14.08.50.mov

[ ] Not able to remove activity card when it is at the end of the carousel.

Could you add more details on that resolution are you record this video? Remove functionality works well, but on this video - the gradient below the Documentation Card covers Close button and that's why you can't click it.

@SorinQ what do you think? Should we move the close button icon to another place or maybe we should reduce width of this gradient?

[ ] Currently, when we have a lot of activity it doesn't look good.

I added information in the PR description that is not related to the scope of this PR, please take a look at AdditionalInfo section: #287 (comment):

The activity details page will be changed in another story, according to the design we are waiting for.

@SorinQ
Copy link
Collaborator

SorinQ commented Mar 22, 2024

_> > Some comments after the tests:

  • Not able to remove activity card when it is at the end of the carousel.

Screen.Recording.2024-03-22.at.14.06.01.mov

  • Currently, when we have a lot of activity it doesn't look good.

Screen.Recording.2024-03-22.at.14.08.50.mov

[ ] Not able to remove activity card when it is at the end of the carousel.

Could you add more details on that resolution are you record this video? Remove functionality works well, but on this video - the gradient below the Documentation Card covers Close button and that's why you can't click it.

@SorinQ what do you think? Should we move the close button icon to another place or maybe we should reduce width of this gradient?

[ ] Currently, when we have a lot of activity it doesn't look good.

I added information in the PR description that is not related to the scope of this PR, please take a look at AdditionalInfo section: #287 (comment):

The activity details page will be changed in another story, according to the design we are waiting for._

We should definitely reduce the gradient.
For the cards, let's add pagination after every 4 or 5 of them.

@ioay
Copy link
Contributor Author

ioay commented Mar 22, 2024

_> > Some comments after the tests:

  • Not able to remove activity card when it is at the end of the carousel.

Screen.Recording.2024-03-22.at.14.06.01.mov

  • Currently, when we have a lot of activity it doesn't look good.

Screen.Recording.2024-03-22.at.14.08.50.mov

[ ] Not able to remove activity card when it is at the end of the carousel.

Could you add more details on that resolution are you record this video? Remove functionality works well, but on this video - the gradient below the Documentation Card covers Close button and that's why you can't click it.
@SorinQ what do you think? Should we move the close button icon to another place or maybe we should reduce width of this gradient?

[ ] Currently, when we have a lot of activity it doesn't look good.

I added information in the PR description that is not related to the scope of this PR, please take a look at AdditionalInfo section: #287 (comment):

The activity details page will be changed in another story, according to the design we are waiting for._

We should definitely reduce the gradient. For the cards, let's add pagination after every 4 or 5 of them.

I reduced the width of a gradient to 32px(but we will always find a resolution in which this close button will be unclickable). I implemented a responsively approach to showing cards, and depending on the resolution, we display the right amount of activity:

Screenshot 2024-03-22 at 20 40 18
Screenshot 2024-03-22 at 20 40 27
Screenshot 2024-03-22 at 20 40 46
Screenshot 2024-03-22 at 20 40 58

@ioay ioay requested a review from kkosiorowska March 25, 2024 08:30
dapp/src/pages/OverviewPage/DocsCard.tsx Outdated Show resolved Hide resolved
dapp/src/pages/ActivityPage/index.tsx Outdated Show resolved Hide resolved
@ioay ioay requested a review from kkosiorowska April 3, 2024 16:59
@nkuba nkuba added the 🎨 dApp dApp label Apr 4, 2024
dapp/src/components/shared/Carousel.tsx Outdated Show resolved Hide resolved
Comment on lines 26 to 31
overflow="hidden"
ref={carouselRef}
pl={2}
ml={-2}
overflowX="hidden"
pb={6}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that we don't need it.

overflowX="hidden" is already set in Carousel
pl={2} ml={-2} - it doesn't do anything
pb={6} - Instead of bottom padding, let's set the gap/pb in the higher component.

Suggested change
overflow="hidden"
ref={carouselRef}
pl={2}
ml={-2}
overflowX="hidden"
pb={6}

Copy link
Contributor Author

@ioay ioay Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overflow- removed, remnants of changes during work on PR.

pl={2} ml={-2} - it doesn't do anything

It does - take a look at the shadow on the left side of the card(without these styles shadow is cut-off):
Screenshot 2024-04-08 at 09 16 07
Screenshot 2024-04-08 at 09 16 17

pb={6} - we can't do it as you propose, because, as I noticed, the carousel has overflow added by default and when we remove this padding shadow below activityCard is cut off. We need this padding-bottom to be consistent with UX.

I added a comment on why we need it to code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, now I understand. Regarding the bottom padding, I would consider simply setting the right height of the component. It seems more intuitive to me to fit the right height content into a component than to use padding. But I leave it up to you.

Comment on lines 44 to 48
// React-slick package: Chakra-ui with react-slick package doesn't
// generate flex style for auto-generated slick-track wrapper.
.slick-track {
display: flex;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this approach, let's add a right description of why we do this. Let's document this decision.

Comment on lines +51 to +54
[data-id="slick-arrow-prev"]:disabled:has(~ [data-id="slick-arrow-next"]:disabled),
[data-id="slick-arrow-prev"]:disabled ~ [data-id="slick-arrow-next"]:disabled{
display: none;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not do it in global styles but in the code related to this carousel. But we can leave it that way now and move it in the future if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably won't change it also for other carousel components if appears. I added a comment to this style when was created:

// React-slick package: Hiding arrows instead of disabling them in case 
// when carousel is not fully completed by slides.

dapp/src/hooks/useActivities.ts Outdated Show resolved Hide resolved
dapp/src/hooks/useActivities.ts Outdated Show resolved Hide resolved
<Grid
templateAreas={'"activity-carousel activity-carousel docs-card"'}
gridTemplateColumns="1fr 1fr auto"
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in another commenter, we can move the spacing between elements to a higher component.

Suggested change
>
pb={6}
>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dapp/src/pages/OverviewPage/index.tsx Outdated Show resolved Hide resolved
@ioay ioay force-pushed the carousel-component-activities branch from 125234e to 3b5aea0 Compare April 8, 2024 07:45
@ioay ioay requested a review from kkosiorowska April 8, 2024 07:48
<Flex
as={Slider}
ref={ref}
// overflow="hidden" is required to hide the items outside the viewport.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking comment

I suggested adding a comment but I meant more to point out that the addition of this line is the result of not including external styles.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking comment

I'm confused but it seems to me that we shouldn't call the file that. The file name indicates the name of the exported component. But there is no such component in reality.

Comment on lines 26 to 31
overflow="hidden"
ref={carouselRef}
pl={2}
ml={-2}
overflowX="hidden"
pb={6}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, now I understand. Regarding the bottom padding, I would consider simply setting the right height of the component. It seems more intuitive to me to fit the right height content into a component than to use padding. But I leave it up to you.

kkosiorowska
kkosiorowska previously approved these changes Apr 9, 2024
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left minor non-blocking comments.

Based on the fact that design will change a bit soon, let's not focus so much on the visual layer.

@ioay ioay merged commit bd4f25f into main Apr 9, 2024
24 checks passed
@ioay ioay deleted the carousel-component-activities branch April 9, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a carousel component
5 participants