Skip to content

Commit

Permalink
Merge branch 'dashboard-editor' of https://github.com/IBM/carbon-addo…
Browse files Browse the repository at this point in the history
…ns-iot-react into dashboard-editor
  • Loading branch information
Joel Armendariz authored and Joel Armendariz committed Oct 13, 2020
2 parents 88f1018 + 058dfd9 commit 18bce41
Show file tree
Hide file tree
Showing 35 changed files with 1,768 additions and 1,903 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
}
&--content {
flex: 1;
overflow-y: auto;
margin: -$spacing-05;
height: 100%;
padding-top: $spacing-05;
Expand Down
2 changes: 1 addition & 1 deletion src/components/CardEditor/CardEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const defaultProps = {
closeGalleryButton: 'Back',
openJSONButton: 'Open JSON editor',
},
supportedTypes: [],
supportedTypes: ['BAR', 'TIMESERIES', 'VALUE', 'IMAGE', 'TABLE'],
};

const CardEditor = ({
Expand Down
76 changes: 41 additions & 35 deletions src/components/CardEditor/CardGalleryList/CardGalleryList.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
Add16,
ChartColumn16,
ChartLine16,
Table16,
SummaryKpi16,
Image16,
} from '@carbon/icons-react';

import { List, Button } from '../../../index';
import { SimpleList } from '../../../index';

import timeSeriesImg from './line-graph.svg';
import simpleBarImg from './simple-bar-graph.svg';
import valueImg from './value-kpi.svg';
import imageImg from './image.svg';
import tableImg from './data-table.svg';

const propTypes = {
supportedTypes: PropTypes.arrayOf(PropTypes.string),
onAddCard: PropTypes.func.isRequired,
i18n: PropTypes.shape({
galleryHeader: PropTypes.string,
searchPlaceHolderText: PropTypes.string,
pageOfPagesText: PropTypes.func,
cardType_TIMESERIES: PropTypes.string,
cardType_BAR: PropTypes.string,
cardType_VALUE: PropTypes.string,
cardType_IMAGE: PropTypes.string,
cardType_TABLE: PropTypes.string,
cardType_OTHER: PropTypes.string,
}),
};

const defaultProps = {
supportedTypes: ['BAR', 'TIMESERIES', 'VALUE', 'IMAGE', 'TABLE'],
i18n: {
galleryHeader: 'Gallery',
searchPlaceHolderText: 'Enter a search',
pageOfPagesText: page => `Page ${page}`,
cardType_TIMESERIES: 'Time series line',
cardType_BAR: 'Simple bar',
cardType_VALUE: 'Value/KPI',
cardType_VALUE: 'Value / KPI',
cardType_IMAGE: 'Image',
cardType_TABLE: 'Data table',
cardType_OTHER: 'Other',
Expand All @@ -34,39 +42,37 @@ const defaultProps = {
};

const iconTypeMap = {
TIMESERIES: <ChartLine16 />,
BAR: <ChartColumn16 />,
VALUE: <SummaryKpi16 />,
IMAGE: <Image16 />,
TABLE: <Table16 />,
TIMESERIES: <img src={timeSeriesImg} alt="Time series" />,
BAR: <img src={simpleBarImg} alt="Simple bar" />,
VALUE: <img src={valueImg} alt="Value / KPI" />,
// eslint-disable-next-line jsx-a11y/img-redundant-alt
IMAGE: <img src={imageImg} alt="Image card" />,
TABLE: <img src={tableImg} alt="Table" />,
};

const CardGalleryList = ({ supportedTypes, onAddCard, i18n }) => {
const mergedI18N = { ...i18n, ...defaultProps.i18n };
const mergedI18n = { ...i18n, ...defaultProps.i18n };
return (
<List
title={mergedI18N.galleryHeader}
<SimpleList
title={mergedI18n.galleryHeader}
isFullHeight
items={supportedTypes.map(i => ({
id: i,
isCategory: true,
hasSearch
showPagination={false}
items={supportedTypes.map(cardType => ({
id: cardType,
content: {
value: mergedI18N[`cardType_${i}`] || i,
icon: iconTypeMap[i],
rowActions: [
<Button
key={`add-${i}`}
data-testid={`card-gallery-list-${i}-add`}
kind="ghost"
size="small"
iconDescription="Add"
hasIconOnly
renderIcon={Add16}
onClick={() => onAddCard(i)}
/>,
],
value: mergedI18n[`cardType_${cardType}`] || cardType,
icon: iconTypeMap[cardType],
},
isSelectable: true,
}))}
onSelect={cardType => {
onAddCard(cardType);
}}
i18n={{
searchPlaceHolderText: i18n.searchPlaceHolderText,
pageOfPagesText: i18n.pageOfPagesText,
}}
/>
);
};
Expand Down
36 changes: 36 additions & 0 deletions src/components/CardEditor/CardGalleryList/alert-table.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/components/CardEditor/CardGalleryList/bar-grouped-graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/components/CardEditor/CardGalleryList/bar-stack-graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/components/CardEditor/CardGalleryList/data-table.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/components/CardEditor/CardGalleryList/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 18bce41

Please sign in to comment.