Skip to content

Commit

Permalink
feat: add chip list
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Apr 23, 2024
1 parent 8460103 commit ab91884
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/frontend/src/features/chips/ChipList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useLiveQuery } from "electric-sql/react"
import { db } from "../../db"
import { Flex, Stack, styled } from '#styled-system/jsx';
import type { Chip } from "../../generated/client";

export const ChipList = () => {
const chips = useLiveQuery(db.chip.liveMany())

if (!chips.results) return null

return <Stack>
{chips.results.map(chip => <ChipEditable chip={chip} key={chip.id} />)}
</Stack>
}

const ChipEditable = ({ chip }: { chip: Chip }) => {
return <Flex>
<styled.div>{chip.label}</styled.div>
<styled.div fontWeight="bold">{chip.value}</styled.div>
</Flex>
}

0 comments on commit ab91884

Please sign in to comment.