Closed hobbes7878 closed 2 years ago
Should say, too, there are dozens of examples of libraries that do this on npm, but I still think let's roll our own.
Still, useful to look at some of em for reference for what ours should do, e.g.: https://www.npmjs.com/package/boolean
Will work on this on a new branch
Made the fix, see PR here: https://github.com/reuters-graphics/bluprint_graphics-kit/pull/63
@hobbes7878 let me know if you want to set up the logic for the string to Boolean conversion differently
PR merged. Page.svelte now uses truthyString()
to convert string into boolean.
@man-shar raises in https://github.com/reuters-graphics/graphics-svelte-components/issues/35 that we're not setting
stackBackground
in a way that it can ever be set to false here, b/c we need to convert the string to a boolean for that prop to work (as a string, it's always true)We do this a lot, and so I think it makes sense to create a simple utils function that handles turning string representations of booleans back into proper JS ones. So something like:
The function can then be case insensitive, tolerate white space and deal with several different ways we may mean true or false.
And then we can use that in our component logic in
Page.svelte
like this:@MinamiFunakoshiTR, you want to take a crack at it in this repo?
Fixing this will close https://github.com/reuters-graphics/graphics-svelte-components/issues/35 and https://github.com/reuters-graphics/graphics-svelte-components/pull/34.