Skip to content

Commit fa38711

Browse files
committed
github pages
1 parent f988d6e commit fa38711

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

gh-pages/sandbox-svg.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>sandbox-svg</title>
5+
<style>
6+
body {
7+
background: #eee;
8+
padding: 0;
9+
margin: 0;
10+
}
11+
object {
12+
transform-origin: top left;
13+
}
14+
</style>
15+
</head>
16+
17+
<body>
18+
<object type="image/svg+xml" data=""></object>
19+
<script>
20+
// retrieving the OBJKT URL
21+
const src = new URLSearchParams(location.search).get('src')
22+
const obj = document.querySelector('object')
23+
24+
// Keep the OBJKT centered
25+
const resize = () => {
26+
const scaleX = innerWidth / obj.offsetHeight
27+
const scaleY = innerHeight / obj.offsetHeight
28+
const scale = Math.min(scaleX, scaleY)
29+
obj.style.transform = `scale(${scale})`
30+
obj.style.marginLeft = `${
31+
(innerWidth - obj.offsetHeight * scale) / 2
32+
}px`
33+
obj.style.marginTop = `${
34+
(innerHeight - obj.offsetHeight * scale) / 2
35+
}px`
36+
}
37+
38+
obj.addEventListener('load', function () {
39+
resize()
40+
setTimeout(resize, 100)
41+
})
42+
obj.setAttribute('data', src)
43+
addEventListener('resize', resize)
44+
</script>
45+
</body>
46+
</html>

src/components/media-types/vector/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export const VectorComponent = ({ src, interactive, token_info }) => {
1010
[styles.interactive]: interactive,
1111
})
1212

13-
let _author_ = false
13+
let _creator_ = false
1414
let _viewer_ = false
1515

1616
if (token_info && token_info.creators[0]) {
17-
_author_ = token_info.creators[0]
17+
_creator_ = token_info.creators[0]
1818
}
1919

2020
if (context.address !== '') {
@@ -25,10 +25,11 @@ export const VectorComponent = ({ src, interactive, token_info }) => {
2525
<div className={classes}>
2626
<iframe
2727
title="hic et nunc SVG renderer"
28-
src={`${src}?author=${_author_}&viewer=${_viewer_}`}
28+
src={`https://hicetnunc2000.github.io/hicetnunc/gh-pages/sandbox-svg.html?src=${src}&creator=${_creator_}&viewer=${_viewer_}`}
2929
sandbox="allow-scripts"
3030
scrolling="no"
3131
/>
3232
</div>
3333
)
3434
}
35+
// old: src={`${src}?author=${_creator_}&viewer=${_viewer_}`}

0 commit comments

Comments
 (0)