Skip to content

Commit

Permalink
Show instructions button when instructions available
Browse files Browse the repository at this point in the history
  • Loading branch information
avoinea committed Mar 29, 2021
1 parent 22df819 commit 02ba2ac
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 57 deletions.
19 changes: 15 additions & 4 deletions src/components/manage/Blocks/Group/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ const Edit = (props) => {
};

const counterComponent = props.data.maxChars ? (
<p style={counterStyle} className="counter">
<p
style={counterStyle}
className="counter"
onClick={() => {
setSelectedBlock();
props.setSidebarTab(1);
}}
aria-hidden="true"
>
{props.data.maxChars - charCount < 0 ? (
<>
<span>{`${
Expand Down Expand Up @@ -141,7 +149,9 @@ const Edit = (props) => {
allowedBlocks={data.allowedBlocks}
title={data.placeholder}
description={data?.instructions?.data}
onSelectBlock={(id) => setSelectedBlock(id)}
onSelectBlock={(id) => {
setSelectedBlock(id);
}}
onChangeFormData={(newFormData) => {
onChangeBlock(block, {
...data,
Expand Down Expand Up @@ -169,15 +179,16 @@ const Edit = (props) => {
disabled={data.disableInnerButtons}
extraControls={
<>
{!data?.readOnlySettings && instructions && (
{instructions && (
<>
<Button
icon
basic
title="Help"
onClick={() => {
setSelectedBlock();
props.setSidebarTab(1);
const tab = manage ? 0 : 1;
props.setSidebarTab(tab);
}}
>
<Icon name={helpSVG} className="" size="19px" />
Expand Down
104 changes: 54 additions & 50 deletions src/components/manage/Blocks/Group/EditBlockWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class EditBlockWrapper extends React.Component {
const type = data['@type'];
const { disableNewBlocks } = data;
const dragVisible = !data.fixed;
const visible = selected && !disabled;
const visible = selected;

const required = isBoolean(data.required)
? data.required
Expand All @@ -91,7 +91,7 @@ class EditBlockWrapper extends React.Component {
{...(selected ? draginfo?.draggableProps : null)}
className={`block-editor-${data['@type']}`}
>
{!selected && (
{(!selected || !visible || disabled) && (
<div
style={{
display: 'none',
Expand All @@ -102,56 +102,60 @@ class EditBlockWrapper extends React.Component {
)}
{visible && (
<div className="block-toolbar">
<div
style={{
display: dragVisible ? 'inline-block' : 'none',
}}
{...draginfo.dragHandleProps}
className="drag handle wrapper-group-block"
>
<Button icon basic title="Drag and drop">
<Icon name={dragSVG} size="19px" />
</Button>
</div>

{extraControls}

{!disableNewBlocks && !blockHasValue(data) && (
<Button
icon
basic
title="Add block"
onClick={() => {
this.setState({
addNewBlockOpened: !this.state.addNewBlockOpened,
});
}}
className="group-block-add-button"
>
<Icon name={addSVG} className="" size="19px" />
</Button>
)}
{!required && (
<Button
icon
basic
title="Remove block"
onClick={() => onDeleteBlock(block)}
className="delete-button-group-block"
aria-label={intl.formatMessage(messages.delete)}
>
<Icon name={trashSVG} size="19px" />
</Button>
)}
{this.state.addNewBlockOpened && (
<BlockChooser
onMutateBlock={(id, value) => {
this.setState({ addNewBlockOpened: false });
onMutateBlock(id, value);
}}
currentBlock={block}
allowedBlocks={allowedBlocks}
/>
{!disabled && (
<>
<div
style={{
display: dragVisible ? 'inline-block' : 'none',
}}
{...draginfo.dragHandleProps}
className="drag handle wrapper-group-block"
>
<Button icon basic title="Drag and drop">
<Icon name={dragSVG} size="19px" />
</Button>
</div>

{!disableNewBlocks && !blockHasValue(data) && (
<Button
icon
basic
title="Add block"
onClick={() => {
this.setState({
addNewBlockOpened: !this.state.addNewBlockOpened,
});
}}
className="group-block-add-button"
>
<Icon name={addSVG} className="" size="19px" />
</Button>
)}
{!required && (
<Button
icon
basic
title="Remove block"
onClick={() => onDeleteBlock(block)}
className="delete-button-group-block"
aria-label={intl.formatMessage(messages.delete)}
>
<Icon name={trashSVG} size="19px" />
</Button>
)}
{this.state.addNewBlockOpened && (
<BlockChooser
onMutateBlock={(id, value) => {
this.setState({ addNewBlockOpened: false });
onMutateBlock(id, value);
}}
currentBlock={block}
allowedBlocks={allowedBlocks}
/>
)}
</>
)}
</div>
)}
Expand Down
8 changes: 5 additions & 3 deletions src/components/manage/Blocks/Group/editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
z-index: 3;
right: -9px;
display: flex;
padding: 5px;
border: none;
border: 1px solid @borderColor;
border-bottom: 1px solid @pageBackground;
Expand All @@ -77,8 +76,11 @@
border-top-right-radius: 1rem;

.ui.basic.button {
padding: 3px;
padding-right: 0;
padding: 8px 5px;
}

.ui.basic.button:hover {
background: transparent !important;
}
}
}

0 comments on commit 02ba2ac

Please sign in to comment.