feat(components): Caption should now be passed as children to Legend/Example
Closes #1043 Note that backwards compatibility is ensured.
This commit is contained in:
parent
1f3fdf6742
commit
3fd0e71f19
3 changed files with 13 additions and 3 deletions
|
@ -1,6 +1,11 @@
|
||||||
2.16.3:
|
2.16.3:
|
||||||
date: Unreleased
|
date: Unreleased
|
||||||
|
|
||||||
|
Changed:
|
||||||
|
components:
|
||||||
|
- Caption should not be passed as children to Legend and Example components
|
||||||
|
See https://github.com/freesewing/freesewing/issues/1043
|
||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
charlie:
|
charlie:
|
||||||
- Add `@freesewing/plugin-mirror` as peer dependency
|
- Add `@freesewing/plugin-mirror` as peer dependency
|
||||||
|
|
|
@ -29,6 +29,7 @@ const Example = ({
|
||||||
pattern = 'examples',
|
pattern = 'examples',
|
||||||
design = true,
|
design = true,
|
||||||
caption = '',
|
caption = '',
|
||||||
|
children=null,
|
||||||
options = {},
|
options = {},
|
||||||
settings,
|
settings,
|
||||||
part = '',
|
part = '',
|
||||||
|
@ -37,6 +38,8 @@ const Example = ({
|
||||||
const [designMode, setDesignMode] = useState(false)
|
const [designMode, setDesignMode] = useState(false)
|
||||||
const [focus, setFocus] = useState(null)
|
const [focus, setFocus] = useState(null)
|
||||||
|
|
||||||
|
if (caption) console.log('Passing the caption prop to @freesewing/components/Legend is deprecated. See: https://github.com/freesewing/freesewing/issues/1043')
|
||||||
|
|
||||||
const raiseEvent = (type, data) => {
|
const raiseEvent = (type, data) => {
|
||||||
if (type === 'clearFocusAll') return setFocus(null)
|
if (type === 'clearFocusAll') return setFocus(null)
|
||||||
let f = {}
|
let f = {}
|
||||||
|
@ -98,7 +101,7 @@ const Example = ({
|
||||||
</div>
|
</div>
|
||||||
<Draft {...patternProps} design={designMode} focus={focus} raiseEvent={raiseEvent} />
|
<Draft {...patternProps} design={designMode} focus={focus} raiseEvent={raiseEvent} />
|
||||||
</div>
|
</div>
|
||||||
<figcaption>{caption}</figcaption>
|
<figcaption>{caption || children}</figcaption>
|
||||||
{designMode && (
|
{designMode && (
|
||||||
<div className="design">
|
<div className="design">
|
||||||
<Design
|
<Design
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
||||||
import LegendPattern from '@freesewing/legend'
|
import LegendPattern from '@freesewing/legend'
|
||||||
import Draft from '../Draft'
|
import Draft from '../Draft'
|
||||||
|
|
||||||
const Legend = ({ caption = '', part = '' }) => {
|
const Legend = ({ caption = false, part = '', children=null }) => {
|
||||||
const patternProps = new LegendPattern({
|
const patternProps = new LegendPattern({
|
||||||
only: part,
|
only: part,
|
||||||
measurements: {
|
measurements: {
|
||||||
|
@ -12,12 +12,14 @@ const Legend = ({ caption = '', part = '' }) => {
|
||||||
.draft()
|
.draft()
|
||||||
.getRenderProps()
|
.getRenderProps()
|
||||||
|
|
||||||
|
if (caption) console.log('Passing the caption prop to @freesewing/components/Legend is deprecated. See: https://github.com/freesewing/freesewing/issues/1043')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<figure>
|
<figure>
|
||||||
<div className="shadow">
|
<div className="shadow">
|
||||||
<Draft {...patternProps} />
|
<Draft {...patternProps} />
|
||||||
</div>
|
</div>
|
||||||
<figcaption>{caption}</figcaption>
|
<figcaption>{caption || children}</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue