1
0
Fork 0

wip(new-design): Initial work to port to v3

This commit is contained in:
Joost De Cock 2022-10-06 14:15:13 +02:00
parent a94f1cc3ef
commit 9c488f6bcb
22 changed files with 999 additions and 444 deletions

View file

@ -1,8 +1,12 @@
export const config = {
node: 14, // Minimum node version
// Minimum node version
node: 16,
// Site to download from
fileUri: 'https://raw.githubusercontent.com',
repo: process.env.FS_REPO || 'freesewing/freesewing', // Repository to download from
branch: process.env.FS_BRANCH || 'main', // Branch to download from
// Repository to download from
repo: process.env.FS_REPO || 'freesewing/freesewing',
// Branch to download from
branch: process.env.FS_BRANCH || 'develop',
i18n: [
'account',
'common',
@ -24,223 +28,6 @@ export const config = {
'settings',
'welcome',
],
fetch: {
sites: [
"shared/utils.mjs",
"shared/config/freesewing.mjs",
"shared/config/i18n.config.mjs",
"shared/config/next.mjs",
"shared/config/postcss.config.js",
"shared/config/tailwind.config.js",
"shared/prebuild/contributors.mjs",
"shared/hooks/useGist.js",
"shared/hooks/useLocalStorage.js",
"shared/hooks/useTheme.js",
"shared/styles/code.css",
"shared/styles/globals.css",
"shared/styles/svg-freesewing-draft.css",
"shared/themes/dark.js",
"shared/themes/hax0r.js",
"shared/themes/index.js",
"shared/themes/lgbtq.js",
"shared/themes/light.js",
"shared/themes/runtime.js",
"shared/themes/trans.js",
"shared/components/copy-to-clipboard.js",
"shared/components/json.js",
"shared/components/lightbox.js",
"shared/components/locale-picker.js",
"shared/components/modal.js",
"shared/components/page-link.js",
"shared/components/pinked-ribbon.js",
"shared/components/popout.js",
"shared/components/raw-span.js",
"shared/components/theme-picker.js",
"shared/components/web-link.js",
"shared/components/yaml.js",
"shared/components/layouts/default.js",
"shared/components/icons/box.js",
"shared/components/icons/camera.js",
"shared/components/icons/clear.js",
"shared/components/icons/close.js",
"shared/components/icons/cog.js",
"shared/components/icons/community.js",
"shared/components/icons/copy.js",
"shared/components/icons/design.js",
"shared/components/icons/discord.js",
"shared/components/icons/docs.js",
"shared/components/icons/down.js",
"shared/components/icons/edit.js",
"shared/components/icons/export.js",
"shared/components/icons/facebook.js",
"shared/components/icons/filter.js",
"shared/components/icons/flip.js",
"shared/components/icons/freesewing.js",
"shared/components/icons/github.js",
"shared/components/icons/google.js",
"shared/components/icons/guide.js",
"shared/components/icons/heart.js",
"shared/components/icons/help.js",
"shared/components/icons/i18n.js",
"shared/components/icons/instagram.js",
"shared/components/icons/left.js",
"shared/components/icons/menu.js",
"shared/components/icons/note.js",
"shared/components/icons/options.js",
"shared/components/icons/page.js",
"shared/components/icons/page-size.js",
"shared/components/icons/print.js",
"shared/components/icons/reddit.js",
"shared/components/icons/right.js",
"shared/components/icons/rotate.js",
"shared/components/icons/rss.js",
"shared/components/icons/search.js",
"shared/components/icons/settings.js",
"shared/components/icons/sheet.js",
"shared/components/icons/theme.js",
"shared/components/icons/tip.js",
"shared/components/icons/tutorial.js",
"shared/components/icons/twitter.js",
"shared/components/icons/user.js",
"shared/components/icons/versions.js",
"shared/components/icons/with-breasts.js",
"shared/components/icons/without-breasts.js",
"shared/components/icons/xray.js",
"shared/components/logos/cc-by.js",
"shared/components/logos/cc.js",
"shared/components/logos/freesewing.js",
"shared/components/logos/osi.js",
"shared/components/navigation/aside.js",
"shared/components/navigation/primary.js",
"shared/components/picker.js",
"shared/components/robot/index.js",
"shared/components/robot/poses.js",
"shared/components/wrappers/img.js",
"shared/components/wrappers/mdx.js",
"shared/components/wrappers/page.js",
"shared/components/wrappers/toc.js",
"shared/components/wrappers/workbench.js",
"shared/components/mdx/index.js",
"shared/components/mdx/tabs.js",
"shared/components/workbench/default-settings.js",
"shared/components/workbench/draft/circle/index.js",
"shared/components/workbench/draft/defs/index.js",
"shared/components/workbench/draft/error.js",
"shared/components/workbench/draft/index.js",
"shared/components/workbench/draft/part/index.js",
"shared/components/workbench/draft/path/index.js",
"shared/components/workbench/draft/point/index.js",
"shared/components/workbench/draft/snippet/index.js",
"shared/components/workbench/draft/svg/index.js",
"shared/components/workbench/draft/svg-wrapper.js",
"shared/components/workbench/draft/text/index.js",
"shared/components/workbench/draft/text-on-path/index.js",
"shared/components/workbench/draft/utils.js",
"shared/components/workbench/events.js",
"shared/components/workbench/exporting/index.js",
"shared/components/workbench/exporting/pdfExporter.js",
"shared/components/workbench/inputs/design-option-count.js",
"shared/components/workbench/inputs/design-option-list.js",
"shared/components/workbench/inputs/design-option-pct-deg.js",
"shared/components/workbench/inputs/measurement.js",
"shared/components/workbench/json.js",
"shared/components/workbench/layout/cut/index.js",
"shared/components/workbench/layout/cut/settings.js",
"shared/components/workbench/layout/draft/buttons.js",
"shared/components/workbench/layout/draft/index.js",
"shared/components/workbench/layout/draft/part.js",
"shared/components/workbench/layout/print/index.js",
"shared/components/workbench/layout/print/orientation-picker.js",
"shared/components/workbench/layout/print/pagesize-picker.js",
"shared/components/workbench/layout/print/plugin.js",
"shared/components/workbench/layout/print/settings.js",
"shared/components/workbench/measurements/index.js",
"shared/components/workbench/measurements/non-human.js",
"shared/components/workbench/menu/core-settings/core-setting-bool.js",
"shared/components/workbench/menu/core-settings/core-setting-list.js",
"shared/components/workbench/menu/core-settings/core-setting-mm.js",
"shared/components/workbench/menu/core-settings/core-setting-nr.js",
"shared/components/workbench/menu/core-settings/core-setting-only.js",
"shared/components/workbench/menu/core-settings/core-setting-sa-bool.js",
"shared/components/workbench/menu/core-settings/core-setting-sa-mm.js",
"shared/components/workbench/menu/core-settings/index.js",
"shared/components/workbench/menu/core-settings/setting.js",
"shared/components/workbench/menu/design-options/index.js",
"shared/components/workbench/menu/design-options/option-group.js",
"shared/components/workbench/menu/design-options/option-input.js",
"shared/components/workbench/menu/design-options/option.js",
"shared/components/workbench/menu/design-options/option-value.js",
"shared/components/workbench/menu/index.js",
"shared/components/workbench/menu/test-design-options/index.js",
"shared/components/workbench/menu/test-design-options/option-group.js",
"shared/components/workbench/menu/test-design-options/option.js",
"shared/components/workbench/menu/test-design-options/option-sub-group.js",
"shared/components/workbench/menu/view.js",
"shared/components/workbench/menu/xray/attributes.js",
"shared/components/workbench/menu/xray/disable.js",
"shared/components/workbench/menu/xray/index.js",
"shared/components/workbench/menu/xray/list.js",
"shared/components/workbench/menu/xray/log.js",
"shared/components/workbench/menu/xray/path.js",
"shared/components/workbench/menu/xray/path-ops.js",
"shared/components/workbench/menu/xray/point.js",
"shared/components/workbench/menu/xray/reset.js",
"shared/components/workbench/preload.js",
"shared/components/workbench/sample.js",
"shared/components/workbench/yaml.js",
"shared/components/error/error-boundary.js",
"shared/components/error/error-boundary.js",
"shared/components/error/reset-buttons.js",
"shared/components/error/view.js",
"shared/components/workbench/layout/draft/index.js",
"shared/components/workbench/layout/draft/part.js",
"shared/components/workbench/layout/cut/index.js",
"shared/components/workbench/layout/cut/settings.js",
"shared/components/workbench/layout/print/index.js",
"shared/components/workbench/layout/print/orientation-picker.js",
"shared/components/workbench/layout/print/pagesize-picker.js",
"shared/components/workbench/layout/print/plugin.js",
"shared/components/workbench/layout/print/settings.js",
"shared/components/workbench/menu/index.js",
"shared/components/workbench/menu/view.js",
"shared/components/workbench/menu/core-settings/core-setting-bool.js",
"shared/components/workbench/menu/core-settings/core-setting-list.js",
"shared/components/workbench/menu/core-settings/core-setting-mm.js",
"shared/components/workbench/menu/core-settings/core-setting-nr.js",
"shared/components/workbench/menu/core-settings/core-setting-only.js",
"shared/components/workbench/menu/core-settings/core-setting-sa-bool.js",
"shared/components/workbench/menu/core-settings/core-setting-sa-mm.js",
"shared/components/workbench/menu/core-settings/index.js",
"shared/components/workbench/menu/core-settings/setting.js",
"shared/components/workbench/menu/design-options/index.js",
"shared/components/workbench/menu/design-options/option-group.js",
"shared/components/workbench/menu/design-options/option-input.js",
"shared/components/workbench/menu/design-options/option-value.js",
"shared/components/workbench/menu/design-options/option.js",
"shared/components/workbench/menu/test-design-options/index.js",
"shared/components/workbench/menu/test-design-options/option-group.js",
"shared/components/workbench/menu/test-design-options/option-sub-group.js",
"shared/components/workbench/menu/test-design-options/option.js",
"shared/components/workbench/menu/xray/attributes.js",
"shared/components/workbench/menu/xray/disable.js",
"shared/components/workbench/menu/xray/index.js",
"shared/components/workbench/menu/xray/list.js",
"shared/components/workbench/menu/xray/log.js",
"shared/components/workbench/menu/xray/path-ops.js",
"shared/components/workbench/menu/xray/path.js",
"shared/components/workbench/menu/xray/point.js",
"shared/components/workbench/menu/xray/reset.js",
"lab/components/footer.js",
"lab/components/wrappers/layout.js",
"lab/components/wrappers/page.js"
],
config: [
{
from: 'measurements.mjs',
to: 'shared/config/measurements.mjs'
}
],
},
gitignore: `
# See https://help.github.com/ignore-files/ for more about ignoring files.
@ -263,5 +50,216 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
`,
fetch: {
config: [
{
from: 'measurements.mjs',
to: 'shared/config/measurements.mjs',
},
],
sites: [
'shared/utils.mjs',
'shared/designs/index.js',
'shared/hooks/useGist.js',
'shared/hooks/useLocalStorage.js',
'shared/hooks/useTheme.js',
'shared/mdx/compiler.js',
'shared/mdx/loader.js',
'shared/mdx/mdx-plugin-toc.mjs',
'shared/mdx/remark-intro-plugin.mjs',
'shared/config/freesewing.mjs',
'shared/config/i18n.config.mjs',
'shared/config/next.mjs',
'shared/config/postcss.config.js',
'shared/config/tailwind-force.html',
'shared/config/tailwind.config.js',
'shared/prebuild/contributors.mjs',
'shared/prebuild/feed.mjs',
'shared/prebuild/i18n-only.mjs',
'shared/prebuild/i18n.mjs',
'shared/prebuild/index.mjs',
'shared/prebuild/lab.mjs',
'shared/prebuild/mdx.mjs',
'shared/prebuild/navigation.mjs',
'shared/prebuild/patrons.mjs',
'shared/prebuild/strapi.mjs',
'shared/strapi/loader.js',
'shared/strapi/qa.mjs',
'shared/themes/dark.js',
'shared/themes/hax0r.js',
'shared/themes/index.js',
'shared/themes/lgbtq.js',
'shared/themes/light.js',
'shared/themes/runtime.js',
'shared/styles/code.css',
'shared/styles/globals.css',
'shared/styles/svg-freesewing-draft.css',
'shared/components/breadcrumbs.js',
'shared/components/code.js',
'shared/components/copy-to-clipboard.js',
'shared/components/docs-link.js',
'shared/components/json-highlight.js',
'shared/components/lightbox.js',
'shared/components/locale-picker.js',
'shared/components/modal.js',
'shared/components/page-link.js',
'shared/components/picker.js',
'shared/components/popout.js',
'shared/components/raw-span.js',
'shared/components/ribbon.js',
'shared/components/theme-picker.js',
'shared/components/web-link.js',
'shared/components/wordmark.js',
'shared/components/worm.js',
'shared/components/yaml.js',
'shared/components/error/error-boundary.js',
'shared/components/error/reset-buttons.js',
'shared/components/error/view.js',
'shared/components/layouts/default.js',
'shared/components/logos/cc-by.js',
'shared/components/logos/cc.js',
'shared/components/logos/freesewing.js',
'shared/components/logos/osi.js',
'shared/components/mdx/example.js',
'shared/components/mdx/examples.js',
'shared/components/mdx/figure.js',
'shared/components/mdx/highlight.js',
'shared/components/mdx/index.js',
'shared/components/mdx/prev-next.js',
'shared/components/mdx/read-more.js',
'shared/components/mdx/tabs.js',
'shared/components/mdx/youtube.js',
'shared/components/navigation/aside.js',
'shared/components/navigation/primary.js',
'shared/components/icons/box.js',
'shared/components/icons/camera.js',
'shared/components/icons/clear.js',
'shared/components/icons/close.js',
'shared/components/icons/cog.js',
'shared/components/icons/community.js',
'shared/components/icons/copy.js',
'shared/components/icons/design.js',
'shared/components/icons/discord.js',
'shared/components/icons/docs.js',
'shared/components/icons/down.js',
'shared/components/icons/edit.js',
'shared/components/icons/export.js',
'shared/components/icons/facebook.js',
'shared/components/icons/filter.js',
'shared/components/icons/flip.js',
'shared/components/icons/freesewing.js',
'shared/components/icons/github.js',
'shared/components/icons/google.js',
'shared/components/icons/guide.js',
'shared/components/icons/heart.js',
'shared/components/icons/help.js',
'shared/components/icons/i18n.js',
'shared/components/icons/instagram.js',
'shared/components/icons/left.js',
'shared/components/icons/menswear.js',
'shared/components/icons/menu.js',
'shared/components/icons/note.js',
'shared/components/icons/options.js',
'shared/components/icons/page-size.js',
'shared/components/icons/page.js',
'shared/components/icons/print.js',
'shared/components/icons/reddit.js',
'shared/components/icons/right.js',
'shared/components/icons/rotate.js',
'shared/components/icons/rss.js',
'shared/components/icons/search.js',
'shared/components/icons/settings.js',
'shared/components/icons/sheet.js',
'shared/components/icons/swipeleft.js',
'shared/components/icons/swiperight.js',
'shared/components/icons/theme.js',
'shared/components/icons/tip.js',
'shared/components/icons/tutorial.js',
'shared/components/icons/twitter.js',
'shared/components/icons/user.js',
'shared/components/icons/versions.js',
'shared/components/icons/womenswear.js',
'shared/components/icons/xray.js',
'shared/components/robot/index.js',
'shared/components/robot/poses.js',
'shared/components/wrappers/img.js',
'shared/components/wrappers/mdx.js',
'shared/components/wrappers/page.js',
'shared/components/wrappers/toc.js',
'shared/components/wrappers/workbench.js',
'shared/components/workbench/default-settings.js',
'shared/components/workbench/gist-as-json.js',
'shared/components/workbench/logs.js',
'shared/components/workbench/preload.js',
'shared/components/workbench/sample.js',
'shared/components/workbench/yaml.js',
'shared/components/workbench/inputs/design-option-count.js',
'shared/components/workbench/inputs/design-option-list.js',
'shared/components/workbench/inputs/design-option-pct-deg.js',
'shared/components/workbench/inputs/measurement.js',
'shared/components/workbench/exporting/export-handler.js',
'shared/components/workbench/exporting/export-worker.js',
'shared/components/workbench/exporting/index.js',
'shared/components/workbench/exporting/pdf-maker.js',
'shared/components/workbench/measurements/index.js',
'shared/components/workbench/measurements/non-human.js',
'shared/components/workbench/draft/error.js',
'shared/components/workbench/draft/index.js',
'shared/components/workbench/draft/stack.js',
'shared/components/workbench/draft/svg-wrapper.js',
'shared/components/workbench/draft/utils.js',
'shared/components/workbench/draft/circle/index.js',
'shared/components/workbench/draft/defs/index.js',
'shared/components/workbench/draft/part/index.js',
'shared/components/workbench/draft/path/index.js',
'shared/components/workbench/draft/point/index.js',
'shared/components/workbench/draft/snippet/index.js',
'shared/components/workbench/draft/svg/index.js',
'shared/components/workbench/draft/text/index.js',
'shared/components/workbench/draft/text-on-path/index.js',
'shared/components/workbench/layout/cut/index.js',
'shared/components/workbench/layout/cut/settings.js',
'shared/components/workbench/layout/draft/buttons.js',
'shared/components/workbench/layout/draft/index.js',
'shared/components/workbench/layout/draft/part.js',
'shared/components/workbench/layout/print/index.js',
'shared/components/workbench/layout/print/orientation-picker.js',
'shared/components/workbench/layout/print/pagesize-picker.js',
'shared/components/workbench/layout/print/plugin.js',
'shared/components/workbench/layout/print/settings.js',
'shared/components/workbench/menu/index.js',
'shared/components/workbench/menu/view.js',
'shared/components/workbench/menu/core-settings/core-setting-bool.js',
'shared/components/workbench/menu/core-settings/core-setting-list.js',
'shared/components/workbench/menu/core-settings/core-setting-mm.js',
'shared/components/workbench/menu/core-settings/core-setting-nr.js',
'shared/components/workbench/menu/core-settings/core-setting-only.js',
'shared/components/workbench/menu/core-settings/core-setting-sa-bool.js',
'shared/components/workbench/menu/core-settings/core-setting-sa-mm.js',
'shared/components/workbench/menu/core-settings/index.js',
'shared/components/workbench/menu/core-settings/setting.js',
'shared/components/workbench/menu/design-options/index.js',
'shared/components/workbench/menu/design-options/option-group.js',
'shared/components/workbench/menu/design-options/option-input.js',
'shared/components/workbench/menu/design-options/option-value.js',
'shared/components/workbench/menu/design-options/option.js',
'shared/components/workbench/menu/test-design-options/index.js',
'shared/components/workbench/menu/test-design-options/option.js',
'shared/components/workbench/menu/xray/attributes.js',
'shared/components/workbench/menu/xray/disable.js',
'shared/components/workbench/menu/xray/index.js',
'shared/components/workbench/menu/xray/list.js',
'shared/components/workbench/menu/xray/log.js',
'shared/components/workbench/menu/xray/path-ops.js',
'shared/components/workbench/menu/xray/path.js',
'shared/components/workbench/menu/xray/point.js',
'shared/components/workbench/menu/xray/reset.js',
'lab/components/about.js',
'lab/components/design-picker.js',
'lab/components/layouts/bare.js',
'lab/components/layouts/lab.js',
'lab/components/wrappers/layout.js',
'lab/components/wrappers/page.js',
],
},
}

View file

@ -22,7 +22,7 @@ const nl = '\n'
const tab = ' '
const nlt = nl + tab
// Checks for node 14 or higher
// Checks for node 16 or higher
export const checkNodeVersion = () => {
const node_version = process.version.slice(1).split('.')[0]
if (parseInt(node_version) < config.node) {
@ -134,25 +134,12 @@ const copyTemplate = async (config, choices) => {
// Template files
for (const from of config.files.template) {
/*
* We can't include a package.json file in the templates
* because doing so will prevent NPM from including those folders
* in our package. So we use _package.json, and if we see that we
* rename it here to package.json
*/
let to = join(config.dest, from.slice(config.source.template.length - 7))
if (to.slice(-13) === '_package.json') {
to = to.slice(0, -13) + 'package.json'
}
if (to.slice(-9) === '.mustache') to = to.slice(0, -9)
if (!dirs[to]) await ensureDir(to)
if (['config.js', 'kage.json'].indexOf(from.slice(-9)) !== -1) {
// Template out file rather than coy it
const src = await readFile(from, 'utf-8')
promises.push(writeFile(to, mustache.render(src, { name: choices.name })))
} else {
// Just copy the file
promises.push(copyFile(from, to))
}
// Template out file
const src = await readFile(from, 'utf-8')
promises.push(writeFile(to, mustache.render(src, { name: choices.name })))
}
await Promise.all(promises)

View file

@ -0,0 +1,36 @@
import rdir from 'recursive-readdir'
import path from 'path'
const ignore = [
'package.json',
'node_modules',
'.eslint',
'.gitignore',
'.md',
'lab/components/header.js',
'lab/components/help-us.js',
'lab/components/search.js',
'lab/components/footer.js',
'shared/config/measurements.js',
]
const getFiles = async (dir) => {
const all = await rdir(path.resolve(dir))
return all
.filter((file) => {
for (const skip of ignore) {
if (file.includes(skip)) return false
}
return true
})
.map((file) => file.split('/sites/').pop())
}
const doIt = async () => {
let files = []
const shared = await getFiles('../../sites/shared')
const lab = await getFiles('../../sites/lab/components')
console.log(JSON.stringify([...shared, ...lab], null, 2))
}
doIt()

View file

@ -0,0 +1,119 @@
import Logo from 'shared/components/logos/freesewing.js'
import OsiLogo from 'shared/components/logos/osi.js'
import CreativeCommonsLogo from 'shared/components/logos/cc.js'
import CcByLogo from 'shared/components/logos/cc-by.js'
import { useTranslation } from 'next-i18next'
import Ribbon from 'shared/components/ribbon.js'
import Link from 'next/link'
import { WordMark } from 'shared/components/wordmark.js'
import DiscordIcon from 'shared/components/icons/discord.js'
import FacebookIcon from 'shared/components/icons/facebook.js'
import GithubIcon from 'shared/components/icons/github.js'
import InstagramIcon from 'shared/components/icons/instagram.js'
import RedditIcon from 'shared/components/icons/reddit.js'
import TwitterIcon from 'shared/components/icons/twitter.js'
// Classes
const link = 'text-secondary font-bold hover:pointer hover:underline px-1'
const accent = 'text-accent font-bold text-lg px-1 block sm:inline'
const freesewing = 'px-1 text-lg font-bold block sm:inline'
// Keep these translations in the component because they're only used here
const translations = {
cc: (
<span>
Content on FreeSewing.org is available under{' '}
<a className={link} href="https://creativecommons.org/licenses/by/4.0/">
a Creative Commons license
</a>
</span>
),
mit: (
<span>
The FreeSewing source code is{' '}
<a href="https://github.com/freesewing/freesewing" className={link}>
available on Github
</a>{' '}
under{' '}
<a href="https://opensource.org/licenses/MIT" className={link}>
the MIT license
</a>
</span>
),
sponsors: (
<>
<span className={freesewing}>FreeSewing</span> is sponsored by these{' '}
<span className={accent}>awesome companies</span>
</>
),
}
const icon = { className: 'w-8 lg:w-12 h-8 lg:h-12' }
const social = {
Discord: {
icon: <DiscordIcon {...icon} />,
href: 'https://discord.freesewing.org/',
},
Instagram: {
icon: <InstagramIcon {...icon} />,
href: 'https://instagram.com/freesewing_org',
},
Facebook: {
icon: <FacebookIcon {...icon} />,
href: 'https://www.facebook.com/groups/627769821272714/',
},
Github: {
icon: <GithubIcon {...icon} />,
href: 'https://github.com/freesewing',
},
Reddit: {
icon: <RedditIcon {...icon} />,
href: 'https://www.reddit.com/r/freesewing/',
},
Twitter: {
icon: <TwitterIcon {...icon} />,
href: 'https://twitter.com/freesewing_org',
},
}
const Footer = ({ app }) => {
const { t } = useTranslation(['common', 'patrons'])
return (
<footer className="bg-neutral mt-20">
<Ribbon loading={app.loading} theme={app.theme} />
<div className="py-12 2xl:py-20 text-neutral-content px-4 m-auto">
{/* Logo & Slogan */}
<div className="w-full mb-12 text-center">
<div className="max-w-md m-auto">
<Logo stroke="none" size={164} className="w-40 lg:w-64 m-auto m-auto" />
<h5 className="lg:text-3xl mt-4">
<WordMark />
</h5>
<p className="bold text-neutral-content text-normal lg:text-xl leading-5">
{t('sloganCome')}
<br />
{t('sloganStay')}
</p>
</div>
</div>
{/* Second col - Social */}
<div className="lg:col-span-2 -order-2 2xl:order-2 px-4 lg:px-0">
{/* Social icons */}
<div className="w-full sm:w-auto flex flex-row flex-wrap gap-4 lg:gap-8 items-center justify-center">
{Object.keys(social).map((item) => (
<Link key={item} href={social[item].href}>
<a className="hover:text-secondary hover:-mt-2 transition-all" title={item}>
{social[item].icon}
</a>
</Link>
))}
</div>
</div>
</div>
</footer>
)
}
export default Footer

View file

@ -2,21 +2,18 @@ import { useState, useEffect } from 'react'
import Link from 'next/link'
import ThemePicker from 'shared/components/theme-picker.js'
import LocalePicker from 'shared/components/locale-picker.js'
import DesignPicker from 'site/components/design-picker.js'
import CloseIcon from 'shared/components/icons/close.js'
import MenuIcon from 'shared/components/icons/menu.js'
import HelpIcon from 'shared/components/icons/help.js'
import Ribbon from 'shared/components/ribbon.js'
import { WordMark } from 'shared/components/wordmark.js'
import DocsIcon from 'shared/components/icons/docs.js'
import { useTranslation } from 'next-i18next'
const Right = props => (
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 8l4 4m0 0l-4 4m4-4H3" />
</svg>
)
const Left = props => (
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 19l-7-7m0 0l7-7m-7 7h18" />
</svg>
)
const btnClasses =
'btn btn-ghost text-base font-medium btn-sm text-neutral-content ' +
' capitalize hover:bg-transparent hover:text-secondary-focus'
const Header = ({ app }) => {
const { t } = useTranslation(['common'])
@ -27,11 +24,10 @@ const Header = ({ app }) => {
useEffect(() => {
if (typeof window !== 'undefined') {
const handleScroll = () => {
const curScrollPos = (typeof window !== 'undefined') ? window.pageYOffset : 0
const curScrollPos = typeof window !== 'undefined' ? window.pageYOffset : 0
if (curScrollPos >= prevScrollPos) {
if (show && curScrollPos > 20) setShow(false)
}
else setShow(true)
} else setShow(true)
setPrevScrollPos(curScrollPos)
}
window.addEventListener('scroll', handleScroll)
@ -39,59 +35,53 @@ const Header = ({ app }) => {
}
}, [prevScrollPos, show])
return (
<header className={`
<header
className={`
fixed top-0 left-0
bg-neutral
w-full
z-30
transition-transform
drop-shadow-xl
${show ? '': 'fixed top-0 left-0 -translate-y-20'}
${app.loading ? "theme-gradient loading" : ""}
`}>
<div className="max-w-6xl m-auto">
<div className="p-2 flex flex-row gap-2 justify-between text-neutral-content">
${show ? '' : 'fixed top-0 left-0 -translate-y-20'}
`}
>
<div>
<div className="p-2 flex flex-row justify-between text-neutral-content">
<div className="flex flex-row items-center">
<button
className={`
btn btn-sm
text-neutral-content bg-transparent
border border-transparent
hover:bg-transparent hover:border-base-100
md:hidden
h-12
`}
onClick={app.togglePrimaryMenu}>
{app.primaryMenu
? <><CloseIcon /><span className="opacity-50 pl-2 flex flex-row items-center gap-1"><Left />swipe</span></>
: <><MenuIcon /><span className="opacity-50 pl-2 flex flex-row items-center gap-1"><Right />swipe</span></>
}
btn btn-sm btn-ghost
text-neutral-content bg-transparent
hover:text-secondary-focus
lg:hidden
`}
onClick={app.togglePrimaryMenu}
>
{app.primaryMenu ? <CloseIcon /> : <MenuIcon />}
</button>
<WordMark />
<div className="hidden md:flex flex-row items-center">
<a role="button" className="btn btn-link btn-sm text-neutral-content" href="https://freesewing.dev/">
<DocsIcon /><span className="ml-2">{t('docs')}</span>
<a role="button" className={btnClasses} href="https://freesewing.dev/">
<DocsIcon />
<span className="ml-2">{t('docs')}</span>
</a>
<Link href="/support">
<a role="button" className="btn btn-link btn-sm text-neutral-content ">
<DocsIcon /><span className="ml-2">{t('support')}</span>
<a role="button" className={btnClasses}>
<HelpIcon />
<span className="ml-2">{t('support')}</span>
</a>
</Link>
</div>
<div className="hidden md:flex md:flex-row gap-2">
<Link href="/">
<a role="button" className="btn btn-link btn-sm text-neutral-content h-12 font-normal lowercase text-2xl">
<span className="font-black px-1 normal-case">FreeSewing</span>
</a>
</Link>
</div>
<div className="hidden md:flex flex-row items-center">
<ThemePicker app={app} />
<LocalePicker app={app} />
</div>
</div>
<div className="hidden md:flex flex-row items-center gap-2">
<ThemePicker app={app} />
<LocalePicker app={app} />
</div>
</div>
</header>
</div>
<Ribbon loading={app.loading} theme={app.theme} />
</header>
)
}

View file

@ -6,13 +6,12 @@ import { useRouter } from 'next/router'
import useTheme from 'shared/hooks/useTheme'
function useApp(full = true) {
// Load translation method
const locale = useRouter().locale
// Persistent state
const [account, setAccount] = useLocalStorage('account', { username: false })
const [theme, setTheme] = useTheme();
const [theme, setTheme] = useTheme()
// React State
const [primaryMenu, setPrimaryMenu] = useState(false)
@ -43,13 +42,18 @@ function useApp(full = true) {
setPrimaryMenu,
setSlug,
setTheme,
startLoading: () => { setLoading(true); setPrimaryMenu(false) }, // Always close menu when navigating
startLoading: () => {
setLoading(true)
setPrimaryMenu(false)
}, // Always close menu when navigating
stopLoading: () => setLoading(false),
// State handlers
togglePrimaryMenu,
// Standalone is for the development environment
standalone: true,
}
}
export default useApp

View file

@ -2,25 +2,15 @@ import path from 'path'
import i18nConfig from './next-i18next.config.js'
const config = {
experimental: {
externalDir: true,
},
i18n: i18nConfig.i18n,
pageExtensions: [ 'js', 'mjs' ],
pageExtensions: ['mjs'],
webpack: (config, options) => {
// Suppress warnings about importing version from package.json
// We'll deal with it in v3 of FreeSewing
config.ignoreWarnings = [
/only default export is available soon/
]
// Aliases
config.resolve.alias.shared = path.resolve('./shared/')
config.resolve.alias.site = path.resolve('./lab/')
config.resolve.alias.design = path.resolve('./design/')
return config
}
},
}
export default config

View file

@ -1,4 +1,4 @@
import design from 'design/src/index.js'
import { Pattern } from 'design/src/index.mjs'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import Page from 'site/components/wrappers/page.js'
@ -6,12 +6,12 @@ import useApp from 'site/hooks/useApp.js'
import WorkbenchWrapper from 'shared/components/wrappers/workbench.js'
import Layout from 'site/components/layouts/lab'
const WorkbenchPage = props => {
const WorkbenchPage = (props) => {
const app = useApp()
return (
<Page app={app}>
<WorkbenchWrapper {...{ app, design, layout: Layout }} />
<WorkbenchWrapper {...{ app, design: Pattern, layout: Layout }} />
</Page>
)
}
@ -22,6 +22,6 @@ export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale)),
}
},
}
}

View file

@ -19,8 +19,17 @@ const translations = {
nl: `Naar jouw ontwerp`,
},
tips: {
en: <Popout tip compact>Edit the files in the <strong>design</strong> folder, and we'll auto-update your design</Popout>,
nl: <Popout tip compact>Bewerk de bestanden in de <strong>design</strong> map, en we passen je ontwerp automatisch aan</Popout>,
en: (
<Popout tip compact>
Edit the files in the <strong>design</strong> folder, and we'll auto-update your design
</Popout>
),
nl: (
<Popout tip compact>
Bewerk de bestanden in de <strong>design</strong> map, en we passen je ontwerp automatisch
aan
</Popout>
),
},
}
@ -37,39 +46,38 @@ const HomePage = (props) => {
<h4>{translations.sade[app.locale]}</h4>
<Link href="/design">
<a className="btn btn-primary btn-lg h-20 my-8 mb-12">
<span role='image' className="text-4xl px-6">👉</span>
<span role="image" className="text-4xl px-6">
👉
</span>
<span className="text-xl px-2">{translations.load[app.locale]}</span>
<span role='image' className="text-4xl px-6">👈</span>
<span role="image" className="text-4xl px-6">
👈
</span>
</a>
</Link>
{translations.tips[app.locale]}
</div>
<div className="flex flex-row flex-wrap gap-4 w-full max-w-4xl m-auto justify-center">
{router.locales.map(locale => (
{router.locales.map((locale) => (
<Link href={router.asPath} locale={locale} key={locale}>
<a className="btn btn-ghost text-base-content hover:bg-base-200">
<span className="text-base-content">
{t(`locales:${locale}`)}
</span>
<span className="text-base-content">{t(`locales:${locale}`)}</span>
</a>
</Link>
))}
</div>
<div className="flex flex-row flex-wrap gap-4 w-full max-w-4xl m-auto justify-center mt-4">
{Object.keys(themes).map(theme => (
<button
key={theme}
onClick={() => app.setTheme(theme)}
className="btn btn-ghost hover:bg-base-200"
>
<span className="text-base-content">
{t(`themes:${theme}Theme`)}
</span>
</button>
))}
{Object.keys(themes).map((theme) => (
<button
key={theme}
onClick={() => app.setTheme(theme)}
className="btn btn-ghost hover:bg-base-200"
>
<span className="text-base-content">{t(`themes:${theme}Theme`)}</span>
</button>
))}
</div>
<div className="py-20">
<h2>{t('patrons:supportFreesewing')}</h2>
<div className="flex flex-row flex-wrap gap-2">
@ -78,9 +86,13 @@ const HomePage = (props) => {
<p className="max-w-3xl">{t('patrons:patronPitch')}</p>
</div>
<a className="btn btn-accent btn-lg ">
<span role='image' className="text-4xl px-4">🥰</span>
<span role="image" className="text-4xl px-4">
🥰
</span>
<span className="px-2">{t('patrons:becomeAPatron')}</span>
<span role='image' className="text-4xl px-4">🙏🏻</span>
<span role="image" className="text-4xl px-4">
🙏🏻
</span>
</a>
</div>
</div>
@ -96,9 +108,6 @@ export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale)),
}
},
}
}

View file

@ -32,7 +32,7 @@ const translations = {
ongoing issues, future plans, and news big and small about FreeSewing and its community.`,
nl: `Elke twee weken is er de FreeSewing contributor call (Engelstalig), waar de FreeSewing
vrijwilligers de lopende zaken bespreken. Ook de plannen voor de toekomst en groot en klein
nieuws over FreeSewing en de gemeenschap komen aan bod.`
nieuws over FreeSewing en de gemeenschap komen aan bod.`,
},
docs: {
en: `Our documentation for developers hosted on ${fsd}. You can find guides and how-to's
@ -52,67 +52,70 @@ const SupportPage = (props) => {
const { t } = useTranslation(['common', 'patrons'])
return (
<Page app={app} title={t('support')} layout={Layout}>
<h2>Discord</h2>
<h2 className="border-0">Discord</h2>
<div className="flex flex-row flex-wrap gap-2">
<p className="max-w-3xl">
{translations.discord[app.locale]}
</p>
<a className="btn btn-primary btn-lg w-96"
href="https://discord.freesewing.org/">
<p className="max-w-3xl">{translations.discord[app.locale]}</p>
<a className="btn btn-primary btn-lg w-96" href="https://discord.freesewing.org/">
<DiscordIcon />
<span className="ml-4">discord.freesewing.org</span>
</a>
</div>
<h2>Github</h2>
<h2 className="border-0">Github</h2>
<div className="flex flex-row flex-wrap gap-2">
<p className="max-w-3xl"
dangerouslySetInnerHTML={{__html: translations.github[app.locale]}}/>
<a className="btn btn-primary btn-outline btn-lg w-96"
href="https://github.com/freesewing/freesewing">
<p
className="max-w-3xl"
dangerouslySetInnerHTML={{ __html: translations.github[app.locale] }}
/>
<a
className="btn btn-primary btn-outline btn-lg w-96"
href="https://github.com/freesewing/freesewing"
>
<GithubIcon />
<span className="ml-4">github.com/freesewing</span>
</a>
</div>
<h2>{t('docs')}</h2>
<h2 className="border-0">{t('docs')}</h2>
<div className="flex flex-row flex-wrap gap-2">
<p className="max-w-3xl"
dangerouslySetInnerHTML={{__html: translations.docs[app.locale]}}/>
<a className="btn btn-primary btn-outline btn-lg w-96"
href="https://freesewing.dev/">
<p
className="max-w-3xl"
dangerouslySetInnerHTML={{ __html: translations.docs[app.locale] }}
/>
<a className="btn btn-primary btn-outline btn-lg w-96" href="https://freesewing.dev/">
<DocsIcon />
<span className="ml-4">www.FreeSewing.dev</span>
</a>
</div>
<h2>Contributor Calls</h2>
<h2 className="border-0">Contributor Calls</h2>
<div className="flex flex-row flex-wrap gap-2">
<p className="max-w-3xl"
dangerouslySetInnerHTML={{__html: translations.cc[app.locale]}}/>
<a className="btn btn-primary btn-outline btn-lg w-96"
href="https://github.com/freesewing/freesewing/discussions?discussions_q=label%3A%22%3Atv%3A+fscc%22">
<p
className="max-w-3xl"
dangerouslySetInnerHTML={{ __html: translations.cc[app.locale] }}
/>
<a
className="btn btn-primary btn-outline btn-lg w-96"
href="https://github.com/freesewing/freesewing/discussions?discussions_q=label%3A%22%3Atv%3A+fscc%22"
>
<CcIcon />
<span className="ml-4">Contributor Calls</span>
</a>
</div>
<div className="py-20">
<h2>{t('patrons:supportFreesewing')}</h2>
<h2 className="border-0">{t('patrons:supportFreesewing')}</h2>
<div className="flex flex-row flex-wrap gap-2">
<div>
<p className="max-w-3xl">{t('patrons:patronLead')}</p>
<p className="max-w-3xl">{t('patrons:patronPitch')}</p>
</div>
<a className="btn btn-accent btn-lg w-96">
<HeartIcon className="fill-accent-content stroke-accent-content w-6 h-6"/>
<HeartIcon className="fill-accent-content stroke-accent-content w-6 h-6" />
<span className="ml-4">{t('patrons:becomeAPatron')}</span>
</a>
</div>
</div>
</Page>
)
}
@ -123,9 +126,6 @@ export async function getStaticProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale)),
}
},
}
}

View file

@ -1,27 +0,0 @@
import pkg from '../package.json' assert { type: 'json' }
import { config as brianConfig } from '@freesewing/brian'
export default {
name: '{{name}}',
version: pkg.version,
optionGroups: {
...brianConfig.optionGroups,
},
measurements: [...brianConfig.measurements],
dependencies: {
brianSleevecap: 'brianFront',
},
inject: {
brianBack: 'brianBase',
brianFront: 'brianBack',
brianSleeve: 'brianSleevecap',
back: 'brianBack',
front: 'brianFront',
sleeve: 'brianSleeve',
},
hide: ['brianBase', 'brianFront', 'brianBack', 'brianSleevecap', 'brianSleeve', 'sleevecap'],
parts: [],
options: {
...brianConfig.options,
},
}

View file

@ -1,5 +0,0 @@
export default (part) => {
// Do to this part what you wish, before returning it
return part
}

View file

@ -0,0 +1,155 @@
import { back as brianBack } from '@freesewing/brian'
function draftBack({
// Uncomment below to destructure what you need
/*
* Content constructors
*/
//Path, // A Path constructor to create new paths
//Point, // A Point constructor to create new points
//Snippet, // A Snippet constructor to create new snippets
/*
* Content constainers
*/
//paths, // Add a Path to your part by adding it to this object
//points, // Add a Points to your part by adding it to this object
//snippets, // Add a Snippet to your part by adding it to this object
/*
* Access to settings
*/
//absoluteOptions, // Access to settings.absoluteOptions
//complete, // Access to settings.complete
//measurements, // Access to settings.measurements
//options, // Access to settings.options
//paperless, // Access to settings.paperless
//sa, // Access to settings.sa
//scale, // Access to settings.scale
/*
* Access to utilities
*/
//getId, //See the getId documentation
//hide, //See the hide documentation
//log, //See the logging documentation
//macro, //See the macros documentation
//setHidden, //See the setHidden documentation
//store, //See the store documentation
//unhide, //See the unhide documentation
//units, //See the units documentation
//utils, //See the utils documentation
/*
* Return value
*/
part, // Your draft method must return this
}) {
// Work your magic here
return part
}
export const back = {
/*
* name: Holds the name of this part.
*
* We STRONGLY recommend naming your parts in the format of
* design.part to avoid naming conflicts when people re-use
* parts across designs.
*/
name: '{{ name }}.back',
/*
* draft: Holds the draft method for this part
*
* This should be a function that drafts and returns the part
*
* Documentation: https://freesewing.dev/reference/api/part/draft
*/
draft: draftBack,
after: [
/*
* after: Holds a list of parts that should be drafted prior to this part.
*
* You'll need to import these parts, just as with the from key above.
*
* If you don't have any parts to draft prior to this part,
* you can remove this options key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/dependencies
*/
],
/*
* from: Holds the part you want to extend.
*
* Since you opted to extend brian, and this is the back part,
* we're extending brian's back part here.
* It was imported at the top of this file from @freesewing/brian
*
* Documentation: https://freesewing.dev/reference/api/part/config/dependencies
*/
from: brianBack,
/*
* hide: Set this to true to hide a part.
*
* We've set this to false here to clarify its use.
* I you don't want to hide this part,
* you can remove the hide key entirely.
*/
hide: false,
/*
* hideDependecies: Set this to true to hide a part's dependencies.
*
* We've set this to true here since you're extending Brian's back part.
* I you don't want to hide this part's dependencies,
* you can remove the hideDependencies key entirely.
*/
hideDependencies: true,
/*
* hideAll: Set this to true to hide both the part and its dependencies.
*
* This is a combination of the hide and hideDependencies keys in case
* you want to both hide this part and its dependencies.
* We've included it here with a value of false to its use.
* I you don't want to hide this a part and its dependencies,
* you can remove the hideAll key entirely.
*/
hideAll: false,
options: {
/*
* options: Holds (the configuration of) options for this part
*
* Declare options used in this part here.
* You only need to add additional options.
* All options coming from Brian's back part are already loaded.
*
* If you don't have any options to add,
* you can remove this options key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/options
*/
},
measurements: [
/*
* measurements: Holds a list of measurements required by this part.
*
* Declare measurements required by this part here.
* You only need to add additional measurements.
* All measurements coming from Brian's back part are already loaded.
*
* If you don't have any required measurements to add,
* you can remove this measurements key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/measurements
*/
],
optionalMeasurements: [
/*
* optionalMeasurements: Holds a list of measurements optional in this part.
*
* Declare measurements that are optional for this part here.
*
* If you don't have any optional measurements to add,
* you can remove this optionalMeasurements key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/measurements
*/
],
}

View file

@ -1,5 +0,0 @@
export default (part) => {
// Do to this part what you wish, before returning it
return part
}

View file

@ -0,0 +1,155 @@
import { front as brianFront } from '@freesewing/brian'
function draftFront({
// Uncomment below to destructure what you need
/*
* Content constructors
*/
//Path, // A Path constructor to create new paths
//Point, // A Point constructor to create new points
//Snippet, // A Snippet constructor to create new snippets
/*
* Content constainers
*/
//paths, // Add a Path to your part by adding it to this object
//points, // Add a Points to your part by adding it to this object
//snippets, // Add a Snippet to your part by adding it to this object
/*
* Access to settings
*/
//absoluteOptions, // Access to settings.absoluteOptions
//complete, // Access to settings.complete
//measurements, // Access to settings.measurements
//options, // Access to settings.options
//paperless, // Access to settings.paperless
//sa, // Access to settings.sa
//scale, // Access to settings.scale
/*
* Access to utilities
*/
//getId, //See the getId documentation
//hide, //See the hide documentation
//log, //See the logging documentation
//macro, //See the macros documentation
//setHidden, //See the setHidden documentation
//store, //See the store documentation
//unhide, //See the unhide documentation
//units, //See the units documentation
//utils, //See the utils documentation
/*
* Return value
*/
part, // Your draft method must return this
}) {
// Work your magic here
return part
}
export const front = {
/*
* name: Holds the name of this part.
*
* We STRONGLY recommend naming your parts in the format of
* design.part to avoid naming conflicts when people re-use
* parts across designs.
*/
name: '{{ name }}.front',
/*
* draft: Holds the draft method for this part
*
* This should be a function that drafts and returns the part
*
* Documentation: https://freesewing.dev/reference/api/part/draft
*/
draft: draftFront,
after: [
/*
* after: Holds a list of parts that should be drafted prior to this part.
*
* You'll need to import these parts, just as with the from key above.
*
* If you don't have any parts to draft prior to this part,
* you can remove this options key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/dependencies
*/
],
/*
* from: Holds the part you want to extend.
*
* Since you opted to extend brian, and this is the front part,
* we're extending brian's front part here.
* It was imported at the top of this file from @freesewing/brian
*
* Documentation: https://freesewing.dev/reference/api/part/config/dependencies
*/
from: brianFront,
/*
* hide: Set this to true to hide a part.
*
* We've set this to false here to clarify its use.
* I you don't want to hide this part,
* you can remove the hide key entirely.
*/
hide: false,
/*
* hideDependecies: Set this to true to hide a part's dependencies.
*
* We've set this to true here since you're extending Brian's front part.
* I you don't want to hide this part's dependencies,
* you can remove the hideDependencies key entirely.
*/
hideDependencies: true,
/*
* hideAll: Set this to true to hide both the part and its dependencies.
*
* This is a combination of the hide and hideDependencies keys in case
* you want to both hide this part and its dependencies.
* We've included it here with a value of false to its use.
* I you don't want to hide this a part and its dependencies,
* you can remove the hideAll key entirely.
*/
hideAll: false,
options: {
/*
* options: Holds (the configuration of) options for this part
*
* Declare options used in this part here.
* You only need to add additional options.
* All options coming from Brian's front part are already loaded.
*
* If you don't have any options to add,
* you can remove this options key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/options
*/
},
measurements: [
/*
* measurements: Holds a list of measurements required by this part.
*
* Declare measurements required by this part here.
* You only need to add additional measurements.
* All measurements coming from Brian's front part are already loaded.
*
* If you don't have any required measurements to add,
* you can remove this measurements key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/measurements
*/
],
optionalMeasurements: [
/*
* optionalMeasurements: Holds a list of measurements optional in this part.
*
* Declare measurements that are optional for this part here.
*
* If you don't have any optional measurements to add,
* you can remove this optionalMeasurements key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/measurements
*/
],
}

View file

@ -1,29 +0,0 @@
// Import dependencies
import freesewing from '@freesewing/core'
import plugins from '@freesewing/plugin-bundle'
// Import Brian so we can extend it
import Brian from '@freesewing/brian'
// Import configuration
import config from '../config'
// Import parts
import draftFront from './front'
import draftBack from './back'
import draftSleeve from './sleeve'
// Create the new design
const Design = new freesewing.Design(config, plugins)
// Attach Brian's draft methods to the prototype
for (const m of ['Base', 'Front', 'Back', 'Sleevecap', 'Sleeve']) {
Design.prototype[`draftBrian${m}`] = function (part) {
return new Brian(this.settings)[`draft${m}`](part)
}
}
// Attach the draft methods to the prototype
Design.prototype.draftBack = draftBack
Design.prototype.draftFront = draftFront
Design.prototype.draftSleeve = draftSleeve
// Export the new Design
export default Design

View file

@ -0,0 +1,31 @@
// Import Design constructor
import { Design } from '@freesewing/core'
// Import parts
import { back } from './back'
import { front } from './front'
import { sleeve } from './sleeve'
// Create the new design
const Pattern = new freesewing.Design({
data: {
/*
* If you like, you can add any data you want to your design.
* We'll add the name here as an example.
*
* If you don't use this,
* you can remove this data key enterely.
*/
name: "{{ name }}",
},
// A list of parts is all that is required.
parts: [ back, front, sleeve ],
})
/*
* Named exports
*
* We export the design itself as well as each part individually.
* This allows us to re-use these parts in other designs.
*/
export { back, front, sleeve, Pattern }

View file

@ -1,5 +0,0 @@
export default (part) => {
// Do to this part what you wish, before returning it
return part
}

View file

@ -0,0 +1,155 @@
import { sleeve as brianSleeve } from '@freesewing/brian'
function draftSleeve({
// Uncomment below to destructure what you need
/*
* Content constructors
*/
//Path, // A Path constructor to create new paths
//Point, // A Point constructor to create new points
//Snippet, // A Snippet constructor to create new snippets
/*
* Content constainers
*/
//paths, // Add a Path to your part by adding it to this object
//points, // Add a Points to your part by adding it to this object
//snippets, // Add a Snippet to your part by adding it to this object
/*
* Access to settings
*/
//absoluteOptions, // Access to settings.absoluteOptions
//complete, // Access to settings.complete
//measurements, // Access to settings.measurements
//options, // Access to settings.options
//paperless, // Access to settings.paperless
//sa, // Access to settings.sa
//scale, // Access to settings.scale
/*
* Access to utilities
*/
//getId, //See the getId documentation
//hide, //See the hide documentation
//log, //See the logging documentation
//macro, //See the macros documentation
//setHidden, //See the setHidden documentation
//store, //See the store documentation
//unhide, //See the unhide documentation
//units, //See the units documentation
//utils, //See the utils documentation
/*
* Return value
*/
part, // Your draft method must return this
}) {
// Work your magic here
return part
}
export const sleeve = {
/*
* name: Holds the name of this part.
*
* We STRONGLY recommend naming your parts in the format of
* design.part to avoid naming conflicts when people re-use
* parts across designs.
*/
name: '{{ name }}.sleeve',
/*
* draft: Holds the draft method for this part
*
* This should be a function that drafts and returns the part
*
* Documentation: https://freesewing.dev/reference/api/part/draft
*/
draft: draftSleeve,
after: [
/*
* after: Holds a list of parts that should be drafted prior to this part.
*
* You'll need to import these parts, just as with the from key above.
*
* If you don't have any parts to draft prior to this part,
* you can remove this options key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/dependencies
*/
],
/*
* from: Holds the part you want to extend.
*
* Since you opted to extend brian, and this is the sleeve part,
* we're extending brian's sleeve part here.
* It was imported at the top of this file from @freesewing/brian
*
* Documentation: https://freesewing.dev/reference/api/part/config/dependencies
*/
from: brianSleeve,
/*
* hide: Set this to true to hide a part.
*
* We've set this to false here to clarify its use.
* I you don't want to hide this part,
* you can remove the hide key entirely.
*/
hide: false,
/*
* hideDependecies: Set this to true to hide a part's dependencies.
*
* We've set this to true here since you're extending Brian's sleeve part.
* I you don't want to hide this part's dependencies,
* you can remove the hideDependencies key entirely.
*/
hideDependencies: true,
/*
* hideAll: Set this to true to hide both the part and its dependencies.
*
* This is a combination of the hide and hideDependencies keys in case
* you want to both hide this part and its dependencies.
* We've included it here with a value of false to its use.
* I you don't want to hide this a part and its dependencies,
* you can remove the hideAll key entirely.
*/
hideAll: false,
options: {
/*
* options: Holds (the configuration of) options for this part
*
* Declare options used in this part here.
* You only need to add additional options.
* All options coming from Brian's sleeve part are already loaded.
*
* If you don't have any options to add,
* you can remove this options key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/options
*/
},
measurements: [
/*
* measurements: Holds a list of measurements required by this part.
*
* Declare measurements required by this part here.
* You only need to add additional measurements.
* All measurements coming from Brian's sleeve part are already loaded.
*
* If you don't have any required measurements to add,
* you can remove this measurements key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/measurements
*/
],
optionalMeasurements: [
/*
* optionalMeasurements: Holds a list of measurements optional in this part.
*
* Declare measurements that are optional for this part here.
*
* If you don't have any optional measurements to add,
* you can remove this optionalMeasurements key entirely.
*
* Documentation: https://freesewing.dev/reference/api/part/config/measurements
*/
],
}

View file

@ -1,5 +0,0 @@
export default (part) => {
// Do to this part what you wish, before returning it
return part
}

View file

@ -42,6 +42,7 @@
"@freesewing/plugin-svgattr": "latest",
"@freesewing/plugin-theme": "latest",
"@freesewing/plugin-i18n": "latest",
"@freesewing/plugin-bust": "latest",
"@freesewing/utils": "latest",
"@freesewing/models": "latest",
"@headlessui/react": "^1.6.5",
@ -53,7 +54,6 @@
"react-sizeme": "^3.0.2",
"react-zoom-pan-pinch": "^2.1.3",
"react-markdown": "^8.0.3",
"roughjs": "^4.5.2",
"@tailwindcss/typography": "^0.5.2",
"d3-dispatch": "^3.0.1",
"d3-drag": "^3.0.0",
@ -78,9 +78,11 @@
"js-yaml": "^4.1.0",
"pdfkit": "^0.13.0",
"svg-to-pdfkit": "^0.1.8",
"postcss-for": "^2.1.1",
"postcss": "^8.4.14",
"tailwindcss": "^3.1.3",
"tailwindcss-open-variant": "^1.0.0"
"tailwindcss-open-variant": "^1.0.0",
"web-worker": "^1.2.0"
},
"files": [
"dist/*",
@ -92,7 +94,7 @@
"tag": "next"
},
"engines": {
"node": ">=14.0.0",
"node": ">=16.0.0",
"npm": ">=6"
}
}