Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Pompomon/table prototypes #2379

Merged
merged 5 commits into from
Feb 25, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Adding 'expand', 'collapse', 'companion', 'share-to' and 'settings-audio' icons @TanelVari ([#2343](https://github.com/microsoft/fluent-ui-react/pull/2343))
- Add support for Children API in `List` component @layershifter ([#2207](https://github.com/microsoft/fluent-ui-react/pull/2207))
- Added virtualized table prototype using `react-virtualized` and `Table` components @pompomon ([#2339](https://github.com/microsoft/fluent-ui-react/pull/2339))
- Adding prototype for popover in `Table` header @pompomon ([#2379](https://github.com/microsoft/fluent-ui-react/pull/2379))

### Performance
- Add styles caching when there aren't inline overrides defined @mnajdova ([#2309](https://github.com/microsoft/fluent-ui-react/pull/2309))
Expand Down
78 changes: 78 additions & 0 deletions docs/src/prototypes/table/InteractiveTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {
Icon,
Popup,
Table,
gridNestedBehavior,
gridHeaderCellBehavior,
gridRowBehavior,
gridCellBehavior,
} from '@fluentui/react'
import * as React from 'react'

const columnDescription = 'ID uniquely identifies a uniquely indetifiable item'

const InteractiveTable = () => {
const [popupOpen, setPopupOpen] = React.useState(false)
const handleFocus = () => setPopupOpen(true)
const handleBlur = () => {
setPopupOpen(false)
}

return (
<>
<div id="columnDescription" style={{ display: 'none' }} aria-hidden="true">
{columnDescription}
</div>
<Table aria-label="table" accessibility={gridNestedBehavior}>
<Table.Row header accessibility={gridRowBehavior}>
<Table.Cell
content={
<>
<span>Id</span>
<Popup
trigger={<Icon name="info" xSpacing="before" />}
content={columnDescription}
onOpenChange={(e, { open }) => setPopupOpen(open)}
on="hover"
open={popupOpen}
/>
</>
}
key="id"
accessibility={gridHeaderCellBehavior}
aria-describedby="columnDescription"
onFocus={handleFocus}
onBlur={handleBlur}
/>
<Table.Cell content="Name" key="name" accessibility={gridHeaderCellBehavior} />
<Table.Cell content="Picture" key="pic" accessibility={gridHeaderCellBehavior} />
<Table.Cell content="Age" key="age" accessibility={gridHeaderCellBehavior} />
</Table.Row>
<Table.Row key="1" accessibility={gridRowBehavior}>
<Table.Cell content="1" key="1-1" accessibility={gridCellBehavior} />
<Table.Cell
content="Roman van von der Longername"
key="1-2"
accessibility={gridCellBehavior}
/>
<Table.Cell content="None" key="1-3" accessibility={gridCellBehavior} />
<Table.Cell content="30 years" key="1-4" accessibility={gridCellBehavior} />
</Table.Row>
<Table.Row key="2" accessibility={gridRowBehavior}>
<Table.Cell content="2" key="1-1" accessibility={gridCellBehavior} />
<Table.Cell content="Alex" key="1-2" accessibility={gridCellBehavior} />
<Table.Cell content="None" key="1-3" accessibility={gridCellBehavior} />
<Table.Cell content="1 year" key="1-4" accessibility={gridCellBehavior} />
</Table.Row>
<Table.Row key="3" accessibility={gridRowBehavior}>
<Table.Cell content="3" key="1-1" accessibility={gridCellBehavior} />
<Table.Cell content="Ali" key="1-2" accessibility={gridCellBehavior} />
Copy link
Member

Choose a reason for hiding this comment

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

key are redundant there

<Table.Cell content="None" key="1-3" accessibility={gridCellBehavior} />
<Table.Cell content="30000000000000 years" key="1-4" accessibility={gridCellBehavior} />
</Table.Row>
</Table>
</>
)
}

export default InteractiveTable
63 changes: 37 additions & 26 deletions docs/src/prototypes/table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import * as React from 'react'
import {
Button,
Menu,
Flex,
gridCellMultipleFocusableBehavior,
gridCellWithFocusableElementBehavior,
} from '@fluentui/accessibility'
import {
Avatar,
Text,
Dropdown,
Button,
Checkbox,
Dropdown,
Flex,
Icon,
Menu,
MenuButton,
Text,
} from '@fluentui/react'
import {
gridCellWithFocusableElementBehavior,
gridCellMultipleFocusableBehavior,
} from '@fluentui/accessibility'

import AdvancedTable, { stringCellComparator } from './AdvancedTable'
import * as React from 'react'
import chatProtoStyle from '.././chatPane/chatProtoStyle'
import { ComponentPrototype, PrototypeSection } from '../Prototypes'
import AdvancedTable, { stringCellComparator } from './AdvancedTable'
import InteractiveTable from './InteractiveTable'

function handleRowClick(index) {
alert(`OnClick on the row ${index} executed.`)
Expand Down Expand Up @@ -175,18 +176,28 @@ const rowsChannels = [
},
]

const StaticTable = () => (
<>
<AdvancedTable columns={columnsMembers} rows={rowsMembers} label="Channel members" />
<br />
<AdvancedTable columns={columnsChannels} rows={rowsChannels} label="Channels" />
<div
id="ariaLive"
aria-live="polite"
aria-atomic="true"
style={chatProtoStyle.screenReaderContainerStyles}
/>
</>
export default () => (
<PrototypeSection title="Advanced table">
<ComponentPrototype
title="Table example 1"
description="Table with sorting, tags and dropdown menu in a cell"
>
<AdvancedTable columns={columnsMembers} rows={rowsMembers} label="Channel members" />
</ComponentPrototype>
<ComponentPrototype
title="Table example 2"
description="Table with menu, checkboxes and Aria anouncements"
>
<AdvancedTable columns={columnsChannels} rows={rowsChannels} label="Channels" />
<div
id="ariaLive"
aria-live="polite"
aria-atomic="true"
style={chatProtoStyle.screenReaderContainerStyles}
/>
</ComponentPrototype>
<ComponentPrototype title="Table example 3" description="Table with popover and context menu ">
<InteractiveTable />
</ComponentPrototype>
</PrototypeSection>
)

export default StaticTable