04-19-2018 05:14
04-19-2018 05:14
Hello, i want to hide "code" if "viewColoeSelect" is false or undifine. But i have no idea how. Can everyone help me? Thank you.
function mySettings(props) {
return (
<Page>
<Section
title={<Text bold>Color</Text>}>
<Text>
To change accent color, tap at hour on the watch face.
</Text>
<Toggle
settingsKey="viewColorSelect"
label="Color select on watch"
/>
<ColorSelect
settingsKey="color"
colors={[
{color: '#E4FA3C'},
{color: '#FFCC33'},
{color: '#FC6B3A'}
]}
/>
</Section>
</Page>
);
}
registerSettingsPage(mySettings);
Best Answer04-19-2018 11:40
04-19-2018 11:40
My amature move would be to simply define the color as a default in the CSS.
fill: red;
Best Answer04-19-2018 13:41
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
04-19-2018 13:41
There's a tiny example of how to do this in the 'Toggle' section here.
Best Answer04-19-2018 23:44 - edited 04-19-2018 23:46
04-19-2018 23:44 - edited 04-19-2018 23:46
Hi Catplace thank you, of course I know the site but have problems with the syntax:
<ColorSelect
settingsKey="color"
disabled={!(this.props.mySettings.viewColorSelect === "true")}
colors={[
{color: '#E4FA3C'},[HOST] [06:39:48] TypeError: Cannot read property 'props' of undefined
[HOST] [06:39:48] Uncaught TypeError: Cannot read property 'props' of undefined
Best Answer04-20-2018 00:05
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
04-20-2018 00:05
There's no such thing as 'this' in that context.
Best Answer04-20-2018 02:41 - edited 04-20-2018 02:58
04-20-2018 02:41 - edited 04-20-2018 02:58
Hello there,
the syntax is:
disabled={!(props.settings.viewColorSelect === "true")}that works for me.
Try adding the following to "prove" that the syntax is, in fact, correct:
<Select
label="Test"
settingsKey="testValue"
options={[
{name:"1", value:"value_1"},
{name:"2", value:"value_2"},
{name:"3", value:"value_3"},
]}
disabled={!(props.settings.viewColorSelect === "true")}
/>Unfortunately, it does not seem to work on ColorSelect. Please refer to Settings API, where you can see the properties of the ColorSelect element. It does not appear to have a "disabled" property.
Maybe use the "onSelection" function instead and cancel the selection if the value is false?
Cheers,
JDT
Best Answer