Skip to content

Commit

Permalink
Fix: add button styles and restrict cards to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderleegs committed Sep 20, 2023
1 parent 75cb62d commit 73cccf2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/layouts/components/Homepage/TextCardsBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import {
Input,
} from "@opengovsg/design-system-react"
import _ from "lodash"
import { BiPlus } from "react-icons/bi"

import { useEditableContext } from "contexts/EditableContext"

import { Editable } from "../Editable"
import { AddSectionButton } from "../Editable/AddSectionButton"

const NUM_MAX_CARDS = 4
interface TextCardFormFields {
title: string
description?: string
Expand Down Expand Up @@ -42,7 +43,6 @@ export const TextCardsSectionBody = ({
errors,
cardErrors = [],
}: TextCardsSectionProps) => {
console.log(cards)
const { onChange, onDelete, onDragEnd, onCreate } = useEditableContext()

return (
Expand Down Expand Up @@ -187,18 +187,23 @@ export const TextCardsSectionBody = ({
</Editable.Droppable>
</DragDropContext>
</FormControl>
<AddSectionButton
w="100%"
<Button
id={`textcardcard-${index}-create`}
variant="outline"
w="full"
pt="0.5rem"
buttonText="Add card"
leftIcon={<BiPlus fontSize="1.5rem" />}
isDisabled={cards.length >= NUM_MAX_CARDS}
onClick={() => {
onCreate({
target: {
id: `textcardcard-${index}`,
},
})
}}
/>
>
Add card
</Button>
<Button
id={`section-${index}`}
onClick={() => onDelete(`section-${index}`, "Text Cards Section")}
Expand Down

0 comments on commit 73cccf2

Please sign in to comment.