diff --git a/CHANGELOG.md b/CHANGELOG.md index 3febea69..f5372a21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +### Fixed +- `Switch` - not passing correct value. ## v6.0.6 - 2021-10-08 diff --git a/packages/icon/src/Icon.js b/packages/icon/src/Icon.js index c2b4edba..ac9af663 100644 --- a/packages/icon/src/Icon.js +++ b/packages/icon/src/Icon.js @@ -23,20 +23,22 @@ const Icon = ({ name, style, className, ariaLabel, onClick, src, qa }: Props) => /** * Inject SVG icons from core branding into page */ - const fetchAntwerpIcons = async function() { + const fetchAntwerpIcons = function() { if (!fetch) return; + try { const xlinkHref = 'https://cdn.antwerpen.be/core_branding_scss/5.0.0/assets/images/ai.svg'; - const response = await fetch(xlinkHref); - const svgText = await response.text(); - - const svgWrapper = document.createElement('svg'); - - svgWrapper.id = 'aiSvg'; - svgWrapper.innerHTML = svgText; - if(!document.getElementById('aiSvg')) { - document.body.appendChild(svgWrapper); - } + const response = fetch(xlinkHref) + .then((response) => response.text()) + .then((svgText) => { + const svgWrapper = document.createElement('svg'); + + svgWrapper.id = 'aiSvg'; + svgWrapper.innerHTML = svgText; + if(!document.getElementById('aiSvg')) { + document.body.appendChild(svgWrapper); + } + }); } catch(err) { throw new Error(err); } diff --git a/packages/switch/Readme.md b/packages/switch/Readme.md index 63545842..b0c18a46 100644 --- a/packages/switch/Readme.md +++ b/packages/switch/Readme.md @@ -1,3 +1,6 @@ +- `onClick` will pass the element that was clicked +- `onChecked` will pass `true` of `false` based on if the checkbox is checked + ``` console.log('select value is:', value)} /> + onClick={(value) => console.log('select value is:', value)} + onChecked={(value) => console.log('checked value is:', value)} /> ``` diff --git a/packages/switch/src/Switch.jsx b/packages/switch/src/Switch.jsx index 92bf5164..b757f34f 100644 --- a/packages/switch/src/Switch.jsx +++ b/packages/switch/src/Switch.jsx @@ -8,6 +8,7 @@ interface IProps { labelTrue: string; labelFalse: string; onClick?: (event) => void; + onChecked?: (checked) => void; disabled?: boolean; ariaLabel?: string; qa?: string; @@ -34,6 +35,10 @@ class Switch extends Component { if (this.props.onClick && (typeof this.props.onClick === 'function')) { this.props.onClick(e); } + + if (this.props.onChecked && (typeof this.props.onChecked === 'function')) { + this.props.onChecked(!this.state.checked); + } } render() {