Skip to content

Commit

Permalink
[CLD-501] update app-list to have 4 rows option (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatanpham authored Dec 2, 2019
1 parent d828562 commit 9f9c2b9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/components/pages/__tests__/__snapshots__/client.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports[`Client should match a snapshot 1`] = `
}
}
loading={false}
numOfColumn={3}
onCardClick={[Function]}
title="Featured Apps"
/>
Expand Down Expand Up @@ -104,6 +105,7 @@ exports[`Client should match a snapshot 1`] = `
}
}
loading={false}
numOfColumn={3}
onCardClick={[Function]}
pagination={
Object {
Expand Down
2 changes: 2 additions & 0 deletions src/components/pages/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const Client: React.FunctionComponent<ClientProps> = ({
loading={loading}
onCardClick={handleOnCardClick({ setVisible, appDetail, fetchAppDetail, clientId })}
infoType="CLIENT_APPS_EMPTY"
numOfColumn={3}
/>
<div className={styles.divider} />
</>
Expand All @@ -90,6 +91,7 @@ export const Client: React.FunctionComponent<ClientProps> = ({
pageNumber,
onChange: handleOnChange(history)
}}
numOfColumn={3}
/>
</div>
)}
Expand Down
16 changes: 8 additions & 8 deletions src/components/ui/__tests__/__snapshots__/app-list.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`AppList should match a snapshot 1`] = `
className=" "
data-test="app-list-container"
>
<GridThreeColItem
<GridFourColItem
key="09043eb8-9e5e-4650-b7f1-f0cb62699027"
>
<AppCard
Expand Down Expand Up @@ -43,8 +43,8 @@ exports[`AppList should match a snapshot 1`] = `
onClick={[Function]}
onSettingsClick={[Function]}
/>
</GridThreeColItem>
<GridThreeColItem
</GridFourColItem>
<GridFourColItem
key="261da083-cee2-4f5c-a18f-8f9375f1f5af"
>
<AppCard
Expand Down Expand Up @@ -74,7 +74,7 @@ exports[`AppList should match a snapshot 1`] = `
onClick={[Function]}
onSettingsClick={[Function]}
/>
</GridThreeColItem>
</GridFourColItem>
</GridFiveCol>
</div>
<Section>
Expand All @@ -101,7 +101,7 @@ exports[`AppList should match a snapshot when use empty infoType 1`] = `
className=" "
data-test="app-list-container"
>
<GridThreeColItem
<GridFourColItem
key="09043eb8-9e5e-4650-b7f1-f0cb62699027"
>
<AppCard
Expand Down Expand Up @@ -131,8 +131,8 @@ exports[`AppList should match a snapshot when use empty infoType 1`] = `
onClick={[Function]}
onSettingsClick={[Function]}
/>
</GridThreeColItem>
<GridThreeColItem
</GridFourColItem>
<GridFourColItem
key="261da083-cee2-4f5c-a18f-8f9375f1f5af"
>
<AppCard
Expand Down Expand Up @@ -162,7 +162,7 @@ exports[`AppList should match a snapshot when use empty infoType 1`] = `
onClick={[Function]}
onSettingsClick={[Function]}
/>
</GridThreeColItem>
</GridFourColItem>
</GridFiveCol>
</div>
<Section>
Expand Down
12 changes: 11 additions & 1 deletion src/components/ui/__tests__/app-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { shallow } from 'enzyme'
import toJson from 'enzyme-to-json'
import { AppList, AppListProps } from '../app-list'
import { appsDataStub } from '@/sagas/__stubs__/apps'
import { Loader } from '@reapit/elements'
import { Loader, GridFourColItem, GridThreeColItem } from '@reapit/elements'
import { AppSummaryModel } from '../../../types/marketplace-api-schema'
import AppCard from '../app-card'

Expand Down Expand Up @@ -45,4 +45,14 @@ describe('AppList', () => {
expect(props.onCardClick).toHaveBeenCalledTimes(1)
expect(props.onCardClick).toHaveBeenCalledWith(appsDataStub?.data?.data?.[0])
})

it('should default contain GridFourColItem', () => {
const wrapper = shallow(<AppList {...props} />)
expect(wrapper.find(GridFourColItem).length).toBeGreaterThan(0)
})

it('should contain GridThreeColItem', () => {
const wrapper = shallow(<AppList numOfColumn={3} {...props} />)
expect(wrapper.find(GridThreeColItem).length).toBeGreaterThan(0)
})
})
13 changes: 9 additions & 4 deletions src/components/ui/app-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
Section,
Pagination,
GridThreeColItem,
FlexContainerBasic
FlexContainerBasic,
GridFourColItem
} from '@reapit/elements'

export type AppListProps = {
Expand All @@ -23,6 +24,7 @@ export type AppListProps = {
title?: string
infoType: InfoType
pagination?: PaginationProps
numOfColumn?: number
}

export const AppList: React.FunctionComponent<AppListProps> = ({
Expand All @@ -32,8 +34,11 @@ export const AppList: React.FunctionComponent<AppListProps> = ({
onSettingsClick,
title,
infoType,
pagination
pagination,
numOfColumn = 4
}) => {
const WrapperContainer = numOfColumn === 4 ? GridFourColItem : GridThreeColItem

return (
<FlexContainerBasic hasPadding flexColumn>
{title && <H3>{title}</H3>}
Expand All @@ -43,7 +48,7 @@ export const AppList: React.FunctionComponent<AppListProps> = ({
<Info infoType={infoType}>{!infoType && 'UNFORTUNATELY, YOUR SEARCH RETURNED NO RESULTS'}</Info>
) : (
list.map(app => (
<GridThreeColItem key={app.id}>
<WrapperContainer key={app.id}>
<AppCard
app={app}
onClick={
Expand All @@ -63,7 +68,7 @@ export const AppList: React.FunctionComponent<AppListProps> = ({
: undefined
}
/>
</GridThreeColItem>
</WrapperContainer>
))
)}
</GridFiveCol>
Expand Down

0 comments on commit 9f9c2b9

Please sign in to comment.