Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

feat(SLIDER): add vertical slider option and improve design #672

Merged
merged 17 commits into from
Apr 20, 2021

Conversation

timota
Copy link
Contributor

@timota timota commented Mar 22, 2021

Add Vertical Slider tile.

Tile doesn't require any input from user, width and height will be calculated automatically based on Tile size.
Best to use with tile height > 1.
Also, some other options are available for user: sliderHeight and sliderWidth. If they are defined inside slider - they will be used in first place and take precedence via automated calculation.
Also, Tile supports icon. If icon doesn't defined it will be taken to consideration in case of automatic calculation.

Example:

{
    position: [0, 0],
    height: 3,
    id: 'light.entity',
    type: TYPES.SLIDER_VERTICAL,
    unit: '%',
    title: 'Slider',
    icon: 'mdi-lightbulb',
    state: false,
    filter: function (value) {
       var num = parseFloat(value) / 2.55 ;
       return num && !isNaN(num) ? num.toFixed() : 0;
    },
    value: '@attributes.brightness',
    slider: {
       max: 255,
       min: 0,
       step: 5,
       field: 'brightness',
       // sliderWidth: '60',
       // sliderHeight: '270',
       request: {
          type: "call_service",
          domain: "light",
          service: "turn_on",
          field: "brightness"
       },
    },
}

Screenshot 2021-03-22 at 01 36 06

@timota timota mentioned this pull request Mar 22, 2021
@rchl
Copy link
Collaborator

rchl commented Mar 22, 2021

Will also need to be added to TILES.md (example) and README.md (at least the new type)

scripts/controllers/main.js Outdated Show resolved Hide resolved
styles/main.less Outdated Show resolved Hide resolved
scripts/controllers/main.js Outdated Show resolved Hide resolved
scripts/controllers/main.js Outdated Show resolved Hide resolved
scripts/controllers/main.js Outdated Show resolved Hide resolved
scripts/directives/tile.html Outdated Show resolved Hide resolved
styles/main.less Outdated Show resolved Hide resolved
Comment on lines 459 to 499
@sliderValueColor: #555;
@sliderTrackBg: #555;
@sliderColor: #aaa;
@sliderThumbColor: #777;

.slidervertical-inner {
&-value {
color: @sliderValueColor;
font-weight: 400;
}
}

.range-holder input[type="range"] {

&::-webkit-slider-runnable-track {
background-color: @sliderTrackBg;
}

&::-moz-range-track {
background-color: @sliderTrackBg;
}

&::-webkit-slider-thumb{
background: @sliderColor;
border-bottom:20px solid @sliderColor;
border-left:10px solid @sliderColor;
border-right:10px solid @sliderColor;
border-top:20px solid @sliderColor;
box-shadow: -350px 0 0 350px @sliderColor, inset 0 0 0 80px @sliderThumbColor;
}

&::-moz-range-thumb{
background: @sliderColor;
border-bottom:20px solid @sliderColor;
border-left: 12px solid @sliderColor;
border-right: 12px solid @sliderColor;
border-top:20px solid @sliderColor;
box-shadow: -350px 0 0 350px @sliderColor, inset 0 0 0 80px @sliderThumbColor;
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would hope there is some more generic way to do that that works in all themes because this is not very scalable.

I would expect to use some theme-specific color variables without repeating all those selectors in each theme.

Also, have you tested that it looks decent in every theme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would hope there is some more generic way to do that that works in all themes because this is not very scalable.
I would expect to use some theme-specific color variables without repeating all those selectors in each theme.

This can be changed to use parameterised mixins.

#lib-range-holder-input() {
  .range-holder-input() {
    generic_attr: attr;
    
    &::-webkit-slider-runnable-track {
      color: @Value1; 
    }
    &::-moz-range-track {
      color: @Value2;
    }
  }
}

@Value1: green;
@Value2: red;

.range-holder input[type="range"] {
    #lib-range-holder-input.range-holder-input();
}

.-theme-homekit {
  
  @Value1: black;
  @Value2: white;
  
  .range-holder input[type="range"] {
    extend_attr: extend;
    #lib-range-holder-input.range-holder-input();
    
    &::-moz-range-track {
      extend_this: this;
    }
  }
}

Result:

.range-holder input[type="range"] {
  generic_attr: attr;
}
.range-holder input[type="range"]::-webkit-slider-runnable-track {
  color: green;
}
.range-holder input[type="range"]::-moz-range-track {
  color: red;
}
.-theme-homekit .range-holder input[type="range"] {
  extend_attr: extend;
  generic_attr: attr;
}
.-theme-homekit .range-holder input[type="range"]::-webkit-slider-runnable-track {
  color: black;
}
.-theme-homekit .range-holder input[type="range"]::-moz-range-track {
  color: white;
}
.-theme-homekit .range-holder input[type="range"]::-moz-range-track {
  extend_this: this;
}

In this case you can get rid of all those selectors and manage all with variables, but potentially raw css will grow in size as all basic attrs can be populated inside themes selectors. Have to be careful with this.

Another way use parameterised mixins as functions;

#lib-range-holder-input() {
  .range-input(@Val1, @Val2) {
    color: @Val1;
    background: @Val2;
  }
}

