Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d229cf5

Browse files
committedOct 28, 2022
docs: improve dynamic theme documentation
1 parent 6877537 commit d229cf5

File tree

1 file changed

+73
-51
lines changed

1 file changed

+73
-51
lines changed
 

‎readme.md

+73-51
Original file line numberDiff line numberDiff line change
@@ -159,70 +159,92 @@ You can look at a preview for [all available themes](./themes/README.md) or chec
159159

160160
#### Responsive Card Theme
161161

162-
We can not infer the browser theme on the server since GitHub will re-upload the cards and serve them from their CDN.
162+
[![Anurag's GitHub stats-Dark](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark#gh-dark-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-dark-mode-only)
163+
[![Anurag's GitHub stats-Light](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=default#gh-light-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-light-mode-only)
163164

164-
The four methods you can use to create dynamics themes on the client side:
165+
Since GitHub will re-upload the cards and serve them from their [CDN](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-anonymized-urls), we can not infer the browser/GitHub theme on the server side. There are, however, four methods you can use to create dynamics themes on the client side:
165166

166-
- Simplest one: Use the `transparent` theme
167+
##### Use the transparent theme
167168

168-
With inbuilt theme, you can keep the look of the card dynamic to theme.
169+
We have included a `transparent` theme that has a transparent background. This theme is optimized to look good on GitHub's dark and light default themes. You can enable this theme using the `&theme=transparent` parameter like so:
169170

170-
Use `&theme=transparent` parameter like so:
171+
```md
172+
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=transparent)
173+
```
171174

172-
```md
173-
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=transparent)
174-
```
175+
<details>
176+
<summary>:eye: Show example</summary>
175177

176-
- Set the `bg_color` to a color with a transparent alpha channel `bg_color=00000000`
178+
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=transparent)
177179

178-
You can keep your background transparent by keeping the `bg_color` to a color with a transparent alpha channel `bg_color=00000000` in-order to keep it align with themes.
180+
</details>
179181

180-
Use `&bg_color=00000000` parameter like so:
182+
##### Add transparent alpha channel to a themes bg_color
181183

182-
```md
183-
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&bg_color=00000000)
184-
```
185-
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&bg_color=00000000)
186-
187-
- Use GitHub's theme context tags to automatically switch the theme based
184+
You can use the `bg_color` parameter to make any of [the available themes](./themes/README.md) transparent. This is done by setting the `bg_color` to a colour with a transparent alpha channel (i.e. `bg_color=00000000`):
188185

189-
You can now specify the theme an image is displayed for in Markdown. Appending `#gh-dark-mode-only` or `#gh-light-mode-only` to the end of an image url will define whether it's only shown to viewers using a light or a dark GitHub theme.
186+
```md
187+
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&bg_color=00000000)
188+
```
190189

191-
```md
192-
[![Anurag's GitHub stats-Dark](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark#gh-dark-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-dark-mode-only)
193-
[![Anurag's GitHub stats-Light](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=default#gh-light-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-light-mode-only)
194-
```
195-
[![Anurag's GitHub stats-Dark](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark#gh-dark-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-dark-mode-only)
196-
[![Anurag's GitHub stats-Light](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=default#gh-light-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-light-mode-only)
197-
198-
- Use GitHub's new media feature in the HTML
190+
<details>
191+
<summary>:eye: Show example</summary>
192+
193+
![Anurag's GitHub stats](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&bg_color=00000000)
194+
195+
</details>
199196

200-
You can now specify whether to display images for light or dark themes in Markdown, using the HTML `<picture>` element in combination with the `prefers-color-scheme` media feature.
197+
##### Use GitHub's theme context tag
198+
199+
You can use [GitHub's theme context](https://github.blog/changelog/2021-11-24-specify-theme-context-for-images-in-markdown/) tags to switch the theme based on the user GitHub theme automatically. This is done by appending `#gh-dark-mode-only` or `#gh-light-mode-only` to the end of an image URL. This tag will define whether the image specified in the markdown is only shown to viewers using a light or a dark GitHub theme:
200+
201+
```md
202+
[![Anurag's GitHub stats-Dark](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark#gh-dark-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-dark-mode-only)
203+
[![Anurag's GitHub stats-Light](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=default#gh-light-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-light-mode-only)
204+
```
205+
206+
<details>
207+
<summary>:eye: Show example</summary>
208+
209+
[![Anurag's GitHub stats-Dark](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark#gh-dark-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-dark-mode-only)
210+
[![Anurag's GitHub stats-Light](https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=default#gh-light-mode-only)](https://github.com/anuraghazra/github-readme-stats#gh-light-mode-only)
211+
212+
</details>
213+
214+
##### Use GitHub's new media feature
215+
216+
You can use [GitHub's new media feature](https://github.blog/changelog/2022-05-19-specify-theme-context-for-images-in-markdown-beta/) in HTML to specify whether to display images for light or dark themes. This is done using the HTML `<picture>` element in combination with the `prefers-color-scheme` media feature.
201217

202-
```html
203-
<picture>
204-
<source
205-
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark"
206-
media="(prefers-color-scheme: dark)"
207-
/>
208-
<source
209-
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true"
210-
media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
211-
/>
212-
<img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true" />
213-
</picture>
214-
```
215-
<picture>
216-
<source
217-
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark"
218-
media="(prefers-color-scheme: dark)"
219-
/>
220-
<source
221-
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true"
222-
media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
223-
/>
224-
<img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true" />
225-
</picture>
218+
```html
219+
<picture>
220+
<source
221+
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark"
222+
media="(prefers-color-scheme: dark)"
223+
/>
224+
<source
225+
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true"
226+
media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
227+
/>
228+
<img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true" />
229+
</picture>
230+
```
231+
232+
<details>
233+
<summary>:eye: Show example</summary>
234+
235+
<picture>
236+
<source
237+
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&theme=dark"
238+
media="(prefers-color-scheme: dark)"
239+
/>
240+
<source
241+
srcset="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true"
242+
media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)"
243+
/>
244+
<img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true" />
245+
</picture>
246+
247+
</details>
226248

227249
### Customization
228250

0 commit comments

Comments
 (0)
Please sign in to comment.