cleanup
This commit is contained in:
parent
7988aa9b31
commit
cdd080fde4
9 changed files with 10 additions and 210 deletions
|
@ -5,7 +5,6 @@ import { useBackend } from 'shared/hooks/use-backend.mjs'
|
|||
import { useDesign } from 'shared/hooks/use-design.mjs'
|
||||
// Dependencies
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||
import { Aaron } from '@freesewing/aaron'
|
||||
// Components
|
||||
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
|
||||
import { Workbench, ns as wbNs } from 'shared/components/workbench/index.mjs'
|
||||
|
@ -31,7 +30,7 @@ const loadMeasurements = async ({ type, id, backend }) => {
|
|||
else return false
|
||||
}
|
||||
|
||||
const NewAaronFromSetPage = ({ page, id, design, type }) => {
|
||||
const NewDesignFromSetPage = ({ page, id, design, type }) => {
|
||||
const { token } = useAccount()
|
||||
const backend = useBackend(token)
|
||||
const [set, setSet] = useState(false)
|
||||
|
@ -45,7 +44,7 @@ const NewAaronFromSetPage = ({ page, id, design, type }) => {
|
|||
}
|
||||
if (set === false) getSet()
|
||||
else if (set?.id && set.id !== id) getSet()
|
||||
}, [id, type, backend])
|
||||
}, [id, type, backend, set])
|
||||
|
||||
const baseSettings = set?.measies ? { measurements: set.measies } : null
|
||||
|
||||
|
@ -56,7 +55,7 @@ const NewAaronFromSetPage = ({ page, id, design, type }) => {
|
|||
)
|
||||
}
|
||||
|
||||
export default NewAaronFromSetPage
|
||||
export default NewDesignFromSetPage
|
||||
|
||||
export async function getStaticProps({ locale, params }) {
|
||||
return {
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
// import { OptionsIcon } from 'shared/components/icons.mjs'
|
||||
// import { Chevron } from 'shared/components/navigation/primary.mjs'
|
||||
// import { Option } from './option.mjs'
|
||||
// import { useTranslation } from 'next-i18next'
|
||||
// import { optionsMenuStructure } from 'shared/utils.mjs'
|
||||
// import { adult, doll, giant } from '@freesewing/models'
|
||||
|
||||
// const groups = { adult, doll, giant }
|
||||
|
||||
// const SampleDesignOption = (props) => {
|
||||
// const { t } = useTranslation(['app'])
|
||||
|
||||
// return (
|
||||
// <Option
|
||||
// updateGist={props.updateGist}
|
||||
// option={props.option}
|
||||
// design={props.design}
|
||||
// active={props.gist.sample?.option}
|
||||
// label={t(`o_${props.design.designConfig.data.name}:${props.option}.t`)}
|
||||
// sampleSettings={{ type: 'option', option: props.option }}
|
||||
// />
|
||||
// )
|
||||
// }
|
||||
|
||||
export const TestDesignOptions = () => {
|
||||
return <span> FIXME: Implement Sample Options </span>
|
||||
// const { t } = useTranslation(['app'])
|
||||
// const optionsMenu = optionsMenuStructure(props.design.patternConfig.options)
|
||||
|
||||
// const measies = props.draft?.config?.measurements || []
|
||||
|
||||
// return (
|
||||
// <>
|
||||
// <Details open>
|
||||
// <TopSummary icon={<OptionsIcon />}>
|
||||
// <TopSumTitle>{t('designOptions')}</TopSumTitle>
|
||||
// <Chevron />
|
||||
// </TopSummary>
|
||||
// <Ul className="pl-5 list-inside">
|
||||
// {Object.entries(optionsMenu).map(([group, options]) =>
|
||||
// typeof options === 'string' ? (
|
||||
// <SampleDesignOption
|
||||
// {...props}
|
||||
// type={options}
|
||||
// option={group}
|
||||
// key={group}
|
||||
// sampleSettings={{ type: 'option', options }}
|
||||
// />
|
||||
// ) : (
|
||||
// <DesignOptionGroup
|
||||
// {...props}
|
||||
// group={group}
|
||||
// options={options}
|
||||
// key={group}
|
||||
// Option={SampleDesignOption}
|
||||
// />
|
||||
// )
|
||||
// )}
|
||||
// </Ul>
|
||||
// </Details>
|
||||
|
||||
// <Details open>
|
||||
// <TopSummary icon={<OptionsIcon />}>
|
||||
// <TopSumTitle>{t('measurements')}</TopSumTitle>
|
||||
// <Chevron />
|
||||
// </TopSummary>
|
||||
// <Ul className="pl-5 list-inside">
|
||||
// {measies.map((m) => (
|
||||
// <Option
|
||||
// updateGist={props.updateGist}
|
||||
// option={m}
|
||||
// design={props.design}
|
||||
// active={props.gist.sample?.option}
|
||||
// key={m}
|
||||
// label={m}
|
||||
// sampleSettings={{ type: 'measurement', measurement: m }}
|
||||
// />
|
||||
// ))}
|
||||
// </Ul>
|
||||
// </Details>
|
||||
|
||||
// <Details open>
|
||||
// <TopSummary icon={<OptionsIcon />}>
|
||||
// <TopSumTitle>{t('models')}</TopSumTitle>
|
||||
// <Chevron />
|
||||
// </TopSummary>
|
||||
// <Ul className="pl-5 list-inside">
|
||||
// {Object.entries(groups).map(([group, modelGroups]) =>
|
||||
// Object.entries(modelGroups).map(([name, models]) => (
|
||||
// <Option
|
||||
// updateGist={props.updateGist}
|
||||
// label={`${group} - ${name}`}
|
||||
// design={props.design}
|
||||
// active={props.gist.sample?.option}
|
||||
// key={name}
|
||||
// sampleSettings={{ type: 'models', models }}
|
||||
// />
|
||||
// ))
|
||||
// )}
|
||||
// </Ul>
|
||||
// </Details>
|
||||
// </>
|
||||
// )
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
import { Li, SumButton, SumDiv } from 'shared/components/workbench/menus/index.mjs'
|
||||
|
||||
export const Option = (props) => {
|
||||
const active = props.sampleSettings?.type === 'option' && props.active === props.option
|
||||
|
||||
const setSampleSettings = () => {
|
||||
props.updateGist(
|
||||
['sample'],
|
||||
props.sampleSettings,
|
||||
true // Close navigation on mobile
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Li>
|
||||
<SumButton onClick={setSampleSettings}>
|
||||
<SumDiv active={active}>
|
||||
<span
|
||||
className={`
|
||||
text-3xl inline-block p-0 leading-3 px-2
|
||||
${
|
||||
active
|
||||
? 'text-secondary sm:text-secondary-focus translate-y-1 font-bold'
|
||||
: 'translate-y-3'
|
||||
}`}
|
||||
>
|
||||
{active ? <span>•</span> : <span>°</span>}
|
||||
</span>
|
||||
<span className={active ? 'text-secondary font-bold' : ''}>{props.label}</span>
|
||||
</SumDiv>
|
||||
</SumButton>
|
||||
</Li>
|
||||
)
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
import { useTranslation } from 'next-i18next'
|
||||
import { svgattrPlugin } from '@freesewing/plugin-svgattr'
|
||||
import { SvgWrapper } from './pattern/svg.mjs'
|
||||
import { DraftError } from './pattern/error.mjs'
|
||||
|
||||
export const LabSample = ({ gist, draft, updateGist, unsetGist, showInfo, app, feedback }) => {
|
||||
const { t } = useTranslation(['workbench'])
|
||||
let svg
|
||||
let title = ''
|
||||
let patternProps
|
||||
const errors = []
|
||||
|
||||
draft.use(svgattrPlugin, {
|
||||
class: 'freesewing pattern max-h-screen',
|
||||
})
|
||||
|
||||
if (gist.sample) {
|
||||
try {
|
||||
draft = draft.sample()
|
||||
patternProps = draft.getRenderProps()
|
||||
// Render as React
|
||||
for (const logs of patternProps.logs.sets) errors.push(...logs.error)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
//FIXME this doesn't work for models
|
||||
title = t('testThing', {
|
||||
thing: ` : ${t(gist.sample.type)} : ${gist.sample[gist.sample.type]}`,
|
||||
})
|
||||
} else {
|
||||
// don't error on first page landing
|
||||
draft.draft()
|
||||
patternProps = draft.getRenderProps()
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2>{title}</h2>
|
||||
{!patternProps || errors.length > 0 ? (
|
||||
<DraftError {...{ draft, patternProps, updateGist, errors }} />
|
||||
) : null}
|
||||
<SvgWrapper
|
||||
{...{ draft, patternProps, gist, updateGist, unsetGist, showInfo, app, feedback }}
|
||||
/>
|
||||
<div className="freesewing pattern" dangerouslySetInnerHTML={{ __html: svg }} />
|
||||
</>
|
||||
)
|
||||
}
|
|
@ -1,14 +1,12 @@
|
|||
import { useState } from 'react'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { PanZoomPattern } from 'shared/components/workbench/pan-zoom-pattern.mjs'
|
||||
import { TestMenu, ns as menuNs } from './menu.mjs'
|
||||
import { objUpdate } from 'shared/utils.mjs'
|
||||
|
||||
export const ns = menuNs
|
||||
|
||||
export const TestView = ({
|
||||
design,
|
||||
pattern,
|
||||
setView,
|
||||
settings,
|
||||
ui,
|
||||
update,
|
||||
|
@ -16,15 +14,19 @@ export const TestView = ({
|
|||
account,
|
||||
DynamicDocs,
|
||||
}) => {
|
||||
const { t } = useTranslation(ns)
|
||||
if (!pattern) return null
|
||||
if (settings.sample) pattern.sample()
|
||||
else pattern.draft()
|
||||
|
||||
const renderProps = pattern.getRenderProps()
|
||||
const patternConfig = pattern.getConfig()
|
||||
|
||||
const title = t('testThing', { design, thing: t(settings.sample?.[settings.sample.type]) })
|
||||
return (
|
||||
<div className="flex flex-row">
|
||||
<div className="w-2/3 shrink-0 grow lg:p-4 sticky top-0">
|
||||
<h2 className="capitalize">{title}</h2>
|
||||
<PanZoomPattern {...{ renderProps }} />
|
||||
</div>
|
||||
<div className="w-1/3 shrink grow-0 lg:p-4 max-w-2xl h-screen overflow-scroll">
|
||||
|
|
|
@ -5,7 +5,6 @@ import { SampleItem } from './options.mjs'
|
|||
export const ns = ['measurements', 'test-view', 'workbench']
|
||||
|
||||
export const TestMeasurements = ({
|
||||
design,
|
||||
patternConfig,
|
||||
settings,
|
||||
update,
|
||||
|
|
|
@ -2,28 +2,14 @@ import { TestOptions, ns as optionsNs } from './options.mjs'
|
|||
import { TestMeasurements, ns as measieNs } from './measurements.mjs'
|
||||
export const ns = [...optionsNs, ...measieNs]
|
||||
|
||||
const TestOption = ({ config, settings, control, name, ...rest }) => {
|
||||
return (
|
||||
<MenuItem
|
||||
{...{
|
||||
...rest,
|
||||
changed: settings.sample === name,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export const TestMenu = ({
|
||||
design,
|
||||
patternConfig,
|
||||
settings,
|
||||
ui,
|
||||
update,
|
||||
language,
|
||||
account,
|
||||
DynamicDocs,
|
||||
inspector = false,
|
||||
renderProps,
|
||||
}) => {
|
||||
const control = account.control
|
||||
const menuProps = {
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
ns as designMenuNs,
|
||||
} from 'shared/components/workbench/menus/design-options/index.mjs'
|
||||
import { OptionsIcon } from 'shared/components/icons.mjs'
|
||||
import { optionsMenuStructure, optionType } from 'shared/utils.mjs'
|
||||
import { optionsMenuStructure } from 'shared/utils.mjs'
|
||||
|
||||
export const ns = ['test-view', ...designMenuNs]
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@ testThis.option: Test this option
|
|||
testThis.measurement: Test this measurement
|
||||
measurements.d: Test the effect of a measurement on the way this pattern looks
|
||||
designOptions.d: Test the effect of an option on the way this pattern looks
|
||||
testThing: "Test {design}: {thing}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue