From 70e0da6ced5e9653b2dc7cdd3811c91a64ba3ed6 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sat, 18 Jun 2022 18:15:17 +0200 Subject: [PATCH] feat(lab): More dev info on Xray mode --- .../components/workbench/draft/part/index.js | 18 +++- .../components/workbench/draft/path/index.js | 87 ++++++++++-------- .../components/workbench/draft/point/index.js | 50 +++++----- .../workbench/draft/snippet/index.js | 52 ++++++++++- .../workbench/draft/text-on-path/index.js | 23 ++++- .../components/workbench/draft/text/index.js | 92 ++++++++++++++++--- 6 files changed, 245 insertions(+), 77 deletions(-) diff --git a/sites/shared/components/workbench/draft/part/index.js b/sites/shared/components/workbench/draft/part/index.js index 2aec3ae500a..43cb0c3266d 100644 --- a/sites/shared/components/workbench/draft/part/index.js +++ b/sites/shared/components/workbench/draft/part/index.js @@ -62,18 +62,32 @@ const partInfo = (props) => { +
{props.gist?.only && props.gist.only.length > 0 ? ( ) : ( )} + + + +
) } diff --git a/sites/shared/components/workbench/draft/path/index.js b/sites/shared/components/workbench/draft/path/index.js index 32f21740930..0d136191323 100644 --- a/sites/shared/components/workbench/draft/path/index.js +++ b/sites/shared/components/workbench/draft/path/index.js @@ -330,49 +330,61 @@ export const Attributes = ({ list }) => list ) : null -const pathInfo = (props) => { +export const pathInfo = (props) => { const bbox = props.path.boundary() return (
Path info
- - - - Name - {bbox.name} - - - Length - {round(props.path.length(), 2)}mm - - - Width - {round(bbox.bottomRight.x - bbox.topLeft.x, 2)}mm - - - Height - {round(bbox.bottomRight.y - bbox.topLeft.y, 2)}mm - - - Top Left - {pointCoords(bbox.topLeft)} - - - Bottom Right - {pointCoords(bbox.bottomRight)} - - - Part - {props.partName} - - - Attributes - - - -
+
+ + + + Name + {bbox.name} + + + Length + {round(props.path.length(), 2)}mm + + + Width + {round(bbox.bottomRight.x - bbox.topLeft.x, 2)}mm + + + Height + {round(bbox.bottomRight.y - bbox.topLeft.y, 2)}mm + + + Top Left + {pointCoords(bbox.topLeft)} + + + Bottom Right + {pointCoords(bbox.bottomRight)} + + + Part + {props.partName} + + + Attributes + + + +
+
+ + +
+
{props.path.ops.map((op, i) => ( @@ -438,6 +450,7 @@ const XrayPath = props => { {...getProps(props.path)} className="opacity-0 stroke-7xl stroke-contrast hover:opacity-25 hover:cursor-pointer" onClick={(evt) => { evt.preventDefault(); props.showInfo(pathInfo(props)) }} + markerStart="none" markerEnd="none" /> {ops.length > 0 ? ops.map((op,i) => (op.ops[1].type === 'curve') diff --git a/sites/shared/components/workbench/draft/point/index.js b/sites/shared/components/workbench/draft/point/index.js index 2110c8dd61a..1c6a5a4bf80 100644 --- a/sites/shared/components/workbench/draft/point/index.js +++ b/sites/shared/components/workbench/draft/point/index.js @@ -29,27 +29,35 @@ const pointInfo = (props) => props.point ? (
Point info
-
-
- - - Coordinates - {pointCoords(props.point)} - - - Name - {props.pointName} - - - Part - {props.partName} - - - Attributes - - - -
+ + + + Coordinates + {pointCoords(props.point)} + + + Name + {props.pointName} + + + Part + {props.partName} + + + Attributes + + + +
+
+ +
) : null diff --git a/sites/shared/components/workbench/draft/snippet/index.js b/sites/shared/components/workbench/draft/snippet/index.js index 1d1fd0b1627..2c6f1ea9e6f 100644 --- a/sites/shared/components/workbench/draft/snippet/index.js +++ b/sites/shared/components/workbench/draft/snippet/index.js @@ -1,5 +1,49 @@ import React from 'react' import { getProps } from '../utils' +import { Tr, KeyTd, ValTd, Attributes, pointCoords } from '../path/index' + +const snippetInfo = (props) => { +console.log(props.snippet) + return ( +
+
Snippet info
+ + + + Def + {props.snippet.def} + + + Anchor + {props.snippet.anchor.name} + + + Coords + {pointCoords(props.snippet.anchor)} + + + Coords + {pointCoords(props.snippet.anchor)} + + + Attributes + + + +
+
+ + +
+
+ ) +} const Snippet = (props) => { const snippetProps = { @@ -21,7 +65,13 @@ const Snippet = (props) => { } } - return + return { evt.stopPropagation(); props.showInfo(snippetInfo(props)) }} + /> } export default Snippet diff --git a/sites/shared/components/workbench/draft/text-on-path/index.js b/sites/shared/components/workbench/draft/text-on-path/index.js index 9714cfb95b5..7d80cbd0375 100644 --- a/sites/shared/components/workbench/draft/text-on-path/index.js +++ b/sites/shared/components/workbench/draft/text-on-path/index.js @@ -1,4 +1,15 @@ import { useTranslation } from 'next-i18next' +import { pathInfo } from '../path/index' + +const XrayTextOnPath = props => ( + { evt.stopPropagation(); props.showInfo(pathInfo(props)) }} + /> +) const TextOnPath = (props) => { const { t } = useTranslation(['app']) @@ -16,14 +27,18 @@ const TextOnPath = (props) => { if (align && align.indexOf('center') > -1) textPathProps.startOffset = '50%' else if (align && align.indexOf('right') > -1) textPathProps.startOffset = '100%' + const attr = props.path.attributes.asPropsIfPrefixIs('data-text-') + return ( - + + {props.gist._state?.xray?.enabled && ( + + + + )} ) } diff --git a/sites/shared/components/workbench/draft/text/index.js b/sites/shared/components/workbench/draft/text/index.js index 7671e38e2b1..a64547e7793 100644 --- a/sites/shared/components/workbench/draft/text/index.js +++ b/sites/shared/components/workbench/draft/text/index.js @@ -1,11 +1,63 @@ import { useTranslation } from 'next-i18next' +import { Tr, KeyTd, ValTd, Attributes, pointCoords } from '../path/index' -const Text = (props) => { +const textInfo = (props) => props.point + ? ( +
+
Text info
+ + + + Coordinates + {pointCoords(props.point)} + + + Name + {props.pointName} + + + Part + {props.partName} + + + Attributes + + + +
+
+ + +
+
+ ) : null + +const XrayText = props => ( + + { evt.stopPropagation(); props.showInfo(textInfo(props)) }} + /> + +) + +const TextSpans = ({ point, className='', style={}, onClick=null }) => { const { t } = useTranslation(['app']) let text = [] // Handle translation let translated = '' - for (let string of props.point.attributes.getAsArray('data-text')) { + for (let string of point.attributes.getAsArray('data-text')) { translated += t(string.toString()).replace(/"/g, '"') + ' ' } // Handle muti-line text @@ -18,23 +70,39 @@ const Text = (props) => { text.push( {line.toString().replace(/"/g, '"')} ) } - } else text.push({translated}) + } else text.push({translated}) + + return text + +} + +const Text = (props) => { + const attr = props.point.attributes.asPropsIfPrefixIs('data-text-') return ( - - {text} - + <> + + + + {props.gist._state?.xray?.enabled && } + ) }