Skip to content

Commit

Permalink
oh-colorpicker: Replace defaultColor option with an actual default co…
Browse files Browse the repository at this point in the history
…lor (#2270)

Remove the defaultColor option.
Instead use RGB(0,0,0) black as default color if the Item state holds no
valid color, so that the color picker is accessible.

---------

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Jan 14, 2024
1 parent 4d4aea4 commit f912de5
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 30 deletions.
5 changes: 0 additions & 5 deletions bundles/org.openhab.ui/doc/components/oh-colorpicker-card.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ Display a color picker in a card
<PropOption value="initial-current-colors" label="Initial current colors" />
</PropOptions>
</PropBlock>
<PropBlock type="TEXT" name="defaultColor" label="Default Color">
<PropDescription>
Color (e.g. <code>[0,0,0]</code> for black) to use for the color picker if state does not contain a color (e.g. because it is <code>NULL</code>)
</PropDescription>
</PropBlock>
</PropGroup>
</div>

Expand Down
5 changes: 0 additions & 5 deletions bundles/org.openhab.ui/doc/components/oh-colorpicker-cell.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ A cell expanding to a color picker
<PropOption value="initial-current-colors" label="Initial current colors" />
</PropOptions>
</PropBlock>
<PropBlock type="TEXT" name="defaultColor" label="Default Color">
<PropDescription>
Color (e.g. <code>[0,0,0]</code> for black) to use for the color picker if state does not contain a color (e.g. because it is <code>NULL</code>)
</PropDescription>
</PropBlock>
</PropGroup>
</div>

Expand Down
5 changes: 0 additions & 5 deletions bundles/org.openhab.ui/doc/components/oh-colorpicker-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ Display a color picker in a list
<PropOption value="initial-current-colors" label="Initial current colors" />
</PropOptions>
</PropBlock>
<PropBlock type="TEXT" name="defaultColor" label="Default Color">
<PropDescription>
Color (e.g. <code>[0,0,0]</code> for black) to use for the color picker if state does not contain a color (e.g. because it is <code>NULL</code>)
</PropDescription>
</PropBlock>
</PropGroup>
</div>

Expand Down
5 changes: 0 additions & 5 deletions bundles/org.openhab.ui/doc/components/oh-colorpicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ Control to pick a color
<PropOption value="initial-current-colors" label="Initial current colors" />
</PropOptions>
</PropBlock>
<PropBlock type="TEXT" name="defaultColor" label="Default Color">
<PropDescription>
Color (e.g. <code>[0,0,0]</code> for black) to use for the color picker if state does not contain a color (e.g. because it is <code>NULL</code>)
</PropDescription>
</PropBlock>
</PropGroup>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ export default () => [
{ value: 'palette', label: 'Palette' },
{ value: 'current-color', label: 'Current color' },
{ value: 'initial-current-colors', label: 'Initial current colors' }
], true, true),
pt('defaultColor', 'Default Color', 'Color (e.g. <code>[0,0,0]</code> for black) to use for the color picker if state does not contain a color (e.g. because it is <code>NULL</code>)')
], true, true)
]
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ export default {
color[2] = color[2] / 100
return color
}
if (this.config.defaultColor) {
try {
return JSON.parse(this.config.defaultColor)
} catch {
return null
}
}
return null
return [0, 0, 0]
}
},
watch: {
Expand Down

0 comments on commit f912de5

Please sign in to comment.