@Val1: green;
@Val2: red;

.range-holder input[type="range"] {
  &::-webkit-slider-runnable-track {
    #lib-range-holder-input.range-input(@Val1, @Val2);
  } 
}

.-theme-homekit {
  
  @Value1: black;
  @Value2: white;
  
  .range-holder input[type="range"] {
    &::-webkit-slider-runnable-track {
      #lib-range-holder-input.range-input(@Value1, @Value2);
    }
  }
}

result:

.range-holder input[type="range"]::-webkit-slider-runnable-track {
  color: green;
  background: red;
}
.-theme-homekit .range-holder input[type="range"]::-webkit-slider-runnable-track {
  color: black;
  background: white;
}

In this case we have to define selectors inside themes as well, but code looks more clear/readable as for me.

So please choose which you prefer.

styles/main.less Outdated Show resolved Hide resolved
scripts/controllers/main.js Outdated Show resolved Hide resolved
@alphasixtyfive
Copy link
Contributor

I'm sorry to interrupt you guys, but here are my two thoughts:

  1. This should probably be called VERTICAL_SLIDER rather than SLIDER_VERTICAL
  2. I would think that default theme should not have rounded corners of the slider to better match the overall boxy style yet Homekit theme would be great with it.

@timota timota requested a review from rchl March 25, 2021 00:44
@timota
Copy link
Contributor Author

timota commented Mar 25, 2021

@alphasixtyfive

  1. to be honest i like VERTICAL_SLIDER more than SLIDER_VERTICAL. I named it slider_vertical as this points to the same tile family - slider. If all parties are ok to rename - im ok with this.

default theme should not have rounded corners

for me it looks so cubic. at least, probably radius:2px ?

Copy link
Collaborator

@rchl rchl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually come to the realization that I'd like this functionality to be merged into SLIDER. It could just have a flag to switch to vertical mode. Otherwise, everything becomes inconsistent as SLIDER has a generic name but can only be horizontal, and also the styles for both of those are completely different. I think the styles for SLIDER don't really work that well for Tileboard as the slider is very small so it would make sense to consolidate that.

I can help with doing that work.

TILE_EXAMPLES.md Outdated Show resolved Hide resolved
scripts/controllers/main.js Outdated Show resolved Hide resolved
@timota
Copy link
Contributor Author

timota commented Apr 8, 2021

Sorry for a long delay in work, was busy with family/work issues.

So, This commit contains Vertical and Horizontal sliders.
Vertical behaves same way as it was before (you can manage width/height on your own or leave it for auto-calculation)

New options:

  vertical: true,
  alignRow: false, - ignored when vertical is tru

alignRow, - ignored when vertical is true. it doesn't make sense

For Horizontal i have added new option to make Tile look column or 'row' aligned:

  • Column looks in similar to old(legacy) one, with some re-arrangements (icon added) and slider positioned horizontally.
  • Row on other side, re arrange items inside Tile to look in-line started with icon, slider and value. (more on screenshots)

To make it testing easier, below you can find Tiles examples.

                  {
                     position: [0, 0],
                     width: 2, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (vertical 1)',
                     vertical: true,
                     alignRow: false,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 50,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [2, 0],
                     width: 2, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (vertical 2)',
                     vertical: true,
                     alignRow: true,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 30,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [2, 1],
                     width: 1, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (vertical 2)',
                     vertical: true,
                     alignRow: true,
                     unit: '%',
                     icon: '',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 30,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [4, 0],
                     width: 1, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (vertical 3)',
                     vertical: true,
                     // alignRow: true,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [5, 0],
                     width: 0.5, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (vertical 4)',
                     vertical: true,
                     alignRow: true,
                     state: '',
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [0, 2],
                     width: 2, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/col)',
                     vertical: false,
                     alignRow: false,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [2, 2],
                     width: 2, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/col)',
                     vertical: false,
                     alignRow: false,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [2, 3],
                     width: 1, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/col)',
                     vertical: false,
                     alignRow: false,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [4, 2],
                     width: 1, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/col)',
                     vertical: false,
                     alignRow: false,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [5, 2],
                     width: 0.5, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/col)',
                     vertical: false,
                     alignRow: false,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [6, 0],
                     width: 2, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/row)',
                     vertical: false,
                     alignRow: true,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [8, 0],
                     width: 2, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/row)',
                     vertical: false,
                     alignRow: true,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [8, 1],
                     width: 1, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/row)',
                     vertical: false,
                     alignRow: true,
                     unit: '%',
                     icon: '',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [6, 2],
                     width: 1, height: 2,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/row)',
                     vertical: false,
                     alignRow: true,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [7, 2],
                     width: 3, height: 1,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/row)',
                     vertical: false,
                     alignRow: true,
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },
                  {
                     position: [7, 3],
                     width: 3, height: 0.5,
                     type: TYPES.SLIDER,
                     title: 'SLIDER (horiz/row)',
                     vertical: false,
                     alignRow: true,
                     state: '',
                     unit: '%',
                     icon: 'mdi-lightbulb',
                     id: 'light.f1_r2_light_tv_wall',
                     value: '@attributes.brightness',
                     slider: {
                        max: 255,
                        min: 0,
                        step: 5,
                        field: 'brightness',
                        // sliderHeight: 120,
                        // sliderWidth: 80,
                        request: {
                           type: "call_service",
                           domain: "light",
                           service: "turn_on",
                           field: "brightness"
                        },
                     }
                  },

If you will have questions - please let me know.

image

@timota timota requested a review from rchl April 8, 2021 19:50
@alphasixtyfive
Copy link
Contributor

Thanks for great work but I really think that the default theme should stay without rounded corners to keep the style consistent.

@timota
Copy link
Contributor Author

timota commented Apr 8, 2021

Thanks for great work but I really think that the default theme should stay without rounded corners to keep the style consistent.

default theme has only radius 2px just to smooth edges. On screenshot homekit theme.

Below screenshot of default theme. Please check it
Screenshot 2021-04-08 at 22 12 53

@rchl
Copy link
Collaborator

rchl commented Apr 9, 2021

It will take me a while to review this properly so please be patient. :)

Just was quickly checking for now and noticed that it doesn't work that well with smaller tiles (tileSize 80):

Screenshot 2021-04-09 at 22 55 48

@rchl
Copy link
Collaborator

rchl commented Apr 9, 2021

Actually bigger tile size doesn't really help. It appears it's more about the colors of the input. I think you need to override more of its styles since it's probably picking OS styles (macOS/chrome here).

Screenshot 2021-04-09 at 22 59 59

@rchl
Copy link
Collaborator

rchl commented Apr 9, 2021

Is the alignRow option really needed? It looks rather cramped in the row configuration. And there is a lot of unused space in the tile. What would be the use case for that?

