Skip to content

Commit

Permalink
fix: List V9 - update stories to work with dark themes (#32392)
Browse files Browse the repository at this point in the history
  • Loading branch information
george-cz authored Oct 7, 2024
1 parent f542b84 commit 22fbb42
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: List V9 - update stories to work with dark themes",
"packageName": "@fluentui/react-list-preview",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
import * as React from 'react';
import { List, ListItem } from '@fluentui/react-list-preview';
import { tokens, Text, makeResetStyles } from '@fluentui/react-components';

export const Default = () => (
<List>
<ListItem>Asia</ListItem>
<ListItem>Africa</ListItem>
<ListItem>Europe</ListItem>
<ListItem>North America</ListItem>
<ListItem>South America</ListItem>
<ListItem>Australia/Oceania</ListItem>
<ListItem>Antarctica</ListItem>
</List>
);
const useTextStyle = makeResetStyles({
color: tokens.colorNeutralForeground1,
});

export const Default = () => {
const textStyle = useTextStyle();
return (
<List>
<ListItem>
<Text className={textStyle}>Asia</Text>
</ListItem>
<ListItem>
<Text className={textStyle}>Africa</Text>
</ListItem>
<ListItem>
<Text className={textStyle}>Europe</Text>
</ListItem>
<ListItem>
<Text className={textStyle}>North America</Text>
</ListItem>
<ListItem>
<Text className={textStyle}>South America</Text>
</ListItem>
<ListItem>
<Text className={textStyle}>Australia/Oceania</Text>
</ListItem>
<ListItem>
<Text className={textStyle}>Antarctica</Text>
</ListItem>
</List>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const useStyles = makeStyles({
borderRadius: '5px',
},
title: {
color: tokens.colorNeutralForeground1,
fontWeight: 600,
display: 'block',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const useStyles = makeStyles({
borderRadius: '5px',
},
title: {
color: tokens.colorNeutralForeground1,
fontWeight: 600,
display: 'block',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const useStyles = makeStyles({
borderRadius: '5px',
},
title: {
color: tokens.colorNeutralForeground1,
fontWeight: 600,
display: 'block',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { FixedSizeList } from 'react-window';
import { List, ListItem } from '@fluentui/react-list-preview';
import { tokens, Text, makeResetStyles } from '@fluentui/react-components';

const countries = [
'Afghanistan',
Expand Down Expand Up @@ -201,11 +202,16 @@ const countries = [
'Zimbabwe',
];

const useTextStyle = makeResetStyles({
color: tokens.colorNeutralForeground1,
});

const CountriesList = React.forwardRef<HTMLUListElement>((props: React.ComponentProps<typeof List>, ref) => (
<List aria-label="Countries" tabIndex={0} {...props} ref={ref} />
));

export const VirtualizedList = () => {
const textStyle = useTextStyle();
return (
<FixedSizeList
height={400}
Expand All @@ -217,7 +223,7 @@ export const VirtualizedList = () => {
>
{({ index, style, data }) => (
<ListItem style={style} aria-setsize={countries.length} aria-posinset={index + 1}>
{data[index]}
<Text className={textStyle}>{data[index]}</Text>
</ListItem>
)}
</FixedSizeList>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { FixedSizeList } from 'react-window';
import { List, ListItem } from '@fluentui/react-list-preview';
import { tokens, Text, makeResetStyles } from '@fluentui/react-components';

const countries = [
'Afghanistan',
Expand Down Expand Up @@ -205,7 +206,12 @@ const CountriesList = React.forwardRef<HTMLUListElement>((props: React.Component
<List navigationMode="items" aria-label="Countries" {...props} ref={ref} />
));

const useTextStyle = makeResetStyles({
color: tokens.colorNeutralForeground1,
});

export const VirtualizedListWithActionableItems = () => {
const textStyle = useTextStyle();
return (
<FixedSizeList
height={400}
Expand All @@ -222,7 +228,7 @@ export const VirtualizedListWithActionableItems = () => {
aria-posinset={index + 1}
onAction={() => alert(data[index])}
>
{data[index]}
<Text className={textStyle}>{data[index]}</Text>
</ListItem>
)}
</FixedSizeList>
Expand Down

0 comments on commit 22fbb42

Please sign in to comment.