Skip to content

Commit

Permalink
[Web] Add ability to caption and resize figures
Browse files Browse the repository at this point in the history
Index page: add a caption
Not found page: resize to 75% parent width
  • Loading branch information
burkenyo committed Aug 13, 2024
1 parent 88e8089 commit cbfd0a5
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 5 deletions.
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@rushstack/eslint-patch": "^1.10.4",
"@tsconfig/node20": "^20.1.4",
"@types/markdown-it": "^14.1.2",
"@types/markdown-it-attrs": "^4.1.3",
"@types/markdown-it-emoji": "^3.0.1",
"@types/node": "~20.14.14",
"@types/plotly.js": "^2.33.3",
Expand Down
10 changes: 10 additions & 0 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/src/main/pages/IndexPage.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ interested in the cross-connections between code, music, art, and life"

Hello there! I am a seasoned software developer and composer in the Greater Boston area. I’m interested in the cross-connections between code, music, art, and life.

![The way home](__ASSETS_BASE_URL/the-way-home.png)
![The way home](__ASSETS_BASE_URL/the-way-home.png "Mt. Blanc peeks out from a layer of clouds.")
2 changes: 1 addition & 1 deletion web/src/main/pages/NotFound.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

The page you were looking for was not found. So, here’s Ronnie instead:

![Ronnie](__ASSETS_BASE_URL/ronnie.png)
![Ronnie](__ASSETS_BASE_URL/ronnie.png){.w75}
8 changes: 7 additions & 1 deletion web/src/shared/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,20 @@ div#engrave-area {
}

figure {
margin: 2em 0;
margin: 2em auto;
}

figure > img {
width: 100%;
box-shadow: 0 0 8px var(--grey-darker);
}

figcaption {
text-align: center;
font-size: smaller;
font-style: italic;
}

div.layout-standard {
max-width: 50em;
min-height: calc(100vh - 2em);
Expand Down
39 changes: 39 additions & 0 deletions web/src/shared/assets/utils.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,42 @@
text-align: right;
}

figure.w50 {
width: 50%;
}

figure.w55 {
width: 55%;
}

figure.w60 {
width: 60%;
}

figure.w65 {
width: 65%;
}

figure.w70 {
width: 70%;
}

figure.w75 {
width: 75%;
}

figure.w80 {
width: 80%;
}

figure.w85 {
width: 85%;
}

figure.w90 {
width: 90%;
}

figure.w95 {
width: 95%;
}
7 changes: 5 additions & 2 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import path from "node:path";

// markdown-it plugins
import { full as mdEmoji } from "markdown-it-emoji";
import mdAttr from "markdown-it-attrs";
import mdSub from "markdown-it-sub";
import mdSup from "markdown-it-sup";
import mdAnchor from "markdown-it-anchor";
Expand Down Expand Up @@ -56,6 +57,8 @@ export default defineConfig(({ command, mode, isSsrBuild }) => {
markdownItSetup(md) {
md.use(mdEmoji);

md.use(mdAttr);

// enable subscripts using ~X~
md.use(mdSub);

Expand All @@ -65,8 +68,8 @@ export default defineConfig(({ command, mode, isSsrBuild }) => {
// automatically generate IDs for h3’s
md.use(mdAnchor, { tabIndex: false, level: [3] });

// place images inside figures
md.use(mdImageFigures);
// place images inside figures, copying classes set via markdown-it-attrs to the figure
md.use(mdImageFigures, { figcaption: "title", copyAttrs: "class" });
},
}),

Expand Down

0 comments on commit cbfd0a5

Please sign in to comment.