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

style(ui-markdown-editor): resolve toolbar icon shrinkage - I228 #229

Conversation

K-Kumar-01
Copy link
Contributor

Closes #228

The toolbar icons in markdown shrank too much. Resolved that issue.

Changes

  • Changed the stylings of toolbar icons
  • Used media queries to achieve this.

Flags

  • The separator has a height:50px that may seem a bit large in some small area range.
  • Devices less than 330px will have an overflow of the toolbar.

Screenshots or Video

DeepinScreenshot_20201220144521
DeepinScreenshot_20201220144528
DeepinScreenshot_20201220144537
DeepinScreenshot_20201220144544
DeepinScreenshot_20201220144610

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to master from fork:branchname
  • Manual accessibility test performed
    • Keyboard-only access, including forms
    • Contrast at least WCAG Level A
    • Appropriate labels, alt text, and instructions

…I228

Signed-off-by: K-Kumar01 <kushalkumargupta4@gmail.com>
@jolanglinais
Copy link
Member

We should have addressed this in #228, but any thoughts on how this should ideally be @Michael-Grover? My first thought is having a minimum width for the whole editor, so the icons can not need to resize or anything.

@K-Kumar-01
Copy link
Contributor Author

We should have addressed this in #228, but any thoughts on how this should ideally be @Michael-Grover? My first thought is having a minimum width for the whole editor, so the icons can not need to resize or anything.

@irmerk
The icons will shrink when the window is resized so I don't think this will be a good approach.
I don't have any other idea about how this should be tackled though

@Michael-Grover
Copy link

@irmerk I agree that a minimum width for the editor would make sense. @K-Kumar-01 How about making the minimum the same width as the contract editor component? It looks like that's 670px.

@K-Kumar-01
Copy link
Contributor Author

@irmerk I agree that a minimum width for the editor would make sense. @K-Kumar-01 How about making the minimum the same width as the contract editor component? It looks like that's 670px.

@Michael-Grover
I cannot understand what to do. Can you explain please as I am confused about what to do? 😅

@Michael-Grover
Copy link

@K-Kumar-01 I'm not sure what the best way to do this is from a coding perspective, but what I'm suggesting is that we:

Make this sure this component can't reduce to a width smaller than 670px. When the screen is too narrow to accommodate the 670px width component, the component will overflow off the right side of the screen. For example, if the viewport is 400px width, the component will be 670px width, however if the viewport is 1200px width, the component will grow in size to fit the screen like it currently does. This will ensure the toolbar is never so narrow that the icons shrink.

image

@K-Kumar-01
Copy link
Contributor Author

@K-Kumar-01 I'm not sure what the best way to do this is from a coding perspective, but what I'm suggesting is that we:

Make this sure this component can't reduce to a width smaller than 670px. When the screen is too narrow to accommodate the 670px width component, the component will overflow off the right side of the screen. For example, if the viewport is 400px width, the component will be 670px width, however if the viewport is 1200px width, the component will grow in size to fit the screen like it currently does. This will ensure the toolbar is never so narrow that the icons shrink.

image

@Michael-Grover
Well, thanks for the explanation. I had a few doubts and queries. On mobile screens wouldn't it be uncomfortable? Besides, I think that it may cause some styling problems though I am not sure about it.
I would like to draw attention to one more thing that 670px +210px i.e. a total of 880px or greater would be required for the working when the sidebar is shown.
So I am not fully confident about this approach.
Would like suggestions from @irmerk also on how can we go.

@jolanglinais
Copy link
Member

I don't think we should be concerned with mobile usage. This repository is not geared towards that end. In the future, we can approach mobile functionality.

In the meantime, I think we should set a minimum width for the editor and toolbar and let if overflow if the page width is reduced to less than that. This should remove the issue of icons resizing because nothing can go lower in width than what we specify.

@K-Kumar-01
Copy link
Contributor Author

I don't think we should be concerned with mobile usage. This repository is not geared towards that end. In the future, we can approach mobile functionality.

In the meantime, I think we should set a minimum width for the editor and toolbar and let if overflow if the page width is reduced to less than that. This should remove the issue of icons resizing because nothing can go lower in width than what we specify.

@irmerk @Michael-Grover
I have tried implementing the above.

Attaching screenshots for reference.

DeepinScreenshot_20201222172038
DeepinScreenshot_20201222172105

If it is suitable, I will commit it otherwise make any more changes needed.
I used js for styling as the styles applied were to the body tag and a slate component which I could not figure out to apply.
The styles though will be applied only here using useEffect.

Code

useEffect(()=>{
    const toolbar = document.getElementById("ap-rich-text-editor-toolbar");
    toolbar.parentElement.style.minWidth = "630px";
    document.body.style.overflowX = "auto";
  },[])

Let me know if there are any changes required.

@Michael-Grover
Copy link

Hi @K-Kumar-01 , I opened the Netlify link and I'm somehow still able to reduce the width of the component below the minimum we set. @irmerk are you seeing the same behavior?

image

@jolanglinais
Copy link
Member

@K-Kumar-01 could you add your commits to the PR so we can view the changes?

…I228

Reverted back to original settings
Toolbar and editor given a minimum width

