|
| 1 | +import { styled } from "stitches.config"; |
| 2 | +import { keyframes } from "@stitches/react"; |
| 3 | +import * as ContextMenu from "@radix-ui/react-context-menu"; |
| 4 | + |
| 5 | +export default ({ children }) => ( |
| 6 | + <ContextMenu.Root> |
| 7 | + <ContextMenu.Trigger>{children}</ContextMenu.Trigger> |
| 8 | + <Content> |
| 9 | + <Item onSelect={() => console.log("cut")}>CSS</Item> |
| 10 | + <Item onSelect={() => console.log("cut")}>SCSS</Item> |
| 11 | + <Item onSelect={() => console.log("copy")}>Stitches</Item> |
| 12 | + <Item onSelect={() => console.log("paste")}>Styled Components</Item> |
| 13 | + <Separator /> |
| 14 | + <Item onSelect={() => console.log("paste")}>JSX</Item> |
| 15 | + <Item onSelect={() => console.log("paste")}>HTML</Item> |
| 16 | + </Content> |
| 17 | + </ContextMenu.Root> |
| 18 | +); |
| 19 | + |
| 20 | +const reveal = keyframes({ |
| 21 | + "0%": { transform: "scale(0.9)", opacity: 0 }, |
| 22 | + "100%": { transform: "scale(1)", opacity: 1 }, |
| 23 | +}); |
| 24 | + |
| 25 | +const Content = styled(ContextMenu.Content, { |
| 26 | + minWidth: 160, |
| 27 | + backgroundColor: "white", |
| 28 | + borderRadius: 6, |
| 29 | + padding: 5, |
| 30 | + boxShadow: "0px 5px 15px -5px hsla(206,22%,7%,.15)", |
| 31 | + transformOrigin: "var(--radix-context-menu-content-transform-origin)", |
| 32 | + animation: `${reveal} 0.1s ease`, |
| 33 | +}); |
| 34 | + |
| 35 | +const Separator = styled(ContextMenu.Separator, { |
| 36 | + height: 1, |
| 37 | + background: "hsl(208, 18%, 92%)", |
| 38 | + margin: 4, |
| 39 | +}); |
| 40 | + |
| 41 | +const Wrapper = styled(ContextMenu.Root, { |
| 42 | + minWidth: 160, |
| 43 | + background: "$white", |
| 44 | + borderRadius: "$1", |
| 45 | + padding: 4, |
| 46 | +}); |
| 47 | + |
| 48 | +const Item = styled(ContextMenu.Item, { |
| 49 | + fontSize: 13, |
| 50 | + padding: "5px 10px", |
| 51 | + borderRadius: "$1", |
| 52 | + cursor: "default", |
| 53 | + height: 28, |
| 54 | + padding: "4px 8px", |
| 55 | + color: "$gray", |
| 56 | + |
| 57 | + "&:focus": { |
| 58 | + outline: "none", |
| 59 | + backgroundColor: "hsl(207, 11%, 96%)", |
| 60 | + color: "$darkGray", |
| 61 | + }, |
| 62 | +}); |
0 commit comments