alt text on collage
This commit is contained in:
parent
90bbdce08f
commit
8910d65ee6
|
@ -71,6 +71,10 @@ section {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section h2,p {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
figure {
|
figure {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 10em;
|
width: 10em;
|
||||||
|
|
|
@ -19,6 +19,6 @@ Antonio](https://utsa.edu).
|
||||||
* [style guide](/style-guide.html) - _Formatting rules for this site_
|
* [style guide](/style-guide.html) - _Formatting rules for this site_
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<img src="favicon.gif" style="width: 10em;"> <br>
|
<img src="favicon.gif" style="width: 10em;" alt="Lain animation"> <br>
|
||||||
<em>If you're not remembered, then you never existed</em>
|
<em>If you're not remembered, then you never existed</em>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
class JsonData extends HTMLElement {
|
class JsonData extends HTMLElement {
|
||||||
static observedAttributes = ["src", "show"];
|
static observedAttributes = ["src", "show", "alt"];
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
static grid(json) {
|
static grid(json, alt) {
|
||||||
let html = "";
|
let html = "";
|
||||||
for (const headerName in json) {
|
for (const headerName in json) {
|
||||||
html = html.concat(`
|
html = html.concat(`
|
||||||
|
<section>
|
||||||
<h2>${headerName}</h2>
|
<h2>${headerName}</h2>
|
||||||
<p>${json[headerName].desc || ""}</p>
|
<p>${json[headerName].desc || ""}</p>
|
||||||
<section>
|
|
||||||
`);
|
`);
|
||||||
let entries = json[headerName].items || [];
|
let entries = json[headerName].items || [];
|
||||||
for (let i = 0; i < entries.length; i++) {
|
for (let i = 0; i < entries.length; i++) {
|
||||||
let entry = entries[i];
|
let entry = entries[i];
|
||||||
html = html.concat(
|
html = html.concat(
|
||||||
`<figure>
|
`<figure>
|
||||||
<img src="${entry.url}">
|
<img src="${entry.url}" alt="${alt || ""}">
|
||||||
<figcaption>
|
<figcaption>
|
||||||
<b>${entry.main}</b><br>
|
<b>${entry.main}</b><br>
|
||||||
<em>${entry.sub}</em>
|
<em>${entry.sub}</em>
|
||||||
|
@ -62,7 +62,7 @@ class JsonData extends HTMLElement {
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
switch(this.show) {
|
switch(this.show) {
|
||||||
case "grid":
|
case "grid":
|
||||||
this.innerHTML = JsonData.grid(json);
|
this.innerHTML = JsonData.grid(json, this.alt);
|
||||||
break;
|
break;
|
||||||
case "list":
|
case "list":
|
||||||
this.innerHTML = JsonData.list(json);
|
this.innerHTML = JsonData.list(json);
|
||||||
|
@ -73,10 +73,16 @@ class JsonData extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
async attributeChangedCallback(name, oldValue, newValue) {
|
async attributeChangedCallback(name, oldValue, newValue) {
|
||||||
if (name == "src") {
|
switch (name) {
|
||||||
this.src = newValue;
|
case "src":
|
||||||
} else if (name == "show") {
|
this.src = newValue;
|
||||||
this.show = newValue;
|
break;
|
||||||
|
case "show":
|
||||||
|
this.show = newValue;
|
||||||
|
break;
|
||||||
|
case "alt":
|
||||||
|
this.alt = newValue;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@ Music is a huge passion of mine. I prefer listening to albums in full from
|
||||||
start to finish in order. My favorite albums are usually experimental, unique,
|
start to finish in order. My favorite albums are usually experimental, unique,
|
||||||
or have a particular theme they explore
|
or have a particular theme they explore
|
||||||
|
|
||||||
<json-data src="/music/albums.json" show="grid"></json-data>
|
<json-data src="/music/albums.json" show="grid" alt="Album cover"></json-data>
|
||||||
|
|
Loading…
Reference in a new issue