diff --git a/aries-site/src/examples/templates/dashboards/components/Measure.js b/aries-site/src/examples/templates/dashboards/components/Measure.js index 994b99d2b..5501294d6 100644 --- a/aries-site/src/examples/templates/dashboards/components/Measure.js +++ b/aries-site/src/examples/templates/dashboards/components/Measure.js @@ -3,45 +3,7 @@ import PropTypes from 'prop-types'; import { Box, Button, NameValuePair, Text } from 'grommet'; import { TextEmphasis } from 'aries-core'; -export const Measure = ({ name, value: valueProp, onClick, ...rest }) => { - const { icon: iconProp, label } = name; - const icon = iconProp ? cloneElement(iconProp, { size: 'small' }) : null; - - const value = valueProp?.value || valueProp; - const valueSize = valueProp?.size || 'xxlarge'; - - let contents = ( - - {icon} - - {label?.label || label} - - - } - > - {value} - - ); - - if (onClick) { - contents = ; - } - - return {contents}; -}; - -Measure.propTypes = { - name: PropTypes.shape({ +const NameType = PropTypes.shape({ label: PropTypes.oneOfType([ PropTypes.string.isRequired, PropTypes.shape({ @@ -50,14 +12,75 @@ Measure.propTypes = { }), ]).isRequired, icon: PropTypes.node, - }), - value: PropTypes.oneOfType([ + }); +const ValueType = PropTypes.oneOfType([ PropTypes.string, PropTypes.number, PropTypes.shape({ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), size: PropTypes.string, }), - ]), + ]); + +const Name = ({ name }) => { + const { icon: iconProp, label } = name; + const icon = iconProp ? cloneElement(iconProp, { size: 'small' }) : null; + + return ( + + {icon} + + {label?.label || label} + + + ); +}; + +Name.propTypes = { + name: NameType, +}; + +const Value = ({ value: valueProp }) => { + const value = valueProp?.value || valueProp; + const valueSize = valueProp?.size || 'xxlarge'; + + return {value}; +}; + +Value.propTypes = { + value: ValueType, +}; + +export const Measure = ({ name, value, onClick }) => { + // If this measure is clickable, render a Button with the Name and Value + // rather a NameValuePair since + ) : ( + } + > + + + ); +}; + +Measure.propTypes = { + name: NameType, + value: ValueType, onClick: PropTypes.func, }; diff --git a/aries-site/src/examples/templates/dashboards/components/StatusBar.js b/aries-site/src/examples/templates/dashboards/components/StatusBar.js index fe5cda2b6..63cebdf67 100644 --- a/aries-site/src/examples/templates/dashboards/components/StatusBar.js +++ b/aries-site/src/examples/templates/dashboards/components/StatusBar.js @@ -4,7 +4,7 @@ import { Card, CardBody, CardHeader, - NameValueList, + Grid, ThemeContext, } from 'grommet'; import { DashboardCardHeader } from '.'; @@ -21,13 +21,14 @@ export const StatusBar = ({ children, title, menuItems, ...rest }) => { - {children} - + ); diff --git a/aries-site/src/examples/templates/dashboards/content/chartCards/CostByMonth.js b/aries-site/src/examples/templates/dashboards/content/chartCards/CostByMonth.js index e38f8ec24..fc5484d8f 100644 --- a/aries-site/src/examples/templates/dashboards/content/chartCards/CostByMonth.js +++ b/aries-site/src/examples/templates/dashboards/content/chartCards/CostByMonth.js @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { Grid, DataChart, Text } from 'grommet'; +import { DataChart, Text, Box, NameValueList } from 'grommet'; import { ChartCard, Measure } from '../../components'; import { convertDatesToFeatures, @@ -115,49 +115,40 @@ export const CostByMonth = ({ period }) => { } }, [values]); - const grid = { - columns: ['auto', 'auto'], - rows: ['auto', 'auto'], - areas: [ - ['measure', 'projection'], - ['chart', 'chart'], - ], - gap: 'medium', - }; - return ( - {values && ( - + {values && ( + + + + + - - - + )} ); diff --git a/aries-site/src/examples/templates/dashboards/content/chartCards/CostByService.js b/aries-site/src/examples/templates/dashboards/content/chartCards/CostByService.js index ddbe4c575..eacc68539 100644 --- a/aries-site/src/examples/templates/dashboards/content/chartCards/CostByService.js +++ b/aries-site/src/examples/templates/dashboards/content/chartCards/CostByService.js @@ -1,6 +1,13 @@ import { useContext, useEffect, useMemo, useState } from 'react'; import PropTypes from 'prop-types'; -import { Box, Grid, Meter, ResponsiveContext, ThemeContext } from 'grommet'; +import { + Box, + Grid, + Meter, + NameValueList, + ResponsiveContext, + ThemeContext, +} from 'grommet'; import { parseMetricToNum } from 'grommet/utils'; import { ChartCard, Legend, Measure } from '../../components'; import { @@ -155,15 +162,20 @@ export const CostByService = ({ period, notification }) => { size="full" /> - + > + + )} diff --git a/aries-site/src/examples/templates/dashboards/content/chartCards/RulesAudit.js b/aries-site/src/examples/templates/dashboards/content/chartCards/RulesAudit.js index aad360c44..8a99137f6 100644 --- a/aries-site/src/examples/templates/dashboards/content/chartCards/RulesAudit.js +++ b/aries-site/src/examples/templates/dashboards/content/chartCards/RulesAudit.js @@ -1,6 +1,6 @@ import { Fragment, useEffect, useState } from 'react'; import PropTypes from 'prop-types'; -import { Box, Grid, Meter, Text } from 'grommet'; +import { Box, Meter, NameValueList, Text } from 'grommet'; import { Calendar } from 'grommet-icons'; import { TextEmphasis } from 'aries-core'; import { ChartCard, Measure, MeterGroup } from '../../components'; @@ -88,15 +88,6 @@ export const RulesAudit = ({ period }) => { setAuditResults(nextAuditResults); }, [rules]); - const grid = { - columns: ['auto', 'auto', 'auto'], - rows: ['auto', 'auto'], - areas: [ - ['rules', 'frameworks', 'audits'], - ['chart', 'chart', 'chart'], - ], - }; - const nextScheduledAudit = nextAudit && ( {/* Placing the icon within a Text component ensures the icon is @@ -118,29 +109,30 @@ export const RulesAudit = ({ period }) => { return ( - - - - + + + + + + - + ); };