-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,134 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.86 KB
.yarn/cache/@radix-ui-react-arrow-npm-0.1.4-1a2ca1bc1c-af09d09a87.zip
Binary file not shown.
Binary file added
BIN
+5.31 KB
.yarn/cache/@radix-ui-react-compose-refs-npm-0.1.0-a16c93a4d0-d1455577b2.zip
Binary file not shown.
Binary file added
BIN
+9.39 KB
.yarn/cache/@radix-ui-react-context-npm-0.1.1-f6f528ee12-6960ed93f3.zip
Binary file not shown.
Binary file added
BIN
+16.2 KB
.yarn/cache/@radix-ui-react-dismissable-layer-npm-0.1.5-c0006f242f-ad75eb6323.zip
Binary file not shown.
Binary file added
BIN
+6.39 KB
.yarn/cache/@radix-ui-react-focus-guards-npm-0.1.0-7ff2b5df5f-d199462ecf.zip
Binary file not shown.
Binary file added
BIN
+18.4 KB
.yarn/cache/@radix-ui-react-focus-scope-npm-0.1.4-c7848ccda0-8753ec9aa0.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+20.9 KB
.yarn/cache/@radix-ui-react-popover-npm-0.1.6-77bf912a3b-28ccdb386b.zip
Binary file not shown.
Binary file added
BIN
+14.6 KB
.yarn/cache/@radix-ui-react-popper-npm-0.1.4-babf34c41f-c591e04bc4.zip
Binary file not shown.
Binary file added
BIN
+8.05 KB
.yarn/cache/@radix-ui-react-portal-npm-0.1.4-5d15e94604-d841636dd1.zip
Binary file not shown.
Binary file added
BIN
+11 KB
.yarn/cache/@radix-ui-react-presence-npm-0.1.2-52b34dc77a-7faad92b1c.zip
Binary file not shown.
Binary file added
BIN
+7.06 KB
.yarn/cache/@radix-ui-react-primitive-npm-0.1.4-115fd5c8b4-5341ce08ce.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+6.88 KB
.yarn/cache/@radix-ui-react-use-body-pointer-events-npm-0.1.1-6331b7dbe8-1f81dc9aad.zip
Binary file not shown.
Binary file added
BIN
+5.16 KB
.yarn/cache/@radix-ui-react-use-callback-ref-npm-0.1.0-838ec38d13-5356971123.zip
Binary file not shown.
Binary file added
BIN
+6.62 KB
.yarn/cache/@radix-ui-react-use-controllable-state-npm-0.1.0-75d1e06cac-ee83e97ca4.zip
Binary file not shown.
Binary file added
BIN
+5.14 KB
.yarn/cache/@radix-ui-react-use-escape-keydown-npm-0.1.0-af4910b082-b92769ecf4.zip
Binary file not shown.
Binary file added
BIN
+4.87 KB
.yarn/cache/@radix-ui-react-use-layout-effect-npm-0.1.0-d80d7efedb-d8be1f9770.zip
Binary file not shown.
Binary file added
BIN
+4.86 KB
.yarn/cache/@radix-ui-react-use-rect-npm-0.1.1-4803859eb8-aacf810744.zip
Binary file not shown.
Binary file added
BIN
+6.29 KB
.yarn/cache/@radix-ui-react-use-size-npm-0.1.1-d97c9e4644-205788806f.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+16 KB
.yarn/cache/react-remove-scroll-bar-npm-2.3.6-92aacd8517-5ab8eda61d.zip
Binary file not shown.
Binary file not shown.
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
86 changes: 86 additions & 0 deletions
86
packages/react-components/src/components/Popover/index.tsx
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import styled from "styled-components"; | ||
import * as RadixPopover from "@radix-ui/react-popover"; | ||
import type { PopoverProps } from "@radix-ui/react-popover"; | ||
import { X } from "@styled-icons/bootstrap/X"; | ||
import React from "react"; | ||
import { Heading } from "../Heading"; | ||
|
||
const ALIGN_OPTIONS: readonly ["start", "center", "end"] = [ | ||
"start", | ||
"center", | ||
"end", | ||
]; | ||
export type Align = (typeof ALIGN_OPTIONS)[number]; | ||
|
||
const StyledPopoverContent = styled(RadixPopover.Content)` | ||
display: flex; | ||
flex-direction: column; | ||
background: ${({ theme }) => theme.color.backgroundLighter}; | ||
border: 1px solid ${({ theme }) => theme.color.selection}; | ||
box-shadow: 0 7px 30px -10px ${({ theme }) => theme.color.black}; | ||
outline: none; | ||
`; | ||
|
||
const StyledPopoverClose = styled(RadixPopover.Close).attrs({ | ||
"aria-label": "Close", | ||
asChild: true, | ||
})` | ||
appearance: initial; | ||
margin-left: auto; | ||
cursor: pointer; | ||
`; | ||
|
||
const Header = styled.div` | ||
display: flex; | ||
padding: 2rem; | ||
align-items: center; | ||
justify-content: space-between; | ||
border-bottom: 0.1rem ${({ theme }) => theme.color.background} solid; | ||
`; | ||
|
||
const ContentWrapper = styled.div` | ||
width: 100%; | ||
`; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
withCloseButton?: boolean; | ||
trigger: React.ReactNode; | ||
width?: number | string; | ||
title?: string; | ||
open?: PopoverProps["open"]; | ||
onOpenChange?: (isOpen: boolean) => void; | ||
align?: Align; | ||
}; | ||
|
||
export const Popover = ({ | ||
children, | ||
withCloseButton = false, | ||
width, | ||
trigger, | ||
title, | ||
open, | ||
onOpenChange, | ||
align, | ||
}: Props) => ( | ||
<RadixPopover.Root onOpenChange={onOpenChange} open={open}> | ||
<RadixPopover.Trigger asChild>{trigger}</RadixPopover.Trigger> | ||
<StyledPopoverContent | ||
style={{ width: width ?? "auto" }} | ||
align={align} | ||
sideOffset={10} | ||
> | ||
{(title || withCloseButton) && ( | ||
<Header> | ||
{title && <Heading level={5}>{title}</Heading>} | ||
{withCloseButton && ( | ||
<StyledPopoverClose> | ||
<X size="18px" /> | ||
</StyledPopoverClose> | ||
)} | ||
</Header> | ||
)} | ||
<ContentWrapper>{children}</ContentWrapper> | ||
</StyledPopoverContent> | ||
</RadixPopover.Root> | ||
); |
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
73 changes: 73 additions & 0 deletions
73
packages/web-console/src/scenes/Editor/Metrics/color-palette.tsx
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from "react" | ||
import styled from "styled-components" | ||
import { Box } from "@questdb/react-components" | ||
import { Check } from "@styled-icons/boxicons-regular" | ||
|
||
export const colors = [ | ||
"#bbbbbb", | ||
"#f8f8f2", | ||
"#6272a4", | ||
"#ff5555", | ||
"#ffb86c", | ||
"#f1fa8c", | ||
"#50fa7b", | ||
"#bd93f9", | ||
"#8be9fd", | ||
"#d14671", | ||
"#fafafa", | ||
] | ||
|
||
export const defaultColor = "#8be9fd" | ||
|
||
export const getColorForNewMetric = ( | ||
existingColors: string[], | ||
lastColor: string, | ||
) => { | ||
const filteredColorPalette = colors.filter((color) => color !== lastColor) | ||
const filterExisting = filteredColorPalette.filter( | ||
(color) => !existingColors.includes(color), | ||
) | ||
return filterExisting.length > 0 | ||
? filterExisting[Math.floor(Math.random() * filterExisting.length)] | ||
: filteredColorPalette[ | ||
Math.floor(Math.random() * filteredColorPalette.length) | ||
] | ||
} | ||
|
||
const Root = styled.div` | ||
padding: 0.5rem; | ||
` | ||
|
||
const ColorBox = styled.div` | ||
position: relative; | ||
width: 1.6rem; | ||
height: 1.6rem; | ||
cursor: pointer; | ||
` | ||
|
||
const CheckIcon = styled(Check)` | ||
position: absolute; | ||
color: black; | ||
` | ||
|
||
export const ColorPalette = ({ | ||
selectedColor, | ||
onSelect, | ||
}: { | ||
selectedColor: string | ||
onSelect: (color: string) => void | ||
}) => ( | ||
<Root> | ||
<Box gap="0.5rem"> | ||
{colors.map((color) => ( | ||
<ColorBox | ||
key={color} | ||
style={{ backgroundColor: color }} | ||
onClick={() => onSelect(color)} | ||
> | ||
{selectedColor === color && <CheckIcon size="16px" />} | ||
</ColorBox> | ||
))} | ||
</Box> | ||
</Root> | ||
) |
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
Oops, something went wrong.