-
Notifications
You must be signed in to change notification settings - Fork 7
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 #837 from shopgate/PWA-2159-a11y-filter-button
Enabled a11y in the filter feature
- Loading branch information
Showing
169 changed files
with
3,770 additions
and
3,101 deletions.
There are no files selected for viewing
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
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
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
33 changes: 23 additions & 10 deletions
33
libraries/common/components/I18n/components/FormatNumber/index.jsx
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,33 +1,46 @@ | ||
import React from 'react'; | ||
import React, { memo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { i18n } from '@shopgate/engage/core'; | ||
/** | ||
* Formats a number. | ||
* @param {Object} props The component props. | ||
* @returns {JSX} | ||
*/ | ||
const FormatNumber = props => ( | ||
<span className={props.className}> | ||
{FormatNumber.format(props)} | ||
</span> | ||
); | ||
const FormatNumber = ({ className, number, fractions }) => { | ||
if (!className) { | ||
FormatNumber.format({ | ||
number, | ||
fractions, | ||
}); | ||
} | ||
|
||
return ( | ||
<span className={className}> | ||
{FormatNumber.format({ | ||
number, | ||
fractions, | ||
})} | ||
</span> | ||
); | ||
}; | ||
|
||
FormatNumber.format = (props) => { | ||
if (!i18n.ready) { | ||
return props.number; | ||
} | ||
|
||
return i18n.number(props.number, props.fractions); | ||
}; | ||
|
||
FormatNumber.propTypes = { | ||
number: PropTypes.number.isRequired, // eslint-disable-line react/no-unused-prop-types | ||
number: PropTypes.number.isRequired, | ||
className: PropTypes.string, | ||
fractions: PropTypes.number, // eslint-disable-line react/no-unused-prop-types | ||
fractions: PropTypes.number, | ||
}; | ||
|
||
FormatNumber.defaultProps = { | ||
className: '', | ||
className: null, | ||
fractions: 0, | ||
}; | ||
|
||
export default FormatNumber; | ||
export default memo(FormatNumber); |
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
36 changes: 22 additions & 14 deletions
36
libraries/common/components/I18n/components/FormatPrice/index.jsx
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,35 +1,43 @@ | ||
import React from 'react'; | ||
import React, { memo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { i18n } from '@shopgate/engage/core'; | ||
/** | ||
* Formats a price. | ||
* @param {Object} props The component props. | ||
* @returns {JSX} | ||
*/ | ||
const FormatPrice = props => ( | ||
<span className={props.className}> | ||
{FormatPrice.format(props)} | ||
</span> | ||
); | ||
const FormatPrice = (props) => { | ||
const { className, ...formatProps } = props; | ||
|
||
FormatPrice.format = (props) => { | ||
if (!className) { | ||
return FormatPrice.format(formatProps); | ||
} | ||
|
||
return ( | ||
<span className={className}> | ||
{FormatPrice.format(formatProps)} | ||
</span> | ||
); | ||
}; | ||
|
||
FormatPrice.format = ({ price, currency, fractions }) => { | ||
if (!i18n.ready) { | ||
return props.price; | ||
return price; | ||
} | ||
|
||
return i18n.price(props.price, props.currency, props.fractions); | ||
return i18n.price(price, currency, fractions); | ||
}; | ||
|
||
FormatPrice.propTypes = { | ||
currency: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types | ||
price: PropTypes.number.isRequired, // eslint-disable-line react/no-unused-prop-types | ||
currency: PropTypes.string.isRequired, | ||
price: PropTypes.number.isRequired, | ||
className: PropTypes.string, | ||
fractions: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types | ||
fractions: PropTypes.bool, | ||
}; | ||
|
||
FormatPrice.defaultProps = { | ||
className: '', | ||
className: null, | ||
fractions: true, | ||
}; | ||
|
||
export default FormatPrice; | ||
export default memo(FormatPrice); |
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
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.