Skip to content

Commit

Permalink
feat(topics): Allow only a single featured topic open at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
rneiss committed Feb 7, 2024
1 parent cb69bdf commit 87e867b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions static/js/Story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,23 @@ SheetListStory.propTypes = {
// todo: if we don't want the monopoly card effect, this component isn't needed. // style={{"borderColor": cardColor || "#18345D"}}>

// todo: if we don't want the monopoly card effect, this component isn't needed. // style={{"borderColor": cardColor || "#18345D"}}>
const StoryFrame = ({cls, cardColor, collapsibleSummary, children}) => (
const StoryFrame = ({cls, cardColor, collapsibleSummary, children}) => {

const handleDetailOpen = (target) => {
const targetDetail = (target.closest("details"))
const details = document.querySelectorAll('details');
details.forEach((detail) => {
if (detail !== targetDetail) {
detail.removeAttribute("open");
}
});
}

return (
<div className={'story ' + cls}>
{collapsibleSummary ? (<details><summary>{collapsibleSummary}</summary>{children}</details>) : children }
{collapsibleSummary ? (<details><summary onClick={(e)=>{handleDetailOpen(e.target)}}>{collapsibleSummary}</summary>{children}</details>) : children }
</div>
);
)};
StoryFrame.propTypes = {
cls: PropTypes.string, // Story type as class name
cardColor: PropTypes.string,
Expand Down

0 comments on commit 87e867b

Please sign in to comment.