Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block editor #70

Open
wants to merge 58 commits into
base: wizard-translations-redux
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5506e77
component reorganization
jthrilly Oct 30, 2024
9212b18
heading and paragraph
jthrilly Oct 30, 2024
9efe94d
wip additional extensions
jthrilly Oct 30, 2024
ee60603
remove figure
jthrilly Oct 30, 2024
cd29821
add nodes
jthrilly Oct 30, 2024
460933d
features: bubble menu, link
buckhalt Oct 30, 2024
a9056c8
menu button component, ability to delete link
buckhalt Oct 30, 2024
4096ace
use useEditorState hook for states
buckhalt Oct 31, 2024
e819a99
first pass at variable drop into editor
buckhalt Oct 31, 2024
1986f67
rm unused extension
buckhalt Oct 31, 2024
503bfed
working example of editing variables
buckhalt Oct 31, 2024
7fad348
fix: allow drag of variables already in content area
buckhalt Nov 1, 2024
b3b8709
render variable components as they will appear on the form
buckhalt Nov 1, 2024
5fa4273
fix edit
buckhalt Nov 1, 2024
6b76874
refactor: individual label, control nodes make parent variable node
buckhalt Nov 4, 2024
2d53ba5
improve varaiable subcomponents
buckhalt Nov 4, 2024
dc3df52
fix edit by disallowing content in control
buckhalt Nov 5, 2024
8df20a1
feature: hint node in variable
buckhalt Nov 5, 2024
a09dcbe
prevent drag of hint and label out of variable
buckhalt Nov 5, 2024
839b90d
add placeholder extension
buckhalt Nov 5, 2024
186103c
implement label and hint placeholders
buckhalt Nov 6, 2024
2aa7d40
clean up types, errors, pull variable utils out for improved readability
buckhalt Nov 6, 2024
2b70185
make hint optional
buckhalt Nov 6, 2024
aebb715
integrate with schema work
buckhalt Nov 6, 2024
1d0f30e
prevent variable drop in invalid drop position
buckhalt Nov 7, 2024
2c488fc
variable hover menu for delete/edit, rm control node type
buckhalt Nov 7, 2024
7486e5f
make variable menu a popover
buckhalt Nov 7, 2024
e447872
wip variable toolbar with dropdrown, required prop
buckhalt Nov 8, 2024
e1a0f2a
custom dropdown menu component based on radix component
buckhalt Nov 8, 2024
40d04c7
custom toolbar component based on radix
buckhalt Nov 8, 2024
b1719d9
add new toolbar to bubble menu, fix nested button issue
buckhalt Nov 8, 2024
d47677d
make menu appear on click of entire var, other code improvements
buckhalt Nov 8, 2024
f7110bc
wip custom dropcursor
buckhalt Nov 12, 2024
593e02f
check for valid drop position
buckhalt Nov 13, 2024
d31da37
implement prosemirror dropcursor replacement
buckhalt Nov 13, 2024
461c8ce
wip group node
buckhalt Nov 13, 2024
a5024a0
wip group node view with toolbar
buckhalt Nov 13, 2024
2aba466
refactor bubble menus, implement group menu
buckhalt Nov 14, 2024
04c27de
fix setting children variable required props
buckhalt Nov 14, 2024
e323055
small styling change
buckhalt Nov 14, 2024
bd87267
fix bubble menu positioning
buckhalt Nov 14, 2024
ef76782
refactor variable menu as a bubble menu
buckhalt Nov 15, 2024
b8bd7b1
refactor: put variable menu options in NodeBubbleMenu to avoid confli…
buckhalt Nov 18, 2024
93f224d
improve node bubble menu shouldshow logic
buckhalt Nov 18, 2024
7f32037
type fixes
buckhalt Nov 18, 2024
7bc01c6
implement group menu as a submenu of node bubble menu
buckhalt Nov 19, 2024
d872b26
refactor group menu, improve styling
buckhalt Nov 20, 2024
46eb16c
feature: drag text nodes from side panel
buckhalt Nov 25, 2024
3f40291
refactor to reduce redundancy bt variable and other component drops
buckhalt Nov 25, 2024
d189437
refactor isValidDropPosition to be generalizable to all dropped elements
buckhalt Nov 25, 2024
1ca432c
fix drop, side panel keys
buckhalt Nov 26, 2024
0ef8ca5
feature: plus menu for adding new content at end of doc
buckhalt Nov 26, 2024
83ea60b
refactor as dropdown menu, add variable functionality
buckhalt Nov 26, 2024
baff735
show placeholder when inserting
buckhalt Nov 26, 2024
d7114ac
linting
buckhalt Dec 3, 2024
5550ad4
replace prosemirror packages with @tiptap/pm
buckhalt Dec 3, 2024
6c3c7d9
fix drop broken from linting
buckhalt Dec 3, 2024
6735aaa
linting fixes
buckhalt Dec 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/(main)/(auth)/_components/SignInForm.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { login } from '~/server/actions/auth';
import { Input } from '~/components/ui/form/Input';
import { SubmitButton } from '~/components/ui/form/SubmitButton';
import Form from '~/components/ui/form/Form';
import { getTranslations } from 'next-intl/server';
import Form from '~/components/form/Form';
import { Input } from '~/components/form/Input';
import { SubmitButton } from '~/components/form/SubmitButton';
import Link from '~/components/Link';
import { login } from '~/server/actions/auth';

