Created
April 14, 2020 15:02
-
-
Save jsmanifest/1bd4df132783a227b8aea6e6db25a5db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [collapsed, setCollapsed] = React.useState(true) | |
function toggle() { | |
setCollapsed((prevValue) => !prevValue) | |
} | |
const pediatricians = [ | |
'Michael Lopez', | |
'Sally Tran', | |
'Brian Lu', | |
'Troy Sakulbulwanthana', | |
'Lisa Wellington', | |
] | |
const psychiatrists = [ | |
'Miguel Rodriduez', | |
'Cassady Campbell', | |
'Mike Torrence', | |
] | |
const limit = 3 | |
return ( | |
<div className="root"> | |
<div className="listContainer"> | |
<List | |
collapsed={collapsed} | |
toggle={toggle} | |
header="Bids on" | |
label="Bidders" | |
items={pediatricians} | |
limit={limit} | |
/> | |
</div> | |
<div className="listContainer"> | |
<List header="Bids on" label="Bidders" items={psychiatrists} /> | |
</div> | |
</div> | |
) | |
} | |
function List({ collapsed, toggle, header, label, items = [], limit = 3 }) { | |
return ( | |
<ListRoot> | |
<ListHeader>{header}</ListHeader> | |
<ListComponent | |
label={label} | |
items={ | |
collapsed && items.length > limit ? items.slice(0, limit) : items | |
} | |
collapsed={collapsed} | |
toggle={toggle} | |
limit={limit} | |
total={items.length} | |
/> | |
</ListRoot> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment