Skip to content

Commit

Permalink
Add colors to sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
github-cyprien committed Jun 12, 2024
1 parent a57d4b0 commit 07cc9c1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
20 changes: 20 additions & 0 deletions nodes/widgets/ui_slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
min: { value: 0, required: true, validate: RED.validators.number() },
max: { value: 10, required: true, validate: RED.validators.number() },
step: { value: 1 },
color: {value: ''},
colorTrack: {value: ''},
colorThumb: {value: ''},
className: { value: '' }
},
inputs: 1,
Expand Down Expand Up @@ -145,6 +148,23 @@
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-min"><i class="fa fa-adjust"></i> Color</label>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); width: 70%">
<div>
<span for="node-input-color">main</span>
<input type="text" id="node-input-color" style="width:60px">
</div>
<div>
<span for="not-input-colorTrack">track</span>
<input type="text" id="node-input-colorTrack" style="width:60px">
</div>
<div>
<span for="not-input-colorThumb">thumb</span>
<input type="text" id="node-input-colorThumb" style="width:60px">
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-outs"><i class="fa fa-sign-out"></i> Output</label>
<select id="node-input-outs" style="width:204px">
Expand Down
9 changes: 9 additions & 0 deletions nodes/widgets/ui_slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ module.exports = function (RED) {
if (typeof (updates.max) !== 'undefined') {
statestore.set(group.getBase(), node, msg, 'max', updates.max)
}
if (typeof (updates.color) !== 'undefined') {
statestore.set(group.getBase(), node, msg, 'color', updates.color)
}

Check failure on line 50 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Trailing spaces not allowed
if (typeof (updates.color-track) !== 'undefined') {

Check failure on line 51 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Operator '-' must be spaced

Check failure on line 51 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

'track' is not defined
statestore.set(group.getBase(), node, msg, 'color-track', updates.color-track)

Check failure on line 52 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Operator '-' must be spaced

Check failure on line 52 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

'track' is not defined
}

Check failure on line 53 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Trailing spaces not allowed
if (typeof (updates.color-thumb) !== 'undefined') {

Check failure on line 54 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Operator '-' must be spaced

Check failure on line 54 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

'thumb' is not defined
statestore.set(group.getBase(), node, msg, 'color-thumb', updates.color-thumb)

Check failure on line 55 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Operator '-' must be spaced

Check failure on line 55 in nodes/widgets/ui_slider.js

View workflow job for this annotation

GitHub Actions / build / build (16.x)

'thumb' is not defined
}
}
return msg
}
Expand Down
15 changes: 14 additions & 1 deletion ui/src/widgets/ui-slider/UISlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:class="className" :thumb-label="thumbLabel"
:min="min"
:max="max" :step="props.step || 1" @update:model-value="onChange" @end="onBlur"
:color="color" :track-color="colorTrack" :thumb-color="colorThumb"

Check warning on line 9 in ui/src/widgets/ui-slider/UISlider.vue

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Attribute ":color" should go before "@EnD"

Check warning on line 9 in ui/src/widgets/ui-slider/UISlider.vue

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Attribute ":track-color" should go before "@EnD"

Check warning on line 9 in ui/src/widgets/ui-slider/UISlider.vue

View workflow job for this annotation

GitHub Actions / build / build (16.x)

Attribute ":thumb-color" should go before "@EnD"
/>
</template>

Expand All @@ -28,7 +29,10 @@ export default {
label: null,
thumbLabel: null,
min: null,
max: null
max: null,
color: null,
colorTrack: null,
colorThumb: null
}
}
},
Expand All @@ -51,6 +55,15 @@ export default {
},
max: function () {
return this.dynamic.max !== null ? this.dynamic.max : this.props.max
},
color: function () {
return this.dynamic.color !== null ? this.dynamic.color : this.props.color
},
colorTrack: function () {
return this.dynamic.colorTrack !== null ? this.dynamic.colorTrack : this.props.colorTrack
},
colorThumb: function () {
return this.dynamic.colorThumb !== null ? this.dynamic.colorThumb : this.props.colorThumb
}
},
watch: {
Expand Down

0 comments on commit 07cc9c1

Please sign in to comment.