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

implement light & dark mode images #21

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,36 @@ We are using [iconify](https://icon-sets.iconify.design) for icons. You can sear
date=""
excerpt=""
url="" />
```
```

### Images

- Images should be placed in the `docs/.vitepress/public/img` folder.
- To reference an image, simply use `/img/...` as the path.

**Light & Dark Mode:**

To include a light and dark mode version of an image, add the `.light-only` and `.dark-only` classes to the image tag:

Markdown:

```md
![image-light](/img/myImage-light.png){.light-only}

![image-dark](/img/myImage-dark.png){.dark-only}
```

HTML:

```html
<img class="light-only" src="/img/myImage-light.png">

<img class="dark-only" src="/img/myImage-dark.png">
```

Tips:
- Keep the size and aspect ratio of the images consistent.
- Use similar filenames, such as with a `-light` or `-dark` suffix.
- Don't include only one version of the image, else content will move when switching between light and dark mode.

To modify this behaviour, see the "Light & Dark Mode images" section in the `docs/.vitepress/theme/style.css` file.
22 changes: 21 additions & 1 deletion docs/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* in custom container, badges, etc.
* -------------------------------------------------------------------------- */

:root {
:root {
--vp-c-default-1: var(--vp-c-gray-1);
/* #dddde3 */
--vp-c-default-2: var(--vp-c-gray-2);
Expand Down Expand Up @@ -234,6 +234,9 @@
}
}




/*
* Iconify
* ========================================================================== */
Expand All @@ -248,6 +251,8 @@
}




/*
* Option Bar
* ========================================================================== */
Expand Down Expand Up @@ -306,4 +311,19 @@
transform: none;
text-align: center;
}
}




/*
* Light & Dark Mode images
* ========================================================================== */

:root:not(.dark) .dark-only {
display: none;
}

:root:is(.dark) .light-only {
display: none;
}
Binary file added docs/public/img/profile-square-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/img/profile-square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.