This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[terra-table] Provide examples and tests for focusable elements in a …
…table. (#1850)
- Loading branch information
Showing
17 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...framework-docs/src/terra-dev-site/doc/table/Examples/TableFocusableCell.doc.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TableFocusableCell from './TableFocusableCell?dev-site-example'; | ||
|
||
<TableFocusableCell title= 'Table With Focusable Cell Elements' /> |
96 changes: 96 additions & 0 deletions
96
packages/terra-framework-docs/src/terra-dev-site/doc/table/Examples/TableFocusableCell.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { useState } from 'react'; | ||
import Table from 'terra-table'; | ||
import NotificationDialog from 'terra-notification-dialog'; | ||
|
||
const TableFocusableCell = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const handleCloseModal = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
const handleButtonOpenModal = () => { | ||
setIsOpen(true); | ||
}; | ||
|
||
const buttonCell = <button type="button" aria-label="Alert" onClick={handleButtonOpenModal}>Alert</button>; | ||
// eslint-disable-next-line react/forbid-dom-props | ||
const inputCell = <input type="text" aria-label="Text Input" style={{ width: '100px', height: '25px', display: 'inline' }} />; | ||
const anchorCell = <a href="https://www.oracle.com/" aria-label="Visit Oracle">Visit Oracle</a>; | ||
const textAreaCell = <textarea name="textArea" aria-label="Text Area" rows="1" cols="15" />; | ||
const selectCell = ( | ||
<select name="specialties" id="specialties" aria-label="Select Specialty"> | ||
<option value="ambulatory">Ambulatory</option> | ||
<option value="cardiology">Cardiology</option> | ||
<option value="radiology">Radiology</option> | ||
<option value="neurology">Neurology</option> | ||
</select> | ||
); | ||
|
||
const tableDataJSON = { | ||
cols: [ | ||
{ id: 'Column-0', displayName: 'Patient' }, | ||
{ id: 'Column-1', displayName: 'Column 1' }, | ||
{ id: 'Column-2', displayName: 'Column 2' }, | ||
{ id: 'Column-3', displayName: 'Column 3' }, | ||
], | ||
rows: [ | ||
{ | ||
id: '1', | ||
cells: [ | ||
{ content: 'Fleck, Arthur' }, | ||
{ | ||
content: <> | ||
{buttonCell} | ||
<div>Non-Focusable Text</div> | ||
{/* eslint-disable-next-line react/jsx-closing-tag-location */} | ||
</>, | ||
}, | ||
{ content: inputCell }, | ||
{ content: anchorCell }, | ||
], | ||
}, | ||
{ | ||
id: '2', | ||
cells: [ | ||
{ content: 'Wayne, Bruce' }, | ||
{ | ||
content: (<div> | ||
{buttonCell} | ||
{inputCell} | ||
{/* eslint-disable-next-line react/jsx-closing-tag-location */} | ||
</div>), | ||
}, | ||
{ content: selectCell }, | ||
{ content: textAreaCell }, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const { cols, rows } = tableDataJSON; | ||
|
||
return ( | ||
<> | ||
{isOpen && ( | ||
<NotificationDialog | ||
variant="hazard-low" | ||
dialogTitle="Button from Focusable Cell" | ||
startMessage="Button Selected" | ||
acceptAction={{ | ||
text: 'OK', | ||
onClick: handleCloseModal, | ||
}} | ||
/> | ||
)} | ||
<Table | ||
id="table-focusable-cell" | ||
overflowColumns={cols} | ||
rows={rows} | ||
ariaLabel="Table with Focusable Elements" | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default TableFocusableCell; |
96 changes: 96 additions & 0 deletions
96
packages/terra-framework-docs/src/terra-dev-site/test/table/TableFocusableCell.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { useState } from 'react'; | ||
import Table from 'terra-table'; | ||
import NotificationDialog from 'terra-notification-dialog'; | ||
|
||
const TableFocusableCell = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const handleCloseModal = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
const handleButtonOpenModal = () => { | ||
setIsOpen(true); | ||
}; | ||
|
||
const buttonCell = <button type="button" aria-label="Alert" onClick={handleButtonOpenModal}>Alert</button>; | ||
// eslint-disable-next-line react/forbid-dom-props | ||
const inputCell = <input type="text" aria-label="Text Input" style={{ width: '100px', height: '25px', display: 'inline' }} />; | ||
const anchorCell = <a href="https://www.oracle.com/" aria-label="Visit Oracle">Visit Oracle</a>; | ||
const textAreaCell = <textarea name="textArea" aria-label="Text Area" rows="1" cols="15" />; | ||
const selectCell = ( | ||
<select name="specialties" id="specialties" aria-label="Select Specialty"> | ||
<option value="ambulatory">Ambulatory</option> | ||
<option value="cardiology">Cardiology</option> | ||
<option value="radiology">Radiology</option> | ||
<option value="neurology">Neurology</option> | ||
</select> | ||
); | ||
|
||
const tableDataJSON = { | ||
cols: [ | ||
{ id: 'Column-0', displayName: 'Patient' }, | ||
{ id: 'Column-1', displayName: 'Column 1' }, | ||
{ id: 'Column-2', displayName: 'Column 2' }, | ||
{ id: 'Column-3', displayName: 'Column 3' }, | ||
], | ||
rows: [ | ||
{ | ||
id: '1', | ||
cells: [ | ||
{ content: 'Fleck, Arthur' }, | ||
{ | ||
content: <> | ||
{buttonCell} | ||
<div>Non-Focusable Text</div> | ||
{/* eslint-disable-next-line react/jsx-closing-tag-location */} | ||
</>, | ||
}, | ||
{ content: inputCell }, | ||
{ content: anchorCell }, | ||
], | ||
}, | ||
{ | ||
id: '2', | ||
cells: [ | ||
{ content: 'Wayne, Bruce' }, | ||
{ | ||
content: (<div> | ||
{buttonCell} | ||
{inputCell} | ||
{/* eslint-disable-next-line react/jsx-closing-tag-location */} | ||
</div>), | ||
}, | ||
{ content: selectCell }, | ||
{ content: textAreaCell }, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const { cols, rows } = tableDataJSON; | ||
|
||
return ( | ||
<> | ||
{isOpen && ( | ||
<NotificationDialog | ||
variant="hazard-low" | ||
dialogTitle="Button from Focusable Cell" | ||
startMessage="Button Selected" | ||
acceptAction={{ | ||
text: 'OK', | ||
onClick: handleCloseModal, | ||
}} | ||
/> | ||
)} | ||
<Table | ||
id="table-focusable-cell" | ||
overflowColumns={cols} | ||
rows={rows} | ||
ariaLabel="Table with Focusable Elements" | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default TableFocusableCell; |
Binary file added
BIN
+18.5 KB
...clinical-lowlight-theme/en/chrome_large/table-spec/table-focus-first-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.1 KB
...erence/clinical-lowlight-theme/en/chrome_large/table-spec/table-focus-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.8 KB
...linical-lowlight-theme/en/chrome_medium/table-spec/table-focus-first-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.4 KB
...rence/clinical-lowlight-theme/en/chrome_medium/table-spec/table-focus-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.6 KB
...ence/orion-fusion-theme/en/chrome_large/table-spec/table-focus-first-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.2 KB
..._/reference/orion-fusion-theme/en/chrome_large/table-spec/table-focus-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.2 KB
...nce/orion-fusion-theme/en/chrome_medium/table-spec/table-focus-first-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.7 KB
.../reference/orion-fusion-theme/en/chrome_medium/table-spec/table-focus-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.6 KB
...nce/terra-default-theme/en/chrome_large/table-spec/table-focus-first-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.4 KB
.../reference/terra-default-theme/en/chrome_large/table-spec/table-focus-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.9 KB
...ce/terra-default-theme/en/chrome_medium/table-spec/table-focus-first-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.7 KB
...reference/terra-default-theme/en/chrome_medium/table-spec/table-focus-input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters