2022-05-29 11:58:48 +02:00
|
|
|
import React from 'react'
|
2022-12-24 22:52:19 +01:00
|
|
|
import { capitalize } from 'shared/utils.mjs'
|
2022-05-29 11:58:48 +02:00
|
|
|
import { getConfig } from 'shared/designs/index.js'
|
|
|
|
import Popout from 'shared/components/popout.js'
|
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-06-02 19:39:59 +02:00
|
|
|
import Design from 'site/components/design.js'
|
2022-06-01 17:04:29 +02:00
|
|
|
import PatternOptions from './pattern-options'
|
|
|
|
import PatternMeasurements from './pattern-measurements'
|
|
|
|
import DocsLink from 'shared/components/docs-link'
|
2022-05-29 11:58:48 +02:00
|
|
|
|
2022-12-24 22:52:19 +01:00
|
|
|
const PatternDocs = ({ pattern = false }) => {
|
2022-06-01 17:04:29 +02:00
|
|
|
const { t } = useTranslation(['common'])
|
2022-05-29 11:58:48 +02:00
|
|
|
|
|
|
|
if (!pattern) return <p>Please specify a pattern prop when using the PatternDocs component</p>
|
|
|
|
|
|
|
|
const config = getConfig(pattern)
|
2022-12-24 22:52:19 +01:00
|
|
|
console.log({ pattern, config })
|
2022-05-29 11:58:48 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{config.deprecated && (
|
|
|
|
<Popout note>
|
2022-12-24 22:52:19 +01:00
|
|
|
<h5>{t('thingIsDeprecated', { thing: capitalize(pattern) })}</h5>
|
|
|
|
<p>{t('weRecommendThingInstead', { thing: capitalize(config.deprecated) })}</p>
|
2022-06-02 19:39:59 +02:00
|
|
|
<Design design={pattern} />
|
2022-05-29 11:58:48 +02:00
|
|
|
</Popout>
|
|
|
|
)}
|
|
|
|
|
2022-12-24 22:52:19 +01:00
|
|
|
<button className="btn btn-primary btn-large btn-contained" href={`/create/${pattern}`}>
|
2022-06-01 17:04:29 +02:00
|
|
|
{t('newThing', { thing: pattern })}
|
|
|
|
</button>
|
|
|
|
<p>{t(`patterns.${pattern}.description`)}</p>
|
|
|
|
|
2022-12-24 22:52:19 +01:00
|
|
|
<PatternMeasurements pattern={pattern} before={<h2>{t('common:requiredMeasurements')}</h2>} />
|
2022-06-01 17:04:29 +02:00
|
|
|
|
2022-12-24 22:52:19 +01:00
|
|
|
<PatternOptions pattern={pattern} before={<h2>{t('common:patternOptions')}</h2>} />
|
2022-06-01 17:04:29 +02:00
|
|
|
|
|
|
|
<h2>{t('common:patternInstructions')}</h2>
|
2022-05-29 11:58:48 +02:00
|
|
|
<ul className="links">
|
|
|
|
<li>
|
2022-06-01 17:04:29 +02:00
|
|
|
<DocsLink slug={`docs/patterns/${pattern}/needs`} />
|
2022-05-29 11:58:48 +02:00
|
|
|
</li>
|
|
|
|
<li>
|
2022-06-01 17:04:29 +02:00
|
|
|
<DocsLink slug={`docs/patterns/${pattern}/fabric`} />
|
2022-05-29 11:58:48 +02:00
|
|
|
</li>
|
|
|
|
<li>
|
2022-06-01 17:04:29 +02:00
|
|
|
<DocsLink slug={`docs/patterns/${pattern}/cutting`} />
|
2022-05-29 11:58:48 +02:00
|
|
|
</li>
|
|
|
|
<li>
|
2022-06-01 17:04:29 +02:00
|
|
|
<DocsLink slug={`docs/patterns/${pattern}/instructions`} />
|
2022-05-29 11:58:48 +02:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PatternDocs
|