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 List({ | |
collapsed, | |
toggle, | |
header, | |
label, | |
items = [], | |
limit = 3, | |
renderHeader, | |
renderList, | |
}) { |
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', |
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 ListComponent({ label, items = [], collapsed, toggle, limit, total }) { | |
return ( | |
<ul> | |
<p>{label}</p> | |
{items.map((member) => ( | |
<li key={member}>{member}</li> | |
))} | |
{total > limit && ( | |
<li className="expand"> | |
<button type="button" onClick={toggle}> |
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 ListRoot({ children, ...rest }) { | |
return <div {...rest}>{children}</div> | |
} | |
function ListHeader({ children }) { | |
return <h5>{children}</h5> | |
} | |
function ListComponent({ label, items = [], limit = 0 }) { | |
const [collapsed, setCollapsed] = React.useState(items.length > 3) |
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 List({ label, labelValue, sublabel, members = [] }) { | |
const [collapsed, setCollapsed] = React.useState(members.length > 3) | |
const constrainedMembers = collapsed ? members.slice(0, 3) : members | |
function toggle() { | |
setCollapsed((prevValue) => !prevValue) | |
} | |
return ( |
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() { | |
return ( | |
<div className="root"> | |
<div className="listContainer"> | |
<List | |
groupName="customerSupport" | |
members={['Lousie Yu', 'Morgan Kelly']} | |
/> | |
</div> | |
</div> |
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 List({ label, groupName, members = [] }) { | |
const [collapsed, setCollapsed] = React.useState(members.length > 3) | |
const constrainedMembers = collapsed ? members.slice(0, 3) : members | |
function toggle() { | |
setCollapsed((prevValue) => !prevValue) | |
} | |
return ( |
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
.root { | |
display: flex; | |
} | |
.listContainer { | |
flex-grow: 1; | |
box-sizing: border-box; | |
width: 100%; | |
} |
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 List({ groupName, members = [] }) { | |
const [collapsed, setCollapsed] = React.useState(members.length > 3) | |
const constrainedMembers = collapsed ? members.slice(0, 3) : members | |
function toggle() { | |
setCollapsed((prevValue) => !prevValue) | |
} | |
return ( |
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
.root { | |
display: flex; | |
} | |
.listContainer { | |
flex-grow: 1; | |
} |