Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element lock ratio for size and padding should be stored to data model #1075

Merged
merged 22 commits into from
Apr 15, 2020

Conversation

ndev1991
Copy link
Contributor

@ndev1991 ndev1991 commented Apr 6, 2020

Fixes #1024

Add aspectLockRation to element as true, and padding locked to text element as true. If multiple element selected with different ratio it will be as true.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2020

Size Change: +133 B (0%)

Total Size: 869 kB

Filename Size Change
assets/js/edit-story.js 444 kB +103 B (0%)
assets/js/stories-dashboard.js 419 kB +30 B (0%)
ℹ️ View Unchanged
Filename Size Change
assets/css/edit-story.css 3.04 kB 0 B
assets/css/stories-dashboard.css 3.01 kB 0 B

compressed-size-action

@ndev1991 ndev1991 self-assigned this Apr 6, 2020
@ndev1991
Copy link
Contributor Author

ndev1991 commented Apr 7, 2020

@pbakaus @dvoytenko @miina @barklund When we select the element with same horizontal and vertical padding the initial padding lock is enabled. If we have different horizontal and vertical padding initially then the padding lock will be opened. One thing here is when the padding lock opened and we input the same value on horizontal and vertical then the padding lock enabled.

Would you confirm if we need to keep padding lock open in this case?

@miina
Copy link
Contributor

miina commented Apr 7, 2020

@ndev1991 I'd expect that the padding lock based on the padding value should be the default (e.g. on refresh), however, the user should still be able to unlock/lock the padding as they'd like, without it automatically changing the value.

Meaning that the initial padding lock state value could be set by padding.h === padding.v, however, if the user changes it manually, it shouldn't automatically change back.

Otherwise, the following could happen for example: if the user unlocks the padding, writes 1 to one field and starts typing 10 to the second field, then after typing the initial 1 to the second field, it already gets locked again.

@swissspidy swissspidy added the Type: Bug Something isn't working label Apr 7, 2020
@ndev1991
Copy link
Contributor Author

ndev1991 commented Apr 7, 2020

@ndev1991 I'd expect that the padding lock based on the padding value should be the default (e.g. on refresh), however, the user should still be able to unlock/lock the padding as they'd like, without it automatically changing the value.

Meaning that the initial padding lock state value could be set by padding.h === padding.v, however, if the user changes it manually, it shouldn't automatically change back.

Otherwise, the following could happen for example: if the user unlocks the padding, writes 1 to one field and starts typing 10 to the second field, then after typing the initial 1 to the second field, it already gets locked again.

@miina Actually it doesn't happen in that way. If the user unlocks the padding and the h is 10 and the input v 100 is fine. but if the user input the h as 10 and input 10 for v and click h again, then the padding locks

@miina
Copy link
Contributor

miina commented Apr 7, 2020

@ndev1991 Just tested it out, it does happen this way currently:
padding

When there is 1 in one field and user starts typing 10 in the other field, then due to the first character of 10 being 1, a match is found and the lock put on again.

In any case -- the user's choice should remain and not change back unexpectedly, the paddings being equal is relevant for the default only.

@pbakaus
Copy link
Contributor

pbakaus commented Apr 7, 2020

IMHO the padding lock should never lock itself on user input of values. Just because they temporarily appear to be the same (10, 10) does not mean the user indicated that she wants them locked.

@dvoytenko
Copy link
Contributor

Hmm. Sounds like this was a horrible suggestion by me. But what should be the behavior? Do we want to make the lock persistent in the data model then?

@swissspidy
Copy link
Collaborator

That‘d be a possibility, yes.

@ndev1991
Copy link
Contributor Author

ndev1991 commented Apr 8, 2020

@pbakaus @swissspidy @dvoytenko We need to add padding lock persistent in the data model. Would you confirm?

@ndev1991
Copy link
Contributor Author

ndev1991 commented Apr 8, 2020

@miina @dvoytenko Added paddingLockOpen to element property so we can solve above problems.

@pbakaus
Copy link
Contributor

pbakaus commented Apr 8, 2020

