Browse Source

Merge pull request #278 from henninghall/fix-fadeToColor--none

fix: fadeToColor "none" throws exception
master
Henning Hall 4 years ago
committed by GitHub
parent
commit
257986e801
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions
  1. +4
    -1
      examples/detox/src/examples/Advanced.js
  2. +4
    -1
      examples/detox/src/propPickers/FadeToColor.js
  3. +1
    -0
      src/colorToHex.js

+ 4
- 1
examples/detox/src/examples/Advanced.js View File

@ -173,7 +173,10 @@ export default class Advanced extends Component {
{ {
name: 'fadeToColor', name: 'fadeToColor',
component: ( component: (
<FadeToColor onChange={() => this.props.setBackground(randomColor())} />
<FadeToColor
onChange={() => this.props.setBackground(randomColor())}
setNone={() => this.props.setBackground("none")}
/>
), ),
}, },
{ {

+ 4
- 1
examples/detox/src/propPickers/FadeToColor.js View File

@ -3,6 +3,9 @@ import { Button } from 'react-native'
export default class extends Component { export default class extends Component {
render() { render() {
return <Button title={'Change color'} onPress={this.props.onChange} />
return <>
<Button title={'Change color'} onPress={this.props.onChange} />
<Button title={'Set "none"'} onPress={this.props.setNone} />
</>
} }
} }

+ 1
- 0
src/colorToHex.js View File

@ -1,5 +1,6 @@
export function colorToHex(c) { export function colorToHex(c) {
if (c === undefined) return c if (c === undefined) return c
if (c === "none") return c
if (c.includes('rgb')) return rgb2hex(c) if (c.includes('rgb')) return rgb2hex(c)
if (c.includes('#')) { if (c.includes('#')) {
if (!isValidHex(c)) throw Error('Invalid color: ' + c) if (!isValidHex(c)) throw Error('Invalid color: ' + c)

Loading…
Cancel
Save