import { set, map, get } from 'lodash'; import React, { useState } from 'react'; import { Story, Meta } from '@storybook/react'; import Selection, { ISelectionProps } from './Selection'; import Resizer from '../Resizer/Resizer'; export default { title: 'Communication/Selection', component: Selection, parameters: { docs: { description: { component: Selection.peek.description, }, }, }, } as Meta; /* Kinds */ export const Kinds: Story = (args) => { return ( {(width) => { const responsiveMode = width >= 400 ? 'large' : 'small'; return (
); }}
); }; /* Nested */ export const Nested: Story = (args) => { return ( {(width) => { const responsiveMode = width >= 400 ? 'large' : 'small'; return (
); }}
); }; /* Interactive */ export const Interactive: Story = (args) => { const groups = [ ['Last Man on Earth', ['Phil']], ['Last Woman on Earth', ['Carol']], [ 'Star Wars', [ 'Ask Aak', 'Admiral Gial Ackbar', 'Acros-Krik', 'Ak-Rev', 'Stass Allie', 'Almec', 'Mas Amedda', ], ], [ 'Lord of the Rings', ['Adrahil', 'Adrahil II', 'Araglas', 'Aragorn I', 'Aragorn II Elessar'], ], [ 'Star Trek', [ 'Jonathan Archer', 'Ayala', 'Azan', 'Bareil Antos', 'Julian Bashir', 'Season 6 (TNG)', 'Lieutenant, JG (S1-3)', ], ], ]; const [removedItems, setRemovedItems] = useState({}); const handleRemove = ({ props }) => { const { callbackId } = props; setRemovedItems({ ...set(removedItems, callbackId, true) }); }; return ( {(width) => { const responsiveMode = width >= 400 ? 'large' : 'small'; return (
{map(groups, ([group, names], groupIndex) => { const groupCallbackId = `${groupIndex}`; if (get(removedItems, groupCallbackId) === true) { return null; } return ( {map(names, (name, nameIndex) => { const nameCallbackId = `${groupIndex}.${nameIndex}`; if (get(removedItems, nameCallbackId) === true) { return null; } return ( ); })} ); })}
); }}
); };