export default async function SignInForm() {
const t = await getTranslations('Auth');
Expand Down
8 changes: 4 additions & 4 deletions app/(main)/(auth)/_components/SignUpForm.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client';

import { useTranslations } from 'next-intl';
import { useFormState } from 'react-dom';
import Form from '~/components/form/Form';
import { Input } from '~/components/form/Input';
import { SubmitButton } from '~/components/form/SubmitButton';
import { signup } from '~/server/actions/auth';
import { Input } from '~/components/ui/form/Input';
import { useTranslations } from 'next-intl';
import { SubmitButton } from '~/components/ui/form/SubmitButton';
import Form from '~/components/ui/form/Form';

export default function SignUpForm() {
const [formState, formAction] = useFormState(signup, {
Expand Down
16 changes: 8 additions & 8 deletions app/(main)/(dashboard)/_components/CreateStudyForm.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { createStudy } from '~/server/actions/study';
import { Role } from '@prisma/client';
import { getTranslations } from 'next-intl/server';
import { SubmitButton } from '~/components/ui/form/SubmitButton';
import { Input } from '~/components/ui/form/Input';
import Form from '~/components/form/Form';
import { Input } from '~/components/form/Input';
import { SubmitButton } from '~/components/form/SubmitButton';
import Section from '~/components/layout/Section';
import {
Select,
SelectContent,
SelectValue,
SelectTrigger,
SelectItem,
} from '~/components/ui/select';
import { Role } from '@prisma/client';
import Form from '~/components/ui/form/Form';
SelectTrigger,
SelectValue,
} from '~/components/select';
import { createStudy } from '~/server/actions/study';

export default async function CreateStudyForm() {
const t = await getTranslations('Components.CreateStudyForm');
Expand Down
5 changes: 2 additions & 3 deletions app/(main)/(dashboard)/_components/SignOutBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
'use client';

import React from 'react';
import { logout } from '~/server/actions/auth';
import { useTranslations } from 'next-intl';
import { SubmitButton } from '~/components/ui/form/SubmitButton';
import { SubmitButton } from '~/components/form/SubmitButton';
import { logout } from '~/server/actions/auth';

export default function SignOutBtn() {
const t = useTranslations('Auth.SignOut');
Expand Down
6 changes: 3 additions & 3 deletions app/(main)/(dashboard)/_components/StudySwitcherClient.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use client';

import { type Study } from '@prisma/client';
import { useParams, useRouter } from 'next/navigation';
import { useTranslations } from 'next-intl';
import { useParams, useRouter } from 'next/navigation';
import { route } from 'nextjs-routes';
import { useEffect, useState } from 'react';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '~/components/ui/select';
import { route } from 'nextjs-routes';
} from '~/components/select';

export default function StudySwitcherClient({ studies }: { studies: Study[] }) {
const t = useTranslations('Components.StudySwitcher');
Expand Down
10 changes: 5 additions & 5 deletions app/(main)/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { SearchIcon } from 'lucide-react';
import { Input } from '~/components/ui/form/Input';
import Image from 'next/image';
import StudySwitcher from './_components/StudySwitcher';
import LanguageSwitcher from '~/app/_components/LocaleSwitcher';
import SignOutBtn from './_components/SignOutBtn';
import { requirePageAuth } from '~/lib/auth';
import ResponsiveContainer from '~/components/layout/ResponsiveContainer';
import ThemeSwitcher from '~/app/_components/ThemeSwitcher';
import { Input } from '~/components/form/Input';
import ResponsiveContainer from '~/components/layout/ResponsiveContainer';
import { requirePageAuth } from '~/lib/auth';
import SignOutBtn from './_components/SignOutBtn';
import StudySwitcher from './_components/StudySwitcher';

export default async function DashboardLayout({
children,
Expand Down
14 changes: 7 additions & 7 deletions app/(main)/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { getUserStudies } from '~/server/queries/studies';
import { getTranslations } from 'next-intl/server';
import Link from '~/components/Link';
import UnorderedList from '~/components/typography/UnorderedList';
import { route } from 'nextjs-routes';
import { Button } from '~/components/Button';
import Section from '~/components/layout/Section';
import Link from '~/components/Link';
import PageHeader from '~/components/typography/PageHeader';
import Paragraph from '~/components/typography/Paragraph';
import UnorderedList from '~/components/typography/UnorderedList';
import { requirePageAuth } from '~/lib/auth';
import { getInterviews } from '~/server/queries/interviews';
import { getUserStudies } from '~/server/queries/studies';
import CreateStudyForm from './_components/CreateStudyForm';
import { requirePageAuth } from '~/lib/auth';
import { Button } from '~/components/ui/Button';
import Paragraph from '~/components/typography/Paragraph';
import { route } from 'nextjs-routes';

export default async function Dashboard() {
await requirePageAuth();
Expand Down
4 changes: 2 additions & 2 deletions app/_components/LocaleSwitcherSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use client';

import { useTransition } from 'react';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '~/components/ui/select';
} from '~/components/select';
import { type Locale } from '~/lib/localisation/config';
import { useTransition } from 'react';
import { setUserLocale } from '~/lib/localisation/locale';
import { getLocaleRecordsFromCodes } from '~/lib/localisation/utils';

Expand Down
14 changes: 7 additions & 7 deletions app/_components/Providers.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { MotionConfig } from 'framer-motion';
import { type AbstractIntlMessages } from 'next-intl';
import { type ReactNode } from 'react';
import RadixDirectionProvider from './RadixDirectionProvider';
import { TooltipProvider } from '~/components/ui/Tooltip';
import { type Locale } from '~/lib/localisation/config';
import IntlProvider from './IntlProvider';
import { ThemeProvider } from 'next-themes';
import { WizardProvider } from '~/lib/onboarding-wizard/Provider';
import { MotionConfig } from 'framer-motion';
import { type ReactNode } from 'react';
import { TooltipProvider } from '~/components/Tooltip';
import DialogProvider from '~/lib/dialogs/DialogProvider';
import { WizardProvider } from '~/lib/onboarding-wizard/Provider';
import { type Locale } from '~/schemas/protocol/i18n';
import IntlProvider from './IntlProvider';
import RadixDirectionProvider from './RadixDirectionProvider';

export default function Providers({
intlParams: { dir, messages, locale, now, timeZone },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Meta } from '@storybook/react';
import { fn } from '@storybook/test';
import Heading from '~/components/typography/Heading';
import {
Button,
type ButtonProps,
type ButtonVariants,
buttonVariants,
} from './Button';
import Heading from '../typography/Heading';

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Card.stories.tsx

import React from 'react';
import type { Meta, StoryFn } from '@storybook/react';
import Paragraph from '~/components/typography/Paragraph';
import { Card, type CardProps } from './Card';
import Paragraph from '../typography/Paragraph';

// Meta configuration for Storybook
const meta: Meta = {
Expand Down
8 changes: 4 additions & 4 deletions components/ui/Card.tsx → components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client';

import * as React from 'react';
import { cn } from '~/lib/utils';
import Divider from '~/components/layout/Divider';
import Surface from '~/components/layout/Surface';
import Heading from '~/components/typography/Heading';
import Paragraph from '../typography/Paragraph';
import Surface from '../layout/Surface';
import Divider from '../layout/Divider';
import Paragraph from '~/components/typography/Paragraph';
import { cn } from '~/lib/utils';

export type CardProps = {
title: string;
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions components/DropdownMenu.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { Meta, StoryFn } from '@storybook/react';
import { Button } from './Button';
import DropdownMenu from './DropdownMenu';

const meta: Meta = {
title: 'UI/DropdownMenu',
component: DropdownMenu.Root,
};

export default meta;

export const Default: StoryFn = () => (
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<Button variant="text" color="primary">
Choose an Option
</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Label>Input Control</DropdownMenu.Label>
<DropdownMenu.RadioGroup>
<DropdownMenu.Item
textValue="checkboxGroup"
onSelect={() => {
alert('selected checkbox');
}}
>
Checkbox Group
</DropdownMenu.Item>
<DropdownMenu.Item
textValue="toggleButtonGroup"
onSelect={() => {
alert('selected toggle');
}}
>
Toggle Button Group
</DropdownMenu.Item>
</DropdownMenu.RadioGroup>
</DropdownMenu.Content>
</DropdownMenu.Root>
);
82 changes: 82 additions & 0 deletions components/DropdownMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
import { type PropsWithChildren } from 'react';
import { cn } from '~/lib/utils';
import Heading from './typography/Heading';

const DropdownTrigger = ({ children }: PropsWithChildren) => (
<DropdownMenuPrimitive.Trigger asChild>
{children}
</DropdownMenuPrimitive.Trigger>
);

const DropdownMenuContent = ({
children,
side = 'bottom',
container,
}: PropsWithChildren<{
side?: 'top' | 'right' | 'bottom' | 'left';
container?: React.RefObject<HTMLDivElement>;
}>) => {
// Use the portal prop if provided, otherwise fallback to the 'dialog-portal' element
const portalContainer = container?.current
? container.current
: typeof window !== 'undefined'
? document.getElementById('dialog-portal')
: null;

return (
<DropdownMenuPrimitive.Portal container={portalContainer}>
<DropdownMenuPrimitive.Content
side={side}
sideOffset={5}
className="z-50 rounded-small border bg-surface-0 p-2"
>
{children}
</DropdownMenuPrimitive.Content>
</DropdownMenuPrimitive.Portal>
);
};

const DropdownItem = ({
children,
textValue,
onSelect,
active,
}: PropsWithChildren<{
textValue: string;
onSelect: () => void;
active?: boolean;
}>) => (
<DropdownMenuPrimitive.Item
textValue={textValue}
onSelect={onSelect}
className={cn(
'rounded-small p-2 text-sm hover:cursor-pointer hover:bg-surface-1',
active && 'bg-surface-1',
)}
>
{children}
</DropdownMenuPrimitive.Item>
);

const DropdownLabel = ({ children }: PropsWithChildren) => (
<DropdownMenuPrimitive.Label className="p-2 text-sm text-muted-foreground">
<Heading variant="label">{children}</Heading>
</DropdownMenuPrimitive.Label>
);

const DropdownSeparator = () => (
<DropdownMenuPrimitive.Separator className="border-t border-surface-2" />
);

const DropdownMenu = {
Root: DropdownMenuPrimitive.Root,
RadioGroup: DropdownMenuPrimitive.RadioGroup,
Trigger: DropdownTrigger,
Content: DropdownMenuContent,
Label: DropdownLabel,
Item: DropdownItem,
Separator: DropdownSeparator,
};

export default DropdownMenu;
9 changes: 6 additions & 3 deletions components/ui/Popover.tsx → components/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { type PropsWithChildren } from 'react';
import * as PopoverPrimitive from '@radix-ui/react-popover';
import { type PropsWithChildren } from 'react';
import { MotionSurface } from '~/components/layout/Surface';
import Heading from '~/components/typography/Heading';
import { cn } from '~/lib/utils';
import CloseButton from './CloseButton';
import Heading from '../typography/Heading';
import { MotionSurface } from '../layout/Surface';

const Popover = ({
children,
title,
content,
modal,
side,
isOpen,
onOpenChange,
}: PropsWithChildren<{
title?: string;
content: string | React.ReactNode;
side?: 'top' | 'right' | 'bottom' | 'left';
modal?: boolean;
isOpen?: boolean;
onOpenChange?: (open: boolean) => void;
Expand Down Expand Up @@ -50,6 +52,7 @@ const Popover = ({
// floating-ui prop exposed in @radix-ui/react-popper patch
// see https://floating-ui.com/docs/flip#fallbackaxissidedirection
fallbackAxisSideDirection="start"
side={side}
>
<MotionSurface
level={0}
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions components/Spotlight.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import * as motion from 'framer-motion/client';
import PopoverBackdrop from './ui/PopoverBackdrop';
import { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import PopoverBackdrop from '~/components/PopoverBackdrop';

/**
* Overlay that darkens the background and highlights a specific element.
Expand Down
Loading
Loading