Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Zoom/scale setting #1651

Closed
wants to merge 16 commits into from
Closed

Zoom/scale setting #1651

wants to merge 16 commits into from

Conversation

monokh
Copy link

@monokh monokh commented Dec 5, 2017

Work towards an interface scale setting.

Fixes element-hq/element-web#3160

Signed-off-by: Mohammad Nokhbatolfoghahai mnokhb@gmail.com

TODO:

  • Add interface scale setting
  • Add font scale setting
  • Only change setting value on slider drop (can be fixed using onMouseUp)
  • Some branding on the slider (probably input-range-scss )

@monokh monokh changed the title WIP: Zoom/scale setting: Initial WIP: Zoom/scale setting Dec 5, 2017
this.setState({
interfaceScale: newInterfaceScale,
});
PlatformPeg.get().reload();
Copy link
Member

Choose a reason for hiding this comment

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

Changing scale yielding a full reload is really bad UX :(

Copy link
Author

Choose a reason for hiding this comment

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

Yes. Just a copy from language setting to start with. What would you prefer happen? Options:

  1. Note that zoom will apply after a restart of the app
  2. Zoom as the setting is changed - might be buggy because of scaling happening while the user is touching controls
  3. Zoom with a delay?

If 2 is preferable, is there a way in this sdk to watch a state change (scale changing) on the root element? Maybe SettingsManager has a watch function? Or is the only way to bubble up the change through the component tree?

Copy link
Member

@t3chguy t3chguy Dec 7, 2017

Choose a reason for hiding this comment

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

you could use the dispatcher to send a zoom_change event that LoggedInView/MatrixChat listens on and acts on when you save the setting

@monokh monokh changed the title WIP: Zoom/scale setting Zoom/scale setting Dec 8, 2017
@monokh
Copy link
Author

monokh commented Dec 8, 2017

@t3chguy let me know what you think. Not quite sure what to do about translations.

@monokh
Copy link
Author

monokh commented Dec 18, 2017

@t3chguy Any chance you could have another peek at this one? Let me know if it's not required anymore or you'd like to see something different. Thanks 🙂

@t3chguy
Copy link
Member

t3chguy commented Dec 18, 2017

I'll take a look at it tomorrow

}
}

InterfaceScaleSlider.propTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

this can be moved into the body of the class as

static propTypes = {
...
};

this._onValueChange = this._onValueChange.bind(this);
}

componentWillMount() {
Copy link
Member

Choose a reason for hiding this comment

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

no point having an empty willMount

Copy link
Author

Choose a reason for hiding this comment

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

Sorry about the goofs 🙂 updated those now

}

