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

Set up DataView layout #5

Merged
merged 7 commits into from
May 14, 2024
Merged

Set up DataView layout #5

merged 7 commits into from
May 14, 2024

Conversation

fhlavac
Copy link
Collaborator

@fhlavac fhlavac commented May 6, 2024

RHCLOUD-32249

  • set up a data view stack layout
  • created a base for the DataViewToolbar
  • updated docs & tests

screencapture-localhost-8006-extensions-data-view-data-view-layout-2024-05-07-11_40_21 (1)

Snímek obrazovky 2024-05-07 v 11 40 11

image

@patternfly-build
Copy link

patternfly-build commented May 6, 2024

@fhlavac
Copy link
Collaborator Author

fhlavac commented May 6, 2024

@nicolethoen @dlabaj with PF6, I've encountered two visual issues

  1. extra space after the Toolbar component
    image
    the div with pf-v6-c-toolbar__content pf-m-hidden was not visible in PF5 but is shown in PF6

  2. aligning items in PF Toolbar does not seem to work
    the pagination ToolbarItem has align={{ default: 'alignRight' }}, but is still aligned left

Do you know if these issues are known? Shall I open issues for these? Thank you


A blank example of the data view layout.
You can make use of the predefined layout components to display a default header and footer. See [data view toolbar](/data-view/data-view-toolbar) for more information
Copy link
Collaborator Author

@fhlavac fhlavac May 6, 2024

Choose a reason for hiding this comment

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

@nicolethoen I also see the a11y tests failing there with link-in-text-block. The link is added the same way as in the older docs framework version. Did anything change with v6?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are not the only person who's run into this error during the migration to the v6 alphas. I will have to investigate how others have resolved this issue.

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 the recommended solution (since the rule being flagged by the a11y tests is a 'new experimental rule') is to ignore it.
You can see that being done in another extension here: patternfly/react-catalog-view@bd81ee6

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool, thank you 🙂

@fhlavac fhlavac requested review from Hyperkid123 and nicolethoen May 6, 2024 15:37
@nicolethoen
Copy link
Contributor

  1. the div with pf-v6-c-toolbar__content pf-m-hidden was not visible in PF5 but is shown in PF6

this does appear to be a bug on v6 right now! if you wouldn't mind opening a v6 alpha bug that would be super helpful!

  1. aligning items in PF Toolbar does not seem to work
    the pagination ToolbarItem has align={{ default: 'alignRight' }}, but is still aligned left

It looks to me that rather than <ToolbarItem align={{ default: 'alignRight' }}> for the pagination ToolbarItem, you'll want <ToolbarItem variant='pagination'>. I agree the align={{ default: 'alignRight' }} does not seem to have any affect. That might also be a worthwhile bug to file as a v6 alpha bug. If it was intended, then we should update the documentation :)

export const DataViewToolbar: React.FunctionComponent<DataViewToolbarProps> = ({ className, ouiaId = 'DataViewToolbar', page, perPage, isBottom }: DataViewToolbarProps) => (
<Toolbar ouiaId={ouiaId} className={className}>
<ToolbarContent>
{page && perPage && (

Choose a reason for hiding this comment

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

I think we might want to pass a prop pagination that will have the object shape. That way we can have a bit more strict typing while keeping the feature optional.

@@ -0,0 +1,4 @@
export interface DataViewPaginationProps {
page?: number;

Choose a reason for hiding this comment

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

This should not be optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Hyperkid123 do you think we want to make perPage mandatory as well? I wonder if our implementation should contain a default value for that or if we want to let that up to the user of our component

Choose a reason for hiding this comment

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

I don't think we will be able to "guess" defaults that would make sense.

Choose a reason for hiding this comment

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

Just a question. Do you plan all of the toolbar features to be object props? Or do we expect some nodes or children to be passed?
(I understand this is very early on)

Copy link
Collaborator Author

@fhlavac fhlavac May 7, 2024

Choose a reason for hiding this comment

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

@Hyperkid123 I planned to use the node approach for actions - the example is mentioned in the ADR. Do you think it is worth applying also somewhere else? Thank you

Choose a reason for hiding this comment

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

I think we want to use one system everywhere. but I think it will get clearer once we move forwards with more.

);
<Stack data-ouia-component-id={`${ouiaId}-stack}`}>
{React.Children.map(children, (child, index) => (
React.isValidElement(child) ? (

Choose a reason for hiding this comment

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

I think we want to throw an error if the element is valid. There is no point passing things that are not elements and acting as if it was OK.

text?: string;
export interface DataViewProps extends DataViewPaginationProps {
/** Content rendered inside the data view */
children?: React.ReactNode;

Choose a reason for hiding this comment

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

This should be mandatory. The view serves no purpose if there are no children.

Also, you should use React.PropsWithChildren generic so you don't have to add types for children (when they are optional).

@fhlavac
Copy link
Collaborator Author

fhlavac commented May 7, 2024

It looks to me that rather than <ToolbarItem align={{ default: 'alignRight' }}> for the pagination ToolbarItem, you'll want . I agree the align={{ default: 'alignRight' }} does not seem to have any affect. That might also be a worthwhile bug to file as a v6 alpha bug. If it was intended, then we should update the documentation :)

@nicolethoen thank you! I've missed the variant prop. It fixes the alignment, I've also opened those issues.

@fhlavac fhlavac requested a review from Hyperkid123 May 7, 2024 09:45
@fhlavac
Copy link
Collaborator Author

fhlavac commented May 13, 2024

@Hyperkid123 all comments should be addressed, can you please take a look?

Copy link

@Hyperkid123 Hyperkid123 left a comment

Choose a reason for hiding this comment

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

I think this is good as a base 👍

@fhlavac fhlavac merged commit 20d290c into patternfly:main May 14, 2024
7 checks passed
@fhlavac fhlavac deleted the layout branch May 14, 2024 08:54
Copy link

🎉 This PR is included in version 1.0.0-prerelease.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants