diff options
author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-07-02 20:15:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 20:15:49 -0700 |
commit | cf3d08ceaabecd80b20aaac24c5c166cd8e6472f (patch) | |
tree | 7559fe0d9500d5156fa99ee5614ac0fe6d4e88f3 /extension/react-app/src/components/PillButton.tsx | |
parent | 0ffd2648d679916872c681036a68741a83d80c0e (diff) | |
parent | 0a812994703791023125177fe4820202374e45b0 (diff) | |
download | sncontinue-cf3d08ceaabecd80b20aaac24c5c166cd8e6472f.tar.gz sncontinue-cf3d08ceaabecd80b20aaac24c5c166cd8e6472f.tar.bz2 sncontinue-cf3d08ceaabecd80b20aaac24c5c166cd8e6472f.zip |
Merge pull request #170 from continuedev/explicit-context
Explicit context
Diffstat (limited to 'extension/react-app/src/components/PillButton.tsx')
-rw-r--r-- | extension/react-app/src/components/PillButton.tsx | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/extension/react-app/src/components/PillButton.tsx b/extension/react-app/src/components/PillButton.tsx new file mode 100644 index 00000000..33451db5 --- /dev/null +++ b/extension/react-app/src/components/PillButton.tsx @@ -0,0 +1,66 @@ +import { useState } from "react"; +import styled from "styled-components"; +import { defaultBorderRadius } from "."; + +const Button = styled.button` + border: none; + color: white; + background-color: transparent; + border: 1px solid white; + border-radius: ${defaultBorderRadius}; + padding: 3px 6px; + + &:hover { + background-color: white; + color: black; + } +`; + +interface PillButtonProps { + onHover?: (arg0: boolean) => void; + onDelete?: () => void; + title: string; +} + +const PillButton = (props: PillButtonProps) => { + const [isHovered, setIsHovered] = useState(false); + return ( + <Button + onMouseEnter={() => { + setIsHovered(true); + if (props.onHover) { + props.onHover(true); + } + }} + onMouseLeave={() => { + setIsHovered(false); + if (props.onHover) { + props.onHover(false); + } + }} + > + <div + style={{ display: "grid", gridTemplateColumns: "1fr auto", gap: "4px" }} + > + <span>{props.title}</span> + <span + style={{ + cursor: "pointer", + color: "red", + borderLeft: "1px solid black", + paddingLeft: "4px", + }} + hidden={!isHovered} + onClick={() => { + props.onDelete?.(); + props.onHover?.(false); + }} + > + X + </span> + </div> + </Button> + ); +}; + +export default PillButton; |