Skip to content

Commit

Permalink
Merge pull request #22 from jenny-s51/IUXD-112-Cards
Browse files Browse the repository at this point in the history
CardView+Toolbar
  • Loading branch information
christiemolloy authored May 1, 2020
2 parents f0fd631 + 8d4085d commit 756a7fb
Show file tree
Hide file tree
Showing 9 changed files with 423 additions and 180 deletions.
40 changes: 0 additions & 40 deletions packages/studio/src/api-data.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/studio/src/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
height: 100vh;
}


.app-api-title {
color: var(--pf-global--primary-color--100);
}
Expand Down
37 changes: 0 additions & 37 deletions packages/studio/src/app/components/api/apiCard/apiCard.tsx

This file was deleted.

117 changes: 98 additions & 19 deletions packages/studio/src/app/components/api/apiCard/apiCardView.tsx
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;
};
1 change: 0 additions & 1 deletion packages/studio/src/app/components/api/apiCard/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './apiCard';
export * from './apiCardView';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import { Drawer, DrawerPanelContent, DrawerContent } from '@patternfly/react-core/dist/esm/experimental';
import ApiDataList from '../apiDataList/apiDataList';
import {ApiCardView} from '../..';
import {ApiCardView} from '../apiCard/apiCardView';
import ApiDrawerPanelContent from './apiDrawerPanelContent';
import { GlobalContext, GlobalContextObj } from '../../../../context';
import './apiDrawer.css';
Expand Down
Loading

0 comments on commit 756a7fb

Please sign in to comment.