convert new files to mjs
This commit is contained in:
parent
5a04baf8be
commit
49f8badcfe
3 changed files with 12 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
import defaultSettings from './default-settings.js'
|
||||
import { defaultGist } from 'shared/components/workbench/gist.mjs'
|
||||
|
||||
/** A utility for validating a gist against a design */
|
||||
class GistValidator {
|
||||
|
@ -16,11 +16,11 @@ class GistValidator {
|
|||
|
||||
/** check that the settings all exist and are all of the right type */
|
||||
validateSettings() {
|
||||
for (const key in defaultSettings) {
|
||||
for (const key in defaultGist) {
|
||||
if (this.givenGist[key] === undefined) {
|
||||
this.errors[key] = 'MissingSetting'
|
||||
this.valid = false
|
||||
} else if (typeof this.givenGist[key] !== typeof defaultSettings[key]) {
|
||||
} else if (typeof this.givenGist[key] !== typeof defaultGist[key]) {
|
||||
this.errors[key] = 'TypeError'
|
||||
this.valid = false
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class GistValidator {
|
|||
const validator = new GistValidator()
|
||||
|
||||
/** make and run a gist validator */
|
||||
export default function validateGist(givenGist, design) {
|
||||
export function validateGist(givenGist, design) {
|
||||
validator.setGist(givenGist, design)
|
||||
return validator.validate()
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
import yaml from 'js-yaml'
|
||||
import defaultSettings from './default-settings'
|
||||
import validateGist from './gist-validator'
|
||||
import { defaultGist } from 'shared/components/workbench/gist.mjs'
|
||||
import { validateGist } from './gist-validator.mjs'
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import Popout from 'shared/components/popout.js'
|
||||
import Popout from 'shared/components/popout.mjs'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { capitalize } from '@freesewing/core'
|
||||
|
||||
/** a view for editing the gist as yaml */
|
||||
const Edit = (props) => {
|
||||
export const EditYaml = (props) => {
|
||||
let { gist, setGist, gistReady } = props
|
||||
|
||||
const inputRef = useRef(null)
|
||||
|
@ -50,8 +50,8 @@ const Edit = (props) => {
|
|||
// and the default settings to make sure all necessary keys are accounted for,
|
||||
// but we're not keeping stuff that was supposed to be cleared
|
||||
const gistFromDefaults = { _state: gist._state }
|
||||
for (const d in defaultSettings) {
|
||||
gistFromDefaults[d] = gist[d] === undefined ? defaultSettings[d] : gist[d]
|
||||
for (const d in defaultGist) {
|
||||
gistFromDefaults[d] = gist[d] === undefined ? defaultGist[d] : gist[d]
|
||||
}
|
||||
|
||||
// merge it all up
|
||||
|
@ -114,5 +114,3 @@ const Edit = (props) => {
|
|||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Edit
|
|
@ -18,7 +18,7 @@ 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'
|
||||
|
||||
const views = {
|
||||
measurements: WorkbenchMeasurements,
|
||||
|
@ -30,7 +30,7 @@ const views = {
|
|||
logs: DraftLogs,
|
||||
yaml: GistAsYaml,
|
||||
json: GistAsJson,
|
||||
edit: Edit,
|
||||
edit: EditYaml,
|
||||
welcome: () => <p>TODO</p>,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue