Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Patrik Meijer
react-components
Commits
8b06e02f
Commit
8b06e02f
authored
Nov 21, 2018
by
Patrik Meijer
Browse files
Move svg handling to utils/getSVGData
parent
01911292
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/components/PartBrowser/PartBrowser.jsx
View file @
8b06e02f
...
...
@@ -16,7 +16,7 @@ import {treeBeardTheme, getTreeDecorators} from './TreeOverrides';
import
PartBrowserItem
from
'
./PartBrowserItem
'
;
import
PartBrowserDragPreview
from
'
./PartBrowserDragPreview
'
;
import
defaultSVG
from
'
../../utils/
defaultSVG
'
;
import
getSVGData
from
'
../../utils/
getSVGData
'
;
const
TREE_PATH_SEP
=
'
$
'
;
const
EXPAND_ALL
=
false
;
...
...
@@ -120,7 +120,7 @@ class PartBrowser extends SingleConnectedNode {
id
:
metaNode
.
getId
(),
name
:
getTitle
(
metaNode
),
treePath
:
getTreePath
(
metaNode
),
svg
:
defaultSVG
,
svg
:
getSVGData
(
metaNode
)
,
};
});
...
...
src/components/PartBrowser/PartBrowserDragPreview.jsx
View file @
8b06e02f
...
...
@@ -5,7 +5,7 @@ import {DragLayer} from 'react-dnd';
// noinspection JSUnresolvedVariable
import
{
Samy
}
from
'
react-samy-svg
'
;
import
DRAG_TYPES
from
'
../../utils/dragTypes
'
;
import
defaultSVG
from
'
../../utils/
defaultSVG
'
;
import
getSVGData
from
'
../../utils/
getSVGData
'
;
// DragLayer
function
collect
(
monitor
)
{
...
...
@@ -53,7 +53,7 @@ class PartBrowserDragPreview extends Component {
const
{
x
,
y
}
=
{
x
:
currentOffset
.
x
-
initialOffset
.
x
,
y
:
currentOffset
.
y
-
initialOffset
.
y
};
const
transform
=
`translate(
${
x
}
px,
${
y
}
px)`
;
const
{
base
,
bbox
}
=
defaultSVG
;
const
{
base
,
bbox
}
=
item
.
nodeData
.
svg
;
return
(
<
Samy
...
...
src/components/SVGRegistryBasedCanvasItem/SVGRegistryBasedCanvasItem.jsx
View file @
8b06e02f
...
...
@@ -13,7 +13,7 @@ import SVGRegistryBasedCanvasItemPort from './SVGRegistryBasedCanvasItemPort';
import
Territory
from
'
../Territory/Territory
'
;
import
BasicConnection
from
'
../BasicConnection/BasicConnection
'
;
import
Z_LEVELS
from
'
../../utils/zLevels
'
;
import
defaultSVG
from
'
../../utils/
defaultSVG
'
;
import
getSVGData
from
'
../../utils/
getSVGData
'
;
const
canvasItemSource
=
{
beginDrag
(
props
)
{
...
...
@@ -62,7 +62,7 @@ class SVGRegistryBasedCanvasItem extends Component {
state
=
{
position
:
null
,
showActions
:
false
,
svg
:
defaultSVG
,
svg
:
getSVGData
()
,
childrenName2Id
:
{},
childInfo
:
{},
isConnection
:
null
,
...
...
@@ -224,7 +224,7 @@ class SVGRegistryBasedCanvasItem extends Component {
this
.
setState
({
position
:
null
,
showActions
:
false
,
svg
:
defaultSVG
,
svg
:
getSVGData
()
,
childrenName2Id
:
{},
childInfo
:
{},
isConnection
:
null
,
...
...
@@ -303,13 +303,7 @@ class SVGRegistryBasedCanvasItem extends Component {
territory
[
activeNode
]
=
{
children
:
1
};
}
const
newSvg
=
{
base
:
nodeObj
.
getRegistry
(
'
SVGIcon
'
)
||
defaultSVG
.
base
,
bbox
:
nodeObj
.
getRegistry
(
'
SVGBbox
'
)
||
defaultSVG
.
bbox
,
ports
:
nodeObj
.
getRegistry
(
'
SVGPorts
'
)
||
defaultSVG
.
ports
,
attributes
:
nodeObj
.
getRegistry
(
'
SVGAttributes
'
)
||
defaultSVG
.
attributes
,
// TODO probably would be better to move towards ejs
};
const
newSvg
=
getSVGData
(
nodeObj
);
this
.
setState
({
position
:
nodeObj
.
getRegistry
(
'
position
'
),
...
...
src/utils/getSVGData.jsx
0 → 100644
View file @
8b06e02f
import
defaultSVG
from
'
./defaultSVG
'
;
const
getSVGData
=
(
nodeObj
)
=>
{
if
(
nodeObj
)
{
return
{
base
:
nodeObj
.
getRegistry
(
'
SVGIcon
'
)
||
defaultSVG
.
base
,
bbox
:
nodeObj
.
getRegistry
(
'
SVGBbox
'
)
||
defaultSVG
.
bbox
,
ports
:
nodeObj
.
getRegistry
(
'
SVGPorts
'
)
||
defaultSVG
.
ports
,
attributes
:
nodeObj
.
getRegistry
(
'
SVGAttributes
'
)
||
defaultSVG
.
attributes
,
};
}
return
defaultSVG
;
};
export
default
getSVGData
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment