import { Flex, Image, Text, Card, cardSelectableBehavior, Grid, cardsContainerBehavior, Checkbox, Button, screenReaderContainerStyles, hiddenComponentBehavior, } from '@fluentui/react-northstar'; import * as React from 'react'; import * as _ from 'lodash'; type SelectableCardProps = { index?: number; title?: string; selected?: boolean; onClick?: (e: React.SyntheticEvent) => void; }; const SelectableCard: React.FC = ({ title, index, selected, onClick, ...rest }) => { const selectedMessageId = `selectedMessageId${index}`; const selectedMessage = 'selected'; const notSelectedMessage = 'not selected'; return ( ); }; type SelectableCardsGridActions = | { type: 'TOGGLE_ITEM'; selected: boolean; index: string } | { type: 'TOGGLE_ALL'; selected: boolean }; type SelectableCardsGridState = Record; const selectableCardsGridStateReducer: React.Reducer = ( state, action, ) => { switch (action.type) { case 'TOGGLE_ITEM': { return { ...state, [action.index]: action.selected }; } case 'TOGGLE_ALL': { return _.mapValues(state, () => action.selected); } } }; const CardExampleSelectableGrid = () => { // Component setup const cardsNumber = 12; const cards = Array(cardsNumber) .fill(undefined) .map((item, index) => ({ index: index + 1, title: `User ${index + 1}` })); const initialState: SelectableCardsGridState = cards.reduce((cards, card) => { cards[card.index] = false; return cards; }, {}); const [state, dispatch] = React.useReducer(selectableCardsGridStateReducer, initialState); return ( <>