Skip to content

Fix header image size and red line alignment #16256

Merged
romani merged 1 commit into
checkstyle:masterfrom
SheikhZaeem:fix-header-image
Feb 1, 2025
Merged

Fix header image size and red line alignment #16256
romani merged 1 commit into
checkstyle:masterfrom
SheikhZaeem:fix-header-image

Conversation

@SheikhZaeem

Copy link
Copy Markdown
Contributor

This pull request solves the issue #16243, where the header image was larger than intended and also the red line was not touching the top of the page. The changes include:

Fixing the size of header image.

Adjusting the CSS to ensure the red line aligns properly with the top of the page.

Thank you.

Issue Link:
Fixes: #16243

@Zopsss

Zopsss commented Jan 29, 2025

Copy link
Copy Markdown
Member

github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

Comment thread src/site/resources/css/site.css Outdated
Comment on lines +50 to +58
#bannerRight img {
transform: translateY(-12px);
}

#banner {
border-bottom: 1px solid #fff;
background: url("../images/header-background.png") repeat-x scroll 0 0 transparent;
transform: translateY(-6px);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you're transforming the banner to upwards, it is causing banner to have more empty space below it.

Current banner:
Screenshot 2025-01-29 104558

Banner after your changes:
Screenshot 2025-01-29 104746

We want the red line to stick to the top, the problem is that it is wrapped inside H1 tag which have margin-top & bottom.

Screenshot 2025-01-29 104401

Removing margin-top will fix the problem

@Zopsss

Zopsss commented Jan 29, 2025

Copy link
Copy Markdown
Member

@romani why do we have this red line? and why it is a link? If the red line is only for aesthetics then it doesn't have to be a link

@romani

romani commented Jan 29, 2025

Copy link
Copy Markdown
Member

why do we have this red line?

This is us how kids use to study to write.
https://www.istockphoto.com/vector/vector-opened-school-cursive-worksheet-copybook-gm872316754-243658512

why it is a link?

I surprised, it supposed to be fancy decor. Link can be removed.

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss Thank you very much for the feedback.

@Zopsss

Zopsss commented Jan 29, 2025

Copy link
Copy Markdown
Member

I surprised, it supposed to be fancy decor. Link can be removed.

@SheikhZaeem it would be very helpful if you can remove the <a> from the red line. It will require some JS. If you cannot do it, that's okay but if you want to do it, then you can ask me for help.

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss Yes I want to do it. Thank you

@SheikhZaeem

SheikhZaeem commented Jan 29, 2025

Copy link
Copy Markdown
Contributor Author

@SheikhZaeem it would be very helpful if you can remove the <a> from the red line. It will require some JS. If you cannot do it, that's okay but if you want to do it, then you can ask me for help.

@Zopsss just to confirm, when removing the <a, should I make sure it s never added in the first place (by changing the js to prevent it), or should I remove it if it already exists in the DOM?

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss Hello again. I am facing some problem. I removed "var a = document.createElement("a"), a.setAttribute("href", link) andvanchor.appendChild(a)" from anchors.js folder as I believe the are responsible for generating for the red line image section. However, no changes are seen when I inspect the updated html file in the target folder. Could it be that other js file is adding tag around the image or am I missing something? Thank you in advance.

@Zopsss

Zopsss commented Jan 29, 2025

Copy link
Copy Markdown
Member

@Zopsss just to confirm, when removing the <a, should I make sure it s never added in the first place (by changing the js to prevent it), or should I remove it if it already exists in the DOM?

make sure it is never added in first place

@Zopsss

Zopsss commented Jan 29, 2025

Copy link
Copy Markdown
Member

@Zopsss Hello again. I am facing some problem. I removed "var a = document.createElement("a"), a.setAttribute("href", link) andvanchor.appendChild(a)" from anchors.js folder as I believe the are responsible for generating for the red line image section. However, no changes are seen when I inspect the updated html file in the target folder. Could it be that other js file is adding tag around the image or am I missing something? Thank you in advance.

are you referring to these 2 lines?

var a = document.createElement("a");
a.setAttribute("href", link);

you don't need to remove <a> from all H1 tags, remove it only from red line. These two lines are used to add <a> to all H1 tags.

In the forEach loop check if the current H1 tag is of red line, if yes then do not create <a> tag for it.

How to check if the current H1 tag is of Red Line?

It is under #bannerRight & .pull-right, use JS to identify it.

Screenshot 2025-01-29 225700

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss Since is already present in target/site/anttask.html, which i am assuming means Maven itself is inserting inside #bannerRight before JavaScript runs. So is coming from
Screenshot 2025-01-30 at 11 53 36 AM
Since the href attribute is present, Maven automatically wraps the image in an tag.

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss Also now when red line is pressed, it doesn't do anything. I think makes more sense.

