| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { InspectorControls } from '@wordpress/block-editor'; |
| 3 |
import { |
| 4 |
PanelBody, |
| 5 |
TextControl, |
| 6 |
Button, |
| 7 |
ButtonGroup, |
| 8 |
BaseControl, |
| 9 |
ToggleControl, |
| 10 |
SelectControl, |
| 11 |
TabPanel, |
| 12 |
Notice |
| 13 |
} from '@wordpress/components'; |
| 14 |
import { useEffect } from '@wordpress/element'; |
| 15 |
import { select, withSelect } from '@wordpress/data'; |
| 16 |
|
| 17 |
import objAttributes from "./attributes"; |
| 18 |
import { DOC_DATE_ALIGNMENT, DOC_DATE_BACKGROUND, DOC_DATE_BORDER, DOC_DATE_MARGIN, DOC_DATE_PADDING } from "./constants"; |
| 19 |
import TypographyDropdown from "../../../util/typography-control-v2"; |
| 20 |
import ResponsiveDimensionsControl from '../../../util/dimensions-control-v2'; |
| 21 |
import BorderShadowControl from '../../../util/border-shadow-control'; |
| 22 |
import BackgroundControl from "../../../util/background-control"; |
| 23 |
import ColorControl from "../../../util/color-control"; |
| 24 |
import { DOC_DATE_TYPO } from './typographyPrefixConstants'; |
| 25 |
|
| 26 |
const Inspector = ({attributes, setAttributes}) => { |
| 27 |
|
| 28 |
const { resOption, doc_date_color, doc_date_align } = attributes; |
| 29 |
|
| 30 |
const resRequiredProps = { |
| 31 |
setAttributes, |
| 32 |
resOption, |
| 33 |
attributes, |
| 34 |
objAttributes, |
| 35 |
}; |
| 36 |
|
| 37 |
return ( |
| 38 |
<InspectorControls key="controls"> |
| 39 |
<div className="eb-panel-control"> |
| 40 |
<TabPanel |
| 41 |
className="eb-parent-tab-panel" |
| 42 |
activeClass="active-tab" |
| 43 |
tabs={[ |
| 44 |
{ |
| 45 |
name: "styles", |
| 46 |
title: __("Style", "betterdocs"), |
| 47 |
className: "eb-tab styles", |
| 48 |
} |
| 49 |
]} |
| 50 |
> |
| 51 |
{(tab) => ( |
| 52 |
<div className={"eb-tab-controls " + tab.name}> |
| 53 |
{( tab.name === "styles" ) && ( |
| 54 |
<PanelBody title={__("Date Style", "betterdocs")} initialOpen={true}> |
| 55 |
<> |
| 56 |
<ResponsiveDimensionsControl |
| 57 |
baseLabel={__("Padding", "betterdocs")} |
| 58 |
resRequiredProps={resRequiredProps} |
| 59 |
controlName={DOC_DATE_PADDING} |
| 60 |
/> |
| 61 |
<ResponsiveDimensionsControl |
| 62 |
baseLabel={__("Margin", "betterdocs")} |
| 63 |
resRequiredProps={resRequiredProps} |
| 64 |
controlName={DOC_DATE_MARGIN} |
| 65 |
/> |
| 66 |
<BaseControl> |
| 67 |
<h3 className="eb-control-title"> |
| 68 |
{__("Border", "betterdocs")} |
| 69 |
</h3> |
| 70 |
</BaseControl> |
| 71 |
<BorderShadowControl |
| 72 |
controlName={DOC_DATE_BORDER} |
| 73 |
resRequiredProps={resRequiredProps} |
| 74 |
/> |
| 75 |
<BackgroundControl |
| 76 |
controlName={DOC_DATE_BACKGROUND} |
| 77 |
resRequiredProps={resRequiredProps} |
| 78 |
noOverlay={true} |
| 79 |
/> |
| 80 |
<TypographyDropdown |
| 81 |
baseLabel={__("Typography", "betterdocs")} |
| 82 |
typographyPrefixConstant={DOC_DATE_TYPO} |
| 83 |
resRequiredProps={resRequiredProps} |
| 84 |
/> |
| 85 |
<ColorControl |
| 86 |
label={__("Color", "betterdocs")} |
| 87 |
color={doc_date_color} |
| 88 |
onChange={(value) => { |
| 89 |
setAttributes({doc_date_color:value}) |
| 90 |
}} |
| 91 |
/> |
| 92 |
<BaseControl label={__("Alignment", "betterdocs")} id="eb-advance-heading-alignment"> |
| 93 |
<ButtonGroup id="eb-advance-heading-alignment"> |
| 94 |
{DOC_DATE_ALIGNMENT.map((item, key) => ( |
| 95 |
<Button |
| 96 |
key={key} |
| 97 |
// isLarge |
| 98 |
isPrimary={doc_date_align === item.value} |
| 99 |
isSecondary={doc_date_align !== item.value} |
| 100 |
onClick={() => |
| 101 |
setAttributes({ |
| 102 |
doc_date_align: item.value, |
| 103 |
}) |
| 104 |
} |
| 105 |
> |
| 106 |
{item.label} |
| 107 |
</Button> |
| 108 |
))} |
| 109 |
</ButtonGroup> |
| 110 |
</BaseControl> |
| 111 |
</> |
| 112 |
</PanelBody> |
| 113 |
)} |
| 114 |
</div> |
| 115 |
)} |
| 116 |
</TabPanel> |
| 117 |
</div> |
| 118 |
</InspectorControls> |
| 119 |
); |
| 120 |
} |
| 121 |
|
| 122 |
export default Inspector; |
| 123 |
|