From c5257f90e1b555b458a98d9f518d4cd7f8c95a8c Mon Sep 17 00:00:00 2001 From: Shawn Date: Wed, 14 Nov 2018 18:54:30 -0600 Subject: [PATCH] Fix flex/dimensions, begin adding toolbar --- client/src/components/Creatify/index.js | 32 +++++++++++++++++++++---- client/src/containers/Dropzone/view.jsx | 13 ++++------ package.json | 3 +++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/client/src/components/Creatify/index.js b/client/src/components/Creatify/index.js index 867183f0..c1ea9e4b 100644 --- a/client/src/components/Creatify/index.js +++ b/client/src/components/Creatify/index.js @@ -1,9 +1,17 @@ +import { library } from '@fortawesome/fontawesome-svg-core' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' + import React, { Component } from 'react'; import Select from 'react-select' import RichDraggable from './RichDraggable'; import EditableFontface, { PRESETS as FontPresets } from './EditableFontface'; +import { + faFont +} from '@fortawesome/free-solid-svg-icons' +library.add(faFont); + const getRasterizedCanvas = (contents, width, height) => { return new Promise((resolve) => { // Parse to xHTML for SVG/foreignObject rendering @@ -102,22 +110,36 @@ export default class Creatify extends Component { } componentDidMount() { + // TODO: Fix bounds + /* const bounds = this.contents.current.getBoundingClientRect(); this.setState({ bounds, }); + + console.log({ + bounds + }) + */ } renderContents() { const me = this; - let contents = me.contents.current.outerHTML; + const contentsElement = me.contents.current; + let contents = contentsElement.outerHTML; // Cheap border/handles removal contents = `` + contents; - getRasterizedCanvas(contents, 600, 500).then((element) => { + const contentsWidth = contentsElement.offsetWidth; + const contentsHeight = contentsElement.offsetHeight; + + // Fix the dimensions, fixes when flex is used. + contents = `
${contents}
`; + + getRasterizedCanvas(contents, contentsWidth, contentsHeight).then((element) => { document.body.appendChild(element); }); } @@ -130,12 +152,12 @@ export default class Creatify extends Component { } = this; return ( -
-
+
+