yes, padding lock should be persistent in the data model. Thanks!

@ndev1991 ndev1991 requested a review from barklund April 8, 2020 18:19
Copy link
Contributor

@barklund barklund left a comment

Choose a reason for hiding this comment

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

Would prefer a rename, otherwise looks good.

@ndev1991 ndev1991 requested a review from barklund April 9, 2020 02:45
@miina
Copy link
Contributor

miina commented Apr 9, 2020

@ndev1991 The same should also go for width/height ratio lock then, I assume.

cc @pbakaus

@dvoytenko
Copy link
Contributor

@miina @barklund And aspect ratio added by using the same format and nits!

Did we confirm we need lock for aspect? Last time I asked @samitron7 she didn't want one. /cc @pbakaus as well.

@ndev1991
Copy link
Contributor Author

ndev1991 commented Apr 11, 2020

@dvoytenko @pbakaus @swissspidy Here is the current workflow of padding lock and aspect ratio.
Default element has lock aspect ratio status. Default text has lock padding status.
When there are multiple elements selected with different aspect ratio and padding ratio, assume it as true status and make the same changes for each size and padding calculation.

If we want to go for each element, lock toggle should be disabled status?
And also for sizePosition calculation, orgRatio is based on common values. Do we need to have separate calculation for each elements? /cc @samitron7

@dvoytenko
Copy link
Contributor

@pbakaus @dvoytenko @miina @barklund When we select the element with same horizontal and vertical padding the initial padding lock is enabled. If we have different horizontal and vertical padding initially then the padding lock will be opened. One thing here is when the padding lock opened and we input the same value on horizontal and vertical then the padding lock enabled.

This is a good point. No matter how we approach this, from the data model point of view: it makes no sense to allow "padding lock" if H and V values are different - otherwise we won't be able to change them. And probably we just need to ensure there're no inconsistencies and it would be enough.

@ndev1991 ndev1991 requested review from barklund and dvoytenko April 13, 2020 00:55
@ndev1991
Copy link
Contributor Author

@dvoytenko @barklund Following the second option, it uses the common lock ratio for padding and size. When there are multiple values, assume it as locked and update the lock ratio for element also.

@barklund
Copy link
Contributor

@dvoytenko should this have a migration? If width/height are still proportional to originalWidth/originalHeight, we migrate to locked? And similarly, if paddings are still equal, we migrate to locked? Or should we just assume all old stories now to be unlocked, and it's not really a big issue?

@ndev1991
Copy link
Contributor Author

@dvoytenko should this have a migration? If width/height are still proportional to originalWidth/originalHeight, we migrate to locked? And similarly, if paddings are still equal, we migrate to locked? Or should we just assume all old stories now to be unlocked, and it's not really a big issue?

We can have basic thing on it. Like rawLockRatio === undefined, we can assume to be true?

Copy link
Contributor

@dvoytenko dvoytenko left a comment

Choose a reason for hiding this comment

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

Very close. But some questions. I'll also loop in Paul on this.

@ndev1991 ndev1991 changed the title Element padding lock should be determined based on initial padding Element lock ratio for size and padding should be stored to data model Apr 13, 2020
@ndev1991 ndev1991 requested a review from dvoytenko April 13, 2020 23:54
Copy link
Contributor

@dvoytenko dvoytenko left a comment

Choose a reason for hiding this comment

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

Just one update requested.

@ndev1991 ndev1991 requested a review from dvoytenko April 14, 2020 16:40
Copy link
Contributor

@barklund barklund left a comment

Choose a reason for hiding this comment

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

I just have a few comments about tests, otherwise things look really good. Please think about good simple test descriptions, that don't go into unnecessary technical details and try to use labels or visual texts rather than test ids whenever possible.

@ndev1991 ndev1991 requested a review from barklund April 15, 2020 01:58
@swissspidy swissspidy merged commit 39d1fa4 into master Apr 15, 2020
@swissspidy swissspidy deleted the element-padding-lock branch April 15, 2020 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Element ratio lock and padding lock not persistent
7 participants