wip(lab): Progess on Xray for points and paths
This commit is contained in:
parent
3f01f67087
commit
e5df2a5ab8
6 changed files with 203 additions and 28 deletions
|
@ -12,6 +12,16 @@ export const Details = props => (
|
||||||
</details>
|
</details>
|
||||||
)
|
)
|
||||||
export const Deg = props => <span className="text-3xl inline-block p-0 leading-3 px-2 translate-y-3">°</span>
|
export const Deg = props => <span className="text-3xl inline-block p-0 leading-3 px-2 translate-y-3">°</span>
|
||||||
|
export const NoSumDiv = props => (
|
||||||
|
<div className={`
|
||||||
|
grow px-2 ml-2 border-l-2
|
||||||
|
${linkClasses}
|
||||||
|
hover:cursor-resize
|
||||||
|
hover:border-secondary
|
||||||
|
sm:hover:border-secondary-focus
|
||||||
|
text-base-content sm:text-neutral-content
|
||||||
|
`}>{props.children}</div>
|
||||||
|
)
|
||||||
export const SumDiv = props => (
|
export const SumDiv = props => (
|
||||||
<div className={`
|
<div className={`
|
||||||
grow pl-2 border-l-2
|
grow pl-2 border-l-2
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
import { Chevron } from 'shared/components/navigation/primary.js'
|
||||||
|
import { Ul, Li, Details, Summary, SumDiv, NoSumDiv, Deg } from 'shared/components/workbench/menu'
|
||||||
|
import { round } from 'shared/utils.js'
|
||||||
|
|
||||||
|
const XrayAttributes = ({ attr=false }) => {
|
||||||
|
if (!attr || !attr.list || Object.keys(attr.list).length < 1) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Li>
|
||||||
|
<Details>
|
||||||
|
<Summary>
|
||||||
|
<SumDiv>
|
||||||
|
<Deg />
|
||||||
|
Attributes
|
||||||
|
</SumDiv>
|
||||||
|
<Chevron />
|
||||||
|
</Summary>
|
||||||
|
<Ul>
|
||||||
|
{Object.keys(attr.list).map(at => (
|
||||||
|
<Li>
|
||||||
|
<Details>
|
||||||
|
<Summary>
|
||||||
|
<SumDiv>
|
||||||
|
<Deg />
|
||||||
|
{at}
|
||||||
|
</SumDiv>
|
||||||
|
<Chevron />
|
||||||
|
</Summary>
|
||||||
|
<Ul>
|
||||||
|
{attr.list[at].map(val => (
|
||||||
|
<Li key={val}>
|
||||||
|
<NoSumDiv>
|
||||||
|
<Deg />
|
||||||
|
<span>{val}</span>
|
||||||
|
</NoSumDiv>
|
||||||
|
</Li>
|
||||||
|
))}
|
||||||
|
</Ul>
|
||||||
|
</Details>
|
||||||
|
</Li>
|
||||||
|
))}
|
||||||
|
</Ul>
|
||||||
|
</Details>
|
||||||
|
</Li>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default XrayAttributes
|
|
@ -14,6 +14,8 @@ const XrayList = props => {
|
||||||
let title = props.app.t(`parts.${props.partName}`)
|
let title = props.app.t(`parts.${props.partName}`)
|
||||||
if (title !== props.partName || true) title + ` (${props.partName})`
|
if (title !== props.partName || true) title + ` (${props.partName})`
|
||||||
|
|
||||||
|
const part = props.gist.xray.parts[props.partName]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Li>
|
<Li>
|
||||||
<Details>
|
<Details>
|
||||||
|
@ -31,7 +33,7 @@ const XrayList = props => {
|
||||||
</button>
|
</button>
|
||||||
<Chevron w={6} m={3}/>
|
<Chevron w={6} m={3}/>
|
||||||
</Summary>
|
</Summary>
|
||||||
{Object.keys(types).map(type => props.gist.xray.parts[props.partName][type] && (
|
{Object.keys(types).map(type => part[type] && (
|
||||||
<Ul>
|
<Ul>
|
||||||
<Li>
|
<Li>
|
||||||
<Details>
|
<Details>
|
||||||
|
@ -39,8 +41,16 @@ const XrayList = props => {
|
||||||
<SumDiv>
|
<SumDiv>
|
||||||
<span className="capitalize">{type}</span>
|
<span className="capitalize">{type}</span>
|
||||||
</SumDiv>
|
</SumDiv>
|
||||||
|
<button
|
||||||
|
className="text-accent px-3 hover:text-secondary-focus"
|
||||||
|
onClick={() => props.unsetGist(['xray', 'parts', props.partName, type])}
|
||||||
|
>
|
||||||
|
<ClearIcon />
|
||||||
|
</button>
|
||||||
|
<Chevron />
|
||||||
</Summary>
|
</Summary>
|
||||||
{Object.keys(props.gist.xray.parts[props.partName][type])
|
<Ul>
|
||||||
|
{Object.keys(part[type])
|
||||||
.map(id => (
|
.map(id => (
|
||||||
<Li>
|
<Li>
|
||||||
<Details>
|
<Details>
|
||||||
|
@ -49,13 +59,21 @@ const XrayList = props => {
|
||||||
<Deg />
|
<Deg />
|
||||||
<span>{id}</span>
|
<span>{id}</span>
|
||||||
</SumDiv>
|
</SumDiv>
|
||||||
|
<button
|
||||||
|
className="text-accent px-3 hover:text-secondary-focus"
|
||||||
|
onClick={() => props.unsetGist(['xray', 'parts', props.partName, type, id])}
|
||||||
|
>
|
||||||
|
<ClearIcon />
|
||||||
|
</button>
|
||||||
<Chevron />
|
<Chevron />
|
||||||
</Summary>
|
</Summary>
|
||||||
{types[type]({...props, id})}
|
{type === 'paths' && <Path path={part.paths[id]} />}
|
||||||
|
{type === 'points' && <Point point={part.points[id]} />}
|
||||||
</Details>
|
</Details>
|
||||||
</Li>
|
</Li>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
</Ul>
|
||||||
</Details>
|
</Details>
|
||||||
</Li>
|
</Li>
|
||||||
</Ul>
|
</Ul>
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
import { Chevron } from 'shared/components/navigation/primary.js'
|
||||||
|
import { Ul, Li, Details, Summary, SumDiv, NoSumDiv, Deg } from 'shared/components/workbench/menu'
|
||||||
|
import { round } from 'shared/utils.js'
|
||||||
|
import Point from './point.js'
|
||||||
|
|
||||||
|
const MoveLine = ({ op }) => <Point point={op.to} />
|
||||||
|
const Curve = ({ op }) => ['cp1', 'cp2', 'to'].map(pnt => (
|
||||||
|
<Li key={pnt}>
|
||||||
|
<Details>
|
||||||
|
<Summary>
|
||||||
|
<SumDiv>
|
||||||
|
<Deg />
|
||||||
|
<span className="font-bold">{pnt}</span>
|
||||||
|
</SumDiv>
|
||||||
|
<Chevron />
|
||||||
|
</Summary>
|
||||||
|
<Point point={op[pnt]} />
|
||||||
|
</Details>
|
||||||
|
</Li>
|
||||||
|
))
|
||||||
|
const Close = () => (
|
||||||
|
<p>Close</p>
|
||||||
|
)
|
||||||
|
|
||||||
|
const XrayPathOp = ({ op }) => (
|
||||||
|
<Li>
|
||||||
|
{op.type === 'close'
|
||||||
|
? (
|
||||||
|
<NoSumDiv>
|
||||||
|
<Deg />
|
||||||
|
<span className="font-bold">{op.type}</span>
|
||||||
|
</NoSumDiv>
|
||||||
|
) : (
|
||||||
|
<Details>
|
||||||
|
<Summary>
|
||||||
|
<SumDiv>
|
||||||
|
<Deg />
|
||||||
|
<span className="font-bold">{op.type}</span>
|
||||||
|
<span>To</span>
|
||||||
|
</SumDiv>
|
||||||
|
<Chevron />
|
||||||
|
</Summary>
|
||||||
|
<Ul>
|
||||||
|
{op.type === 'curve'
|
||||||
|
? <Curve op={op} />
|
||||||
|
: <MoveLine op={op} />
|
||||||
|
}
|
||||||
|
</Ul>
|
||||||
|
</Details>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Li>
|
||||||
|
)
|
||||||
|
|
||||||
|
const XrayPathOps = ({ ops=false }) => {
|
||||||
|
if (!ops || ops.length < 1) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Li>
|
||||||
|
<Details>
|
||||||
|
<Summary>
|
||||||
|
<SumDiv>
|
||||||
|
<Deg />
|
||||||
|
PathOps
|
||||||
|
</SumDiv>
|
||||||
|
<Chevron />
|
||||||
|
</Summary>
|
||||||
|
<Ul>
|
||||||
|
{ops.map(op => <XrayPathOp op={op} />)}
|
||||||
|
</Ul>
|
||||||
|
</Details>
|
||||||
|
</Li>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default XrayPathOps
|
|
@ -1,14 +1,26 @@
|
||||||
|
import { Ul, Li, Details, Summary, NoSumDiv, Deg } from 'shared/components/workbench/menu'
|
||||||
|
import ClearIcon from 'shared/components/icons/clear.js'
|
||||||
|
import Attributes from './attributes.js'
|
||||||
|
import Ops from './path-ops.js'
|
||||||
/*
|
/*
|
||||||
* Things to add
|
* Things to add
|
||||||
*
|
*
|
||||||
* attributes
|
|
||||||
* ops
|
* ops
|
||||||
* render
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const XrayPath = props => {
|
const XrayPath = ({ path }) => (
|
||||||
return <pre>{JSON.stringify(props.gist.xray.parts[props.partName].paths[props.id], null ,2)}</pre>
|
<Ul>
|
||||||
}
|
<Li>
|
||||||
|
<NoSumDiv>
|
||||||
|
<Deg />
|
||||||
|
<span className="font-bold mr-2">Render =</span>
|
||||||
|
<span>{JSON.stringify(path.render)}</span>
|
||||||
|
</NoSumDiv>
|
||||||
|
</Li>
|
||||||
|
<Attributes attr={path.attributes} />
|
||||||
|
<Ops ops={path.ops} />
|
||||||
|
</Ul>
|
||||||
|
)
|
||||||
|
|
||||||
export default XrayPath
|
export default XrayPath
|
||||||
|
|
|
@ -1,9 +1,20 @@
|
||||||
import { Ul, Li, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu'
|
import { Ul, Li, Details, Summary, NoSumDiv, Deg } from 'shared/components/workbench/menu'
|
||||||
|
import { round } from 'shared/utils.js'
|
||||||
|
import Attributes from './attributes.js'
|
||||||
|
|
||||||
const XrayPoint = props => [
|
const XrayPoint = ({ point }) => (
|
||||||
<Li key='x'>x: {props.x}</Li>,
|
<Ul>
|
||||||
<Li key='y'>x: {props.y}</Li>,
|
{['x', 'y'].map(coord => (
|
||||||
<Li key='attributes'>Attributes: {props.y}</Li>,
|
<Li key={coord}>
|
||||||
]
|
<NoSumDiv>
|
||||||
|
<Deg />
|
||||||
|
<span className="font-bold mr-2">{coord} =</span>
|
||||||
|
<span>{round(point[coord])}</span>
|
||||||
|
</NoSumDiv>
|
||||||
|
</Li>
|
||||||
|
))}
|
||||||
|
<Attributes attr={point.attributes} />
|
||||||
|
</Ul>
|
||||||
|
)
|
||||||
|
|
||||||
export default XrayPoint
|
export default XrayPoint
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue