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

Editorial: Add a diagram for storage model #152

Merged
merged 14 commits into from
Dec 1, 2022

Conversation

saschanaz
Copy link
Member

@saschanaz saschanaz commented Nov 21, 2022

Fixes #151

Used SVGO as @annevk suggested, which indeed vastly reduces the size.


Preview | Diff

@saschanaz saschanaz requested a review from annevk November 21, 2022 22:20
@saschanaz
Copy link
Member Author

saschanaz commented Nov 21, 2022

"file:/home/runner/work/storage/storage/storage.spec.whatwg.org/index.html":223.7-223.116: error: An “img” element with no “alt” attribute must not have any “aria-*” attributes other than “aria-hidden”.
"file:/home/runner/work/storage/storage/storage.spec.whatwg.org/index.html":223.7-223.116: error: An “img” element must have an “alt” attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.
"file:/home/runner/work/storage/storage/storage.spec.whatwg.org/commit-snapshots/a976c463f54c26c953f7d6df3a59a5ee146609bc/index.html":232.7-232.116: error: An “img” element with no “alt” attribute must not have any “aria-*” attributes other than “aria-hidden”.
"file:/home/runner/work/storage/storage/storage.spec.whatwg.org/commit-snapshots/a976c463f54c26c953f7d6df3a59a5ee146609bc/index.html":232.7-232.116: error: An “img” element must have an “alt” attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images

It seems the validator blocks any use of ARIA attributes and forces alt? @whatwg/a11y, should I just use alt here instead?

@aardrian
Copy link

I believe we expected you would embed an SVG inline, as it was in the original issue. All the advice was geared toward that. We did not offer advice for referencing it via <img>.

The <img> element requires the alt attribute to provide its accessible name. Your code uses aria-describedby, which provides an accessible description.

@domenic
Copy link
Member

domenic commented Nov 22, 2022

It looks like #148 failed to build. Please replace all browsing session references appropriately before merging... I'll investigate. Edit: build is fixed, and "browsing session" references no longer appear on https://storage.spec.whatwg.org/.

@saschanaz
Copy link
Member Author

saschanaz commented Nov 22, 2022

Does it make sense to do <img alt="A storage model diagram" aria-describedBy="model-description"> or should I copypaste the whole paragraph to the alt attribute? 👀