render() {
const interfaceScale = SettingsStore.getValue("interfaceScale", null, /*excludeDefault:*/true);
Copy link
Member

Choose a reason for hiding this comment

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

comment?

@@ -0,0 +1,50 @@
/*
Copyright 2017 Marcel Radzio (MTRNord)
Copyright 2017 Vector Creations Ltd.
Copy link
Member

Choose a reason for hiding this comment

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

^^ this needs fixing

Copy link
Author

Choose a reason for hiding this comment

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

What should this be changed to? This was a copy from another component. Should I be putting it under my own name?

Copy link
Member

Choose a reason for hiding this comment

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

Yup, unless someone else wrote it :P

Copy link
Author

Choose a reason for hiding this comment

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

ok 😄 and also remove Copyright 2017 Vector Creations?

Copy link
Member

Choose a reason for hiding this comment

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

yup :)

Copy link
Author

Choose a reason for hiding this comment

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

done 😃 hope my name is not taking too much space in the repo


export default class InterfaceScaleSlider extends React.Component {
propTypes = {
className: React.PropTypes.string,
Copy link
Member

Choose a reason for hiding this comment

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

plz use import PropTypes from 'prop-types' and then replace React.PropTypes with PropTypes

@t3chguy
Copy link
Member

t3chguy commented Dec 18, 2017

Then you also need to sign-off, described here: https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.rst

@t3chguy
Copy link
Member

t3chguy commented Dec 18, 2017

will test and throw at toml to play with tomorrow :)

@monokh
Copy link
Author

monokh commented Dec 18, 2017

@t3chguy great 😃 . There are various methods for the UI as seen in the screenshots in element-hq/element-web#3160. The slider seemed more flexible but other ones may work as well. Feel free to let me know if you think another method is more appropriate.

@t3chguy
Copy link
Member

t3chguy commented Dec 18, 2017

My personal fav UI for this is
image

@monokh
Copy link
Author

monokh commented Dec 19, 2017

@t3chguy cool. Well it is a slider but it isn't that fancy 😄 I can see tomorrow what could be added to make it a bit more appealing.



export default class InterfaceScaleSlider extends React.Component {
propTypes = {
Copy link
Member

Choose a reason for hiding this comment

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

missing word static

should be static propTypes

@t3chguy
Copy link
Member

t3chguy commented Dec 19, 2017

I showed it to @lampholder - I think he had a few comments about it

@monokh
Copy link
Author

monokh commented Dec 19, 2017

@t3chguy Happy to hear 🙂
I've been trying to make it a bit more "fancy" in the meantime:
image
Although styles that work cross browser consistently for input ranges are tricky.
There is the option of using a sass module: https://github.com/darlanrod/input-range-scss
I imagine though that you have enough dependencies. Maybe you would like to keep the native input range with some minimal styling?

@monokh
Copy link
Author

monokh commented Dec 19, 2017

On possibly using a library for the slider itself, react-rangeslider and rc-slider seem pretty decent. Styles customisable + labels like discord has.

@lampholder
Copy link
Member

My thoughts so far:

At maximum zoom in:
screen shot 2017-12-20 at 11 07 09

  • This is pretty reasonable for users who need font size/UX elements to be as large as possible
  • By being a zoom-based solution, it increases the width of the room list, which is good for users with vision difficulties still having a usable UX

At maximum zoom out:
screen shot 2017-12-20 at 11 06 43

  • This leaves a lot of unnecessary whitespace (because our CSS makes some unhelpful assumptions)
  • Being a zoom-based solution, it decreases the width of the room list, which is perhaps bad for users who want more information (longer room names) visible on the screen

Also, it doesn't seem like the setting is being persisted beyond the user logging out/in.

The challenge is that the optimal UI-scalaing feature needs to meet two use cases, with different objectives.

  1. For some people with vision difficulties, we want to scale up the text and the UI together
  2. For people who want more information density, we want to scale down the text size (but largely leave the UI the same size)

So I can see why Discord adopted the independent chat text scaling slider.

More thoughts to come (but wanted to show that I am actively considering this issue right now 😄 )

@lampholder
Copy link
Member

lampholder commented Dec 20, 2017

Okay, in terms of what needs to be done to deliver the optimal UX/text scaling solution (which is separate to the question of what needs to be done in order to claim the bounty, which I'll consider afterwards), I think we need:

  • an option to scale chat text indepently of the overall browser zoom level
  • css that better handles zoom (specifically not leaving acres of white space on zooming out)
  • both of those settings to persist beyond the current session
  • zoom settings to be applied immediately (it feels very odd that it takes several seconds for the zoom to apply)
  • a prettier slider 😛

@monokh
Copy link
Author

monokh commented Dec 21, 2017

Thanks for the input @lampholder

I'm with you on the need for a separate font size scaling slider.

css that better handles zoom (specifically not leaving acres of white space on zooming out)

👍 agreed, jumped out at me too.

both of those settings to persist beyond the current session

This should be working but might be persisted at the wrong level - I will double check this.

zoom settings to be applied immediately (it feels very odd that it takes several seconds for the zoom to apply)

This is to prevent the zoom control falling out of the users view while they are scrolling it but it can also be solved be applying the zoom after the user has confirmed a selection so will change it to this.

a prettier slider

Styled sliders are a tricky thing cross browser. This would come with the consequence of a new react component dependency and/or substantial new code. Are you happy with this? Any preferences?

I'm happy to continue to contribute to this regardless of what would be in scope for the bounty
🙂

@lampholder
Copy link
Member

Hi @monokh - hope you had a good break/new year :)

Thanks for you ongoing patience with this!

Responding to your points:

I'm with you on the need for a separate font size scaling slider.

Excellent :)

css that better handles zoom (specifically not leaving acres of white space on zooming out)

👍 agreed, jumped out at me too.

I think we should solve this as a totally separate issue (you're more than welcome to resolve it, but I think it's beyond the scope of this original bounty). Actually, it is a totally separate issue; here: element-hq/element-web#4805. There's already some CSS kicking around for this (wrapped up even in a neat userscript/userstyle in the discussion on element-hq/element-web#1371).

both of those settings to persist beyond the current session

This should be working but might be persisted at the wrong level - I will double check this.

This might be me being a crank - it looks like the changes are persisted across different sessions on the same browser, which I think is probably the desired behaviour here (i.e. change made in Chrome on your laptop will be there the next time you access Riot from that browser, but not from Chrome on your desktop/etc.)

zoom settings to be applied immediately (it feels very odd that it takes several seconds for the zoom to apply)

This is to prevent the zoom control falling out of the users view while they are scrolling it but it can also be solved be applying the zoom after the user has confirmed a selection so will change it to this.

Yeah, I think that'll work - playing around with it now I think it would be fine if it just applied the changes as soon as the user 'drops' the slider.

a prettier slider

Styled sliders are a tricky thing cross browser. This would come with the consequence of a new react component dependency and/or substantial new code. Are you happy with this? Any preferences?

Good point - is there simple styling that can be applied cross browser trivially? I'd rather we not drag in significant dependencies/chunks of code if we can avoid it.

@monokh
Copy link
Author

monokh commented Jan 2, 2018

@lampholder Happy new year 😃

Actually, it is a totally separate issue; here: element-hq/element-web#4805.

cool 🙂 well I can attend to it through there then.

playing around with it now I think it would be fine if it just applied the changes as soon as the user 'drops' the slider.

Will see about doing that!

is there simple styling that can be applied cross browser trivially? I'd rather we not drag in significant dependencies/chunks of code if we can avoid it.

I can't really think of a super simple middle ground besides positioning and extending it to full width. Perhaps just using a sass module (or even importing the required rules into the project) is the leanest approach? This sass module is pretty commonly used. While it doesn't have pretty labels, the slider itself can be styled to fit the riot brand pretty easily and it's not a substantial amount of code or a heavy dependency.

@monokh
Copy link
Author

monokh commented Jan 7, 2018

image
Probably also some general style fixes required for the settings panel as it doesn't cope with scaling well.

@monokh
Copy link
Author

monokh commented Jan 7, 2018

@lampholder Sorry about this going slowly, just been chipping away at this when i get some free time.
I believe it should be at a stage where you can have another look. The behaviour is similar to discord. You will also need riot-web changes from this PR: element-hq/element-web#5931 or some things may look out of whack.

There may be some follow up style changes to make sure everything scales well at the different breakpoints but i fixed anything that stood out anyway.

Let me know what you think :)

@monokh
Copy link
Author

monokh commented Jan 16, 2018

@lampholder @t3chguy Any chance you could have another look at this one? Keen to get this finished eventually.

@t3chguy
Copy link
Member

t3chguy commented Jan 16, 2018

I'll pester him about it 2PM Thursday

@t3chguy
Copy link
Member

t3chguy commented Jan 18, 2018

Its looking better :D
some things aren't font scaling properly
image

@monokh
Copy link
Author

monokh commented Jan 18, 2018

@t3chguy Yep. As i mentioned before, there may be some elements that don't scale correctly but they are easily fixable. When you are happy with the general state of the feature, I can do a more thorough correction on the styles in element-hq/element-web#5931 to make sure everything scales correctly.

@t3chguy
Copy link
Member

t3chguy commented Jan 18, 2018

I built it for toml to have a play with: https://riot.ovh/builds/tomltomltoml/

@monokh
Copy link
Author

monokh commented Jan 31, 2018

Any chance for another look at this? Seems we are pretty close 🙂

@monokh
Copy link
Author

monokh commented Feb 28, 2018

Hi @lampholder @t3chguy

Checking back on this one. Are you happy with the general implementation as demonstrated on the demo link? I'm looking forward to pushing this over the line.

@aaronraimist
Copy link
Contributor

@t3chguy can you look at this again now that you are back?

@rubo77
Copy link
Contributor

rubo77 commented Nov 10, 2018

I tried https://riot.ovh/builds/tomltomltoml/ there are two zoom settings, but only the one for font-size seems to wirk, the other has no effect (tested on firefox 63.0 (64-Bit), Ubuntu 18.04)

@jryans
Copy link
Collaborator

jryans commented Jul 31, 2019

Thanks for making this contribution a while back. Since the code base has changed since this was opened, it no longer applies cleanly, and I don't think there's a need to keep it open in this state, as we can always find the code here again if needed. If you are still interested in pursuing this feature, please discuss with us in #riot-dev:matrix.org to find a good approach forward.

@jryans jryans closed this Jul 31, 2019
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.

make it possible to change font size
6 participants