1
0
Fork 0

chore: Fixing linter warnings

This commit is contained in:
joostdecock 2023-05-19 16:31:28 +02:00
parent e0ce1a8bcf
commit c49a47a0de
33 changed files with 76 additions and 547 deletions

View file

@ -42,7 +42,8 @@ ApikeyModel.prototype.sendResponse = async function (res) {
ApikeyModel.prototype.verify = async function (key, secret) {
await this.unguardedRead({ id: key })
const [valid] = await verifyPassword(secret, this.record.secret)
const verify = await verifyPassword(secret, this.record.secret)
const [valid] = verify
this.verified = valid
return this

View file

@ -313,7 +313,7 @@ SetModel.prototype.userSets = async function (uid) {
log.warn(`Failed to search sets for user ${uid}: ${err}`)
}
const list = []
for (const set of sets) list.push(await this.revealSet(set))
for (const set of sets) list.push(this.revealSet(set))
return list
}

View file

@ -53,7 +53,8 @@ export function encryption(stringKey, salt = 'FreeSewing') {
try {
data = asJson(data)
} catch (err) {
throw ('Could not parse input to encrypt() call', err)
console.log(err)
throw 'Could not parse input to encrypt() call'
}
/*
@ -84,7 +85,8 @@ export function encryption(stringKey, salt = 'FreeSewing') {
try {
data = JSON.parse(data)
} catch (err) {
throw ('Could not parse encrypted data in decrypt() call', err)
console.log(err)
throw 'Could not parse encrypted data in decrypt() call'
}
if (!data.iv || typeof data.ct === 'undefined') {
throw 'Encrypted data passed to decrypt() was malformed'

View file

@ -37,7 +37,7 @@ export const setPatternAvatar = async (id, data) => setAvatar('pattern', id, dat
export async function setAvatar(type, id, data) {
// Step 1: Upload the image as asset
const [contentType, binary] = b64ToBinaryWithType(data)
if (contentType && binary) {
if (contentType) {
const img = await axios.post(`${config.api}/assets/images/${config.dataset}`, binary, {
headers: {
...headers,

View file

@ -8,13 +8,13 @@ import { patternTests } from './pattern.mjs'
import { setup } from './shared.mjs'
const runTests = async (...params) => {
//await userTests(...params)
//await mfaTests(...params)
//await apikeyTests(...params)
//await accountTests(...params)
//await setTests(...params)
await userTests(...params)
await mfaTests(...params)
await apikeyTests(...params)
await accountTests(...params)
await setTests(...params)
await curatedSetTests(...params)
//await patternTests(...params)
await patternTests(...params)
}
// Load initial data required for tests

View file

@ -15,7 +15,7 @@ export const ns = ['account', 'toast']
export const ControlSettings = ({ title = false, welcome = false }) => {
// Context
const { loading, startLoading, stopLoading } = useContext(LoadingContext)
const { startLoading, stopLoading } = useContext(LoadingContext)
// Hooks
const { account, setAccount, token } = useAccount()

View file

@ -1,8 +1,6 @@
// Dependencies
import { useState, useEffect, useContext, useCallback } from 'react'
import { useTranslation } from 'next-i18next'
import { DateTime } from 'luxon'
import { CopyToClipboard } from 'react-copy-to-clipboard'
import orderBy from 'lodash.orderby'
import { measurements, isDegreeMeasurement } from 'config/measurements.mjs'
import { measurementAsMm, formatMm } from 'shared/utils.mjs'
@ -30,10 +28,7 @@ import {
PlusIcon,
OkIcon,
NoIcon,
DownIcon,
CopyIcon,
TrashIcon,
LeftIcon,
EditIcon,
} from 'shared/components/icons.mjs'
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
@ -41,8 +36,6 @@ import Markdown from 'react-markdown'
import { Tab } from './bio.mjs'
import Timeago from 'react-timeago'
import { Spinner } from 'shared/components/spinner.mjs'
import Link from 'next/link'
import { SaveSettingsButton } from 'shared/components/buttons/save-settings-button.mjs'
export const ns = ['account', 'patterns', 'toast']
@ -70,7 +63,7 @@ export const NewSet = ({
standalone = false,
}) => {
// Context
const { loading, startLoading, stopLoading } = useContext(LoadingContext)
const { startLoading, stopLoading } = useContext(LoadingContext)
// Hooks
const router = useRouter()
@ -97,11 +90,6 @@ export const NewSet = ({
stopLoading()
}
// Helper method to clear inputs
const clear = () => {
setMset(false)
}
return (
<div>
{title ? <h2>{t('newSet')}</h2> : null}
@ -145,8 +133,6 @@ const EditField = (props) => {
return <p>FIXME: No edit component for this field</p>
}
const noop = () => null
export const EditRow = (props) => (
<Collapse
color="secondary"
@ -207,8 +193,8 @@ export const MeasieRow = (props) => {
const MeasieInput = ({ m, mset, backend, toast, refresh }) => {
const { t } = useTranslation(['measurements'])
const title = t(`measurements:${m}`)
const { loading, startLoading, stopLoading } = useContext(LoadingContext)
//const title = t(`measurements:${m}`)
const { startLoading, stopLoading } = useContext(LoadingContext)
const isDegree = isDegreeMeasurement(m)
const factor = isDegree ? 1 : mset.imperial ? 25.4 : 10
@ -230,6 +216,7 @@ const MeasieInput = ({ m, mset, backend, toast, refresh }) => {
setValid(isValid(useVal))
}
/*
const save = async () => {
startLoading()
const measies = {}
@ -241,6 +228,7 @@ const MeasieInput = ({ m, mset, backend, toast, refresh }) => {
} else toast.for.backendError()
stopLoading()
}
*/
const fraction = (i, base) => update({ target: { value: Math.floor(val) + i / base } })
@ -554,7 +542,7 @@ const EditNotes = ({ t, mset, account, backend, toast, refresh }) => {
const EditUnits = ({ t, mset, account, backend, toast, refresh }) => {
const [selection, setSelection] = useState(mset?.imperial === true ? 'imperial' : 'metric')
const { loading, startLoading, stopLoading } = useContext(LoadingContext)
const { startLoading, stopLoading } = useContext(LoadingContext)
const update = async (val) => {
setSelection(val)
@ -776,7 +764,7 @@ const EditMeasurementsSet = (props) => {
const MeasurementsSet = ({ mset, t, account, backend, refresh }) => {
// Context
const { loading, startLoading, stopLoading } = useContext(LoadingContext)
const { startLoading, stopLoading } = useContext(LoadingContext)
const { setModal } = useContext(ModalContext)
// Hooks
@ -864,9 +852,6 @@ const MeasurementsSet = ({ mset, t, account, backend, refresh }) => {
// Component for the account/sets page
export const Sets = ({ title = true }) => {
// Context
const { loading, startLoading, stopLoading } = useContext(LoadingContext)
// Hooks
const { account, token } = useAccount()
const backend = useBackend(token)

View file

@ -1,8 +1,9 @@
import { useState } from 'react'
import { CloseIcon, DownIcon } from 'shared/components/icons.mjs'
import { CloseIcon } from 'shared/components/icons.mjs'
const OpenTitleButton = ({ title, toggle, color = 'primary', openButtons = [] }) => (
<button
<div
role="button"
className={`flex flex-row items-center justify-between w-full
bg-${color} text-${color}-content px-4 py-1 text-lg font-medium`}
onClick={toggle}
@ -14,7 +15,7 @@ const OpenTitleButton = ({ title, toggle, color = 'primary', openButtons = [] })
<CloseIcon stroke={3} />
</button>
</div>
</button>
</div>
)
export const Collapse = ({

View file

@ -1,4 +1,3 @@
import { useState } from 'react'
import { designList, designs } from 'shared/config/designs.mjs'
import { Design, ns as designNs } from 'shared/components/designs/design.mjs'
@ -11,7 +10,7 @@ export const DesignList = ({ tag = false }) => {
return (
<div className="flex flex-row flex-wrap gap-2">
{list.map((name) => (
<Design name={name} />
<Design name={name} key={name} />
))}
</div>
)

View file

@ -18,7 +18,7 @@ export const DesignPicker = () => {
{Object.keys(translated)
.sort()
.map((d) => (
<Design name={translated[d]} />
<Design name={translated[d]} key={d} />
))}
</div>
)

View file

@ -1,60 +0,0 @@
import dynamic from 'next/dynamic'
import { MDXProvider } from '@mdx-js/react'
import { useState } from 'react'
import { Spinner } from 'shared/components/spinner.mjs'
import { PageLink } from 'shared/components/page-link.mjs'
import { useTranslation } from 'next-i18next'
import { components } from 'shared/components/mdx/index.mjs'
import { MdxWrapper, ns as wrapperNs } from './wrapper.mjs'
export const ns = wrapperNs
/*
* Webpack will check on disk for all possible files matching this
* dynamic import. So unless we divide it up a bit your computer
* will melt when running this in development mode
*
* This will return a language-specific component
*/
const dynamicDocsFactory = (lang) => {
return function ({ setting = false }) {
const [frontmatter, setFrontmatter] = useState({})
const mdx = dynamic(
() =>
import(
`orgmarkdown/docs/site/draft/core-settings/${setting ? setting + '/' : ''}${lang}.md`
).then((mod) => {
setFrontmatter(mod.frontmatter)
return mod
}),
{ ssr: false }
)
const MDX = mdx ? mdx : <Spinner className="w16 h-16 animate-spin text-primary" />
return (
<MdxWrapper {...frontmatter} path={`site/draft/core-settings`} language={lang}>
<MDX components={components} />
</MdxWrapper>
)
}
}
/*
* Instantiate language-specific components
*/
const CoreSettingsDocsEn = dynamicDocsFactory('en')
const CoreSettingsDocsDe = dynamicDocsFactory('de')
const CoreSettingsDocsFr = dynamicDocsFactory('fr')
const CoreSettingsDocsEs = dynamicDocsFactory('es')
const CoreSettingsDocsNl = dynamicDocsFactory('nl')
/*
* Return language-specific component
*/
export const DynamicCoreSettingsDocs = ({ setting = false, language = 'en' }) => {
if (language === 'en') return <CoreSettingsDocsEn setting={setting} />
if (language === 'de') return <CoreSettingsDocsDe setting={setting} />
if (language === 'es') return <CoreSettingsDocsEs setting={setting} />
if (language === 'fr') return <CoreSettingsDocsFr setting={setting} />
if (language === 'nl') return <CoreSettingsDocsNl setting={setting} />
}

View file

@ -1,7 +1,7 @@
import { Popout } from 'shared/components/popout.mjs'
import { Highlight } from './highlight.mjs'
import { YouTube } from './youtube.mjs'
import { Figure } from './figure.mjs'
//import { Figure } from './figure.mjs'
import { ReadMore } from './read-more.mjs'
import { Tab, Tabs } from './tabs.mjs'
import { TabbedExample as Example } from './tabbed-example.mjs'

View file

@ -2,7 +2,6 @@ import get from 'lodash.get'
import orderBy from 'lodash.orderby'
import Link from 'next/link'
import { LeftIcon, RightIcon } from 'shared/components/icons.mjs'
import { Popout } from 'shared/components/popout.mjs'
// helper method to order nav entries
const order = (obj) => orderBy(obj, ['o', 't'], ['asc', 'asc'])

View file

@ -1,26 +1,10 @@
// Dependencies
import { useRouter } from 'next/router'
import { useTranslation } from 'next-i18next'
import Link from 'next/link'
// Components
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
export const ns = ['designs']
const btnClasses = {
dflt:
'btn w-full mt-2 btn-secondary ' +
'flex flex-row flex-nowrap items-center gap-4 py-4 h-auto ' +
'border border-secondary justify-start text-left bg-opacity-30',
active:
'btn-ghost bg-secondary hover:bg-secondary ' + 'hover:bg-opacity-30 hover:border-secondary',
inactive:
'hover:bg-opacity-20 hover:bg-secondary btn-ghost ' +
'border border-secondary hover:border hover:border-secondary',
}
const spanClasses =
'p-2 w-8 h-8 shrink-0 rounded-full text-center p-0 py-2 bg-secondary text-secondary-content'
export const ModalDesignPicker = ({
modalWrapperProps = {},
designs = [],
@ -41,6 +25,7 @@ export const ModalDesignPicker = ({
<div className="flex flex-row p-4 w-full flex-wrap gap-2">
{designs.map((d) => (
<button
key={d}
className={`btn w-64 btn-secondary flex flex-col flex-nowrap items-start
gap-2 py-2 h-auto border border-secondary justify-start text-left bg-opacity-30
hover:bg-opacity-20 hover:bg-secondary btn-ghost

View file

@ -12,7 +12,6 @@ import {
UserIcon,
MeasureIcon,
PageIcon,
PrintIcon,
TrophyIcon,
CodeIcon,
I18nIcon,
@ -273,7 +272,7 @@ const getCrumb = (index, crumbs) => crumbs[index].s.split('/').pop()
export const ActiveSection = () => {
// Get navigation context
const { sections = false, crumbs = [], nav = {}, slug } = useContext(NavigationContext)
const { crumbs = [], nav = {}, slug } = useContext(NavigationContext)
// Don't bother if we don't know where we are
if (!crumbs || !Array.isArray(crumbs) || crumbs.length < 1) return null
@ -281,7 +280,7 @@ export const ActiveSection = () => {
let slice = 1
let nodes = nav
// Some sections are further trimmed
if (crumbs && crumbs[0].s === 'docs') {
if (crumbs[0].s === 'docs') {
if (crumbs.length > 1 && crumbs[1].s === 'docs/faq') {
slice = 2
nodes = nav[getCrumb(1, crumbs)]
@ -303,11 +302,9 @@ export const ActiveSection = () => {
return (
<div>
{crumbs ? (
<div className="pl-4 my-2">
<Breadcrumbs crumbs={crumbs.slice(0, slice)} />
</div>
) : null}
<div className="pl-4 my-2">
<Breadcrumbs crumbs={crumbs.slice(0, slice)} />
</div>
<div className="pr-2">
<SubLevel hasChildren={1} nodes={nodes} active={slug} />
</div>

View file

@ -19,7 +19,7 @@ export const ns = setNs
export const CuratedSetPicker = ({ design, language }) => {
// Hooks
const { account, token } = useAccount()
const { token } = useAccount()
const backend = useBackend(token)
const { t } = useTranslation('sets')
@ -29,9 +29,6 @@ export const CuratedSetPicker = ({ design, language }) => {
const [tags, setTags] = useState([])
const [reload, setReload] = useState(0)
// Force a refresh
const refresh = () => setReload(reload + 1)
// Effects
useEffect(() => {
const getCuratedSets = async () => {
@ -101,14 +98,14 @@ export const CuratedSetPicker = ({ design, language }) => {
</button>
</div>
{filter.map((tag) => (
<Tag onClick={() => removeFilter(tag)} color="success" hoverColor="error">
<Tag onClick={() => removeFilter(tag)} color="success" hoverColor="error" key={tag}>
{tag}
</Tag>
))}
</div>
<div className="flex flex-row flex-wrap gap-2">
{orderBy(list, ['name'], ['asc']).map((set) => (
<div className="w-full lg:w-96">
<div className="w-full lg:w-96" key={set.id}>
<CuratedSetCandidate
href={`/new/pattern/${design}/cset/${set.id}`}
set={set}
@ -124,7 +121,7 @@ export const CuratedSetPicker = ({ design, language }) => {
export const UserSetPicker = ({ design, t, language }) => {
// Hooks
const { account, token } = useAccount()
const { token } = useAccount()
const backend = useBackend(token)
// State
@ -160,7 +157,7 @@ export const UserSetPicker = ({ design, t, language }) => {
<>
<div className="flex flex-row flex-wrap gap-2">
{orderBy(sets, ['name'], ['asc']).map((set) => (
<div className="w-full lg:w-96">
<div className="w-full lg:w-96" key={set.id}>
<SetCandidate set={set} requiredMeasies={measurements[design]} design={design} />
</div>
))}

View file

@ -10,6 +10,7 @@ export const Set = ({ name }) => {
const { t } = useTranslation(ns)
return <p>fixme</p>
/*
return (
<Link
href={`/new/pattern/${name}`}
@ -34,4 +35,5 @@ export const Set = ({ name }) => {
</div>
</Link>
)
*/
}

View file

@ -9,7 +9,6 @@ import {
RedditIcon,
TwitterIcon,
OpenSourceIcon,
CcByIcon,
YouTubeIcon,
} from 'shared/components/icons.mjs'
import { colors } from 'shared/components/wordmark.mjs'

View file

@ -1,5 +1,5 @@
// Hooks
import { useState, useEffect, useContext } from 'react'
import { useState, useContext } from 'react'
import { useTranslation } from 'next-i18next'
// Context
import { ModalContext } from 'shared/context/modal-context.mjs'
@ -15,9 +15,7 @@ import {
MenuIcon,
OptionsIcon,
PrintIcon,
SettingsIcon,
UploadIcon,
WrenchIcon,
} from 'shared/components/icons.mjs'
import { Ribbon } from 'shared/components/ribbon.mjs'
import Link from 'next/link'
@ -71,7 +69,6 @@ export const colors = [
'violet',
'purple',
]
const views = ['menu', 'draft', 'test', 'print', 'cut', 'save', 'export', 'edit', 'clear', 'help']
const NavIcons = ({ setModal, setView, view }) => {
const { t } = useTranslation(['header'])

View file

@ -3,25 +3,10 @@ import { useEffect, useState } from 'react'
import { useTranslation } from 'next-i18next'
import { useView } from 'shared/hooks/use-view.mjs'
import { useAccount } from 'shared/hooks/use-account.mjs'
import { useBackend } from 'shared/hooks/use-backend.mjs'
// Dependencies
import { pluginTheme } from '@freesewing/plugin-theme'
import { pluginI18n } from '@freesewing/plugin-i18n'
import { objUpdate } from 'shared/utils.mjs'
//import { preloaders } from 'shared/components/workbench/preloaders.mjs'
// Components
//import { DraftError } from 'shared/components/workbench/pattern/error.mjs'
import { Modal } from 'shared/components/modal/modal.mjs'
import { ErrorBoundary } from 'shared/components/error/error-boundary.mjs'
// Views
//import { LabSample } from 'shared/components/workbench/sample.mjs'
//import { ExportDraft } from 'shared/components/workbench/exporting/index.mjs'
//import { GistAsJson, GistAsYaml } from 'shared/components/workbench/gist.mjs'
//import { DraftLogs } from 'shared/components/workbench/logs.mjs'
//import { CutLayout } from 'shared/components/workbench/layout/cut/index.mjs'
//import { PrintLayout } from 'shared/components/workbench/layout/print/index.mjs'
//import { EditYaml } from 'shared/components/workbench/edit/index.mjs'
// Components
import { WorkbenchHeader } from './header.mjs'
import { ErrorView } from 'shared/components/error/view.mjs'
@ -47,7 +32,6 @@ export const Workbench = ({ design, Design, set = false, DynamicDocs = false })
const { t, i18n } = useTranslation(ns)
const { language } = i18n
const { account, token } = useAccount()
const { backend } = useBackend(token)
const defaultSettings = loadDefaultSettings({
units: account.imperial ? 'imperial' : 'metric',
@ -128,171 +112,3 @@ export const Workbench = ({ design, Design, set = false, DynamicDocs = false })
</>
)
}
/*
const views = {
measurements: WorkbenchMeasurements,
//draft: LabDraft,
test: LabSample,
printingLayout: PrintLayout,
cuttingLayout: CutLayout,
export: ExportDraft,
logs: DraftLogs,
yaml: GistAsYaml,
json: GistAsJson,
edit: EditYaml,
welcome: () => <p>TODO</p>,
}
const hasRequiredMeasurementsMethod = (design, gist) => {
if (design.patternConfig?.measurements?.length > 0 && !gist.measurements) return false
for (const m of design.patternConfig?.measurements || []) {
if (!gist.measurements[m]) return false
}
return true
}
const doPreload = async (preload, from, design, gist, setGist, setPreloaded) => {
const g = await preloaders[from](preload, design)
setPreloaded(preload)
setGist({ ...gist, ...g.settings })
}
/*
* This component wraps the workbench and is in charge of
* keeping the gist state, which will trickle down
* to all workbench subcomponents
export const WorkbenchWrapper = ({
app,
design,
preload = false,
from = false,
layout = false,
}) => {
// State for gist
const { gist, setGist, unsetGist, updateGist, gistReady, undoGist, resetGist } = useGist(
design.designConfig?.data?.name,
app.locale
)
const [messages, setMessages] = useState([])
const [popup, setPopup] = useState(false)
const [preloaded, setPreloaded] = useState(false)
// we'll only use this if the renderer is svg, but we can't call hooks conditionally
const { t } = useTranslation(['plugin'])
// We'll use this in more than one location
const hasRequiredMeasurements = hasRequiredMeasurementsMethod(design, gist)
// If we don't have the required measurements,
// force view to measurements
useEffect(() => {
if (!gistReady) return
if (!['measurements', 'edit'].includes(gist._state?.view) && !hasRequiredMeasurements)
updateGist(['_state', 'view'], 'measurements')
}, [gistReady, gist._state?.view, hasRequiredMeasurements, updateGist])
// If we need to preload the gist, do so
useEffect(() => {
if (preload && preload !== preloaded && from && preloaders[from]) {
doPreload(preload, from, design, gist, setGist, setPreloaded)
}
}, [preload, preloaded, from, design, gist, setGist])
// Helper methods to manage the gist state
const updateWBGist = useMemo(
() =>
(path, value, closeNav = false, addToHistory = true) => {
updateGist(path, value, addToHistory)
// Force close of menu on mobile if it is open
if (closeNav && app.primaryMenu) app.setPrimaryMenu(false)
},
[app, updateGist]
)
// Helper methods to handle messages
const feedback = {
add: (msg) => {
const newMsgs = [...messages]
if (Array.isArray(msg)) newMsgs.push(...msg)
else newMsgs.push(msg)
setMessages(newMsgs)
},
set: setMessages,
clear: () => setMessages([]),
}
// don't do anything until the gist is ready
if (!gistReady) {
return null
}
// Generate the draft here so we can pass it down to both the view and the options menu
let draft = false
if (['draft', 'logs', 'test', 'printingLayout'].indexOf(gist._state?.view) !== -1) {
gist.embed = true
// get the appropriate layout for the view
const layout = gist.layouts?.[gist._state.view] || gist.layout || true
// hand it separately to the design
draft = new design({ ...gist, layout })
//draft.__init()
// add theme to svg renderer
if (gist.renderer === 'svg') {
draft.use(pluginI18n, { t })
draft.use(pluginTheme, { skipGrid: ['pages'] })
}
// draft it for draft and event views. Other views may add plugins, etc and we don't want to draft twice
try {
if (['draft', 'logs'].indexOf(gist._state.view) > -1) draft.draft()
} catch (error) {
return <DraftError error={error} app={app} draft={draft} at={'draft'} />
}
}
// Props to pass down
const componentProps = {
app,
design,
gist,
updateGist: updateWBGist,
unsetGist,
setGist,
feedback,
gistReady,
showInfo: setPopup,
hasRequiredMeasurements,
draft,
}
// Required props for layout
const layoutProps = {
app: app,
noSearch: true,
workbench: true,
AltMenu: <WorkbenchMenu {...componentProps} />,
showInfo: setPopup,
}
const errorProps = {
undoGist,
resetGist,
gist,
}
// Layout to use
const LayoutComponent = layout
const Component = views[gist._state?.view] ? views[gist._state.view] : views.welcome
return (
<LayoutComponent {...layoutProps}>
{messages}
<ErrorBoundary {...errorProps}>
<Component {...componentProps} draft={draft} />
{popup && <Modal cancel={() => setPopup(false)}>{popup}</Modal>}
</ErrorBoundary>
</LayoutComponent>
)
}
*/

View file

@ -9,18 +9,6 @@ import { loadSettingsConfig } from './config.mjs'
import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
import { SettingsIcon, ClearIcon, HelpIcon } from 'shared/components/icons.mjs'
import Link from 'next/link'
import {
Li,
Ul,
SumButton,
SumDiv,
Summary,
Deg,
SecText,
Details,
TopSummary,
TopSumTitle,
} from '../index.mjs'
import { Collapse } from 'shared/components/collapse.mjs'
import {
CompleteSettingInput,

View file

@ -1,6 +1,4 @@
import { useState } from 'react'
import { useTranslation } from 'next-i18next'
import { SecText, SumButton, Li, SumDiv, Deg } from 'shared/components/workbench/menus/index.mjs'
import { formatMm } from 'shared/utils.mjs'
import { ClearIcon } from 'shared/components/icons.mjs'
import { ChoiceButton } from 'shared/components/choice-button.mjs'
@ -202,10 +200,6 @@ export const SaMmSettingInput = ({ name, config, current, update, t, units }) =>
[['sa'], newCurrent],
])
}
const reset = () => {
update.settings([[['samm']], [['sa'], config.dflt]])
setValue(config.dflt)
}
return (
<>
@ -238,7 +232,6 @@ export const SaBoolSettingInput = ({ config, current, update, t, samm, changed }
if (typeof current === 'undefined') current = config.dflt
const handleChange = (newCurrent) => {
const newSa = newCurrent ? samm : 0
if (newCurrent === config.dflt) reset()
else {
update.settings([[['sabool'], newCurrent], [['sa']]])

View file

@ -1,5 +1,4 @@
import { formatMm } from 'shared/utils.mjs'
import { SecText, AccentText, PrimaryText } from 'shared/components/workbench/menus/index.mjs'
const ListValue = ({ current, t, config, changed }) =>
changed

View file

@ -8,17 +8,6 @@ import { ModalWrapper } from 'shared/components/wrappers/modal.mjs'
import { Collapse } from 'shared/components/collapse.mjs'
import { OptionsIcon, ClearIcon, HelpIcon, EditIcon, CloseIcon } from 'shared/components/icons.mjs'
import { Chevron } from 'shared/components/navigation/primary.mjs'
import {
Li,
Ul,
Details,
Summary,
SumDiv,
SumButton,
Deg,
TopSummary,
TopSumTitle,
} from 'shared/components/workbench/menus/index.mjs'
import { optionsMenuStructure } from 'shared/utils.mjs'
import { optionType } from 'shared/utils.mjs'
import {

View file

@ -1,152 +0,0 @@
import { DesignOptions } from './design-options/index.mjs'
import { CoreSettings, ns as coreSettingsNs } from './core-settings/index.mjs'
import { XrayMenu } from './xray/index.mjs'
import { TestDesignOptions } from './test-design-options/index.mjs'
import { BulletIcon } from 'shared/components/icons.mjs'
export const linkClasses = `
text-base text-base-content sm:text-base-content
hover:text-secondary
sm:hover:text-secondary
`
export const ns = coreSettingsNs
export const Ul = (props) => <ul className="pl-5 list-inside">{props.children}</ul>
export const Li = (props) => (
<li className="flex flex-row border-r-2 border-r-transparent hover:border-r-secondary">
{props.children}
</li>
)
export const Details = (props) => (
<details className="grow" open={props.open || false}>
{props.children}
</details>
)
export const Deg = ({ changed }) => (
<BulletIcon
className={`w-2.5 h-2.5 inline-block p-0 mr-1 ${changed ? 'text-accent' : ''}`}
stroke={6}
/>
)
export const NoSumDiv = (props) => (
<div
className={`
grow px-2 ml-2 border-l-2
${linkClasses}
hover:cursor-pointer
hover:border-secondary
sm:hover:border-secondary-focus
text-base-content sm:text-base-content
`}
>
{props.children}
</div>
)
export const SumDiv = (props) => (
<div
className={`
grow pl-2 border-l-2
${linkClasses}
hover:cursor-pointer
hover:border-secondary
sm:hover:border-secondary-focus
text-base-content sm:text-base-content
py-2
`}
>
{props.children}
</div>
)
export const Summary = (props) => (
<summary
className={`
flex flex-row
px-2
text-base-content
sm:text-base-content
hover:cursor-pointer
items-start
`}
>
{props.children}
</summary>
)
export const TopSummary = (props) => (
<summary
className={`
flex flex-row gap-4 text-lg
hover:cursor-pointer
p-2
text-base-content
sm:text-base-content
items-center
`}
>
<span className="text-secondary-focus mr-4">{props.icon || null}</span>
{props.children}
</summary>
)
export const SumButton = (props) => (
<button
className={`
flex flex-row
px-2
w-full justify-between
text-left
text-base-content
sm:text-base-content
hover:cursor-pointer
items-start
mr-4
`}
onClick={props.onClick}
>
{props.children}
</button>
)
export const TopSumTitle = (props) => (
<span className={`grow ${linkClasses} hover:cursor-pointer font-bold uppercase`}>
{props.children}
</span>
)
export const SecText = (props) =>
props.raw ? (
<span className="text-secondary-focus" dangerouslySetInnerHTML={{ __html: props.raw }} />
) : (
<span className="text-secondary-focus">{props.children}</span>
)
export const AccentText = (props) =>
props.raw ? (
<span className="text-accent-focus" dangerouslySetInnerHTML={{ __html: props.raw }} />
) : (
<span className="text-accent-focus">{props.children}</span>
)
export const PrimaryText = (props) =>
props.raw ? (
<span className="text-primary-focus" dangerouslySetInnerHTML={{ __html: props.raw }} />
) : (
<span className="text-primary-focus">{props.children}</span>
)
export const DraftMenu = (props) => {
const { design, patternConfig, settings, ui, update, Option = false } = props
return (
<nav className="grow mb-12">
<DesignOptions {...{ design, update, settings, patternConfig }} />
<CoreSettings {...{ design, update, settings, patternConfig }} />
{ui.renderer === 'react' ? <XrayMenu {...props} /> : null}
</nav>
)
}
export const TestMenu = (props) => {
return (
<nav className="grow mb-12">
<TestDesignOptions {...props} />
</nav>
)
}

View file

@ -1,15 +1,9 @@
import { Chevron } from 'shared/components/navigation/primary'
import {
Ul,
Li,
Details,
Summary,
SumDiv,
NoSumDiv,
Deg,
} from 'shared/components/workbench/menus/index.mjs'
export const XrayAttributes = ({ attr = false, t }) => {
return null
// FIXME
/*
if (!attr || !attr.list || Object.keys(attr.list).length < 1) return null
return (
@ -50,4 +44,5 @@ export const XrayAttributes = ({ attr = false, t }) => {
</Details>
</Li>
)
*/
}

View file

@ -3,7 +3,6 @@ import { linkClasses, Chevron } from 'shared/components/navigation/primary.mjs'
import { ConsoleLog } from './log.mjs'
import { XrayReset } from './reset.mjs'
import { XrayList } from './list.mjs'
import { Ul, Details, TopSummary } from 'shared/components/workbench/menus/index.mjs'
import { useTranslation } from 'next-i18next'
import { Collapse } from 'shared/components/collapse.mjs'
import { ChoiceButton } from 'shared/components/choice-button.mjs'

View file

@ -1,6 +1,5 @@
import { Chevron } from 'shared/components/navigation/primary.mjs'
import { ClearIcon, FilterIcon, SearchIcon } from 'shared/components/icons.mjs'
import { Ul, Li, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menus/index.mjs'
import { XrayPath } from './path.mjs'
import { XrayPoint } from './point.mjs'
import { useTranslation } from 'next-i18next'
@ -12,6 +11,9 @@ const types = {
export const XrayList = (props) => {
const { t } = useTranslation(['app', 'parts'])
return null
// FIXME
/*
const title = t(`parts:${props.partName}`) + ` (${props.partName})`
@ -159,4 +161,5 @@ export const XrayList = (props) => {
</Details>
</Li>
)
*/
}

View file

@ -1,15 +1,9 @@
import { Chevron } from 'shared/components/navigation/primary.mjs'
import {
Ul,
Li,
Details,
Summary,
SumButton,
SumDiv,
Deg,
} from 'shared/components/workbench/menus/index.mjs'
export const ConsoleLog = (props) => (
export const ConsoleLog = (props) => null
// FIXME
/*
(
<Li>
<Details>
<Summary>
@ -41,3 +35,4 @@ export const ConsoleLog = (props) => (
</Details>
</Li>
)
*/

View file

@ -1,17 +1,9 @@
import { Chevron } from 'shared/components/navigation/primary'
import {
Ul,
Li,
Details,
Summary,
SumDiv,
NoSumDiv,
Deg,
} from 'shared/components/workbench/menus/index.mjs'
import { XrayPoint } from './point'
const MoveLine = ({ op }) => <XrayPoint point={op.to} />
const Curve = ({ op }) =>
const Curve = ({ op }) => null
/*
['cp1', 'cp2', 'to'].map((pnt) => (
<Li key={pnt}>
<Details>
@ -26,8 +18,10 @@ const Curve = ({ op }) =>
</Details>
</Li>
))
const XrayPathOp = ({ op }) => (
*/
const XrayPathOp = ({ op }) => null
/*
* (
<Li>
{op.type === 'close' ? (
<NoSumDiv>
@ -49,8 +43,10 @@ const XrayPathOp = ({ op }) => (
)}
</Li>
)
export const XrayPathOps = ({ ops = false }) => {
*/
export const XrayPathOps = ({ ops = false }) => null
/*
* {
if (!ops || ops.length < 1) return null
return (
@ -72,3 +68,4 @@ export const XrayPathOps = ({ ops = false }) => {
</Li>
)
}
*/

View file

@ -1,9 +1,9 @@
import { Ul, Li, NoSumDiv, Deg } from 'shared/components/workbench/menus/index.mjs'
import { formatMm } from 'shared/utils.mjs'
import { XrayAttributes } from './attributes.mjs'
import { XrayPathOps } from './path-ops.mjs'
export const XrayPath = ({ pathName, partName, draft, units }) => {
export const XrayPath = ({ pathName, partName, draft, units }) => null
/*{
const path = draft?.parts?.[partName]?.paths?.[pathName]
if (!path) return null
@ -32,3 +32,4 @@ export const XrayPath = ({ pathName, partName, draft, units }) => {
</Ul>
)
}
*/

View file

@ -1,8 +1,8 @@
import { Ul, Li, NoSumDiv, Deg } from 'shared/components/workbench/menus/index.mjs'
import { round } from 'shared/utils'
import { XrayAttributes } from './attributes'
export const XrayPoint = ({ pointName, partName, draft, t }) => {
export const XrayPoint = ({ pointName, partName, draft, t }) => null
/*{
const point = draft?.parts?.[partName]?.points?.[pointName]
return point ? (
@ -20,3 +20,4 @@ export const XrayPoint = ({ pointName, partName, draft, t }) => {
</Ul>
) : null
}
*/

View file

@ -1,7 +1,7 @@
import { Li, SumButton, SumDiv, Deg } from 'shared/components/workbench/menus/index.mjs'
import { useTranslation } from 'next-i18next'
export const XrayReset = (props) => {
export const XrayReset = (props) => null
/*{
const { t } = useTranslation(['app'])
return (
@ -15,3 +15,4 @@ export const XrayReset = (props) => {
</Li>
)
}
*/