summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2021-03-16 14:43:00 +0100
committerJules Laplace <julescarbon@gmail.com>2021-03-16 14:43:00 +0100
commit6e18c6e4ef6344f92fed99dad9c83484487c32d7 (patch)
tree03bd8a0be46d4bc8ce1a0bf06cff5fbab5f9c8a0
parent35a5ebebc2e3c3535cbef00fab08b5fe43bebe85 (diff)
add units to links
-rw-r--r--frontend/app/views/graph/graph.css2
-rw-r--r--frontend/app/views/page/components/page.editor.js4
-rw-r--r--frontend/app/views/page/components/tile.form.js12
-rw-r--r--frontend/app/views/page/components/tile.handle.js23
4 files changed, 31 insertions, 10 deletions
diff --git a/frontend/app/views/graph/graph.css b/frontend/app/views/graph/graph.css
index 389a55d..2805cb0 100644
--- a/frontend/app/views/graph/graph.css
+++ b/frontend/app/views/graph/graph.css
@@ -156,7 +156,7 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
- max-width: 8rem;
+ max-width: 12rem;
user-select: none;
cursor: arrow;
}
diff --git a/frontend/app/views/page/components/page.editor.js b/frontend/app/views/page/components/page.editor.js
index 25342d2..7f6182d 100644
--- a/frontend/app/views/page/components/page.editor.js
+++ b/frontend/app/views/page/components/page.editor.js
@@ -159,7 +159,7 @@ class PageEditor extends Component {
}
}
- render(){
+ render() {
if (!this.state.bounds || (!this.props.page.show.res && !this.props.page.show.res.tiles)) {
return (
<div className='page' ref={this.pageRef} />
@@ -173,7 +173,7 @@ class PageEditor extends Component {
const pageStyle = { backgroundColor: settings ? settings.background_color : '#000000' }
return (
<div className='page' ref={this.pageRef} style={pageStyle}>
- {res.tiles.map(tile => {
+ {res.tiles && res.tiles.map(tile => {
if (temporaryTile && temporaryTile.id === tile.id) {
tile = temporaryTile
}
diff --git a/frontend/app/views/page/components/tile.form.js b/frontend/app/views/page/components/tile.form.js
index a9f34a7..3e31758 100644
--- a/frontend/app/views/page/components/tile.form.js
+++ b/frontend/app/views/page/components/tile.form.js
@@ -113,6 +113,7 @@ const newText = (data) => ({
background_color: 'transparent',
width: 0,
height: 0,
+ units: 'px',
external_link_url: "",
cursor: 'hand_up',
},
@@ -126,6 +127,7 @@ const newLink = (data) => ({
...newPosition({ width: 100, height: 100, }),
external_link_url: "",
cursor: 'hand_up',
+ units: 'px',
},
type: 'link',
target_page_id: null,
@@ -662,6 +664,16 @@ class TileForm extends Component {
autoComplete="off"
/>
</div>
+ <div className='row pair'>
+ <TextInput
+ title="Units"
+ name="units"
+ data={temporaryTile.settings}
+ error={errorFields.has('units')}
+ onChange={this.handleSettingsChange.bind(this)}
+ autoComplete="off"
+ />
+ </div>
</div>
)
}
diff --git a/frontend/app/views/page/components/tile.handle.js b/frontend/app/views/page/components/tile.handle.js
index 993acce..9331cb3 100644
--- a/frontend/app/views/page/components/tile.handle.js
+++ b/frontend/app/views/page/components/tile.handle.js
@@ -68,8 +68,8 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
}
content = <span dangerouslySetInnerHTML={{ __html: tile.settings.content }} />
className += ' ' + tile.settings.align
- style.width = tile.settings.width ? tile.settings.width + 'px' : 'auto'
- style.height = tile.settings.height ? tile.settings.height + 'px' : 'auto'
+ style.width = unitsDimension(tile, 'width')
+ style.height = unitsDimension(tile, 'height')
style.fontFamily = tile.settings.font_family
style.fontSize = tile.settings.font_size + 'px'
style.lineHeight = 1.5
@@ -82,8 +82,8 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
case 'link':
content = ""
className += ' ' + tile.settings.align
- style.width = tile.settings.width ? tile.settings.width + 'px' : 'auto'
- style.height = tile.settings.height ? tile.settings.height + 'px' : 'auto'
+ style.width = unitsDimension(tile, 'width')
+ style.height = unitsDimension(tile, 'height')
break
case 'script':
@@ -134,7 +134,7 @@ const TileHandle = ({ tile, bounds, box, viewing, onMouseDown, onDoubleClick })
}
const generateTransform = (tile, box) => {
- let { x, y, align, rotation, scale, is_tiled } = tile.settings
+ let { x, y, align, rotation, scale, units, is_tiled } = tile.settings
if (is_tiled) {
return 'translateZ(0)'
}
@@ -142,6 +142,7 @@ const generateTransform = (tile, box) => {
x += box.dx
y += box.dy
}
+ units = units || 'px'
const [yalign, xalign] = align.split('_')
let transform = ['translateZ(0)']
if (yalign === 'center') {
@@ -150,10 +151,11 @@ const generateTransform = (tile, box) => {
if (xalign === 'center') {
transform.push('translateX(-50%)')
}
+ console.log(units)
// if (x % 2 == 1) x += 0.5
// if (y % 2 == 1) y += 0.5
- transform.push('translateX(' + x + 'px)')
- transform.push('translateY(' + y + 'px)')
+ transform.push('translateX(' + x + units + ')')
+ transform.push('translateY(' + y + units + ')')
if (scale !== 1) {
transform.push('scale(' + scale + ')')
}
@@ -195,4 +197,11 @@ const generateVideoStyle = (tile, bounds) => {
return style
}
+const unitsDimension = (tile, dimension) => {
+ const value = tile.settings[dimension]
+ if (!value) return "auto"
+ if (tile.settings.units) return value + tile.settings.units
+ return value + "px"
+}
+
export default TileHandle