From 5b99f92cb16398ade059686b83674aa5883fb0dd Mon Sep 17 00:00:00 2001 From: Benjamin Fan Date: Tue, 30 May 2023 14:45:44 -0700 Subject: [PATCH 001/142] fix(docs): (waistToHips) Removed ambiguous trousers reference --- markdown/org/docs/measurements/waisttohips/en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/markdown/org/docs/measurements/waisttohips/en.md b/markdown/org/docs/measurements/waisttohips/en.md index 24ee4fe0f8f..0b7677670b6 100644 --- a/markdown/org/docs/measurements/waisttohips/en.md +++ b/markdown/org/docs/measurements/waisttohips/en.md @@ -2,4 +2,4 @@ title: Waist to hips --- -The **waist to hips** measurement is measured from your waist down to the top of your hip bone (where your trousers sit). Measure it at the side of your body. +The **waist to hips** measurement is measured from your waist down to the top of your hip bone. Measure it at the side of your body. From 8baf531335ed146d151ceaa0a52e284f1f8a749d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 19:08:39 +0000 Subject: [PATCH 002/142] chore(deps): bump c8 from 7.14.0 to 8.0.0 Bumps [c8](https://github.com/bcoe/c8) from 7.14.0 to 8.0.0. - [Release notes](https://github.com/bcoe/c8/releases) - [Changelog](https://github.com/bcoe/c8/blob/main/CHANGELOG.md) - [Commits](https://github.com/bcoe/c8/compare/v7.14.0...v8.0.0) --- updated-dependencies: - dependency-name: c8 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f0cfa3f1a8c..46a9a634e94 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "version": "0.0.0", "dependencies": { "autoprefixer": "^10.4.0", - "c8": "^7.12.0", + "c8": "^8.0.0", "handlebars": "^4.7.7", "jsonfile": "^6.1.0", "postcss": "^8.4.5", diff --git a/yarn.lock b/yarn.lock index b2ce17491d1..e14fb1072d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5830,10 +5830,10 @@ bytes@3.1.2: resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== -c8@^7.12.0: - version "7.14.0" - resolved "https://registry.yarnpkg.com/c8/-/c8-7.14.0.tgz#f368184c73b125a80565e9ab2396ff0be4d732f3" - integrity sha512-i04rtkkcNcCf7zsQcSv/T9EbUn4RXQ6mropeMcjFOsQXQ0iGLAr/xT6TImQg4+U9hmNpN9XdvPkjUL1IzbgxJw== +c8@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/c8/-/c8-8.0.0.tgz#99c7408fbbafaa5630ddc80881adbfe461fc6c8f" + integrity sha512-XHA5vSfCLglAc0Xt8eLBZMv19lgiBSjnb1FLAQgnwkuhJYEonpilhEB4Ea3jPAbm0FhD6VVJrc0z73jPe7JyGQ== dependencies: "@bcoe/v8-coverage" "^0.2.3" "@istanbuljs/schema" "^0.1.3" From 39655daf6a99b00fd0dd9cce67724362618a2de0 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Sat, 17 Jun 2023 16:57:17 -0500 Subject: [PATCH 003/142] rudimentary implementation of blog pages --- config/dependencies.yaml | 3 + sites/org/package.json | 3 + sites/org/pages/blog/[slug].mjs | 169 ++++++++++++++++++++++ sites/org/pages/blog/index.mjs | 93 +++++++++++- sites/shared/components/wrappers/mdx.mjs | 20 ++- sites/shared/components/wrappers/page.mjs | 6 + sites/shared/sanity.mjs | 29 ++++ yarn.lock | 107 +++++++++++++- 8 files changed, 412 insertions(+), 18 deletions(-) create mode 100644 sites/org/pages/blog/[slug].mjs create mode 100644 sites/shared/sanity.mjs diff --git a/config/dependencies.yaml b/config/dependencies.yaml index 6278305e403..215ba36fc67 100644 --- a/config/dependencies.yaml +++ b/config/dependencies.yaml @@ -314,6 +314,8 @@ org: '@mdx-js/mdx': *mdx '@mdx-js/react': *mdx '@mdx-js/runtime': *mdxRuntime + '@portabletext/react': '^1.0.6' + '@sanity/client': '^6.1.2' '@tailwindcss/typography': *tailwindTypography 'algoliasearch': *algoliasearch 'react-copy-to-clipboard': 5.1.0 @@ -323,6 +325,7 @@ org: 'lodash.set': *_set 'luxon': '3.3.0' 'next': *next + 'next-sanity': '^4.3.3' 'react-dropzone': '14.2.3' 'react-hotkeys-hook': *reactHotkeysHook 'react-instantsearch-dom': *reactInstantsearchDom diff --git a/sites/org/package.json b/sites/org/package.json index a2e01091375..f4020b0a350 100644 --- a/sites/org/package.json +++ b/sites/org/package.json @@ -34,6 +34,8 @@ "@mdx-js/mdx": "2.3.0", "@mdx-js/react": "2.3.0", "@mdx-js/runtime": "2.0.0-next.9", + "@portabletext/react": "^1.0.6", + "@sanity/client": "^6.1.2", "@tailwindcss/typography": "0.5.9", "algoliasearch": "4.17.2", "react-copy-to-clipboard": "5.1.0", @@ -43,6 +45,7 @@ "lodash.set": "4.3.2", "luxon": "3.3.0", "next": "13.4.6", + "next-sanity": "^4.3.3", "react-dropzone": "14.2.3", "react-hotkeys-hook": "4.4.0", "react-instantsearch-dom": "6.40.0", diff --git a/sites/org/pages/blog/[slug].mjs b/sites/org/pages/blog/[slug].mjs new file mode 100644 index 00000000000..a4673379728 --- /dev/null +++ b/sites/org/pages/blog/[slug].mjs @@ -0,0 +1,169 @@ +import { useState, useEffect } from 'react' +import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs' +import { PlainMdxWrapper, TimeAgo } from 'shared/components/wrappers/mdx.mjs' +import ReactMarkdown from 'react-markdown' +import Head from 'next/head' +import { Lightbox } from 'shared/components/lightbox.mjs' +import { ImageWrapper } from 'shared/components/wrappers/img.mjs' +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' +import { useTranslation } from 'next-i18next' +import { sanityLoader, sanityImage } from 'shared/strapi/loader.js' +import { strapiImage } from 'shared/utils.mjs' + +const strapi = 'https://posts.freesewing.org' + +const Author = ({ author }) => { + return ( +
+
+ +
+ +
+ {author?.displayname} +
+
+

+ {author?.displayname} + Wrote this +

+
+ + {author.about} + +
+
+
+ ) +} + +const BlogPostPage = ({ post, author }) => { + const { t } = useTranslation(['common']) + return ( + + + + + + + + + + + + + + + + ) +} + +/* + * getStaticProps() is used to fetch data at build-time. + * + * On this page, it is loading the blog content from strapi. + * + * This, in combination with getStaticPaths() below means this + * page will be used to render/generate all blog content. + * + * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching + */ +export async function getStaticProps({ params, locale }) { + const { slug } = params + const post = await sanityLoader({ type: 'blog', language: locale, slug, withImage: true }) + .then((data) => data[0]) + .catch((err) => console.log(err)) + + return { + props: { + post: { + slug, + body: post.body, + title: post.title, + date: post.date, + caption: post.caption, + image: sanityImage(post.image), + }, + // FIXME load the author separately + author: { + displayname: post.author, + // slug: post.author.slug, + // about: post.author.about, + // image: strapiImage(post.author.picture, ['small']), + // about: post.author.about, + }, + ...(await serverSideTranslations(locale)), + }, + } +} + +export const getStaticPaths = async () => { + const paths = await sanityLoader({ language: 'en', type: 'blog' }) + .then((data) => data.map((post) => `/blog/${post.slug.current}`)) + .catch((err) => console.log(err)) + + return { + paths: [ + ...paths, + ...paths.map((p) => `/de${p}`), + ...paths.map((p) => `/es${p}`), + ...paths.map((p) => `/fr${p}`), + ...paths.map((p) => `/nl${p}`), + ], + fallback: false, + } +} + +export default BlogPostPage diff --git a/sites/org/pages/blog/index.mjs b/sites/org/pages/blog/index.mjs index 28a23405f71..ac62e259cf1 100644 --- a/sites/org/pages/blog/index.mjs +++ b/sites/org/pages/blog/index.mjs @@ -1,34 +1,111 @@ // Dependencies import { serverSideTranslations } from 'next-i18next/serverSideTranslations' +import { sanityLoader, sanityImage } from 'shared/sanity.mjs' +// Hooks +import { useTranslation } from 'next-i18next' // Components +import Link from 'next/link' +import { TimeAgo } from 'shared/components/wrappers/mdx.mjs' import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs' -import { V3Wip } from 'shared/components/v3-wip.mjs' // Translation namespaces used on this page const namespaces = [...new Set(['designs', ...pageNs])] +const textShadow = { + style: { + textShadow: + '1px 1px 1px #000000, -1px -1px 1px #000000, 1px -1px 1px #000000, -1px 1px 1px #000000, 2px 2px 1px #000000', + }, +} + +const Preview = ({ post, t }) => ( +
+ +
+
+
+
+ {post.title} +
+ +
+
+
+ +
+) /* * Each page MUST be wrapped in the PageWrapper component. * You also MUST spread props.page into this wrapper component * when path and locale come from static props (as here) * or set them manually. */ -const BlogIndexPage = ({ page }) => ( - -
- -
-
-) +const BlogIndexPage = ({ page, posts }) => { + const { t } = useTranslation() + return ( + +
+ {posts.map((post) => ( + + ))} +
+
+ ) +} export default BlogIndexPage export async function getStaticProps({ locale }) { + const posts = await sanityLoader({ language: locale, type: 'blog' }).catch((err) => + console.log(err) + ) + return { props: { + posts: posts.map((post) => ({ + slug: post.slug.current, + title: post.title, + date: post.date, + // FIXME get the authors separately + author: post.author, + image: sanityImage(post.image) + '?fit=clip&w=400', + })), ...(await serverSideTranslations(locale, namespaces)), page: { locale, + // title: 'Freesewing Blog', path: ['blog'], }, }, diff --git a/sites/shared/components/wrappers/mdx.mjs b/sites/shared/components/wrappers/mdx.mjs index cb6b3d16cad..20087f954b3 100644 --- a/sites/shared/components/wrappers/mdx.mjs +++ b/sites/shared/components/wrappers/mdx.mjs @@ -6,6 +6,7 @@ import { docUpdates } from 'site/prebuild/doc-updates.mjs' // Components import { PageLink } from 'shared/components/page-link.mjs' import { DateTime, Interval } from 'luxon' +import ReactMarkdown from 'react-markdown' // Context import { useContext } from 'react' import { NavigationContext } from 'shared/context/navigation-context.mjs' @@ -16,7 +17,7 @@ import { useTranslation } from 'next-i18next' //import { PrevNext } from '../mdx/prev-next.mjs' // // -const TimeAgo = ({ date, t }) => { +export const TimeAgo = ({ date, t }) => { const i = Interval.fromDateTimes(DateTime.fromISO(date), DateTime.now()) .toDuration(['hours', 'days', 'months', 'years']) .toObject() @@ -101,9 +102,22 @@ const MetaData = ({ authors = [], maintainers = [], updated = '20220825', locale ) +export const PlainMdxWrapper = ({ MDX = false, components = {}, compile, children }) => { + const allComponents = { ...baseComponents, ...components } + const compiledMdx = MDX ? ( + + ) : compile ? ( + {children} + ) : ( + children + ) + + return
{compiledMdx}
+} + export const MdxWrapper = ({ MDX = false, frontmatter = {}, components = {}, children = [] }) => { const { t } = useTranslation('docs') - const allComponents = { ...baseComponents, ...components } + const { locale, slug } = useContext(NavigationContext) const updates = docUpdates[slug] || {} @@ -116,7 +130,7 @@ export const MdxWrapper = ({ MDX = false, frontmatter = {}, components = {}, chi updated={updates.u} {...{ locale, slug, t }} /> -
{MDX ? : children}
+ ) } diff --git a/sites/shared/components/wrappers/page.mjs b/sites/shared/components/wrappers/page.mjs index 97577ac7015..91359defc4a 100644 --- a/sites/shared/components/wrappers/page.mjs +++ b/sites/shared/components/wrappers/page.mjs @@ -4,6 +4,7 @@ import React, { useState, useEffect, useContext } from 'react' // Hooks import { useTheme } from 'shared/hooks/use-theme.mjs' // Components +import Head from 'next/head' import { SwipeWrapper } from 'shared/components/wrappers/swipes.mjs' import { LayoutWrapper, ns as layoutNs } from 'site/components/wrappers/layout.mjs' import { DocsLayout, ns as docsNs } from 'site/components/layouts/docs.mjs' @@ -80,6 +81,11 @@ export const PageWrapper = (props) => { // Return wrapper return ( + {pageTitle && ( + + + + )}
{ + sanityClient = + sanityClient || + createClient({ + projectId: 'hl5bw8cj', + dataset: 'site-content', + apiVersion: '2023-06-17', + token: process.env.SANITY_TOKEN, + useCdn: false, + }) + + if (!query) { + query = `*[_type == "${type}${language}"` + if (slug) query += ` && slug.current == "${slug}"` + query += ']' + } + + return sanityClient.fetch(query) +} + +export const sanityImage = (image, dataset = 'site-content') => { + const [, assetName, origSize, format] = image.asset._ref.split('-') + return `https://cdn.sanity.io/images/${sanityId}/${dataset}/${assetName}-${origSize}.${format}` +} diff --git a/yarn.lock b/yarn.lock index fe3ff5f3bb0..b33663e0f6d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3747,6 +3747,15 @@ golden-fleece "^1.0.9" pkg-dir "^5.0.0" +"@sanity/client@^6.0.0", "@sanity/client@^6.1.2": + version "6.1.3" + resolved "https://registry.yarnpkg.com/@sanity/client/-/client-6.1.3.tgz#94b87b1de78b041fb85cc489fefc03304c353e3b" + integrity sha512-asO/AvN+/D1Ljd6UNPWlo/toeO6SmZdsxyl+fJdLfI9by4svp/K3hD4Qy2DXXmwOfGYqGSH7etv2lnRhu+C5YA== + dependencies: + "@sanity/eventsource" "^5.0.0" + get-it "^8.1.0" + rxjs "^7.0.0" + "@sanity/client@^6.1.1": version "6.1.2" resolved "https://registry.yarnpkg.com/@sanity/client/-/client-6.1.2.tgz#03a032c3b1c98c35efa94db6acd478ae2a71a46c" @@ -3785,7 +3794,7 @@ eslint-plugin-react "^7.31.10" eslint-plugin-react-hooks "^4.6.0" -"@sanity/eventsource@^5.0.0": +"@sanity/eventsource@5", "@sanity/eventsource@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@sanity/eventsource/-/eventsource-5.0.0.tgz#45410c8259e0bb80b4e308e1872846439590805a" integrity sha512-0ewT+BDzfiamHwitUfRcwsl/RREHjWv6VNZvQ8Q4OnnNKXfEEGXbWmqzof0okOTkp4XELgyliht4Qj28o9AU2g== @@ -3814,6 +3823,21 @@ resolved "https://registry.yarnpkg.com/@sanity/generate-help-url/-/generate-help-url-3.0.0.tgz#60e9cba61b82103ea3761730a53cd9310b98892d" integrity sha512-wtMYcV5GIDIhVyF/jjmdwq1GdlK07dRL40XMns73VbrFI7FteRltxv48bhYVZPcLkRXb0SHjpDS/icj9/yzbVA== +"@sanity/groq-store@^2.1.0": + version "2.1.0" + resolved "https://registry.yarnpkg.com/@sanity/groq-store/-/groq-store-2.1.0.tgz#a7ddd25399bdc8469362384107a68386caa8db98" + integrity sha512-GYWtsi0TyTOXiFbGmlPccKE/UsFom9byU8DpPsshNpD0z2MNy19/L0lAaV5/JdUgb8uu84sEKYMPumkRG94lhw== + dependencies: + "@sanity/eventsource" "5" + "@sanity/types" "3" + fast-deep-equal "^3.1.3" + groq "3" + groq-js "1" + mendoza "^2.1.1" + simple-get "^4.0.1" + split2 "^4.1.0" + throttle-debounce "^5.0.0" + "@sanity/icons@^1.3": version "1.3.10" resolved "https://registry.yarnpkg.com/@sanity/icons/-/icons-1.3.10.tgz#df934a94ae6669fe6b15515d800afb221cba0498" @@ -3892,6 +3916,19 @@ lodash "^4.17.21" slate "0.81.1" +"@sanity/preview-kit@^1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@sanity/preview-kit/-/preview-kit-1.5.4.tgz#13da6703278200f6eb734379b332e2b0a2d69b8a" + integrity sha512-yeaToBDOuxAYmJptV10tvDN9FPb1+rryRzBW8722aVkJizVZnEAl6//9lDy7Hg6xsJ51C0VwnOF5R7jw5oOHrQ== + dependencies: + "@sanity/client" "^6.1.1" + "@sanity/eventsource" "^5.0.0" + "@sanity/groq-store" "^2.1.0" + "@vercel/stega" "^0.0.5" + lodash.isplainobject "^4.0.6" + suspend-react "^0.0.10" + tiny-invariant "^1.3.1" + "@sanity/schema@3.12.0": version "3.12.0" resolved "https://registry.yarnpkg.com/@sanity/schema/-/schema-3.12.0.tgz#1a0133cfe52c8714913059312b1d222333579041" @@ -3919,6 +3956,14 @@ scroll-into-view-if-needed "^2.2.20" tiny-invariant "1.0.6" +"@sanity/types@3": + version "3.12.1" + resolved "https://registry.yarnpkg.com/@sanity/types/-/types-3.12.1.tgz#55f8440426b8e9479333c9bd79bc21adba88f2cf" + integrity sha512-o2JRt/8RoKFIYtBapQyeo7Ktf7+QSBJjpM64c7xVcbEVMI6OHkm0hKGHmRTLCKta5BzmzaJq541HOClsz+cTTw== + dependencies: + "@sanity/client" "^6.1.1" + "@types/react" "^18.0.25" + "@sanity/types@3.12.0": version "3.12.0" resolved "https://registry.yarnpkg.com/@sanity/types/-/types-3.12.0.tgz#231ab61e83231fcdac163cad90d62a7084f856e4" @@ -3990,6 +4035,14 @@ json5 "^2.2.3" lodash "^4.17.21" +"@sanity/webhook@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sanity/webhook/-/webhook-2.0.0.tgz#22e5916fd6ea616625b4105a68f2858408de8eee" + integrity sha512-KusHeWVy6yW3hcgVHbGx6qVv//bUj3CD9Nr0EOw086+mo/ESrUV21HjOCrNQ+AYqXvJ9H5qhqmMiuc8H5dXUGA== + dependencies: + base64url "^3.0.1" + tslib "^2.3.1" + "@selderee/plugin-htmlparser2@^0.11.0": version "0.11.0" resolved "https://registry.yarnpkg.com/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz#d5b5e29a7ba6d3958a1972c7be16f4b2c188c517" @@ -4721,6 +4774,11 @@ optionalDependencies: ajv "^6.0.0" +"@vercel/stega@^0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@vercel/stega/-/stega-0.0.5.tgz#96e0efd2c7ecfed35f30bf76c7ce618f613fa288" + integrity sha512-vvuUYW0rBp4Ea9xv0LilqFyDHAW9tvy4GL70G1ayGisQwpOYIPChmiw/56jqZvpxjE9gjQIApLfglOcdZe3PcA== + "@vitejs/plugin-react@^3.0.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@vitejs/plugin-react/-/plugin-react-3.1.0.tgz#d1091f535eab8b83d6e74034d01e27d73c773240" @@ -5530,6 +5588,11 @@ base64id@2.0.0, base64id@~2.0.0: resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== +base64url@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d" + integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A== + batch-processor@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/batch-processor/-/batch-processor-1.0.0.tgz#75c95c32b748e0850d10c2b168f6bdbe9891ace8" @@ -10052,11 +10115,16 @@ graphemer@^1.4.0: resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== -groq-js@^1.0.0: +groq-js@1, groq-js@^1.0.0: version "1.1.9" resolved "https://registry.yarnpkg.com/groq-js/-/groq-js-1.1.9.tgz#e32498d3a0eff01da1dd2fb63db754d9e76fbb04" integrity sha512-Kml1SgKotOOEmm1rK1w/K4UprIWJ/UU0SzeO2dPy8ab2wcAGfE82X5CTdaD1AMaP+40Ug1gAsVgPF5S2H/fcPw== +groq@3, groq@^3.0.0: + version "3.12.1" + resolved "https://registry.yarnpkg.com/groq/-/groq-3.12.1.tgz#ce644a2f916d90c37e022edfd7367d25037c7600" + integrity sha512-hxkLbHvyM2DnKna1TwzJu8aUK1HdjQ2tk1KoWKczF6YsUeajsQyUPs2xQV1G7CwiSbyVoJs5wd3kGLz60T6uug== + gunzip-maybe@^1.4.1: version "1.4.2" resolved "https://registry.yarnpkg.com/gunzip-maybe/-/gunzip-maybe-1.4.2.tgz#b913564ae3be0eda6f3de36464837a9cd94b98ac" @@ -11759,10 +11827,10 @@ jotai-location@0.5.1: resolved "https://registry.yarnpkg.com/jotai-location/-/jotai-location-0.5.1.tgz#1a08b683cd7823ce57f7fef8b98335f1ce5c7105" integrity sha512-6b34X6PpUaXmHCcyxdMFUHgRLUEp+SFHq9UxHbg5HxHC1LddVyVZbPJI+P15+SOQJcUTH3KrsIeKmeLko+Vw/A== -jotai@2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/jotai/-/jotai-2.2.0.tgz#80c176efeb59d32d7eef7f14510ba8e01ef7b0db" - integrity sha512-2gsMVpoaBa6aPHLArNhphck4+n8unZ8xF4Ciqhb+Z+tjsvabn5QFisNFHBMWooMAAmmTNU5TcvBIP8/XAsZy8Q== +jotai@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/jotai/-/jotai-2.1.1.tgz#7fc4edf16d7e20ff42952fbf2c36e8bd57510c07" + integrity sha512-LaaiuSaq+6XkwkrCtCkczyFVZOXe0dfjAFN4DVMsSZSRv/A/4xuLHnlpHMEDqvngjWYBotTIrnQ7OogMkUE6wA== js-base64@^2.1.9: version "2.6.4" @@ -14256,6 +14324,16 @@ next-i18next@13.3.0: hoist-non-react-statics "^3.3.2" i18next-fs-backend "^2.1.1" +next-sanity@^4.3.3: + version "4.3.3" + resolved "https://registry.yarnpkg.com/next-sanity/-/next-sanity-4.3.3.tgz#96f8e9af06fb07eb4a487d6601e77ca10aa796a3" + integrity sha512-537xLC4hpTgV3SGj6w4aXvBvm/nHdyZGtZ5IcZpH33p70J7UjptF4+D4FvWKZGPjF3v3SFk75AHjxWVPORL9RA== + dependencies: + "@sanity/client" "^6.0.0" + "@sanity/preview-kit" "^1.5.4" + "@sanity/webhook" "^2.0.0" + groq "^3.0.0" + next@13.4.6: version "13.4.6" resolved "https://registry.yarnpkg.com/next/-/next-13.4.6.tgz#ebe52f5c74d60176d45b45e73f25a51103713ea4" @@ -18683,7 +18761,7 @@ split2@^3.0.0, split2@^3.2.2: dependencies: readable-stream "^3.0.0" -split2@^4.0.0: +split2@^4.0.0, split2@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/split2/-/split2-4.2.0.tgz#c9c5920904d148bab0b9f67145f245a86aadbfa4" integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg== @@ -19279,6 +19357,11 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +suspend-react@^0.0.10: + version "0.0.10" + resolved "https://registry.yarnpkg.com/suspend-react/-/suspend-react-0.0.10.tgz#9b1cc83d13e0ded81fd6f65a3d564bbbfa7024ab" + integrity sha512-7yyJ1aBr9Ap4XZQOBaYlOelNcRc42zv50C0pVNOHfhW/DwTbHGFVZKKJsVndyQvQTv/fAkIO9TAMvGiSCjT0Zw== + "svg-to-pdfkit@https://github.com/eriese/SVG-to-PDFKit": version "0.1.10" resolved "https://github.com/eriese/SVG-to-PDFKit#388d8c29a7b6b1353ea6b65f683ed939e4a7725f" @@ -19518,6 +19601,11 @@ throttle-debounce@^3.0.1: resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-3.0.1.tgz#32f94d84dfa894f786c9a1f290e7a645b6a19abb" integrity sha512-dTEWWNu6JmeVXY0ZYoPuH5cRIwc0MeGbJwah9KUNYSJwommQpCzTySTpEe8Gs1J23aeWEuAobe4Ag7EHVt/LOg== +throttle-debounce@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/throttle-debounce/-/throttle-debounce-5.0.0.tgz#a17a4039e82a2ed38a5e7268e4132d6960d41933" + integrity sha512-2iQTSgkkc1Zyk0MeVrt/3BvuOXYPl/R8Z0U2xxo9rjwNciaHDG3R+Lm6dh4EeUci49DanvBnuqI6jshoQQRGEg== + through2@^2.0.0, through2@^2.0.3, through2@~2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" @@ -19569,6 +19657,11 @@ tiny-invariant@1.0.6: resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.0.6.tgz#b3f9b38835e36a41c843a3b0907a5a7b3755de73" integrity sha512-FOyLWWVjG+aC0UqG76V53yAWdXfH8bO6FNmyZOuUrzDzK8DI3/JRY25UD7+g49JWM1LXwymsKERB+DzI0dTEQA== +tiny-invariant@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.3.1.tgz#8560808c916ef02ecfd55e66090df23a4b7aa642" + integrity sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw== + tiny-warning@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.3.tgz#94a30db453df4c643d0fd566060d60a875d84754" From 50a1d3c93e8c6e7f86930719c9b8642830819949 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Sun, 18 Jun 2023 10:11:12 +0200 Subject: [PATCH 004/142] fix(lab): Fix header after renaming icon --- sites/lab/components/header/index.mjs | 6 +- .../new/pattern/[design]/[type]/[id].mjs | 95 +++++++++++++++++++ 2 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 sites/lab/pages/new/pattern/[design]/[type]/[id].mjs diff --git a/sites/lab/components/header/index.mjs b/sites/lab/components/header/index.mjs index fc9975cc04d..10ca605854c 100644 --- a/sites/lab/components/header/index.mjs +++ b/sites/lab/components/header/index.mjs @@ -12,7 +12,7 @@ import { UserIcon, ThemeIcon, I18nIcon, - MeasureIcon, + MeasieIcon, PageIcon, GitHubIcon, PlusIcon, @@ -53,7 +53,7 @@ const NavIcons = ({ setModal }) => { color={colors[3]} extraClasses="hidden lg:flex" > - + {
{/* Non-mobile content */} -
+
diff --git a/sites/lab/pages/new/pattern/[design]/[type]/[id].mjs b/sites/lab/pages/new/pattern/[design]/[type]/[id].mjs new file mode 100644 index 00000000000..cf5991f5083 --- /dev/null +++ b/sites/lab/pages/new/pattern/[design]/[type]/[id].mjs @@ -0,0 +1,95 @@ +// Hooks +import { useEffect, useState } from 'react' +import { useAccount } from 'shared/hooks/use-account.mjs' +import { useBackend } from 'shared/hooks/use-backend.mjs' +import { useDesign } from 'shared/hooks/use-design.mjs' +// Dependencies +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' +import { nsMerge } from 'shared/utils.mjs' +// Components +import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs' +import { Workbench, ns as wbNs } from 'shared/components/workbench/index.mjs' +import { WorkbenchLayout } from 'site/components/layouts/workbench.mjs' +import { DynamicOrgDocs as DynamicDocs } from 'site/components/dynamic-org-docs.mjs' +import { VagueError, ns as errorNs } from 'shared/components/errors/vague.mjs' + +// Translation namespaces used on this page +const namespaces = nsMerge(errorNs, wbNs, pageNs) + +const loadMeasurements = async ({ type, id, backend }) => { + const method = { + set: backend.getSet, + cset: backend.getCuratedSet, + } + const key = { + set: 'set', + cset: 'curatedSet', + } + if (!type || !method[type]) return false + + const result = await method[type](id) + if (result.success) return result.data[key[type]] + else return false +} + +const NewDesignFromSetPage = ({ page, id, design, type }) => { + const { token } = useAccount() + const backend = useBackend(token) + const [set, setSet] = useState(false) + const [error, setError] = useState(false) + const Design = useDesign(design) + + useEffect(() => { + // Guard against loops as the backend object is recreated on each render + const getSet = async () => { + const data = await loadMeasurements({ type, id, backend }) + if (data) setSet(data) + else setError(true) + } + if (set === false) getSet() + else if (set?.id && set.id !== id) getSet() + }, [id, type, backend, set]) + + // Short-circuit errors + if (error) + return ( + +
+ +
+
+ ) + + const baseSettings = set?.measies ? { measurements: set.measies } : null + + return ( + + + + ) +} + +export default NewDesignFromSetPage + +export async function getStaticProps({ locale, params }) { + return { + props: { + ...(await serverSideTranslations(locale, [`o_${params.design}`, ...namespaces])), + id: Number(params.id), + design: params.design, + type: params.type, + page: { + locale, + path: ['new', 'pattern', params.design, 'set', params.id], + title: '', + }, + }, + } +} + +export async function getStaticPaths() { + return { + paths: [], + fallback: true, + } +} From 947a9fda857c6e426a7ee43f7146dc040c93019b Mon Sep 17 00:00:00 2001 From: joostdecock Date: Sun, 18 Jun 2023 10:51:13 +0200 Subject: [PATCH 005/142] fix(shared): Fix inspector view --- sites/shared/components/workbench/views/inspect/index.mjs | 8 ++------ sites/shared/components/workbench/views/inspect/menu.mjs | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/sites/shared/components/workbench/views/inspect/index.mjs b/sites/shared/components/workbench/views/inspect/index.mjs index bc4e5169de8..801dea31cef 100644 --- a/sites/shared/components/workbench/views/inspect/index.mjs +++ b/sites/shared/components/workbench/views/inspect/index.mjs @@ -6,7 +6,7 @@ import { objUpdate } from 'shared/utils.mjs' export const ns = menuNs -export const DraftView = ({ +export const InspectView = ({ design, pattern, patternConfig, @@ -62,11 +62,7 @@ export const DraftView = ({ } } else { renderProps = pattern.getRenderProps() - output = ui.inspect ? ( - - ) : ( - - ) + output = } return ( diff --git a/sites/shared/components/workbench/views/inspect/menu.mjs b/sites/shared/components/workbench/views/inspect/menu.mjs index e0bcf8292e3..1341b657e24 100644 --- a/sites/shared/components/workbench/views/inspect/menu.mjs +++ b/sites/shared/components/workbench/views/inspect/menu.mjs @@ -39,7 +39,7 @@ export const DraftMenu = ({ return (