-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from eecs485staff/dark-mode-images
[Images] Auto-invert colors, add subtle border
- Loading branch information
Showing
9 changed files
with
161 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
index.md | ||
demo/images.md | ||
demo/mermaid-diagrams.md | ||
_includes/ | ||
_layouts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
layout: spec | ||
--- | ||
|
||
# Images | ||
|
||
## Basic syntax | ||
|
||
Primer Spec automatically adds a subtle `1px` border to images. In my opinion, the border helps with readability, especially for images whose background colors match the background of the page. | ||
|
||
For instance, try viewing this image in the "default" theme in "light" mode: | ||
|
||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](https://drive.google.com/uc?export=view&id=1_QPsSGlXKjfqY-3TUbsXej5isOZypK7U) | ||
|
||
You can use either Markdown syntax or HTML syntax to define images. | ||
|
||
<details mardown="1"> | ||
<summary>Source code for basic image syntax</summary> | ||
|
||
<pre data-title="Basic image syntax"> | ||
Markdown syntax: | ||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](./screenshot.png) | ||
|
||
Equivalent HTML syntax: | ||
<img | ||
src="./screenshot.png" | ||
alt="This image shows a screenshot of Primer Spec in the 'Bella' theme." /> | ||
</pre> | ||
</details> | ||
|
||
<div class="primer-spec-callout warning" markdown="1"> | ||
Don't forget the 'alt' text! It's the only way fot visually-impaired users to understand the context provided by the image. | ||
</div> | ||
|
||
## Opt-out of image borders | ||
|
||
Simply add the `no-border` class to the image. For instance: | ||
|
||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](https://drive.google.com/uc?export=view&id=1_QPsSGlXKjfqY-3TUbsXej5isOZypK7U){: .no-border } | ||
|
||
<details mardown="1"> | ||
<summary>Source code for borderless images</summary> | ||
|
||
<pre data-title="Auto-inverted image syntax"> | ||
Markdown syntax: | ||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](./screenshot.png){: .no-border } | ||
|
||
Equivalent HTML syntax: | ||
<img | ||
src="./screenshot.png" | ||
alt="This image shows a screenshot of Primer Spec in the 'Bella' theme." | ||
class="no-border" /> | ||
</pre> | ||
</details> | ||
|
||
## Auto-invert colors in dark mode | ||
|
||
If you add the `invert-colors-in-dark-mode` class to an image, Primer Spec will automatically invert the colors of the image when users view the page in a dark theme! | ||
|
||
For instance, the following image changes colors in light mode and dark mode: | ||
|
||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](https://drive.google.com/uc?export=view&id=1_QPsSGlXKjfqY-3TUbsXej5isOZypK7U){: .invert-colors-in-dark-mode } | ||
|
||
<details mardown="1"> | ||
<summary>Source code for auto-inverted images</summary> | ||
|
||
<pre data-title="Auto-inverted image syntax"> | ||
Markdown syntax: | ||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](./screenshot.png){: .invert-colors-in-dark-mode } | ||
|
||
Equivalent HTML syntax: | ||
<img | ||
src="./screenshot.png" | ||
alt="This image shows a screenshot of Primer Spec in the 'Bella' theme." | ||
class="invert-colors-in-dark-mode" /> | ||
</pre> | ||
</details> | ||
|
||
If you prefer to opt-out of borders, also add the `no-border` class. | ||
|
||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](https://drive.google.com/uc?export=view&id=1_QPsSGlXKjfqY-3TUbsXej5isOZypK7U){: .invert-colors-in-dark-mode .no-border } | ||
|
||
<details mardown="1"> | ||
<summary>Source code for auto-inverted images</summary> | ||
|
||
<pre data-title="Auto-inverted borderless image syntax"> | ||
Markdown syntax: | ||
![This image shows a screenshot of Primer Spec in the 'Bella' theme.](./screenshot.png){: .invert-colors-in-dark-mode .no-border } | ||
|
||
Equivalent HTML syntax: | ||
<img | ||
src="./screenshot.png" | ||
alt="This image shows a screenshot of Primer Spec in the 'Bella' theme." | ||
class="invert-colors-in-dark-mode no-border" /> | ||
</pre> | ||
</details> | ||
|
||
## [Excalidraw](https://excalidraw.com) | ||
|
||
While you can use [Mermaid](https://eecs485staff.github.io/primer-spec/demo/mermaid-diagrams.html) to create diagrams, I recommend using [Excalidraw](https://excalidraw.com) for creating free-form diagrams. | ||
|
||
After you've created your diagram on Exccalidraw, I recommend exporting it as a PNG *with the scene embedded*. ("Embedding the scene" allows you to reopen the PNG file on Excalidraw in future to make updates!) | ||
|
||
Upload the exported PNG image to your Primer Spec website. Then, when you add the image to your page, don't forget to [auto-invert the colors](#auto-invert-colors-in-dark-mode)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters