Skip to content

Commit

Permalink
feat: implement create persona feature (#13)
Browse files Browse the repository at this point in the history
* feat: add viem package

* feat: mvp for create persona feature

* fix: signer address overflows card & formatter fix

* build: fix lib/account build issues

* refactor: factor sidebar into multiple components, split messages & queries

* chore: fix wack bottom bar resize behavior & code formatting

---------

Co-authored-by: Ryan Martin <rmrt1n@users.noreply.github.com>
  • Loading branch information
rmrt1n and rmrt1n authored Mar 19, 2024
1 parent 75f535c commit 4f508b7
Show file tree
Hide file tree
Showing 15 changed files with 708 additions and 189 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"format": "prettier --ignore-path .gitignore --ignore-path 'src/routeTree.gen.ts' --write ."
},
"dependencies": {
"@noble/curves": "^1.4.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-label": "^2.0.2",
Expand All @@ -28,7 +29,8 @@
"react-dom": "^18.2.0",
"react-resizable-panels": "^2.0.11",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7"
"tailwindcss-animate": "^1.0.7",
"viem": "^2.7.20"
},
"devDependencies": {
"@tanstack/router-vite-plugin": "^1.16.5",
Expand Down
146 changes: 145 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/bottom-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export function BottomBar() {
const handleExpand = () => {
const panel = ref.current
if (panel) {
setCollapsed(!(panel.getSize() >= 65))
setCollapsed(panel.getSize() <= 3)
}
}
const expandBottomBar = () => {
const panel = ref.current
if (panel) {
panel.resize(panel.getSize() >= 65 ? 3 : 65)
panel.resize(panel.getSize() > 3 ? 3 : 65)
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/components/entity-group-sheets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ import { worldQueryOptions } from '@/lib/query-options'
import { Entity, WorldField } from '@/lib/types'

const sampleEntity = (selected: string[], components: WorldField[]): Entity => {
const componentsMap: { [key: string]: string } = components.reduce((acc, c) => ({ ...acc, [c.name]: c.fields }), {})
const componentsMap: { [key: string]: string } = components.reduce(
(acc, c) => ({ ...acc, [c.name]: c.fields }),
{},
)
return {
id: 0,
components: selected.reduce((acc, c) => ({ ...acc, [c]: componentsMap[c] }), {}),
Expand All @@ -67,6 +70,7 @@ export function NewEntityGroupSheet() {
if (entityGroupName.length === 0) {
e.preventDefault()
setEntityGroupError('Please enter a name for the entity group')
return
}
if (selected.length === 0) {
e.preventDefault()
Expand Down Expand Up @@ -128,7 +132,9 @@ export function NewEntityGroupSheet() {
<AccordionItem value="default" className="border-0 space-y-2">
<AccordionTrigger className="py-2 text-sm">Sample entities</AccordionTrigger>
<AccordionContent>
{hasSelectedComponents && <EntityCard entity={sampleEntity(selected, components)} />}
{hasSelectedComponents && (
<EntityCard entity={sampleEntity(selected, components)} />
)}
</AccordionContent>
</AccordionItem>
</Accordion>
Expand Down Expand Up @@ -242,7 +248,9 @@ export function EditEntityGroupSheet({ entityGroup }: EditEntityGroupProps) {
<AccordionItem value="default" className="border-0 space-y-2">
<AccordionTrigger className="py-2 text-sm">Sample entities</AccordionTrigger>
<AccordionContent>
{hasSelectedComponents && <EntityCard entity={sampleEntity(selected, components)} />}
{hasSelectedComponents && (
<EntityCard entity={sampleEntity(selected, components)} />
)}
</AccordionContent>
</AccordionItem>
</Accordion>
Expand Down
2 changes: 1 addition & 1 deletion src/components/entity-views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function ComponentDetails({ name, component }: ComponentDetailsProps) {
</summary>
<div>
{attributes.map((attr) => (
<p key={attr} className="ml-3 text-muted-foreground font-medium">
<p key={attr} className="ml-3 text-muted-foreground font-medium break-all">
{attr}: {formatAttribute(component[attr])}
</p>
))}
Expand Down
Loading

0 comments on commit 4f508b7

Please sign in to comment.