Skip to content

Commit

Permalink
chore: update selectable list example in docsite (#18639)
Browse files Browse the repository at this point in the history
* update selectable list background

* changelog
  • Loading branch information
YuanboXue-Amber committed Jul 2, 2021
1 parent 441e322 commit 27cc926
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 42 deletions.
1 change: 1 addition & 0 deletions packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Documentation
- Allow switching to V2 themes in maximized examples @Hirse ([#18292](https://github.com/microsoft/fluentui/pull/18292))
- Add DocumentTitle from Prototype section @Hirse ([#18539](https://github.com/microsoft/fluentui/pull/18539))
- Update selectable list example to make sure selection state is visible in all themes @yuanboxue-amber ([#18639](https://github.com/microsoft/fluentui/pull/18639))

<!--------------------------------[ v0.56.0 ]------------------------------- -->
## [v0.56.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-northstar_v0.56.0) (2021-05-14)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { List, Image } from '@fluentui/react-northstar';
import { Box, List, Image } from '@fluentui/react-northstar';

const items = [
{
Expand All @@ -25,6 +25,14 @@ const items = [
},
];

const ListExampleSelectable = () => <List selectable defaultSelectedIndex={0} items={items} />;
const ListExampleSelectable = () => (
<Box
styles={({ theme: { siteVariables } }) => ({
backgroundColor: siteVariables.colorScheme.default.background4,
})}
>
<List selectable defaultSelectedIndex={0} items={items} />
</Box>
);

export default ListExampleSelectable;
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import * as React from 'react';
import { List, Image } from '@fluentui/react-northstar';
import { List, Image, Box } from '@fluentui/react-northstar';

const ListExampleSelectable = () => (
<List selectable>
<List.Item
media={
<Image src="https://fabricweb.azureedge.net/fabric-website/assets/images/avatar/RobertTolbert.jpg" avatar />
}
header="Robert Tolbert"
headerMedia="7:26:56 AM"
index={0}
content="Program the sensor to the SAS alarm through the haptic SQL card!"
/>
<List.Item
media={
<Image src="https://fabricweb.azureedge.net/fabric-website/assets/images/avatar/CelesteBurton.jpg" avatar />
}
header="Celeste Burton"
headerMedia="11:30:17 PM"
index={1}
content="Use the online FTP application to input the multi-byte application!"
/>
<List.Item
media={<Image src="https://fabricweb.azureedge.net/fabric-website/assets/images/avatar/CecilFolk.jpg" avatar />}
header="Cecil Folk"
headerMedia="5:22:40 PM"
index={2}
content="The GB pixel is down, navigate the virtual interface!"
/>
</List>
<Box
styles={({ theme: { siteVariables } }) => ({
backgroundColor: siteVariables.colorScheme.default.background4,
})}
>
<List selectable>
<List.Item
media={
<Image src="https://fabricweb.azureedge.net/fabric-website/assets/images/avatar/RobertTolbert.jpg" avatar />
}
header="Robert Tolbert"
headerMedia="7:26:56 AM"
index={0}
content="Program the sensor to the SAS alarm through the haptic SQL card!"
/>
<List.Item
media={
<Image src="https://fabricweb.azureedge.net/fabric-website/assets/images/avatar/CelesteBurton.jpg" avatar />
}
header="Celeste Burton"
headerMedia="11:30:17 PM"
index={1}
content="Use the online FTP application to input the multi-byte application!"
/>
<List.Item
media={<Image src="https://fabricweb.azureedge.net/fabric-website/assets/images/avatar/CecilFolk.jpg" avatar />}
header="Cecil Folk"
headerMedia="5:22:40 PM"
index={2}
content="The GB pixel is down, navigate the virtual interface!"
/>
</List>
</Box>
);

export default ListExampleSelectable;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { List, Image } from '@fluentui/react-northstar';
import { Box, List, Image } from '@fluentui/react-northstar';

class SelectableListControlledExample extends React.Component<any, any> {
state = { selectedIndex: -1 };
Expand Down Expand Up @@ -34,15 +34,21 @@ class SelectableListControlledExample extends React.Component<any, any> {

render() {
return (
<List
selectable
selectedIndex={this.state.selectedIndex}
onSelectedIndexChange={(e, newProps) => {
alert(`List is requested to change its selectedIndex state to "${newProps.selectedIndex}"`);
this.setState({ selectedIndex: newProps.selectedIndex });
}}
items={this.items}
/>
<Box
styles={({ theme: { siteVariables } }) => ({
backgroundColor: siteVariables.colorScheme.default.background4,
})}
>
<List
selectable
selectedIndex={this.state.selectedIndex}
onSelectedIndexChange={(e, newProps) => {
alert(`List is requested to change its selectedIndex state to "${newProps.selectedIndex}"`);
this.setState({ selectedIndex: newProps.selectedIndex });
}}
items={this.items}
/>
</Box>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { List, Status } from '@fluentui/react-northstar';
import { List, Status, Box } from '@fluentui/react-northstar';
import { ErrorIcon, AcceptIcon } from '@fluentui/react-icons-northstar';

const items = [
Expand All @@ -20,6 +20,14 @@ const items = [
},
];

const ListExampleSelectable = () => <List selectable defaultSelectedIndex={0} items={items} horizontal />;
const ListExampleSelectable = () => (
<Box
styles={({ theme: { siteVariables } }) => ({
backgroundColor: siteVariables.colorScheme.default.background4,
})}
>
<List selectable defaultSelectedIndex={0} items={items} horizontal />
</Box>
);

export default ListExampleSelectable;

0 comments on commit 27cc926

Please sign in to comment.