From 5b15171dad44fb1211be06954b1a3e623c8ac1b9 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Thu, 29 May 2025 18:05:31 +0200 Subject: [PATCH] [react] feat: Added docs for hooks/useDesign --- .../packages/react/hooks/usedesign/readme.mdx | 1 - .../hooks/usedesigntranslation/readme.mdx | 85 ++++++++++++++++++- 2 files changed, 82 insertions(+), 4 deletions(-) diff --git a/sites/dev/docs/reference/packages/react/hooks/usedesign/readme.mdx b/sites/dev/docs/reference/packages/react/hooks/usedesign/readme.mdx index 355774f6a4e..53ccba705b3 100644 --- a/sites/dev/docs/reference/packages/react/hooks/usedesign/readme.mdx +++ b/sites/dev/docs/reference/packages/react/hooks/usedesign/readme.mdx @@ -3,7 +3,6 @@ title: useDesign --- import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus' -import { MiniTip } from '@freesewing/react/components/Mini' import { Popout } from '@freesewing/react/components/Popout' import { Tab, Tabs } from '@freesewing/react/components/Tab' diff --git a/sites/dev/docs/reference/packages/react/hooks/usedesigntranslation/readme.mdx b/sites/dev/docs/reference/packages/react/hooks/usedesigntranslation/readme.mdx index 946dec33538..31d6f905bea 100644 --- a/sites/dev/docs/reference/packages/react/hooks/usedesigntranslation/readme.mdx +++ b/sites/dev/docs/reference/packages/react/hooks/usedesigntranslation/readme.mdx @@ -2,6 +2,85 @@ title: useDesignTranslation --- -:::note -This page is yet to be created -::: +import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus' +import { Popout } from '@freesewing/react/components/Popout' +import { Tab, Tabs } from '@freesewing/react/components/Tab' + + + +The **useDesignTranslation** hook provides translations for the entire FreeSewing collection of designs. + + +Use this hook to load design translations when you plan to use the entire collection. If +you only plan to use one or a few designs, you may want to load them differently as +incluyding this hook will include all FreeSewing designs in your code bundle. + + +## Example + + + +Using the hook makes it easy to load a design translations if you want to be able to +dynamically load a different design, or do not know in advance what designs +should be made available. + +```js +import { useDesign } from '@freesewing/react/hooks/useDesign' +import { useDesignTranslation } from '@freesewing/react/hooks/useDesignTranslation' + +const MyComponent = ({ name = 'aaron' }) => { + const Aaron = useDesign(name) + const i18n = useDesignTranslation(name) + + // ... +} +``` + + +This hook has a `designTranslations` named export that holds translations for the entire FreeSewing collection. + +```js +import { designs } from '@freesewing/react/hooks/useDesign' +import { designTranslations } from '@freesewing/react/hooks/useDesignTranslations' + +const MyComponent = () => { + const Aaron = designs.aaron + const i18n = designTranslations.aaron + + // ... +} +``` + + +If you know in advance what design you want, importing directly is more efficient. +```js +import { Aaron, i18n } from '@freesewing/aaron' + +const MyComponent = () => { + + // ... +} +``` + + + +## Return value + +Calling the hook returns an object holding design translations. + +## Named exports + +You can also load the `designTranslations` named exports from the same import: + +```js +import { + designTranslations, // An object where the key is the (lowercase) design name, and the value on object holding the design translations + useDesignTranslation, // The hook +} from '@freesewing/react/hooks/useDesignTranslation' +``` + +- `designTranslations` is an object where the key is the (lowercase) design name, and the value on object holding the design translations. + + + +