EDIT: But maybe the "cramped" issue is just a matter of adding some more padding. I guess it could be useful for creating tiles that take little space vertically...

@rchl
Copy link
Collaborator

rchl commented Apr 9, 2021

Quick update. Looks saner when the slider is not at max value but still not good enough. Not enough contrast to be able to tell where the slider control is.

Screenshot 2021-04-09 at 23 09 15

@timota
Copy link
Contributor Author

timota commented Apr 9, 2021

It will take me a while to review this properly so please be patient. :)

Just was quickly checking for now and noticed that it doesn't work that well with smaller tiles (tileSize 80):

Screenshot 2021-04-09 at 22 55 48

i will take a look what i can do

@timota
Copy link
Contributor Author

timota commented Apr 9, 2021

Actually bigger tile size doesn't really help. It appears it's more about the colors of the input. I think you need to override more of its styles since it's probably picking OS styles (macOS/chrome here).

Screenshot 2021-04-09 at 22 59 59

Thats really strange. i'm using mac/catalina/chrome and dont have access to WinOS at all. If you can help me to identify colours for that it will be great.

@timota
Copy link
Contributor Author

timota commented Apr 9, 2021

Quick update. Looks saner when the slider is not at max value but still not good enough. Not enough contrast to be able to tell where the slider control is.

Screenshot 2021-04-09 at 23 09 15

same as previous comment - for me colours look nice. I can make them a bit darker to look better. I will try android tablet to and hope i can find golden middle.

@rchl
Copy link
Collaborator

rchl commented Apr 9, 2021

Thats really strange. i'm using mac/catalina/chrome and dont have access to WinOS at all. If you can help me to identify colours for that it will be great.

I'm on macOS also, not Windows. I'm on Big Sur though, which can make a difference.

@timota
Copy link
Contributor Author

timota commented Apr 9, 2021

Is the alignRow option really needed? It looks rather cramped in the row configuration. And there is a lot of unused space in the tile. What would be the use case for that?

EDIT: But maybe the "cramped" issue is just a matter of adding some more padding. I guess it could be useful for creating tiles that take little space vertically...

I can be wrong but as for me slider horizontal/AlignRow as it should looks like.

scripts/globals/constants.js Outdated Show resolved Hide resolved
@timota
Copy link
Contributor Author

timota commented Apr 9, 2021

Thats really strange. i'm using mac/catalina/chrome and dont have access to WinOS at all. If you can help me to identify colours for that it will be great.

I'm on macOS also, not Windows. I'm on Big Sur though, which can make a difference.

can you be so kind and pickup colours that work well on Big Sur ? i can compare them with colours on Catalina and Android.
Thanks

Copy link
Collaborator

@rchl rchl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you be so kind and pickup colours that work well on Big Sur ? i can compare them with colours on Catalina and Android.
Thanks

Actually, I see now what's happening. Your entity is in "off" state so its background is a bit transparent, making the slider stand out. Turn that entity on and you will see the same as me.

styles/main.less Outdated Show resolved Hide resolved
@rchl
Copy link
Collaborator

rchl commented Apr 9, 2021

I haven't checked all themes but it seems to look decent with border: 1px solid #808080;

Screenshot 2021-04-09 at 23 55 35

Copy link
Contributor Author

@timota timota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are done

scripts/globals/constants.js Outdated Show resolved Hide resolved
styles/main.less Outdated Show resolved Hide resolved
@timota
Copy link
Contributor Author

timota commented Apr 14, 2021

So... in the latest commit i have rearrange styles a bit to fit into lowest possible(without modification) tileSize: 90px.
If tileSize < 90 - some inputs from user are required:

  • icon has to be removed to fit it nicely
  • state can be disabled as for me it doesnt make any sense as we have value

Below you can find screenshots:

tileSize: 90px
Screenshot 2021-04-14 at 13 02 56

tileSize: 80px default view. Some tiles are marked FIXME
Screenshot 2021-04-14 at 13 05 14

