Skip to content

Commit

Permalink
fix(config): ent-3230 unlimited quantity, use aria-label (#924)
Browse files Browse the repository at this point in the history
* chartIcon, pass any props
* config, rhel, openshift, rhosak use aria-label
  • Loading branch information
cdcabrera committed Apr 19, 2022
1 parent d061078 commit 07092e7
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports[`ChartIcon Component should handle basic icons, variations in settings:
className="curiosity-chartarea__icon curiosity-chartarea__icon-eye"
>
<EyeIcon
aria-label="hello world"
color="currentColor"
noVerticalAlign={false}
size="md"
Expand All @@ -75,7 +76,6 @@ exports[`ChartIcon Component should handle basic icons, variations in settings:
className="curiosity-chartarea__icon curiosity-chartarea__icon-infinity"
>
<span
aria-label="lorem ipsum infinity"
className="curiosity-icon__f-infinity"
style={
Object {
Expand Down
3 changes: 2 additions & 1 deletion src/components/chart/__tests__/chartIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe('ChartIcon Component', () => {
{
size: 'md',
symbol: 'eye',
title: 'lorem ipsum eye'
title: 'lorem ipsum eye',
'aria-label': 'hello world'
},
{
size: 'md',
Expand Down
20 changes: 15 additions & 5 deletions src/components/chart/chartIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ const getSize = size => {
* @param {string} props.symbol
* @param {string} props.size
* @param {string} props.title
* @returns {Node}
* @returns {React.ReactNode}
*/
const ChartIcon = ({ fill, symbol, size, title }) => {
const svgProps = {};
const iconProps = { size, title };
const fontProps = { style: { fontSize: getSize(size) }, title, 'aria-label': title };
const ChartIcon = ({ fill, symbol, size, title, ...props }) => {
const svgProps = { ...props };
const iconProps = { size, title, ...props };
const fontProps = { style: { fontSize: getSize(size) }, title, ...props };
const emSvgSize = getSize(size);

if (title) {
Expand Down Expand Up @@ -106,13 +106,23 @@ const ChartIcon = ({ fill, symbol, size, title }) => {
return <span className={`curiosity-chartarea__icon curiosity-chartarea__icon-${symbol}`}>{setIcon()}</span>;
};

/**
* Prop types.
*
* @type {{symbol: string, size: string, fill: string, title: string}}
*/
ChartIcon.propTypes = {
fill: PropTypes.string,
size: PropTypes.oneOf([...Object.keys(IconSize)]),
symbol: PropTypes.oneOf(['dash', 'eye', 'eyeSlash', 'infinity', 'square', 'threshold']),
title: PropTypes.string
};

/**
* Default props.
*
* @type {{symbol: string, size: string, fill: null, title: null}}
*/
ChartIcon.defaultProps = {
fill: null,
size: 'sm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@ Object {
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
title={null}
/>
</Tooltip>,
},
Expand Down Expand Up @@ -387,10 +388,11 @@ Object {
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
title={null}
/>
</Tooltip>,
},
Expand Down
6 changes: 4 additions & 2 deletions src/config/__tests__/__snapshots__/product.rhel.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,11 @@ Object {
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
title={null}
/>
</Tooltip>,
},
Expand Down Expand Up @@ -419,10 +420,11 @@ Object {
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
title={null}
/>
</Tooltip>,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ Object {
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
title={null}
/>
</Tooltip>,
},
Expand Down Expand Up @@ -367,10 +368,11 @@ Object {
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
title={null}
/>
</Tooltip>,
},
Expand Down
2 changes: 1 addition & 1 deletion src/config/product.openshiftContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const config = {
const content = translate('curiosity-inventory.label', { context: ['hasInfiniteQuantity', uom?.value] });
return (
<Tooltip content={content}>
<ChartIcon symbol="infinity" title={content} />
<ChartIcon symbol="infinity" aria-label={content} />
</Tooltip>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/product.rhel.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const config = {
const content = translate('curiosity-inventory.label', { context: ['hasInfiniteQuantity', uom?.value] });
return (
<Tooltip content={content}>
<ChartIcon symbol="infinity" title={content} />
<ChartIcon symbol="infinity" aria-label={content} />
</Tooltip>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/product.rhosak.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ const config = {
const content = translate('curiosity-inventory.label', { context: ['hasInfiniteQuantity', uom?.value] });
return (
<Tooltip content={content}>
<ChartIcon symbol="infinity" title={content} />
<ChartIcon symbol="infinity" aria-label={content} />
</Tooltip>
);
}
Expand Down

0 comments on commit 07092e7

Please sign in to comment.