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

Issue #16243: Fixed margin-left of #bodyColumn #16251

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Zopsss
Copy link
Member

@Zopsss Zopsss commented Jan 28, 2025

Comment on lines -164 to -174
#bodyColumn {
margin-left: 286px;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

we dont need this anymore as we're calculating margin-left in JS

@Zopsss
Copy link
Member Author

Zopsss commented Jan 28, 2025

github, generate site

@Zopsss
Copy link
Member Author

Zopsss commented Jan 28, 2025

Copy link
Contributor

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Items

@@ -80,6 +80,9 @@ function setBodyColumnMargin() {
if (window.innerWidth < 823 && !document.querySelector("#hamburger")) {
setCollapsableMenuButton();
}

const leftColumnWidth = leftColumn.offsetWidth;
bodyColumn.style.marginLeft = `${leftColumnWidth + 15}px`;
Copy link
Member

Choose a reason for hiding this comment

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

Fixing style layout problems by js is not ok.

Please share details on why it is not possible to be css only fix.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you visit some page where sidebar is small, you won't see the problem, for example: https://checkstyle.org/index.html

But in some pages the sidebar becomes very large, for example: https://checkstyle.org/checks/naming/abbreviationaswordinname.html#AbbreviationAsWordInName

Here you can see that there is no space between sidebar and main content. It is happening because I removed following JS in one of my previous PR as I thought we don't need it but I was wrong: https://github.com/checkstyle/checkstyle/pull/16239/files#diff-74191770f323d7fd9586fae43dcc6310dec524a85cc7fcfaa03e69a2cf089eeaL90-L91

We cannot fix this problem only by using CSS because sidebar's width changes dynamically based on which page we're visiting. In the above example, the AbbreviationAsWordInName name is too long so sidebar's width also becomes too large. We cannot dynamically define sidebar's width with CSS only, for that we require JS.

Currently, we have defined static width of the sidebar in site.css but I have removed it in this PR as mentioned here: https://github.com/checkstyle/checkstyle/pull/16251/files#r1931496896

I have added back the JS I removed in one of my previous PR which calculates the width of the sidebar dynamically and adds spacing between sidebar and main content of the page.

Copy link
Member

Choose a reason for hiding this comment

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

dynamic width is only for mobile mode, as far as I understand.
long text can wrap in width of area it has, having two lines for long name is in menu is ok.

is it possible ?

Copy link
Member Author

Choose a reason for hiding this comment

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

long text can wrap in width of area it has, having two lines for long name is in menu is ok.

wrapping text in menu will confuse users, it will become hard for them to read the Check name. IMO we should not wrap text

Copy link
Member Author

Choose a reason for hiding this comment

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

dynamic width is only for mobile mode, as far as I understand.

the dynamic width of sidebar is not our concern. The problem is placement of main content of the page, it statically gets it margin-left from site.css.

Screenshot 2025-02-03 215332

This was SS of current master branch site, the blue part the of main content and orange part is margin-left of main content of body, you can see the blue part is overlapping sidebar. So if you try to click something on that overlapped area of sidebar, it won't work.

Why? because we gave static margin-left to our main content in site.css, and also there seem to be some placement related issue, Im not able to figure out that placement issue. But it's not good to give static margin from our site.css, instead we should rely on JS for that.

Copy link
Member

Choose a reason for hiding this comment

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

ok, this explains why we should remove strict width #bodyColumn {.
So it(left panel) should take now all horizontal space that it needs, so there should be some way to configure it by CSS.

function setBodyColumnMargin() { should exists only for mobile mode of website, not for big screens.

@SheikhZaeem , may be you know a CSS trick to make it possible?

Copy link
Member Author

@Zopsss Zopsss Feb 18, 2025

Choose a reason for hiding this comment

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

ok, this explains why we should remove strict width

Yes, this will also require to revert the code which made the sidebar to have fixed width.

In normal cases this is possible by only using CSS but we're using maven-site-plugin so site has some predefined structure so making the sidebar to have dynamic width with only using CSS might be very tricky or even impossible... Not sure about this

Copy link
Member

Choose a reason for hiding this comment

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

Dynamic width is only in mobile mode, and there we have wrapping of long names, so no problems with dynamic width.

We have issue for case for desktop rendering , when all is well defined. We can disable hamburger, and it works same, with overlap.

@Zopsss
Copy link
Member Author

Zopsss commented Feb 2, 2025

Github, generate site

Copy link
Contributor

github-actions bot commented Feb 2, 2025

@Zopsss Zopsss force-pushed the 16243-bodyColumn-margin branch from d19ae2b to 66405f1 Compare February 3, 2025 16:00
@romani
Copy link
Member

romani commented Feb 4, 2025

https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/d19ae2b_20250202155204/checks/coding/index.html

Screenshot_20250203-182118

I like this wrapping of text, can we do same in non mobile mode?

@Zopsss
Copy link
Member Author

Zopsss commented Feb 10, 2025

it is possible but it'll make it hard to read long check names so I think we should stick with dynamic width

Screenshot 2025-02-10 164928

@mahfouz72
Copy link
Member

How was it in the old site?

@Zopsss
Copy link
Member Author

Zopsss commented Feb 10, 2025

it wasn't wrapping:

image

@romani
Copy link
Member

romani commented Feb 11, 2025

@mahfouz72 , do you like wrap of long names or how it is now - overlap ?
#16077 (comment)

actually fixed at #16297 (review) please approve if you like it.

This PR is not conflicting to that PR, we can merge both.

@mahfouz72
Copy link
Member

do you like wrap of long names or how it is now - overlap ?

@romani I don't like either of them, Overlapping is bad for UI, and wrapping long names makes them hard to read and inconvenient.
I prefer the approach in this PR. The left column should be wide enough to accommodate the longest name without wrapping, and the margin should be adjusted accordingly. I think this was the case in the old site. We can take others opinion also

@romani
Copy link
Member

romani commented Feb 12, 2025

My concern here is usage of JS for layout, it smells very badly, usually red flag.
Try to keep this PR a bit longer to collect ideas on how to resolve this by css only.

@Zopsss
Copy link
Member Author

Zopsss commented Feb 12, 2025

My concern here is usage of JS for layout, it smells very badly, usually red flag.

JS is not that heavy, it's only of two lines. Currently it is inside setBodyColumnMargin function which is invoked on load and resize events. If you want to optimize we can load this JS only once, when the page loads.

This is a very small JS code so it'll not affect user's experience even if we keep it as it is now.

@romani
Copy link
Member

romani commented Feb 12, 2025

This is a very small xxxx code

All mess in engineering is starting from this phrase :) .

@romani
Copy link
Member

romani commented Feb 17, 2025

GitHub, generate website

Copy link
Contributor

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

Successfully merging this pull request may close these issues.

Inprove website rendering
3 participants