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

BccPagination #300

Merged
merged 17 commits into from
Apr 18, 2024
Merged

BccPagination #300

merged 17 commits into from
Apr 18, 2024

Conversation

starkris51
Copy link
Contributor

@starkris51 starkris51 commented Apr 4, 2024

Change summary

Added BccPagination

Change type

  • No review
  • Big PR
  • Small PR
  • Refactor

Closes #ISSUE_NUMBER or Part of #ISSUE_NUMBER

@starkris51
Copy link
Contributor Author

@laurensgroeneveld Kunne du sjekke denne?

@laurensgroeneveld laurensgroeneveld self-requested a review April 4, 2024 14:46
Copy link
Collaborator

@laurensgroeneveld laurensgroeneveld left a comment

Choose a reason for hiding this comment

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

Thanks a lot, this is an important component currently missing from the library! I have quite a few comments but most of them are pretty small code quality/design things. Functionality wise the component is already very good 👍 Let me know if you don't agree with something 😊

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this file was included by accident - we added some tools for rendering the shadows in #285 but are waiting on updated shadows I think before including them in the design library. In any case it would belong in a different PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The file seems to be still here, despite Github saying this comment is "outdated".

Comment on lines 52 to 58
.bcc-pagination-button-left {
@apply rounded-l-lg px-3.5 text-interactive;
}

.bcc-pagination-button-right {
@apply rounded-r-lg px-3.5 text-interactive;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment on consolidating these in one bcc-pagination-button (or just call them bcc-pagination-arrow?) and then a modifier class that only changes the rounding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when I fixed the double border, the right arrow needed different tailwind code and its so little shared code that I don't think its worth having a separate class

import BccFormLabel from "../BccFormLabel/BccFormLabel.vue";

type Props = {
tableItems: Item[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

For discussion: I'm not sure if tableItems needs to be part of this component. Instead, I feel like we should build pagination into the table component, so that that is the only component that is concerned about the actual data (this doesn't have to happen necessarily in this PR though).

It's still good to have this as a separate component, but instead I feel like it should only concern itself with the actual pagination. That way it can be used for other usecases as well, not just together with our table component. Instead of passing a full tableItems array, we could maybe just pass the amount of items so the amount of pages can be correctly calculated?

Curious to hear your opinion on this!

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 do agree that it should not only be used for the table, the change I've did is that it supports array with any types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@laurensgroeneveld i have made a alternative version of this using Radix vue libary, it uses passing amount of items instead of a array.
#301

Copy link
Collaborator

Choose a reason for hiding this comment

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

@laurensgroeneveld i have made a alternative version of this using Radix vue libary, it uses passing amount of items instead of a array.

Yes, that's what I meant here as well. I'll take a look.

i do agree that it should not only be used for the table, the change I've did is that it supports array with any types.

I feel like the pagination component should not need to be aware of the actual items at all, but instead just the total amount.

Copy link
Collaborator

@laurensgroeneveld laurensgroeneveld left a comment

Choose a reason for hiding this comment

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

The CSS is much more consolidated, looks really good 👍 Thanks for picking up all the comment, sorry for late re-review 😅 Just have three small comments (two I added as a comment to previous open threads), other than that it looks good. If you can just remove that shadows file I'll approve it 😊

Comment on lines 106 to 110
'bcc-pagination-left':
(align === 'left' && displayRowsPerPage === true) ||
(align === 'right' && displayRowsPerPage === false),
'bcc-pagination-center': align === 'center',
'bcc-pagination': align === 'right',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the underlying CSS is mostly the same, I think it makes more sense to have bcc-pagination as a default class and then just adding the -left and -center variants in addition when applicable. That's how it's done in most other components as well, for example the secondary button is bcc-button bcc-button-secondary, with the last class just adding or overriding classes that are different from the default.

Comment on lines 97 to 100
watchEffect(() => {
emit("update:paginatedItems", paginatedRows.value);
emit("update:totalPages", totalPages.value);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, I should use watchEffect more instead of plain watch, it works nicer for instances like this 👍

@starkris51
Copy link
Contributor Author

@laurensgroeneveld i'm wondering about if the Table in pagination storybook should be kept or removed like with the Radix Vue version where i only show the component itself.

@laurensgroeneveld
Copy link
Collaborator

@laurensgroeneveld i'm wondering about if the Table in pagination storybook should be kept or removed like with the Radix Vue version where i only show the component itself.

I think that's fine, then when we add pagination support to the Table component itself it can instead be shown there.

I didn't add a comment on it before, but you could even add a few stories showing some different options at a glance, like if you hide the page selector, alignment etc.

@starkris51
Copy link
Contributor Author

@laurensgroeneveld i'm wondering about if the Table in pagination storybook should be kept or removed like with the Radix Vue version where i only show the component itself.

I think that's fine, then when we add pagination support to the Table component itself it can instead be shown there.

I didn't add a comment on it before, but you could even add a few stories showing some different options at a glance, like if you hide the page selector, alignment etc.

I've moved the table as a story instead.

Copy link
Collaborator

@laurensgroeneveld laurensgroeneveld left a comment

Choose a reason for hiding this comment

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

Thanks a lot 👍

@laurensgroeneveld laurensgroeneveld merged commit 1636a57 into bcc-code:main Apr 18, 2024
5 checks passed
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