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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 32 additions & 127 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,133 +1,38 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
# Javascript builds
node_modules
dist
tsc_out
.out
.changelog
.DS_Store
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.cache
results
.tmp
.eslintcache
generated

# Cypress cache
.cypress-cache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# package managers
lerna-debug.log

# IDEs and editors
.idea
.project
.classpath
.c9
*.launch
.settings
*.sublime-workspace
.history
.vscode
.yo-rc.json

# IDE - VSCode
.vscode
# For vim
*.swp

public
30 changes: 25 additions & 5 deletions cypress/component/DataView.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import React from 'react';
import { Pagination } from '@patternfly/react-core';
import DataView from '../../packages/module/dist/dynamic/DataView';
import DataViewToolbar from '../../packages/module/dist/esm/DataViewToolbar';

const PAGINATION = {
page: 1,
perPage: 1
}

describe('DataView', () => {
it('renders data view', () => {
cy.mount(<div id="test">Some text</div>);
it('renders the data view layout', () => {
cy.mount(<DataView><>Data view content</></DataView>)
cy.get('[data-ouia-component-id="DataView-stack-item-0"]').contains('Data view content');
});

cy.get('[id="test"]').should('contain', 'Some text');
})
})
it('renders the data view with toolbar, data section and footer', () => {
cy.mount(
<DataView>
<DataViewToolbar pagination={<Pagination {...PAGINATION} ouiaId="DataViewToolbar-pagination" />} />
<>Data section</>
<DataViewToolbar pagination={<Pagination isCompact {...PAGINATION} ouiaId="DataViewFooter-pagination" />} ouiaId="DataViewFooter" />
</DataView>
);
cy.get('[data-ouia-component-id="DataViewToolbar-pagination"]').should('exist');
cy.get('[data-ouia-component-id="DataView-stack-item-1"]').contains('Data section');
cy.get('[data-ouia-component-id="DataViewFooter-pagination"]').should('exist');
});
});
11 changes: 11 additions & 0 deletions cypress/component/DataViewToolbar.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { Pagination } from '@patternfly/react-core';
import DataViewToolbar from '../../packages/module/dist/dynamic/DataViewToolbar';

describe('DataViewToolbar', () => {
it('renders the data view toolbar', () => {
cy.mount(<DataViewToolbar pagination={<Pagination page={1} perPage={10} ouiaId="DataViewToolbar-pagination" />} />)
cy.get('[data-ouia-component-id="DataViewToolbar"]').should('exist');
cy.get('[data-ouia-component-id="DataViewToolbar-pagination"]').should('exist');
});
});
2 changes: 1 addition & 1 deletion cypress/e2e/DataView.spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Test the Data view docs page', () => {

it('renders the docs', () => {
it.skip('renders the docs', () => {
cy.visit('http://localhost:8006/extensions/data-view/data-view');
})
})
42 changes: 39 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/module/generate-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ async function generateIndex(files) {

files.forEach(file => {
const name = file.replace('/index.ts', '').split('/').pop();
stream.write(`\nexport { default as ${name} } from './${name}';\n`);
// do not generate default exports for Hooks/
name !== 'Hooks' && stream.write(`\nexport { default as ${name} } from './${name}';\n`);
stream.write(`export * from './${name}';\n`);
});
stream.end();
Expand Down
3 changes: 2 additions & 1 deletion packages/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"tag": "prerelease"
},
"dependencies": {
"@patternfly/react-core": "^6.0.0-alpha.50",
"@patternfly/react-core": "^6.0.0-alpha.55",
"@patternfly/react-icons": "^6.0.0-alpha.20",
"@patternfly/react-table": "^6.0.0-alpha.55",
"react-jss": "^10.10.0",
"clsx": "^2.1.1"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/module/patternfly-a11y.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = {
'color-contrast',
'landmark-no-duplicate-main',
'landmark-main-is-top-level',
'scrollable-region-focusable'
'scrollable-region-focusable',
'link-in-text-block',
].join(','),
ignoreIncomplete: true
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@ section: extensions
subsection: Data view
# Sidenav secondary level section
# should be the same for all markdown files
id: Data view
id: Data view layout
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
source: react
# If you use typescript, the name of the interface to display props for
# These are found through the sourceProps function provided in patternfly-docs.source.js
propComponents: ['DataView']
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md
---

import { Pagination } from '@patternfly/react-core';
import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
import DataViewToolbar from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';

The **data view** component renders record data in a configured layout.

### Basic example
### Layout example

Data view is expected to consist of header, data part and footer stacked below each other and passed as `children`.

```js file="./DataViewLayoutExample.tsx"

```

### Predefined layout components

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 🙂


```js file="./DataViewExample.tsx"
```js file="./DataViewPredefinedLayoutExample.tsx"

```

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';

const layoutItemStyling = {
width: '100%',
height: '5rem',
padding: 'var(--pf-t--global--spacer--md)',
border: 'var(--pf-t--global--border--width--box--default) dashed var(--pf-t--global--border--color--default)'
};

export const BasicExample: React.FunctionComponent = () => (
<DataView>
<div style={layoutItemStyling}>Header</div>
<div style={layoutItemStyling}>Data representation</div>
<div style={layoutItemStyling}>Footer</div>
</DataView>
)
Loading