Skip to content

Commit 87f557d

Browse files
committed
Add theme option to display caption above
REDMINE-21063
1 parent 00ebcef commit 87f557d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

entry_types/scrolled/package/src/contentElements/inlineImage/stories.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ storiesOfContentElement(module, {
2828
}
2929
}
3030
},
31+
{
32+
name: 'With Caption Above',
33+
configuration: {
34+
caption: 'Some text here'
35+
},
36+
themeOptions: {
37+
figureCaptionPosition: 'above'
38+
}
39+
},
3140
{
3241
name: 'With Rounded Corners',
3342
configuration: {

entry_types/scrolled/package/src/frontend/Figure.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {EditableText} from './EditableText';
66
import {useDarkBackground} from './backgroundColor';
77
import {useContentElementEditorState} from './useContentElementEditorState';
88
import {useI18n} from './i18n';
9+
import {useTheme} from '../entryState';
910
import {isBlankEditableTextValue} from './utils/blank';
1011

1112
import styles from './Figure.module.css';
@@ -32,6 +33,9 @@ export function Figure({
3233
const {isSelected, isEditable} = useContentElementEditorState();
3334
const [isEditingCaption, setIsEditingCaption] = useState(false);
3435
const {t} = useI18n({locale: 'ui'});
36+
const theme = useTheme();
37+
38+
const captionAbove = (theme.options.figureCaptionPosition === 'above');
3539

3640
caption = useMemo(
3741
() => typeof caption === 'string' ?
@@ -43,7 +47,7 @@ export function Figure({
4347
if (!isBlankEditableTextValue(caption) || isEditable) {
4448
return (
4549
<figure className={classNames(styles.root, {[styles.invert]: !darkBackground})}>
46-
{children}
50+
{!captionAbove && children}
4751

4852
{isBlankEditableTextValue(caption) && isSelected && !isEditingCaption && addCaptionButtonVisible &&
4953
<ActionButton position={addCaptionButtonPosition}
@@ -63,6 +67,8 @@ export function Figure({
6367
hyphens="none"
6468
placeholder={t('pageflow_scrolled.inline_editing.type_text')} />
6569
</figcaption>}
70+
71+
{captionAbove && children}
6672
</figure>
6773
);
6874
}

0 commit comments

Comments
 (0)