tileSize: 80px user modified (removed: icon, state)
Screenshot 2021-04-14 at 13 08 23

Hopefully all these make sense.

@timota timota requested a review from rchl April 14, 2021 12:10
@timota
Copy link
Contributor Author

timota commented Apr 19, 2021

@rchl sorry for bothering, but did you have a chance to review this PR ?

@rchl
Copy link
Collaborator

rchl commented Apr 19, 2021

Didn't have much time. Will try in the evening.

@rchl
Copy link
Collaborator

rchl commented Apr 19, 2021

I'll be fixing those as I comment as I don't want to prolong this but just mentioning here so you are up to date.

In the default theme, the value text color should be white (to match existing tiles and make the contrast better):

Screenshot 2021-04-19 at 21 09 06

TILE_EXAMPLES.md Outdated
Comment on lines 509 to 541
![SLIDER](images/tile-screenshots/SLIDER_VERTICAL.png)
```js
{
position: [6, 1],
id: 'input_number.casatunes_volume_6',
type: TYPES.SLIDER,
unit: '%',
state: false,
//bottom: true, // puts slider on bottom
slider: {
//max: 100,
//min: 0,
//step: 2,
request: {
type: "call_service",
domain: "input_number",
service: "set_value",
field: "value"
}
}
position: [0, 0],
height: 2, // Best works with height > 1. In case height=1, better use custom sliderHeight to achieve your needs
id: 'light.entity',
type: TYPES.SLIDER_VERTICAL,
unit: '%',
title: 'Slider',
icon: 'mdi-lightbulb', // Can be defined or omited. Slider height will be calculated automatically
// legacy: true, // old-style slider that only works in horizontal mode (defaults to `false`)
// bottom: true, // puts slider on the bottom (defaults to `true`)
// vertical: true, // show vertical slider (defaults to `false` - horizontal)
state: false,
filter: function (value) {
var num = parseFloat(value) / 2.55;
return num && !isNaN(num) ? num.toFixed() : 0;
},
value: '@attributes.brightness',
slider: {
max: 255,
min: 0,
step: 5,
field: 'brightness',
// sliderWidth: '60', // Custom slider width
// sliderHeight: '270', // Custom slider height
request: {
type: "call_service",
domain: "light",
service: "turn_on",
field: "brightness"
},
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot needs to be made up to date here. Also update screenshot to use the default theme, for consistency.

Comment on lines 340 to 341
<span ng-bind="getSliderValue(item, entity, _c)"></span>
<span ng-if="(_unit = entityUnit(item, entity))" ng-bind="_unit"></span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing classes need to be reused (with some overrides) instead of creating a completely new one as that is a recipe for creating inconsistencies with existing themes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually didn't change much here as things are a bit messy currently.

@rchl
Copy link
Collaborator

rchl commented Apr 19, 2021

OK, I did some updates that I wanted. Feel free to try it out and check if I did break something, before merging.

Copy link
Contributor Author

@timota timota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except one comment regarding custom slider height - all looks good

Comment on lines 454 to 456
if (sliderWidth <= 0 || sliderHeight <= 22) {
styles.display = 'none';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not agree with this, as this can affect user entered values (sliderHeight). What if user has his own styles applied, and his tile can accommodate height lower than 22. I know that it too small to be useable but...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that if the input is not visible then it should not have a layout since then it would be focusable. That said, focusing stuff with the keyboard is probably not something very relevant in TileBoard so it's more a theoretical issue. But OK, will revert that.

@timota timota requested a review from rchl April 20, 2021 09:37
Copy link
Contributor Author

@timota timota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@timota
Copy link
Contributor Author

timota commented Apr 20, 2021

Thanks for all your help and effort. all looks good. If you are happy - can you merge it please.

@rchl rchl changed the title Add Vertical Slider feat(SLIDER): add vertical slider option and improve design Apr 20, 2021
@rchl rchl merged commit e713089 into resoai:master Apr 20, 2021
@rchl
Copy link
Collaborator

rchl commented Apr 20, 2021

Thanks for your work on this!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants