DEV Community

Cover image for GitHub Readme: Responsive? πŸ€” Animated? 🀯 Light and dark modes? 😱 You bet! πŸ’ͺ🏼

GitHub Readme: Responsive? πŸ€” Animated? 🀯 Light and dark modes? 😱 You bet! πŸ’ͺ🏼

GrahamTheDev on January 19, 2024

Yes, you heard me right, my GitHub readme has light and dark modes and is even responsive. In this article I will briefly cover the tricks I used t...
Collapse
 
cicirello profile image
Vincent A. Cicirello

You should submit your README to:

GitHub logo matiassingers / awesome-readme

A curated list of awesome READMEs

Awesome README Awesome

A curated list of awesome READMEs

Elements in beautiful READMEs include, but are not limited to: images, screenshots, GIFs, text formatting, etc.

Examples

  • ai/size-limit - Project logo, clear description, screenshot, step-by-step installing instructions.
  • aimeos/aimeos-typo3 - Project logo. Clear description of what the project does. Demo screenshot. TOC for easy navigation. Easy installation and setup sections with screenshots. Links for further reading.
  • ajeetdsouza/zoxide - Badges, project GIF, concise description, quick links, stepwise installation instructions.
  • alichtman/shallow-backup - Clear description of what the project does. GIF Demo. TOC for easy navigation. Badges. Links for further reading. Simple install instructions.
  • alichtman/stronghold - Project logo. Clear description of what the project does. GIF Demo. TOC for easy navigation. Badges. Links for further reading. Simple install instructions.
  • amitmerchant1990/electron-markdownify - Project logo. Minimalist description of what it is. GIF demo of the project. Key features. How to install guide. Credits.
  • amplication/amplication - Clear project logo…
Collapse
 
grahamthedev profile image
GrahamTheDev

Nice, I was going to submit it to the other repo that showcases readmes but it had like 425 issues. This one looks maintained, so thanks! πŸ™πŸΌπŸ’—

Collapse
 
cicirello profile image
Vincent A. Cicirello

You're welcome.

Collapse
 
arthurneuron profile image
Arthur Neuron

It looks fine πŸ‘πŸΎ, but for some reason one half is generated in a light style and the other half in a dark style.

Image description

Collapse
 
grahamthedev profile image
GrahamTheDev

Hmmmm, that looks like you have the theme set to dark directly in GitHub but the system setting is light mode maybe (and they do some weird trickery for light and dark mode on images)?

Darn, not sure how to fix that unless I use 2 different versions for the buttons and then use the <picture> element to fix.

I will have to have a fiddle, can I ask what browser (and if you have light mode as your system preference as I think?). Thanks for the bug report! πŸ€£πŸ™πŸΌπŸ’—

Collapse
 
arthurneuron profile image
Arthur Neuron • Edited

Safari Version 17.1.2 (19616.2.9.11.12)

I change the system theme, and the light version works fine.
When I change to the dark version, only the bottom half of the readme changes.

Image description

Thread Thread
 
grahamthedev profile image
GrahamTheDev • Edited

Ahhhh, it is the other problem, SVGs using embedded media queries for light mode preference don't work on Safari (actual iOS / MacOS issue) if you have dark mode enabled there!

I will fix that with 2 <picture> elements then, thanks for the heads up, never knew that restriction! πŸ™πŸΌπŸ’—

Collapse
 
taufik-h profile image
Taufik Hidayatulloh

use image with transparent background

Collapse
 
grahamthedev profile image
GrahamTheDev

Doesn’t work like that sadly as the colour scheme within the buttons needs to change for colour contrast. πŸ’—

Collapse
 
azasypkin profile image
Aleh Zasypkin • Edited

Very nice job @grahamthedev! Just one small correction:

This is because of something called a Content Security Policy (CSP) and the way it is implemented on GitHub.
Luckily, data URIs are counted as the same context / origin.

The data: URIs aren't considered the same context/origin (and will never be). It works because GitHub explicitly allows loading images using the data: protocol as the image source. I've imported the policy from your profile with Secutils.dev to illustrate (take a look at the Image source (img-src) field): "[Dev.To] GrahamTheDev's Profile" content security policy

The Image source (img-src) also shows that we have a few other options should GitHub remove data: from the allowed sources :)

Now I won't explain CSPs, but in essence they have a rule that says "hey, no images can be loaded from anywhere other than the current context".

And a shameless plug, if anyone likes to learn more about CSP, feel free to check out my other post on exploring web applications through their (CSP): dev.to/azasypkin/explore-web-appli...

Collapse
 
grahamthedev profile image
GrahamTheDev

Ahhhh, maybe that was raw.github.com that had the more restrictive policy (or maybe I just made it up lol).

I will try and have a dig around on Monday and will correct it!

Thanks! πŸ™πŸΌπŸ’—

Collapse
 
nickytonline profile image
Nick Taylor

Love this! Cool stuff Graham!

Yes, that's awesome!

Collapse
 
grahamthedev profile image
GrahamTheDev

Thanks bud! πŸ™πŸΌπŸ’—

Collapse
 
acontreras89 profile image
Aaron Contreras

To get rid of the vertical space between images, just set line-height to 0 in the wrapping div:

Image description

Collapse
 
grahamthedev profile image
GrahamTheDev

I don't think GitHub will allow you to that and it will get stripped (or is line-height an allowed style attribute they accept?).

Collapse
 
robole profile image
Rob OLeary • Edited

I had the same thought with SVGs on the profile readme! I just was not motivated to carve up images to demonstrate. Nice work!

Collapse
 
grahamthedev profile image
GrahamTheDev

Haha, don't blame you on that one, this took me hours to get right and working within all the restrictions! Better to just have a simple readme in the end lol! πŸ€£πŸ’—

Collapse
 
grahamthedev profile image
GrahamTheDev

If you have seen some beautiful GitHub readme's, please share them in the comments section, I would love to see them! πŸ’ͺπŸΌπŸ’—

Collapse
 
tharakamts profile image
Tharaka Sandaruwan

Nice work πŸ”₯

Collapse
 
it0dan profile image
D.aΘ 

Awesome!!

Collapse
 
lilxyzz profile image
Travis

Killer work! This is a great idea, Graham πŸ”₯

Image description

Collapse
 
ohaddahan profile image
ohaddahan

Wonder if this is a big vulnerability to hide JS code in.

Collapse
 
grahamthedev profile image
GrahamTheDev

No, JS code will not work in an SVG foreignObject on GitHub due to their Content Security Policy settings, so it is pretty safe in that respect. πŸ’—

Collapse
 
tobysolutions profile image
Tobiloba Adedeji

Amazing stuff!!!

Collapse
 
randellbrianknight profile image
Randell Brian Knight

This is so Cool. Thanks for sharing your insights, and I look forward to more posts about these topics.

Collapse
 
rivercory profile image
hyeonho • Edited

The most important point is that your README.md should be expressed according to your personality.

Collapse
 
grahamthedev profile image
GrahamTheDev

100% πŸ’ͺπŸΌπŸ’—

Collapse
 
greenteaisgreat profile image
Nathan G Bornstein

Incredible, thanks for sharing!

Collapse
 
grahamthedev profile image
GrahamTheDev

No problem, I hope you manage to steal a trick or two! πŸ’ͺπŸΌπŸ’—

Collapse
 
hellowwworld profile image
hellowwworld

You're so extra lol 😁

Collapse
 
taufik-h profile image
Taufik Hidayatulloh

impressive πŸ”₯πŸ”₯πŸ”₯, I'll try myself

Collapse
 
get_pieces profile image
Pieces 🌟

Love this! Useful stuff πŸ”₯

Collapse
 
grahamthedev profile image
GrahamTheDev

I hope it helps someone create a cool looking readme! πŸ€žπŸΌπŸ’—

Collapse
 
ranjancse profile image
Ranjan Dailata

Amazing.

GitHub might contact and grab you into their UI/UX team :)

Collapse
 
grahamthedev profile image
GrahamTheDev

Haha, doubt it, there are far too many hacks here that will make them cry! πŸ€£πŸ’—

Collapse
 
pillar008 profile image
Neeraj Sharma

Guys anyone tell me how to implement this and where please

Collapse
 
yashjit profile image
Yashjit Pal

Is there a way to create it easily for myself? I don't have any idea about html

Collapse
 
grahamthedev profile image
GrahamTheDev

I am afraid that if you do not know html and css this will be very difficult to do. You can always grab the source code from my repo and the images and try and adjust them to your needs but I imagine it will be tough if you don’t understand some of what is going on. πŸ’—

Collapse
 
sinisterchef profile image
Kyle O'Brien

Exceptionally dank. Thank you for the tips! I will be taking a few ideas an incorporating them in my own GitHub profile.

Collapse
 
grahamthedev profile image
GrahamTheDev

Awesome, let me know when you do, would love to see it! πŸ’—

Collapse
 
fahim815 profile image
fahim815

wow

Collapse
 
seancannon profile image
Sean Cannon

Stop MySpacing my GitHub 😝

Collapse
 
grahamthedev profile image
GrahamTheDev

Uh oh...you just gave me an idea! πŸ˜±πŸ€£πŸ’—

Collapse