| 1 |
import objAttributes from "./attributes"; |
| 2 |
import { InspectorControls } from "@wordpress/block-editor"; |
| 3 |
import { TabPanel, PanelBody, BaseControl, SelectControl } from "@wordpress/components"; |
| 4 |
import { __ } from "@wordpress/i18n"; |
| 5 |
import { HEADER_BACKGROUND_COLOR, HEADER_ICON_INNER_HEIGHT, HEADER_ICON_INNER_WIDTH, HEADER_ICON_SIZE, HEADER_MARGIN, HEADER_PADDING } from "./constants"; |
| 6 |
import { header_doc_count_typo, header_title_typo } from "./typographyPrefixConstants"; |
| 7 |
import ResponsiveDimensionsControl from "../../../util/dimensions-control-v2"; |
| 8 |
import ColorControl from "../../../util/color-control"; |
| 9 |
import ResponsiveRangeController from "../../../util/responsive-range-control"; |
| 10 |
import BackgroundControl from "../../../util/background-control"; |
| 11 |
import TypographyDropdown from "../../../util/typography-control-v2"; |
| 12 |
|
| 13 |
const Inspector = ({ attributes, setAttributes }) => { |
| 14 |
const { resOption, archiveHeaderTitleColor, archiveHeaderDocCountColor, titleTag } = attributes; |
| 15 |
|
| 16 |
const resRequiredProps = { |
| 17 |
setAttributes, |
| 18 |
resOption, |
| 19 |
attributes, |
| 20 |
objAttributes, |
| 21 |
}; |
| 22 |
|
| 23 |
return ( |
| 24 |
<InspectorControls key="controls"> |
| 25 |
<div className="eb-panel-control"> |
| 26 |
<TabPanel |
| 27 |
className="eb-parent-tab-panel" |
| 28 |
activeClass="active-tab" |
| 29 |
tabs={[ |
| 30 |
{ |
| 31 |
name: "general", |
| 32 |
title: __("General", "betterdocs"), |
| 33 |
className: "eb-tab general", |
| 34 |
}, |
| 35 |
{ |
| 36 |
name: "style", |
| 37 |
title: __("Style", "betterdocs"), |
| 38 |
className: "eb-tab styles", |
| 39 |
} |
| 40 |
]} |
| 41 |
> |
| 42 |
{(tab) => { |
| 43 |
return ( |
| 44 |
<div className={"eb-tab-controls " + tab.name}> |
| 45 |
{tab.name === 'general' && ( |
| 46 |
<PanelBody |
| 47 |
title={__("Settings", "betterdocs")} |
| 48 |
initialOpen={true} |
| 49 |
> |
| 50 |
<SelectControl |
| 51 |
label={__( |
| 52 |
"Archive Title Tag", |
| 53 |
"betterdocs", |
| 54 |
)} |
| 55 |
value={titleTag} |
| 56 |
options={[ |
| 57 |
{ |
| 58 |
label: __( |
| 59 |
"H1", |
| 60 |
"betterdocs", |
| 61 |
), |
| 62 |
value: "h1", |
| 63 |
}, |
| 64 |
{ |
| 65 |
label: __( |
| 66 |
"H2", |
| 67 |
"betterdocs", |
| 68 |
), |
| 69 |
value: "h2", |
| 70 |
}, |
| 71 |
{ |
| 72 |
label: __( |
| 73 |
"H3", |
| 74 |
"betterdocs", |
| 75 |
), |
| 76 |
value: "h3", |
| 77 |
}, |
| 78 |
{ |
| 79 |
label: __( |
| 80 |
"H4", |
| 81 |
"betterdocs", |
| 82 |
), |
| 83 |
value: "h4", |
| 84 |
}, |
| 85 |
{ |
| 86 |
label: __( |
| 87 |
"H5", |
| 88 |
"betterdocs", |
| 89 |
), |
| 90 |
value: "h5", |
| 91 |
}, |
| 92 |
]} |
| 93 |
onChange={(newTag) => |
| 94 |
setAttributes({ |
| 95 |
titleTag: newTag, |
| 96 |
}) |
| 97 |
} |
| 98 |
/> |
| 99 |
</PanelBody> |
| 100 |
)} |
| 101 |
{tab.name === "style" && ( |
| 102 |
<PanelBody |
| 103 |
title={__("Header", "betterdocs")} |
| 104 |
initialOpen={false} |
| 105 |
> |
| 106 |
<BaseControl> |
| 107 |
<h3 className="eb-control-title"> |
| 108 |
{__("Archive Header", "betterdocs")} |
| 109 |
</h3> |
| 110 |
</BaseControl> |
| 111 |
<ResponsiveDimensionsControl |
| 112 |
baseLabel={__("Padding", "betterdocs")} |
| 113 |
resRequiredProps={resRequiredProps} |
| 114 |
controlName={HEADER_PADDING} |
| 115 |
/> |
| 116 |
<ResponsiveDimensionsControl |
| 117 |
baseLabel={__("Margin", "betterdocs")} |
| 118 |
resRequiredProps={resRequiredProps} |
| 119 |
controlName={HEADER_MARGIN} |
| 120 |
/> |
| 121 |
<BackgroundControl |
| 122 |
controlName={HEADER_BACKGROUND_COLOR} |
| 123 |
resRequiredProps={resRequiredProps} |
| 124 |
noOverlay={true} |
| 125 |
/> |
| 126 |
<ResponsiveRangeController |
| 127 |
baseLabel={__("Icon Size", "betterdocs")} |
| 128 |
controlName={HEADER_ICON_SIZE} |
| 129 |
resRequiredProps={resRequiredProps} |
| 130 |
min={1} |
| 131 |
max={500} |
| 132 |
step={1} |
| 133 |
/> |
| 134 |
<ResponsiveRangeController |
| 135 |
baseLabel={__("Inner Image Width", "betterdocs")} |
| 136 |
controlName={HEADER_ICON_INNER_WIDTH} |
| 137 |
resRequiredProps={resRequiredProps} |
| 138 |
min={1} |
| 139 |
max={500} |
| 140 |
step={1} |
| 141 |
/> |
| 142 |
<ResponsiveRangeController |
| 143 |
baseLabel={__("Inner Image Height", "betterdocs")} |
| 144 |
controlName={HEADER_ICON_INNER_HEIGHT} |
| 145 |
resRequiredProps={resRequiredProps} |
| 146 |
min={1} |
| 147 |
max={500} |
| 148 |
step={1} |
| 149 |
/> |
| 150 |
<BaseControl> |
| 151 |
<h3 className="eb-control-title"> |
| 152 |
{__("Archive Doc Count", "betterdocs")} |
| 153 |
</h3> |
| 154 |
</BaseControl> |
| 155 |
<ColorControl |
| 156 |
label={__("Color", "betterdocs")} |
| 157 |
color={archiveHeaderTitleColor} |
| 158 |
onChange={(value) =>{ |
| 159 |
setAttributes({ |
| 160 |
archiveHeaderTitleColor:value |
| 161 |
}) |
| 162 |
}} |
| 163 |
/> |
| 164 |
<TypographyDropdown |
| 165 |
baseLabel={__("Typography", "betterdocs")} |
| 166 |
typographyPrefixConstant={header_doc_count_typo} |
| 167 |
resRequiredProps={resRequiredProps} |
| 168 |
defaultFontSize={32} |
| 169 |
/> |
| 170 |
<BaseControl> |
| 171 |
<h3 className="eb-control-title"> |
| 172 |
{__("Archive Doc Title", "betterdocs")} |
| 173 |
</h3> |
| 174 |
</BaseControl> |
| 175 |
<ColorControl |
| 176 |
label={__("Color", "betterdocs")} |
| 177 |
color={archiveHeaderTitleColor} |
| 178 |
onChange={(value) =>{ |
| 179 |
setAttributes({ |
| 180 |
archiveHeaderDocCountColor:value |
| 181 |
}) |
| 182 |
}} |
| 183 |
/> |
| 184 |
<TypographyDropdown |
| 185 |
baseLabel={__("Typography", "betterdocs")} |
| 186 |
typographyPrefixConstant={header_title_typo} |
| 187 |
resRequiredProps={resRequiredProps} |
| 188 |
defaultFontSize={32} |
| 189 |
/> |
| 190 |
</PanelBody> |
| 191 |
)} |
| 192 |
</div> |
| 193 |
) |
| 194 |
}} |
| 195 |
</TabPanel> |
| 196 |
</div> |
| 197 |
</InspectorControls> |
| 198 |
); |
| 199 |
}; |
| 200 |
|
| 201 |
export default Inspector; |
| 202 |
|