chiark / gitweb /
css: make it possible to style <svg> as .m-image
authorVladimír Vondruš <mosra@centrum.cz>
Mon, 1 Jan 2018 17:45:30 +0000 (18:45 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Mon, 1 Jan 2018 17:46:50 +0000 (18:46 +0100)
css/m-components.css
doc/css/components-test.rst
doc/css/components.rst

index 2453d358a38ef1fe8bc176edbd1f9ebd18813805..62770e1e10c04c6261968747cec9709747c2b308 100644 (file)
@@ -983,7 +983,7 @@ a.m-button.m-dim:hover, a.m-button.m-dim:focus, a.m-button.m-dim:active {
 }
 
 /* Image */
-img.m-image {
+img.m-image, svg.m-image {
   display: block;
   margin-left: auto;
   margin-right: auto;
@@ -991,11 +991,11 @@ img.m-image {
 div.m-image {
   text-align: center;
 }
-img.m-image, div.m-image img {
+img.m-image, svg.m-image, div.m-image img {
   max-width: 100%;
   border-radius: var(--border-radius);
 }
-div.m-image.m-fullwidth img {
+div.m-image.m-fullwidth img, div.m-image.m-fullwidth svg {
   width: 100%;
 }
 
@@ -1348,7 +1348,7 @@ div.m-math.m-dim svg, svg.m-math.m-dim { fill: var(--dim-color); }
 p, ul, ol, dl, blockquote, pre, figure.m-code-figure, figure.m-console-figure,
 hr, article, article > header, article section,
 .m-note, .m-frame, .m-block, .m-button,
-div.m-scroll, table.m-table, div.m-image, img.m-image,
+div.m-scroll, table.m-table, div.m-image, img.m-image, svg.m-image,
 figure.m-figure, .m-imagegrid, div.m-math {
   margin-bottom: 1rem;
 }
@@ -1356,8 +1356,9 @@ p:last-child, ul:last-child, ol:last-child, dl:last-child, blockquote:last-child
 pre:last-child, figure.m-code-figure:last-child, figure.m-console-figure:last-child,
 hr:last-child, article:last-child, article section:last-child,
 .m-note:last-child, .m-frame:last-child, .m-block:last-child, .m-button:last-child,
-table.m-table:last-child, img.m-image:last-child, div.m-image:last-child,
-figure.m-figure:last-child, .m-imagegrid:last-child, div.m-math:last-child {
+table.m-table:last-child, img.m-image:last-child, svg.m-image:last-child,
+div.m-image:last-child, figure.m-figure:last-child, .m-imagegrid:last-child,
+div.m-math:last-child {
   margin-bottom: 0;
 }
 
@@ -1368,17 +1369,18 @@ li > p:last-child, li > blockquote:last-child, li > pre:last-child,
 li > figure.m-code-figure:last-child, li > figure.m-console-figure:last-child,
 li > .m-note:last-child, li > .m-frame:last-child, li > .m-block:last-child,
 li > .m-button:last-child, li > div.m-scroll:last-child,
-li > table.m-table:last-child, li > div.m-image:last-child,
-li > img.m-image:last-child, li > figure.m-figure:last-child,
-li > div.m-math:last-child {
+li > table.m-table:last-child,
+li > img.m-image:last-child, li > svg.m-image:last-child, li > div.m-image:last-child,
+li > figure.m-figure:last-child, li > div.m-math:last-child {
   margin-bottom: 1rem;
 }
 li:last-child > p:last-child, li:last-child > blockquote:last-child, li:last-child > pre:last-child,
 li:last-child > figure.m-code-figure:last-child, li:last-child > figure.m-console-figure:last-child,
 li:last-child > .m-note:last-child, li:last-child > .m-frame:last-child, li:last-child > .m-block:last-child,
 li:last-child > .m-button:last-child, li:last-child > div.m-scroll:last-child,
-li:last-child > table.m-table:last-child, li:last-child > div.m-image:last-child,
-li:last-child > img.m-image:last-child, li:last-child > figure.m-figure:last-child,
+li:last-child > table.m-table:last-child,
+li:last-child > img.m-image:last-child, li:last-child > svg.m-image:last-child,
+li:last-child > div.m-image:last-child, li:last-child > figure.m-figure:last-child,
 li:last-child > div.m-math:last-child {
   margin-bottom: 0;
 }
index 5807edf61eb8d03d7eb78c9400ea68784556b3a9..a7057e5f701c021761beeffeeda025f674cd16c3 100644 (file)
@@ -812,6 +812,34 @@ Image, fullwidth, link (yes, it should be pixelated):
       <a href="http://blog.mosra.cz/"><img src="{filename}/static/flowers-small.jpg" /></a>
     </div>
 
+SVG image:
+
+.. raw:: html
+
+    <svg class="m-image" width="80" height="80">
+      <text x="16" y="40" style="text-anchor: middle; fill: #ff0000">Hello</text>
+    </svg>
+
+SVG image, fullwidth, with link inside:
+
+.. raw:: html
+
+    <svg width="80" height="80" class="m-image m-fullwidth">
+      <a xlink:href="#"><text x="16" y="40" style="text-anchor: middle; fill: #ff0000">Hello</text></a>
+    </svg>
+
+SVG image, fullwidth, with link outside:
+
+.. raw:: html
+
+    <div class="m-image m-fullwidth">
+      <a href="#">
+        <svg width="80" height="80">
+          <text x="16" y="40" style="text-anchor: middle; fill: #ff0000">Hello</text>
+        </svg>
+      </a>
+    </div>
+
 Figures
 =======
 
index 4b3e254a3ddb9f4f2839d5abd24e249e5b7f9412..12bbd26b848585f8364bd0c76122b35992564904 100644 (file)
@@ -598,10 +598,10 @@ justified.
 `Images`_
 =========
 
-Putting :css:`.m-image` class onto the :html:`<img>` tag makes it centered,
-slightly rounded and sets its max width to 100%. Adding :css:`.m-fullwidth` on
-the image element works as expected. For accessibility reasons it's a good
-practice to include the ``alt`` attribute.
+Putting :css:`.m-image` class onto an :html:`<img>` / :html:`<svg>` tag makes
+the image centered, slightly rounded and sets its max width to 100%. Adding
+:css:`.m-fullwidth` on the image element works as expected. For accessibility
+reasons it's a good practice to include the ``alt`` attribute.
 
 .. code-figure::