(I'm not against embedding the SVG, it's just that it'll introduce some manual work if the diagram ever changes. I wonder Bikeshed can just import SVG files.)

@aardrian
Copy link

alt="Storage model diagram" is fine, as long as it accompanies the actual storage model diagram.

Makefile Outdated Show resolved Hide resolved
storage.bs Outdated Show resolved Hide resolved
"Browsing session" ||--|| "Storage shed" : "holds (session)"
"Storage shed" ||--o{ "Storage shelf" : "for each storage key"
"Storage shelf" ||--|| "Storage bucket" : "holds (default)"
"Storage bucket" ||--|{ "Storage bottle" : "for each storage endpoint"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we lowercase all these terms? I'm not entirely sure, but it looks a little off to me at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about that either, diagrams tend to have the cases this way.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that preview doesn't work for this image. I guess that's due to it only doing a Bikeshed build and not a full build.

@domenic can you do a quick peak? I'd love your thoughts on:

  1. Doing diagrams.
  2. The Node.js stuff here.
  3. Using assets/ for structure.

(Mainly because if this is good, we should adopt it elsewhere, e.g., in Fetch.)

.gitignore Outdated
@@ -1,3 +1,5 @@
/storage.spec.whatwg.org/
/deploy.sh
/storage.html
/node_modules/
package-lock.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This we'll also have to change upstream: https://github.com/whatwg/spec-factory/blob/main/factory.json. But it's straightforward enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it override this file if unchanged btw?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure on whether or not we should check in package-lock.json. It looks like we don't for other Node-using spec repos. But it's generally good practice. We check it in for participate.whatwg.org.

If you check it in, you get reproducible builds. If you don't check it in, all your dependencies-of-dependencies will get recomputed each time, potentially with inadvertent breaking changes.

However, if you check it in, you also start getting annoying GitHub security alerts about all your dependencies-of-dependencies :-/.

storage.bs Outdated Show resolved Hide resolved
Co-authored-by: Anne van Kesteren <[email protected]>
.gitignore Outdated
@@ -1,3 +1,5 @@
/storage.spec.whatwg.org/
/deploy.sh
/storage.html
/node_modules/
package-lock.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure on whether or not we should check in package-lock.json. It looks like we don't for other Node-using spec repos. But it's generally good practice. We check it in for participate.whatwg.org.

If you check it in, you get reproducible builds. If you don't check it in, all your dependencies-of-dependencies will get recomputed each time, potentially with inadvertent breaking changes.

However, if you check it in, you also start getting annoying GitHub security alerts about all your dependencies-of-dependencies :-/.

%% Build command: `npm i && npm run build-diagram`

"User agent" ||--|| "Storage shed" : "holds (local)"
"Browsing session" ||--|| "Storage shed" : "holds (session)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change "Browsing session" to "Top-level traversable", per the latest spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A browsing session holds a storage shed, which is a storage shed. A browsing session’s storage shed holds all session storage data.

Err, it's still there, should it be fixed too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, that's because the build failure. 😅

package.json Outdated
@@ -0,0 +1,14 @@
{
"name": "storage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving "private": true to the top, and removing "name" and "version". Compare to https://github.com/whatwg/webidl/blob/main/package.json.

@@ -0,0 +1,50 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-labelledby="chart-title-mermaid-1669067354847 chart-desc-mermaid-1669067354847" style="max-width:396.227px;background-color:#fff;font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;fill:#333" viewBox="0 0 396.227 815">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to check in this build output? Or should it be generated on each deploy?

If the latter, we need to do some work to make this repo more like webidl. (Which is another repo which uses Node as part of its build process.) We can make the changes as part of this PR, but we'd also need to update spec-factory so that it generates the files appropriately next time in the same way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way is fine to me, but let's try that...

@@ -0,0 +1,50 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-labelledby="chart-title-mermaid-1669067354847 chart-desc-mermaid-1669067354847" style="max-width:396.227px;background-color:#fff;font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;fill:#333" viewBox="0 0 396.227 815">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will need to be added as an "extra_files in https://github.com/whatwg/spec-factory/blob/main/factory.json otherwise the build will not work. That updates the Makefile like so: https://github.com/whatwg/encoding/blob/main/Makefile#L23 .

We'll need to be sure to exclude all the other files. So maybe something like assets/*.svg?

Alternately, you could have all the other stuff live in scripts/, and have it generate a new file in assets/ or images/. Then you'd add assets/*.* as the extra files.

@@ -0,0 +1,50 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-labelledby="chart-title-mermaid-1669067354847 chart-desc-mermaid-1669067354847" style="max-width:396.227px;background-color:#fff;font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px;fill:#333" viewBox="0 0 396.227 815">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image is unreadably small when viewed standalone. https://raw.githubusercontent.com/whatwg/storage/651b26d44e2572123dbc82f93adb61359ed71dda/assets/model-diagram.svg

Will it be extremely small when embedded in the spec, too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure what's happening, but on Firefox it seems it gets smaller with larger viewport and gets bigger with smaller-but-bigger-than-the-image viewport. Anyway we set width and height manually in HTML, so it should be fine.

<path fill="none" stroke="gray" marker-end="url(#a)" marker-start="url(#b)" d="M187.818 445v100" class="er relationshipLine"/>
<path fill="none" stroke="gray" marker-end="url(#d)" marker-start="url(#b)" d="M187.818 620v100" class="er relationshipLine"/>
<path fill="#f0fff0" fill-opacity="100%" stroke="gray" d="M20 20h107.523v75H20z" class="er entityBox"/>
<text class="er entityLabel" dominant-baseline="middle" style="font-family:&quot;trebuchet ms&quot;,verdana,arial,sans-serif;font-size:16px" text-anchor="middle" transform="translate(73.762 57.5)">User agent</text>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why these style attributes exist, despite the overall SVG element already having that style. Oh well; I assume there's nothing we can do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at this and SVGOMG has a "Style to attributes" option that indeed reduces the file size further. Not sure how to use that from CLI however.

The other things I see are the redundant aria-* attribute and a bunch of useless class attributes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saschanaz added a commit to saschanaz/spec-factory that referenced this pull request Nov 23, 2022
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking promising!

Makefile Outdated Show resolved Hide resolved
@@ -0,0 +1,12 @@
erDiagram
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, now this lives in scripts/, which is a bit weird... maybe it should live in top-level?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure how it would look if we get more diagrams... But for now SGTM.

@annevk
Copy link
Member

annevk commented Nov 30, 2022

@domenic any final feedback from you here? I have a couple minor things I can do in a fixup, but I want to make sure we're aligned on the big picture stuff.

storage.bs Outdated
<p><img src=assets/model-diagram.svg alt="Storage model diagram (described in the next paragraph)."
width=434 height=815>

<p id=model-description>To isolate this data this standard defines a <a for=/>storage shed</a>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this id="" is not really needed anymore. (Although it doesn't hurt.)

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed my nits, but I realized I have another question for @saschanaz.

model-diagram.mmd Outdated Show resolved Hide resolved
Co-authored-by: Anne van Kesteren <[email protected]>
@annevk annevk merged commit 8b93c4c into whatwg:main Dec 1, 2022
annevk pushed a commit to whatwg/spec-factory that referenced this pull request Dec 1, 2022
@saschanaz saschanaz deleted the model-diagram branch December 1, 2022 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add a diagram for the storage model?
4 participants