@Zopsss

Zopsss commented Jan 30, 2025

Copy link
Copy Markdown
Member

Github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

@Zopsss

Zopsss commented Jan 30, 2025

Copy link
Copy Markdown
Member

Hmm now the line isnt a link anymore but when hovered over, the anchor image appears next to it

Screenshot 2025-01-30 145225

I think you can fix this by adding some JS here:

var anchors = document.querySelectorAll("h1, h2");
[].forEach.call(anchors, function (anchorItem) {
var name = anchorItem.childNodes[0].textContent.replaceAll(" ", "_");
var link = "" + url + "#" + name + "";

Add some logic like if the h1 tag is child of #bannerRight then skip that element. This will help you: https://www.w3schools.com/jsref/prop_node_parentelement.asp

@Zopsss Zopsss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fixing extra margins and paddings

Comment thread src/site/resources/css/site.css Outdated
h1 {
text-transform: capitalize;
font-size: x-large;
margin: 0px;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

revert this, we want margin-top: 0 only for Red Line's H1 tag. Following CSS should remove margin-top and extra padding-top

#bannerRight h1 {
    margin: 0;
}

.container-fluid-top {
    padding-top: 0 !important;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add this code before following line:

to keep same section's CSS together

Comment thread src/site/resources/css/site.css Outdated
Comment on lines +51 to +58
#bannerRight img {
transform: translateY(-12px);
}

#banner {
border-bottom: 1px solid #fff;
background: url("../images/header-background.png") repeat-x scroll 0 0 transparent;
transform: translateY(-6px);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

revert this, use above mentioned code.

@Zopsss

Zopsss commented Jan 30, 2025

Copy link
Copy Markdown
Member

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss Fixed and reverted the code as you said. But I don't know why I get these errors regarding commit messages.

@Zopsss

Zopsss commented Jan 30, 2025

Copy link
Copy Markdown
Member

Github, generate site

@Zopsss

Zopsss commented Jan 30, 2025

Copy link
Copy Markdown
Member

@Zopsss Fixed and reverted the code as you said. But I don't know why I get these errors regarding commit messages.

Read the commit message carefully, it has mentioned some rules regarding commit message. You seem to have break 1st rule. The commit message should contain this prefix: Issue #YourIssueNumber

Normally you should run mvn clean verify before pushing changes, it'll give you such errors so you can fix them early. But this was website issue so it's okay to not run this command.

@github-actions

Copy link
Copy Markdown
Contributor

@Zopsss

Zopsss commented Jan 30, 2025

Copy link
Copy Markdown
Member

Please squash all commits. Always keep 1 commit per PR.

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

Please squash all commits. Always keep 1 commit per PR.

Can you explain in more detail. Do you mean if i keep changing the code of my pull request again and again, I don't need to write new commit messages?

@Zopsss

Zopsss commented Jan 31, 2025

Copy link
Copy Markdown
Member

Yes, you can amend your changes in your previous commit. No need to create different commit each time. You currently have more than one commit so squash them into one commit, you can google how to do it.

@SheikhZaeem SheikhZaeem force-pushed the fix-header-image branch 2 times, most recently from 1858a32 to 9b2e89c Compare January 31, 2025 22:01
@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

github, generate site

@github-actions

Copy link
Copy Markdown
Contributor

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

github, generate site

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

@Zopsss I squashed and then I lost some of the changes i did due to my mistake. But I think now it is fine.

@Zopsss

Zopsss commented Feb 1, 2025

Copy link
Copy Markdown
Member

Github, generate site

@github-actions

github-actions Bot commented Feb 1, 2025

Copy link
Copy Markdown
Contributor

@SheikhZaeem

Copy link
Copy Markdown
Contributor Author

Hey @Zopsss. Thanks for so much help. Is there anything else left for this PR? If not, then I will move to other issues?

@Zopsss Zopsss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Red line isn't a link anymore and it is sticked to the top now. Thanks a lot for all the hard work!

@Zopsss

Zopsss commented Feb 1, 2025

Copy link
Copy Markdown
Member

@romani the Checkstyle logo in banner is a link. But I guess it is fine, or do you want to change it?

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@SheikhZaeem , @Zopsss , thanks a lot for collaboration to make a fix !!!

great job !!

@romani romani merged commit 42174f8 into checkstyle:master Feb 1, 2025
@SheikhZaeem SheikhZaeem deleted the fix-header-image branch February 2, 2025 14:37
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