-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from jenny-s51/IUXD-112-Cards
CardView+Toolbar
- Loading branch information
Showing
9 changed files
with
423 additions
and
180 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -29,7 +29,6 @@ | |
height: 100vh; | ||
} | ||
|
||
|
||
.app-api-title { | ||
color: var(--pf-global--primary-color--100); | ||
} | ||
|
37 changes: 0 additions & 37 deletions
37
packages/studio/src/app/components/api/apiCard/apiCard.tsx
This file was deleted.
Oops, something went wrong.
117 changes: 98 additions & 19 deletions
117
packages/studio/src/app/components/api/apiCard/apiCardView.tsx
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 |
---|---|---|
@@ -1,26 +1,105 @@ | ||
import React, { useContext } from 'react'; | ||
import { Gallery } from '@patternfly/react-core'; | ||
import {ApiCard} from './apiCard'; | ||
import { GlobalContext } from '../../../../context'; | ||
import React, { useContext, useState } from "react"; | ||
import { | ||
Card, | ||
CardHead, | ||
CardHeader, | ||
CardBody, | ||
CardFooter, | ||
CardActions, | ||
Gallery, | ||
Checkbox | ||
} from "@patternfly/react-core"; | ||
import { ApiTag } from "../apiTag"; | ||
import ApicurioIcon from "./../../../assets/apicurio-icon.png"; | ||
import "./apiCard.css"; | ||
import AppDropdownKebab from "../apiDropDownKebab/apiDropdownKebab"; | ||
import { GlobalContext, GlobalContextObj } from "../../../../context"; | ||
|
||
export const ApiCardView: React.FunctionComponent<any> = (props) => { | ||
const { apis } = {... useContext(GlobalContext).store} | ||
interface ApiCardProps { | ||
id?: string; | ||
name?: string; | ||
description?: string; | ||
tags?: string[]; | ||
type?: string; | ||
} | ||
|
||
const cardList = apis.map((api, index) => | ||
<ApiCard | ||
key={index} | ||
id={api.id} | ||
name={api.name} | ||
description={api.description} | ||
tags={api.tags} | ||
/> | ||
); | ||
export const ApiCardView: React.FunctionComponent<ApiCardProps> = ({ | ||
name, | ||
description, | ||
tags = [] | ||
}: ApiCardProps) => { | ||
const globalContext: GlobalContextObj = useContext(GlobalContext); | ||
const { selectedItems } = { ...globalContext.store.toolbarStatus }; | ||
|
||
const getAllItems = () => { | ||
const collection: number[] = []; | ||
for (const items of selectedItems) { | ||
// tslint:disable-next-line: radix | ||
collection.push(parseInt(items.id)); | ||
} | ||
return collection; | ||
}; | ||
|
||
const handleCheckboxClick = (checked: boolean, e: any) => { | ||
const { value } = e.target; | ||
|
||
if (checked) { | ||
globalContext.updateToolbarStatus({ | ||
areAllSelected: | ||
globalContext.store.apis.length - 1 === selectedItems.length, | ||
selectedItems: selectedItems.concat(value * 1) | ||
}); | ||
} else { | ||
globalContext.updateToolbarStatus({ | ||
areAllSelected: false, | ||
selectedItems: selectedItems.filter(item => item !== Number(value)) | ||
}); | ||
} | ||
}; | ||
|
||
const { apis } = { ...useContext(GlobalContext).store }; | ||
|
||
return ( | ||
<Gallery gutter="md"> | ||
{cardList} | ||
{apis.map((api, key) => ( | ||
<React.Fragment> | ||
<Card key={key}> | ||
<CardHead> | ||
<img src={ApicurioIcon} /> | ||
<CardActions> | ||
<AppDropdownKebab /> | ||
<Checkbox | ||
value={api.id} | ||
// tslint:disable-next-line: radix | ||
isChecked={globalContext.store.toolbarStatus.selectedItems.includes( | ||
parseInt(api.id) | ||
)} | ||
checked={globalContext.store.toolbarStatus.isChecked} | ||
onChange={handleCheckboxClick} | ||
aria-label="card checkbox" | ||
id={"check " + api.id} | ||
name="check" | ||
/> | ||
</CardActions> | ||
</CardHead> | ||
<CardHeader className="api-card-view-card-header"> | ||
{api.name} | ||
</CardHeader> | ||
<CardBody className="api-card-view-card-body"> | ||
{api.description} | ||
</CardBody> | ||
<CardFooter> | ||
<div className="api-api-tag-group"> | ||
{api.tags.map( | ||
(tag: string, index: string | number | undefined) => ( | ||
<ApiTag text={tag} /> | ||
) | ||
)} | ||
</div> | ||
</CardFooter> | ||
</Card> | ||
</React.Fragment> | ||
))} | ||
</Gallery> | ||
); | ||
} | ||
|
||
export default ApiCardView; | ||
}; |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './apiCard'; | ||
export * from './apiCardView'; |
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
Oops, something went wrong.