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

Button Examples: Add Open in Codepen and inline SVG in HTML using SVG "def"s #1642

Merged
merged 3 commits into from
Dec 13, 2020

Conversation

spectranaut
Copy link
Contributor

@spectranaut spectranaut commented Dec 1, 2020

Inlining in HTML

In #1534, @carmacleod suggested we use SVG defs to inline the SVGs into the HTML so they will load in codepen. See the code for the button example for an implementation of this suggestion.

Preview Button Example

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2020

Regression test coverage:

Examples without any regression tests:

  • dialog-modal/alertdialog.html

Examples missing some regression tests:

  • dialog-modal/datepicker-dialog.html:
    • textbox-aria-describedby
  • menu-button/menu-button-actions-active-descendant.html:
    • menu-up-arrow
    • menu-down-arrow
    • menu-character
  • toolbar/toolbar.html:
    • toolbar-tab
    • toolbar-right-arrow
    • toolbar-left-arrow
    • toolbar-home
    • toolbar-end
    • toolbar-toggle-esc
    • toolbar-toggle-enter-or-space
    • toolbar-radio-enter-or-space
    • toolbar-radio-down-arrow
    • toolbar-radio-up-arrow
    • toolbar-button-enter-or-space
    • toolbar-menubutton-enter-or-space-or-down-or-up
    • toolbar-menu-enter-or-space
    • toolbar-menu-down-arrow
    • toolbar-menu-up-arrow
    • toolbar-menu-escape
    • toolbar-spinbutton-down-arrow
    • toolbar-spinbutton-up-arrow
    • toolbar-spinbutton-page-down
    • toolbar-spinbutton-page-up
    • toolbar-checkbox-space
    • toolbar-link-enter-or-space
    • toolbar-spinbutton-role

Example pages with Keyboard or Attribute table rows that do not have data-test-ids:

  • dialog-modal/alertdialog.html
    • "Keyboard Support" table(s):
      • Tab
      • Shift + Tab
      • Escape
      • Command + S
      • Control + S
    • "Attributes" table(s):
      • alertdialog
      • aria-labelledby=IDREF
      • aria-describedby=IDREF
      • aria-modal=true
      • alert

SUMMARY:

55 example pages found.
1 example pages have no regression tests.
3 example pages are missing approximately 27 out of approximately 780 tests.

ERROR - missing tests:

Please write missing tests for this report to pass.

@spectranaut spectranaut changed the title Open in Codepen: Inlining SVG in CSS and using SVG "def"s Open in Codepen: Inlining SVG in CSS and inlining in HTML using SVG "def"s Dec 2, 2020
@carmacleod
Copy link
Contributor

Very cool, @spectranaut !

Nice work-around for :before and :after!
What tool did you use to get the svgs encoded with the special URL characters?

Not sure why the codepens are untitled? Did you create this branch from slightly old code? :)

Noticed that the menubar example needs some margin between it and the codepen button. Not sure why other examples have enough space? Changing the margin to have 5px on top (and bottom) fixes it, but I'm not sure if that's the best fix.

.menubar-editor {
    margin: 5px 0;
    ...
}

@spectranaut
Copy link
Contributor Author

You are right @carmacleod I was on old code, I just rebased! Titles should be in now.

I used this URL encorder: https://yoksel.github.io/url-encoder/

Also, do you think this is a ok direction to move forward with the APG? Essentially, we will have to require that a "image" folder is no longer used, and instead the options are to inline the SVG in the CSS or inline them in the HTML.

@carmacleod
Copy link
Contributor

@spectranaut

Also, do you think this is a ok direction to move forward with the APG? Essentially, we will have to require that a "image" folder is no longer used, and instead the options are to inline the SVG in the CSS or inline them in the HTML.

Good question. I don't know enough about SVGs to know what people "usually" do. We need to be sure we don't break Windows HCM, which is why we converted some of the other examples over to inline SVGs in the HTML and made the SVGs use currentColor. I don't know if currentColor works for inline CSS content SVGs? It might.

Unfortunately, the editor menubar icons don't yet work properly in high contrast mode (not because of this PR - I guess we didn't convert the SVGs over to be inline and use currentColor, and I see that the grey triangles and blue dots and checkmarks fail in High Contrast Black). We did fix the navigation menubar example though (inlined triangles that use currentColor), so maybe we can do something similar for editor menubar. (And then we can test whether currentColor works in CSS content url()'s or not).

I think the button example is good to go! The SVG defs work nicely for that one. Thanks for rebasing - title working now. Did you want to split this into 2 PRs so button example can go in right away? It seems we have some discussion and/or further svg coding/testing still to do for the editor menubar example.

@spectranaut
Copy link
Contributor Author

Thanks for the suggestions @carmacleod ! I'll break this up into two PRs and use the navigational menubar as an example for the inline-css option instead.

@spectranaut spectranaut marked this pull request as ready for review December 2, 2020 19:35
examples/js/examples.js Outdated Show resolved Hide resolved
Copy link
Contributor

@carmacleod carmacleod left a comment

Choose a reason for hiding this comment

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

+1
Very nice, @spectranaut !
The mute off/on icons look great in both CodePen and High Contrast Mode (Black and White - tested in Edge).

@mcking65
Copy link
Contributor

@spectranaut
Now we have this new feature in examples.js that uses the idsvg_definitions to effect display of the HTML source. How can we enforce consistency in its use? Would it be possible to have a lint rule that can identify when it should be used?

@mcking65 mcking65 changed the title Open in Codepen: Inlining SVG in CSS and inlining in HTML using SVG "def"s Button Examples: Add Open in Codepen and inline SVG in HTML using SVG "def"s Dec 13, 2020
@mcking65 mcking65 added enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy Infrastructure Related to maintaining task force and repo operations, processes, systems, documentation labels Dec 13, 2020
@mcking65 mcking65 added this to the 1.2 Release 1 milestone Dec 13, 2020
@mcking65 mcking65 added Example Page Related to a page containing an example implementation of a pattern and removed Infrastructure Related to maintaining task force and repo operations, processes, systems, documentation labels Dec 13, 2020
@mcking65 mcking65 merged commit b034ccd into master Dec 13, 2020
@mcking65 mcking65 deleted the SVG-define branch December 13, 2020 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy Example Page Related to a page containing an example implementation of a pattern
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants