Skip to content

feat: add slight delay in color mode transitions#407

Closed
orimdominic wants to merge 6 commits intoadityatelange:masterfrom
orimdominic:feat/color-mode-transition-delay
Closed

feat: add slight delay in color mode transitions#407
orimdominic wants to merge 6 commits intoadityatelange:masterfrom
orimdominic:feat/color-mode-transition-delay

Conversation

@orimdominic
Copy link
Copy Markdown

@orimdominic orimdominic commented May 9, 2021

Add slight delay in color mode transitions

Here is a sample deployed

@kdkasad
Copy link
Copy Markdown
Contributor

kdkasad commented May 9, 2021

I think it looks great, but there's one thing I don't like; the transition fires when the page is first loaded, so the page fades in instead of just appearing as it normally does. Also, I think the transition should be applied to .post-entry and .toc elements as well.

Copy link
Copy Markdown
Contributor

@kdkasad kdkasad left a comment

Choose a reason for hiding this comment

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

The transitions look good, but the page load problem still exists.

Edit: also the TOC element's padding is now messed up.

@orimdominic
Copy link
Copy Markdown
Author

@kdkasad Thanks
Kindly confirm if the issue on page first load still exists.

@@ -267,6 +267,7 @@
background: var(--code-bg);
border-radius: var(--radius);
padding: .4em
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing semicolon. This messes up the padding of TOC elements.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I thought as much. This was what came to mind
Thanks.

@orimdominic
Copy link
Copy Markdown
Author

The transitions look good, but the page load problem still exists.

Edit: also the TOC element's padding is now messed up.

I'm on the page load issue at the moment
That of of the TOC element's padding is quite odd. Nothing related to it was tampered with (to the best of my knowledge) but I'll look into it

@orimdominic
Copy link
Copy Markdown
Author

How do I deploy to test these changes so that I can see what you see before I push new commits?
@kdkasad

@kdkasad
Copy link
Copy Markdown
Contributor

kdkasad commented May 9, 2021

The transitions look good, but the page load problem still exists.
Edit: also the TOC element's padding is now messed up.

...

That of of the TOC element's padding is quite odd. Nothing related to it was tampered with (to the best of my knowledge) but I'll look into it

It's because of a missing semicolon. See my previous comment

@kdkasad
Copy link
Copy Markdown
Contributor

kdkasad commented May 9, 2021

How do I deploy to test these changes so that I can see what you see before I push new commits?
@kdkasad

I just run hugo server -DF locally; no fancy deployement.

@orimdominic
Copy link
Copy Markdown
Author

hugo server -DF

That is what I do, but I don't see text.
I'll keep working with my own repo and verify the changes from there

@kdkasad
Copy link
Copy Markdown
Contributor

kdkasad commented May 9, 2021

hugo server -DF

That is what I do, but I don't see text.
I'll keep working with my own repo and verify the changes from there

Ah. I have the exampleSite branch checked out in a separate directory, with a symlink from $WORKDIR/exampleSite/themes/hugo-PaperMod to $WORKDIR/hugo-PaperMod, where the repo is.

Here are the commands to set that up:

$ cd $WORKDIR # for me, $WORKDIR is ~/code/papermod
$ mkdir exampleSite
$ git clone https://github.com/adityatelange/hugo-PaperMod
$ cd hugo-PaperMod
$ git worktree add ../exampleSite exampleSite
$ cd ../exampleSite/themes
$ rm -rf hugo-PaperMod
$ ln -s ../../hugo-PaperMod hugo-PaperMod

After that, you'll have the following directory structure:

$WORKDIR (~/code/papermod)
├── exampleSite
│   ├── (site content/configuration)
│   └── themes
│       └── hugo-PaperMod → ../../hugo-PaperMod
└── hugo-PaperMod
    └── (theme files)

Then run hugo server -DF from inside the exampleSite directory. I run it using tmux, so I can have it running in the background while I work on the theme.

@orimdominic
Copy link
Copy Markdown
Author

hugo server -DF

That is what I do, but I don't see text.
I'll keep working with my own repo and verify the changes from there

Ah. I have the exampleSite branch checked out in a separate directory, with a symlink from $WORKDIR/exampleSite/themes/hugo-PaperMod to $WORKDIR/hugo-PaperMod, where the repo is.

Here are the commands to set that up:

$ cd $WORKDIR # for me, $WORKDIR is ~/code/papermod
$ mkdir exampleSite
$ git clone https://github.com/adityatelange/hugo-PaperMod
$ cd hugo-PaperMod
$ git worktree add ../exampleSite exampleSite
$ cd ../exampleSite/themes
$ rm -rf hugo-PaperMod
$ ln -s ../../hugo-PaperMod hugo-PaperMod

After that, you'll have the following directory structure:

$WORKDIR (~/code/papermod)
├── exampleSite
│   ├── (site content/configuration)
│   └── themes
│       └── hugo-PaperMod → ../../hugo-PaperMod
└── hugo-PaperMod
    └── (theme files)

Then run hugo server -DF from inside the exampleSite directory. I run it using tmux, so I can have it running in the background while I work on the theme.

Awesome!
I'll try this out now!

@orimdominic
Copy link
Copy Markdown
Author

@kdkasad Update

Sorry for the delay. I'm working on some other projects.
I've been able to solve the overlay appearing on page load by setting the transition delay to work for only dark to light.
I'm still trying to figure out why that happens. I've scanned the sample website I referenced in the discussion about this feature and I replicated the method there but the delay still happens (unless I apply the fix I talked about in this comment)
I'm held back by the projects I'm working on but I felt that it's best to give an update on the progress of this.
I'm still trying to figure out why that happens and a better fix

@kdkasad
Copy link
Copy Markdown
Contributor

kdkasad commented May 14, 2021

@kdkasad Update

Sorry for the delay. I'm working on some other projects.
I've been able to solve the overlay appearing on page load by setting the transition delay to work for only dark to light.
I'm still trying to figure out why that happens. I've scanned the sample website I referenced in the discussion about this feature and I replicated the method there but the delay still happens (unless I apply the fix I talked about in this comment)
I'm held back by the projects I'm working on but I felt that it's best to give an update on the progress of this.
I'm still trying to figure out why that happens and a better fix

No problem taking your time; there's no need to rush.

As for why the delay happens on page load, it's because the stylesheet originally loads the page in the light theme, and the page's JavaScript instantly switches it to the dark theme when it's been selected.

I think the only way to fix this is to set the transition property after the inital theme switch using JavaScript.

@orimdominic
Copy link
Copy Markdown
Author

@kdkasad Thanks
Finally got around to implementing your suggestion.
How does it look now?

Copy link
Copy Markdown
Contributor

@kdkasad kdkasad left a comment

Choose a reason for hiding this comment

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

The color switch on page load seems to be solved, but one transition was removed which shouldn't have been.

background: var(--entry);
border-radius: var(--radius);
transition: transform .1s;
transition: background-color 350ms, border 350ms;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be changed to the following, otherwise the second rule will override the first, effectively canceling it.

transition: transform .1s, background-color 350ms, border 350ms;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Apologies.
I'm working on a serious bug on another project currently.
I half-mindedly added that so I could go back to the project.
Fixing it soon

Copy link
Copy Markdown
Contributor

@kdkasad kdkasad 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!

Sorry for all the comments and requests for tiny changes; only maintainers have the ability to add commits to a pull request, so commenting is the only way for me to make changes, no matter how trivial.

@orimdominic
Copy link
Copy Markdown
Author

@kdkasad This feature is 50% my work and 50% your work.
I'm grateful for your guidance via the comments

@orimdominic
Copy link
Copy Markdown
Author

@kdkasad This PR has not been merged.
Is the conflict the only issue here?

@kdkasad
Copy link
Copy Markdown
Contributor

kdkasad commented Jun 22, 2021

@kdkasad This PR has not been merged.
Is the conflict the only issue here?

I'm not sure. @adityatelange is the maintainer, so it's up to him to merge PRs. However I suspect that the conflict may be one reason he hasn't merged it. I'd recommend rebasing on the latest commit if you can.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Jul 1, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@orimdominic
Copy link
Copy Markdown
Author

@adityatelange Could you please give this a review?
I guess you skipped it because of merge conflicts.

Thanks.

@adityatelange
Copy link
Copy Markdown
Owner

@adityatelange Could you please give this a review?
I guess you skipped it because of merge conflicts.

Thanks.

I am so sorry to keep you waiting.
I am not really a fan of this feature, and I hope many wouldn't want a feature that is hard to disable.

@orimdominic
Copy link
Copy Markdown
Author

@adityatelange
If there's a setting in config.yml that helps users enable or disable this feature, will you accept it?

PS: You just taught me a practical lesson in Don't give users a feature they cannot configure to their taste

@adityatelange
Copy link
Copy Markdown
Owner

adityatelange commented Jul 4, 2021

@adityatelange
If there's a setting in config.yml that helps users enable or disable this feature, will you accept it?

PS: You just taught me a practical lesson in Don't give users a feature they cannot configure to their taste

IMO that is not easy to override and keep CSS styling with Hugo without using Hugo extended tricks.
Also, the animation lags on low-powered mobile devices is what I have experienced with my primary device.

@orimdominic
Copy link
Copy Markdown
Author

Alright. Thanks!

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.

3 participants