[react] fix: the inspect view popup when clicking on a path or point, fix missing translations in the xray path and point components (#256)
This fixes some react wiring in the inspect view. The drillProps argument contains the info function which displays the popup. Also `strings` should be passed for translation, instead of the t function. Reviewed-on: https://codeberg.org/freesewing/freesewing/pulls/256 Reviewed-by: Joost De Cock <joostdecock@noreply.codeberg.org> Co-authored-by: Jonathan Haas <haasjona@gmail.com> Co-committed-by: Jonathan Haas <haasjona@gmail.com>
This commit is contained in:
parent
bc1d873b19
commit
647205661b
5 changed files with 25 additions and 14 deletions
|
@ -3,7 +3,7 @@ import React, { forwardRef } from 'react'
|
||||||
import { getId, getProps } from './utils.mjs'
|
import { getId, getProps } from './utils.mjs'
|
||||||
|
|
||||||
export const PartInner = forwardRef(
|
export const PartInner = forwardRef(
|
||||||
({ stackName, partName, part, settings, components, strings }, ref) => {
|
({ stackName, partName, part, settings, components, strings, drillProps }, ref) => {
|
||||||
const { Group, Path, Point, Snippet } = components
|
const { Group, Path, Point, Snippet } = components
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -15,7 +15,7 @@ export const PartInner = forwardRef(
|
||||||
topLeft={part.topLeft}
|
topLeft={part.topLeft}
|
||||||
bottomRight={part.bottomRight}
|
bottomRight={part.bottomRight}
|
||||||
units={settings[0].units}
|
units={settings[0].units}
|
||||||
{...{ stackName, partName, pathName, part, settings, components, strings }}
|
{...{ stackName, partName, pathName, part, settings, components, strings, drillProps }}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{Object.keys(part.points).map((pointName) => (
|
{Object.keys(part.points).map((pointName) => (
|
||||||
|
@ -24,14 +24,23 @@ export const PartInner = forwardRef(
|
||||||
point={part.points[pointName]}
|
point={part.points[pointName]}
|
||||||
topLeft={part.topLeft}
|
topLeft={part.topLeft}
|
||||||
bottomRight={part.bottomRight}
|
bottomRight={part.bottomRight}
|
||||||
{...{ stackName, partName, pointName, part, settings, components, strings }}
|
{...{ stackName, partName, pointName, part, settings, components, strings, drillProps }}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{Object.keys(part.snippets).map((snippetName) => (
|
{Object.keys(part.snippets).map((snippetName) => (
|
||||||
<Snippet
|
<Snippet
|
||||||
key={snippetName}
|
key={snippetName}
|
||||||
snippet={part.snippets[snippetName]}
|
snippet={part.snippets[snippetName]}
|
||||||
{...{ stackName, partName, snippetName, part, settings, components, strings }}
|
{...{
|
||||||
|
stackName,
|
||||||
|
partName,
|
||||||
|
snippetName,
|
||||||
|
part,
|
||||||
|
settings,
|
||||||
|
components,
|
||||||
|
strings,
|
||||||
|
drillProps,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -41,12 +50,12 @@ export const PartInner = forwardRef(
|
||||||
|
|
||||||
PartInner.displayName = 'PartInner'
|
PartInner.displayName = 'PartInner'
|
||||||
|
|
||||||
export const Part = ({ stackName, partName, part, settings, components, strings }) => {
|
export const Part = ({ stackName, partName, part, settings, components, strings, drillProps }) => {
|
||||||
const { Group } = components
|
const { Group } = components
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group {...getProps(part)} id={getId({ settings, stackName, partName })}>
|
<Group {...getProps(part)} id={getId({ settings, stackName, partName })}>
|
||||||
<PartInner {...{ stackName, partName, part, settings, components, strings }} />
|
<PartInner {...{ stackName, partName, part, settings, components, strings, drillProps }} />
|
||||||
</Group>
|
</Group>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { getProps } from './utils.mjs'
|
import { getProps } from './utils.mjs'
|
||||||
|
|
||||||
export const Stack = ({ stackName, stack, settings, components, strings }) => {
|
export const Stack = ({ stackName, stack, settings, components, strings, drillProps }) => {
|
||||||
const { Group, Part, Grid } = components
|
const { Group, Part, Grid } = components
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group {...getProps(stack)}>
|
<Group {...getProps(stack)}>
|
||||||
{settings[0].paperless ? <Grid {...{ stack, stackName }} /> : null}
|
{settings[0].paperless ? <Grid {...{ stack, stackName }} /> : null}
|
||||||
{[...stack.parts].map((part, key) => (
|
{[...stack.parts].map((part, key) => (
|
||||||
<Part {...{ settings, components, part, stackName, strings }} key={key} />
|
<Part {...{ settings, components, part, stackName, strings, drillProps }} key={key} />
|
||||||
))}
|
))}
|
||||||
</Group>
|
</Group>
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,11 +17,11 @@ export const Xray = forwardRef((props, ref) => {
|
||||||
// desctructure props
|
// desctructure props
|
||||||
const {
|
const {
|
||||||
renderProps = false,
|
renderProps = false,
|
||||||
t = (string) => string,
|
|
||||||
children = false,
|
children = false,
|
||||||
className = 'freesewing pattern',
|
className = 'freesewing pattern',
|
||||||
components = {},
|
components = {},
|
||||||
drillProps = {},
|
drillProps = {},
|
||||||
|
strings = [],
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
// Merge pattern, default, and custom components
|
// Merge pattern, default, and custom components
|
||||||
|
@ -57,7 +57,7 @@ export const Xray = forwardRef((props, ref) => {
|
||||||
stack={renderProps.stacks[stackName]}
|
stack={renderProps.stacks[stackName]}
|
||||||
settings={renderProps.settings}
|
settings={renderProps.settings}
|
||||||
components={mergedComponents}
|
components={mergedComponents}
|
||||||
t={t}
|
strings={strings}
|
||||||
drillProps={drillProps}
|
drillProps={drillProps}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const PathXray = ({
|
||||||
path,
|
path,
|
||||||
settings,
|
settings,
|
||||||
components,
|
components,
|
||||||
t,
|
strings,
|
||||||
drillProps = {},
|
drillProps = {},
|
||||||
}) => {
|
}) => {
|
||||||
/*
|
/*
|
||||||
|
@ -87,7 +87,7 @@ export const PathXray = ({
|
||||||
return (
|
return (
|
||||||
<g>
|
<g>
|
||||||
{output}
|
{output}
|
||||||
<Path {...{ stackName, pathName, path, part, settings, components, t, drillProps }} />
|
<Path {...{ stackName, pathName, path, part, settings, components, strings, drillProps }} />
|
||||||
</g>
|
</g>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const PointXray = ({
|
||||||
point,
|
point,
|
||||||
settings,
|
settings,
|
||||||
components,
|
components,
|
||||||
t,
|
strings,
|
||||||
drillProps = {},
|
drillProps = {},
|
||||||
}) => {
|
}) => {
|
||||||
// Don't include parts outside the part bounding box
|
// Don't include parts outside the part bounding box
|
||||||
|
@ -32,7 +32,9 @@ export const PointXray = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Point {...{ stackName, pointName, part, point, settings, components, t, drillProps }} />
|
<Point
|
||||||
|
{...{ stackName, pointName, part, point, settings, components, strings, drillProps }}
|
||||||
|
/>
|
||||||
<circle
|
<circle
|
||||||
cx={point.x}
|
cx={point.x}
|
||||||
cy={point.y}
|
cy={point.y}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue