-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(frontend): add text diff view (#89)
* fix(frontend): add text diff view * fix(frontend): fiw warnin
- Loading branch information
Showing
7 changed files
with
167 additions
and
94 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,41 @@ | ||
import PropTypes from "prop-types"; | ||
import React, { useState } from "react"; | ||
import { IoMdGitNetwork } from "react-icons/io"; | ||
import React, { useRef, useState } from "react"; | ||
import { IoIosArrowDown, IoIosArrowUp, IoMdGitCompare } from "react-icons/io"; | ||
|
||
import { Button } from "../button"; | ||
import { Inline } from "../layout/Inline"; | ||
|
||
export function Collapsible({ label, children, ...props }) { | ||
const COLLAPSIBLE_ID = 1; | ||
|
||
export function Collapsible({ label, children, id, ...props }) { | ||
const [isVisible, setVisible] = useState(false); | ||
const collapsibleRef = useRef(COLLAPSIBLE_ID); | ||
if (!id) { | ||
id = `collapsible-component-${collapsibleRef.current++}`; | ||
} | ||
return ( | ||
<div {...props}> | ||
<Button variant="link" onClick={() => setVisible(!isVisible)}> | ||
<IoMdGitNetwork /> {label} | ||
<Button | ||
aria-controls={id} | ||
aria-expanded={isVisible} | ||
size="small" | ||
variant="link" | ||
onClick={() => setVisible(!isVisible)} | ||
> | ||
<Inline space="xxsmall"> | ||
<IoMdGitCompare /> {label} | ||
{isVisible ? <IoIosArrowUp /> : <IoIosArrowDown />} | ||
</Inline> | ||
</Button> | ||
{isVisible && children} | ||
<div id={id} tabIndex="-1" hidden={!isVisible}> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
Collapsible.propTypes = { | ||
children: PropTypes.node, | ||
id: PropTypes.string, | ||
label: PropTypes.string, | ||
}; |
This file contains 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
This file contains 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
Oops, something went wrong.