Skip to content

Commit

Permalink
#25 Table editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Polleps committed Mar 13, 2023
1 parent 4165667 commit fec9523
Show file tree
Hide file tree
Showing 61 changed files with 4,000 additions and 32 deletions.
9 changes: 9 additions & 0 deletions .vscode/StyledTheme.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"StyledTheme": {
"prefix": "theme-interpolation",
"body": [
"${p => p.theme.${1:colors}.$2};"
],
"description": "Insert Theme interpolation in styled-component"
}
}
11 changes: 8 additions & 3 deletions data-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"@bugsnag/core": "^7.16.1",
"@bugsnag/js": "^7.16.5",
"@bugsnag/plugin-react": "^7.16.5",
"@dnd-kit/core": "^6.0.5",
"@dnd-kit/sortable": "^7.0.1",
"@dnd-kit/utilities": "^3.2.0",
"@dnd-kit/core": "^4.0.3",
"@dnd-kit/sortable": "^5.1.0",
"@dnd-kit/utilities": "^3.0.2",
"@radix-ui/react-popover": "^1.0.2",
"@radix-ui/react-scroll-area": "^1.0.1",
"@tomic/react": "workspace:*",
"polished": "^4.1.0",
"query-string": "^7.0.0",
Expand All @@ -29,6 +31,8 @@
"react-pdf": "^6.2.2",
"react-router": "^6.0.0",
"react-router-dom": "^6.0.0",
"react-virtualized-auto-sizer": "^1.0.7",
"react-window": "^1.8.7",
"remark-gfm": "^3.0.1",
"styled-components": "^5.3.3",
"yamde": "^1.7.1"
Expand All @@ -38,6 +42,7 @@
"@types/react-dom": "^18.0.5",
"@types/react-pdf": "^6.2.0",
"@types/react-router-dom": "^5.0.0",
"@types/react-window": "^1.8.5",
"@types/styled-components": "^5.1.25",
"babel-plugin-styled-components": "^2.0.7",
"csstype": "^3.1.0",
Expand Down
3 changes: 3 additions & 0 deletions data-browser/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const Content = styled.div<ContentProps>`
display: block;
flex: 1;
overflow-y: auto;
border-top: 1px solid ${p => p.theme.colors.bg2};
border-left: 1px solid ${p => p.theme.colors.bg2};
border-top-left-radius: ${p => p.theme.radius};
`;

/** Persistently shown navigation bar */
Expand Down
74 changes: 74 additions & 0 deletions data-browser/src/components/Popover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import * as RadixPopover from '@radix-ui/react-popover';
import { FaEdit, FaTimes } from 'react-icons/fa';
import styled from 'styled-components';

export interface PopoverProps {
label: string;
open?: boolean;
onOpenChange: (open: boolean) => void;
}

export function Popover({
children,
open,
onOpenChange,
label,
}: React.PropsWithChildren<PopoverProps>): JSX.Element {
return (
<RadixPopover.Root open={open} onOpenChange={onOpenChange}>
<Trigger>
<FaEdit /> {label}
</Trigger>
<RadixPopover.Portal>
<Content sideOffset={5}>
{children}
<Close>
<FaTimes />
</Close>
<Arrow />
</Content>
</RadixPopover.Portal>
</RadixPopover.Root>
);
}

const Trigger = styled(RadixPopover.Trigger)`
max-width: 100%;
`;

const Content = styled(RadixPopover.Content)`
--popover-close-offset: ${p => p.theme.margin}rem;
--popover-close-size: 25px;
--popover-close-safe-area: calc(
var(--popover-close-size) + (var(--popover-close-offset) * 2) -
${p => p.theme.margin}rem
);
background-color: ${p => p.theme.colors.bgBody};
border: 1px solid ${p => p.theme.colors.bg2};
padding: ${p => p.theme.margin}rem;
box-shadow: ${p => p.theme.boxShadowSoft};
border-radius: ${p => p.theme.radius};
position: relative;
`;

const Arrow = styled(RadixPopover.Arrow)`
fill: ${p => p.theme.colors.bg2};
`;

const Close = styled(RadixPopover.Close)`
border: none;
background-color: ${p => p.theme.colors.main};
color: white;
appearance: none;
font-family: inherit;
border-radius: 100%;
height: var(--popover-close-size);
width: var(--popover-close-size);
display: inline-flex;
align-items: center;
justify-content: center;
position: absolute;
top: var(--popover-close-offset);
right: var(--popover-close-offset);
`;
57 changes: 57 additions & 0 deletions data-browser/src/components/ScrollArea.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import * as RadixScrollArea from '@radix-ui/react-scroll-area';
import styled from 'styled-components';
import { transparentize } from 'polished';

const SIZE = '0.8rem';

export interface ScrollAreaProps {
className?: string;
}

export const ScrollArea = React.forwardRef<
HTMLDivElement,
React.PropsWithChildren<ScrollAreaProps>
>(({ children, className }, ref): JSX.Element => {
return (
<RadixScrollArea.Root type='scroll'>
<RadixScrollArea.Viewport className={className} ref={ref}>
{children}
</RadixScrollArea.Viewport>
<ScrollBar orientation='horizontal'>
<Thumb />
</ScrollBar>
<ScrollBar orientation='vertical'>
<Thumb />
</ScrollBar>
<RadixScrollArea.Corner />
</RadixScrollArea.Root>
);
});

ScrollArea.displayName = 'ScrollArea';

const ScrollBar = styled(RadixScrollArea.Scrollbar)`
display: flex;
/* ensures no selection */
user-select: none;
/* disable browser handling of all panning and zooming gestures on touch devices */
touch-action: none;
padding: 2px;
background-color: transparent;
transition: background-color ${p => p.theme.animation.duration} ease-out;
&[data-orientation='horizontal'] {
flex-direction: column;
height: ${() => SIZE};
}
`;

const Thumb = styled(RadixScrollArea.Thumb)`
position: relative;
bottom: 1px;
flex: 1;
background-color: ${p => transparentize(0.25, p.theme.colors.bg2)};
border-radius: ${() => SIZE};
backdrop-filter: blur(10px);
z-index: 2;
`;
7 changes: 5 additions & 2 deletions data-browser/src/components/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ const SideBarStyled = styled('nav').attrs<SideBarStyledProps>(p => ({
z-index: ${p => p.theme.zIndex.sidebar};
box-sizing: border-box;
background: ${p => p.theme.colors.bg};
border-right: solid 1px ${p => p.theme.colors.bg2};
transition: opacity 0.3s, left 0.3s;
left: ${p => (p.exposed ? '0' : `calc(var(--width) * -1 + 0.5rem)`)};
/* When the user is hovering, show half opacity */
opacity: ${p => (p.exposed ? 1 : 0)};
height: 100vh;
width: var(--width);
position: ${p => (p.locked ? 'relative' : 'absolute')};
border-right: ${p => (p.locked ? 'none' : `1px solid ${p.theme.colors.bg2}`)};
box-shadow: ${p => (p.locked ? 'none' : p.theme.boxShadowSoft)};
display: flex;
flex-direction: column;
overflow-y: auto;
Expand Down Expand Up @@ -135,7 +136,9 @@ const SideBarOverlay = styled.div<SideBarOverlayProps>`
`;

const SideBarDragArea = styled(DragAreaBase)`
height: 100%;
--handle-margin: 1rem;
height: calc(100% - var(--handle-margin) * 2);
margin-top: var(--handle-margin);
width: 12px;
right: -6px;
top: 0;
Expand Down
Loading

0 comments on commit fec9523

Please sign in to comment.