1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/svg-notifications.md

39 lines
1.2 KiB
Markdown
Raw Normal View History

Chrome notifications allow you to show an SVG image via a data-uri
Taking advantage of this might allow us to show nicely formatted notifications
build a template using pure svg:
2016-06-04 21:32:54 +02:00
```svg
<svg xmlns='http://www.w3.org/2000/svg'
width='1000px' height='500px' viewBox='0 0 200 100'>
<rect x='0' y='0' width='100%' height='100%' fill='white' />
<text x='0' y='20' font-family='monospace' font-size='6' fill='black'>
<tspan x='0' dy='1.2em'>Domain: https://boardroom.to</tspan>
<tspan x='0' dy='1.2em'>From: 0xabcdef</tspan>
<tspan x='0' dy='1.2em'>To: 0xfedcba</tspan>
<tspan x='0' dy='1.2em'>Value: 1.025 Ether</tspan>
<tspan x='0' dy='1.2em'>Gas: 0.025 Ether</tspan>
</text>
</svg>
2016-06-04 21:31:15 +02:00
```
2016-06-04 21:32:31 +02:00
generate uri
`'data:image/svg+xml;charset=utf-8,'+encodeURIComponent(svgSrc)`
or svg-embedded html:
2016-06-04 21:32:54 +02:00
```svg
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="500">
<rect x='0' y='0' width='100%' height='100%' fill='white' />
<foreignObject class="node" x="46" y="22" width="200" height="300">
<body xmlns="http://www.w3.org/1999/xhtml">
<div style="font-size: 120px">
The quick brown fox jumps over the lazy dog.
Pack my box with five dozen liquor jugs
</div>
</body>
</foreignObject>
2016-06-04 21:31:15 +02:00
</svg>
```