forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(CatalogTileView): Support tiles without categories. (patternfly#977)
- Loading branch information
1 parent
9790a10
commit 134af90
Showing
9 changed files
with
816 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...nsions/src/components/CatalogTileView/__mocks__/mockCatalogTileViewNoCategoriesExample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React from 'react'; | ||
import { Icon } from 'patternfly-react'; | ||
import { mockItems } from './mockItems'; | ||
|
||
import { CatalogTile } from '../../CatalogTile'; | ||
import { CatalogTileView } from '../index'; | ||
|
||
const MockCatalogTileViewNoCategoriesExample = () => { | ||
const getBadges = item => { | ||
const badges = []; | ||
|
||
if (item.certified) { | ||
badges.push( | ||
<CatalogTile.Badge key="certified" id="certified" title="Certified"> | ||
<Icon type="fa" name="cog" /> | ||
</CatalogTile.Badge> | ||
); | ||
} | ||
|
||
if (item.approved) { | ||
badges.push( | ||
<CatalogTile.Badge key="certified" title="USDA Approved" id="approved"> | ||
<Icon type="pf" name="ok" /> | ||
</CatalogTile.Badge> | ||
); | ||
} | ||
|
||
return badges; | ||
}; | ||
|
||
return ( | ||
<CatalogTileView useCategories={false}> | ||
{mockItems.map((item, index) => ( | ||
<CatalogTile | ||
id={item.id} | ||
key={`tile-${index}`} | ||
title={item.title} | ||
featured={item.featured} | ||
iconImg={item.image} | ||
vendor={item.vendor} | ||
description={item.description} | ||
badges={getBadges(item)} | ||
/> | ||
))} | ||
</CatalogTileView> | ||
); | ||
}; | ||
|
||
export { MockCatalogTileViewNoCategoriesExample }; | ||
|
||
export const MockCatalogTileViewNoCategoriesExampleSource = ` | ||
import React from 'react'; | ||
import { Icon } from 'patternfly-react'; | ||
import { mockItems } from './mockItems'; | ||
import { CatalogTile } from '../../CatalogTile'; | ||
import { CatalogTileView } from '../index'; | ||
const MockCatalogTileViewNoCategoriesExample = () => { | ||
const getBadges = item => { | ||
const badges = []; | ||
if (item.certified) { | ||
badges.push( | ||
<CatalogTile.Badge key="certified" id="certified" title="Certified"> | ||
<Icon type="fa" name="cog" /> | ||
</CatalogTile.Badge> | ||
); | ||
} | ||
if (item.approved) { | ||
badges.push( | ||
<CatalogTile.Badge key="certified" title="USDA Approved" id="approved"> | ||
<Icon type="pf" name="ok" /> | ||
</CatalogTile.Badge> | ||
); | ||
} | ||
return badges; | ||
}; | ||
return ( | ||
<CatalogTileView useCategories={false}> | ||
{mockItems.map((item, index) => ( | ||
<CatalogTile | ||
id={item.id} | ||
key={\`tile-\${index}\`} | ||
title={item.title} | ||
featured={item.featured} | ||
iconImg={item.image} | ||
vendor={item.vendor} | ||
description={item.description} | ||
badges={getBadges(item)} | ||
/> | ||
))} | ||
</CatalogTileView> | ||
); | ||
}; | ||
export { MockCatalogTileViewNoCategoriesExample }; | ||
`; |
Oops, something went wrong.