Signed-off-by: K-Kumar01 <kushalkumargupta4@gmail.com>
@K-Kumar-01
Copy link
Contributor Author

@irmerk @Michael-Grover
I have added my latest commits to the PR.
Let me know if there are any changes required.
I apologize for the earlier incident @Michael-Grover. I forgot to push the commits 😅

Copy link

@Michael-Grover Michael-Grover left a comment

Choose a reason for hiding this comment

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

looks good to me, thanks 👍 . @irmerk may want to review as well.

Copy link
Member

@jolanglinais jolanglinais left a comment

Choose a reason for hiding this comment

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

I don't think this is the right approach. I. think the consumer of the ui-markdown-editor component should determine the overflow. In this instance that would be the Storybook. Also, you've already set the min-width on the Menu, so this useEffect isn't necessary.

@K-Kumar-01
Copy link
Contributor Author

@irmerk

I. think the consumer of the ui-markdown-editor component should determine the overflow. In this instance that would be the Storybook.

I am not quite getting what you are trying to say. 😅
Could you please tell me about this?

As for the useEffect part, the minWidth only makes the toolbar to a min-width.
The area that will contain the text (where the slate tag is used) won't be shrinked. So I had to resort to useEffect for that part

@K-Kumar-01
Copy link
Contributor Author

@irmerk

I. think the consumer of the ui-markdown-editor component should determine the overflow. In this instance that would be the Storybook.

I am not quite getting what you are trying to say.
Could you please tell me about this?

As for the useEffect part, the minWidth only makes the toolbar to a min-width.
The area that will contain the text (where the slate tag is used) won't be shrinked. So I had to resort to useEffect for that part

@irmerk
Any updates on this one?

@jolanglinais
Copy link
Member

Yes the ui-markdown-editor is a component, which is used in the Storybook and ui-contract-editor, or any other app that decides to use it. Those components are the ones that should decide the overflow of ui-markdown-editor when they render it.

@K-Kumar-01
Copy link
Contributor Author

Yes the ui-markdown-editor is a component, which is used in the Storybook and ui-contract-editor, or any other app that decides to use it. Those components are the ones that should decide the overflow of ui-markdown-editor when they render it.

@irmerk
So basically the component which is currently active i.e. ui-markdown-editor or ui-contract-editor should be responsible for the
resize?
Am I correct here?

@jolanglinais
Copy link
Member

Yes I believe that is correct.

…I228

Minimum width given to markdown editor
Added global styles to storybook body

Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
@K-Kumar-01
Copy link
Contributor Author

Yes I believe that is correct.

@irmerk @Michael-Grover
I have changed the approach as suggested by @irmerk .
There are global body styles added for the storybook to see overflow and div added only for markdown editor.
Let me know if there are any changes required :)

Copy link

@Michael-Grover Michael-Grover left a comment

Choose a reason for hiding this comment

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

This looks good to me, thanks!

@jolanglinais
Copy link
Member

jolanglinais commented Jan 22, 2021

This still doesn't look like the right approach to me - wrapping the editor in a div with a min-width. I'll look into this more when I have a chance.

Copy link
Member

@jolanglinais jolanglinais left a comment

Choose a reason for hiding this comment

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

Sorry I haven't had much time to look into this more before and haven't been able to give very helpful guidance. I didn't look at this well enough and that resulted in this idea.

But I believe all we really need is to configure min-width: 600px in these two places. We don't need overflow-x: auto or anything else.

packages/ui-markdown-editor/src/index.js Outdated Show resolved Hide resolved
packages/ui-markdown-editor/src/index.js Outdated Show resolved Hide resolved
@K-Kumar-01
Copy link
Contributor Author

Sorry I haven't had much time to look into this more before and haven't been able to give very helpful guidance. I didn't look at this well enough and that resulted in this idea.

But I believe all we really need is to configure min-width: 600px in these two places. We don't need overflow-x: auto or anything else.

@irmerk
If overflow-x:auto is not set then on resizing window below a certain size the content gets cut off in my implementations. I will try to implement the suggested changes but I think that overflow-x:auto would be required. Will confirm and tell you after the implementation.

@jolanglinais
Copy link
Member

Ah, well that should be added in the storybook, not on ui-markdown-editor

Min-width given to toolbar and text editor separately
Removed the enclosing div

Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
@K-Kumar-01
Copy link
Contributor Author

@irmerk and @Michael-Grover
I have made some changes to the PR.
Basically providing min-width to toolbar menu and text editor separately.
Let me know if there are any changes required.

Copy link
Member

@jolanglinais jolanglinais left a comment

Choose a reason for hiding this comment

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

Great, thanks for your patience! Want to get @DianaLease's 👀 on this as well.

@jolanglinais jolanglinais changed the title Resolve Toolbar Icon Excessive Shrinkage - I228 style(ui-markdown-editor): resolve toolbar icon shrinkage - I228 Jan 25, 2021
@jolanglinais jolanglinais merged commit f008d44 into accordproject:master Jan 25, 2021
@K-Kumar-01 K-Kumar-01 deleted the k-kumar-01/i228/toolbar-icon-shrink branch February 1, 2021 06:48
@mttrbrts mttrbrts added the Type: Enhancement ✨ Improvement to process or efficiency label Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Toolbar icons shrink too much
5 participants