Skip to content

Commit

Permalink
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flipper-ui",
"version": "0.29.3",
"version": "0.29.4",
"description": "",
"main": "dist/index.js",
"homepage": "https://flipper-ui.ngi.com.br/",
16 changes: 16 additions & 0 deletions src/experimental/card/card.spec.tsx
Original file line number Diff line number Diff line change
@@ -36,6 +36,22 @@ describe('Card', () => {
expect(title).toBeDefined()
})

it('should render add button with label', () => {
const onAddClickSpy = jest.fn()
render(
<Card
name='test'
title='test-title'
onAddBtnLabel='add button'
onClickAdd={onAddClickSpy}>
<h1>test</h1>
</Card>
)
const addBtn = screen.getByText('add button')

expect(addBtn).toBeDefined()
})

it('should render edit button with editing state', () => {
const onToggleEdit = jest.fn()
const onEditProps: Partial<IconButtonProps> = {
8 changes: 8 additions & 0 deletions src/experimental/card/card.stories.tsx
Original file line number Diff line number Diff line change
@@ -37,3 +37,11 @@ Editing.args = {
onToggleEdit: () => alert('onToggleEdit'),
children: <Typography>Dummy content</Typography>
}

export const WithOnClickAdd = Template.bind({})
WithOnClickAdd.args = {
readonly: false,
onAddBtnLabel: 'Add',
onClickAdd: () => alert('onToggleEdit'),
children: <Typography>Dummy content</Typography>
}
13 changes: 12 additions & 1 deletion src/experimental/card/index.tsx
Original file line number Diff line number Diff line change
@@ -27,6 +27,11 @@ export interface IProps {
*/
title?: string
name: string
/**
* Label to be displayed on the add button.
* @default undefined
*/
onAddBtnLabel?: string
id?: string
editing?: boolean
action?: JSX.Element | null
@@ -71,6 +76,7 @@ export const Card = (props: IProps) => {
const {
id,
name,
onAddBtnLabel,
nested,
title,
action,
@@ -121,7 +127,12 @@ export const Card = (props: IProps) => {
</div>
</>
)}
{onClickAdd && <AddButton {...onAddProps} onClick={onClickAdd} />}

{onClickAdd && (
<AddButton {...onAddProps} onClick={onClickAdd}>
{onAddBtnLabel}
</AddButton>
)}
<div>{children}</div>
</Paper>
)

0 comments on commit 6b0c15d

Please sign in to comment.