Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
fix(icons): use title from SVG file
Browse files Browse the repository at this point in the history
  • Loading branch information
rofe committed Nov 11, 2019
1 parent a800f98 commit 5fe3fe4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/utils/icon-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/**
* Handles `icon` MDAST nodes by converting them into `<svg>` tags, e.g.
* `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"><title>smile</title></use></svg>`
* `<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"></use></svg>`
* @param {string} id the identifier of the icon
*/
function icon() {
Expand All @@ -23,10 +23,7 @@ function icon() {
className: `icon icon-${value}`,
}, [h(node, 'use', {
href: `/icons/${value}.svg`,
}, [h(node, 'title', null, [{
type: 'text',
value,
}])])])];
})])];
};
}

Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/icon-example.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html><head></head><body><h1 id="the-helix-pipeline-supports-icons-now">The <strong>Helix</strong> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-pipeline"><use href="/icons/pipeline.svg"><title>pipeline</title></use></svg> supports icons now</h1>
<p>This <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tada"><use href="/icons/tada.svg"><title>tada</title></use></svg> will render as an icon. <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-thumbsup"><use href="/icons/thumbsup.svg"><title>thumbsup</title></use></svg></p>
<p>I said: this is cool. There are smiles :) - even <strong>big <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smiles"><use href="/icons/smiles.svg"><title>smiles</title></use></svg></strong> and <a href="http://www.example.com/"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-foo"><use href="/icons/foo.svg"><title>foo</title></use></svg></a></p>
<p>:: smile <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"><title>smile</title></use></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"><title>smile</title></use></svg>:<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"><title>smile</title></use></svg>::<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"><title>smile</title></use></svg></p>
<html><head></head><body><h1 id="the-helix-pipeline-supports-icons-now">The <strong>Helix</strong> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-pipeline"><use href="/icons/pipeline.svg"></use></svg> supports icons now</h1>
<p>This <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tada"><use href="/icons/tada.svg"></use></svg> will render as an icon. <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-thumbsup"><use href="/icons/thumbsup.svg"></use></svg></p>
<p>I said: this is cool. There are smiles :) - even <strong>big <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smiles"><use href="/icons/smiles.svg"></use></svg></strong> and <a href="http://www.example.com/"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-foo"><use href="/icons/foo.svg"></use></svg></a></p>
<p>:: smile <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"></use></svg><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"></use></svg>:<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"></use></svg>::<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-smile"><use href="/icons/smile.svg"></use></svg></p>
<pre><code class="language-javascript">console.log('this is in a :code: block');
</code></pre>
<p><code>this is inline :code:</code></p></body></html>

0 comments on commit 5fe3fe4

Please sign in to comment.