Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nmsimons committed Dec 5, 2023
1 parent 4a60690 commit 7c9f2c8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
70 changes: 35 additions & 35 deletions src/react_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ export function ReactApp(props: { data: TreeView<App> }): JSX.Element {
);
}

export function ListGroup(props: {
target: StringList;
destination: StringList;
}): JSX.Element {
return (
<div className="flex flex-col gap-3 justify-center content-center m-6">
<div className="flex flex-row gap-3 justify-center content-center ">
<ItemCount target={props.target} />
</div>
<div className="flex flex-row gap-3 justify-center content-center ">
<InsertButton target={props.target} />
<RemoveButton target={props.target} />
<MoveButton
target={props.target}
destination={props.destination}
/>
</div>
</div>
);
}

export function ItemCount(props: {
target: StringList;
}): JSX.Element {
Expand Down Expand Up @@ -74,6 +95,20 @@ export function MoveButton(props: {
return <Button handleClick={handleClick}>Move</Button>;
}

export function Button(props: {
children: ReactNode;
handleClick: () => void;
}): JSX.Element {
return (
<button
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded w-24"
onClick={() => props.handleClick()}
>
{props.children}
</button>
);
}

export function Explanation(): JSX.Element {
return (
<div className="flex flex-col max-w-sm gap-4 justify-left my-8">
Expand Down Expand Up @@ -127,38 +162,3 @@ export function DemoLink(props: { href: string; children: ReactNode }): JSX.Elem
</div>
);
}

export function ListGroup(props: {
target: StringList;
destination: StringList;
}): JSX.Element {
return (
<div className="flex flex-col gap-3 justify-center content-center m-6">
<div className="flex flex-row gap-3 justify-center content-center ">
<ItemCount target={props.target} />
</div>
<div className="flex flex-row gap-3 justify-center content-center ">
<InsertButton target={props.target} />
<RemoveButton target={props.target} />
<MoveButton
target={props.target}
destination={props.destination}
/>
</div>
</div>
);
}

export function Button(props: {
children: ReactNode;
handleClick: () => void;
}): JSX.Element {
return (
<button
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded w-24"
onClick={() => props.handleClick()}
>
{props.children}
</button>
);
}
2 changes: 1 addition & 1 deletion src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TreeConfiguration, SchemaFactory } from '@fluid-experimental/tree2';

const sf = new SchemaFactory('d302b84c-75f6-4ecd-9663-524f467013e3');

export class StringList extends sf.list('List', sf.string) {
export class StringList extends sf.list('StringList', sf.string) {
// Moves the first item in the source list to the start of this list
public moveToSourceList(source: StringList) {
if (source.length > 0) this.moveToStart(0, source);
Expand Down

0 comments on commit 7c9f2c8

Please sign in to comment.