Skip to content

Commit

Permalink
fixing progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Sep 5, 2023
1 parent bfc8da1 commit d548930
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 4.0.74
* Version: 4.0.75
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/form/assets/state/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export function setSteps(formElement, formId) {
setState([StateEnum.FORM, StateEnum.STEPS, StateEnum.STEPS_PROGRESS_BAR], stepsProgressBar, formId);
setState([StateEnum.FORM, StateEnum.STEPS, StateEnum.STEPS_ELEMENTS_PROGRESS_BAR], {}, formId);

Object.values(stepsProgressBar).forEach((item) => {
[...stepsProgressBar.children].forEach((item) => {
const stepId = item.getAttribute(getStateAttribute('stepId'));
setState([StateEnum.FORM, StateEnum.STEPS, StateEnum.STEPS_ELEMENTS_PROGRESS_BAR, stepId], item, formId);
});
Expand Down
4 changes: 2 additions & 2 deletions src/Blocks/components/form/assets/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class Steps {
// Multistep setup.
// Find current step.
const currentStep = this.state.getStateFormStepsCurrent(formId);

// Remove active from current step.
this.state.getStateFormStepsElementProgressBar(currentStep, formId)?.classList?.remove(this.state.getStateSelectorsClassActive());

Expand All @@ -266,7 +266,7 @@ export class Steps {

// Reset filled steps.
this.state.getStateFormStepsElementsProgressBar(formId).forEach((item) => item?.classList?.remove(this.state.getStateSelectorsClassFilled()));

// Add filled to all filled steps.
flow.forEach((item) => {
this.state.getStateFormStepsElementProgressBar(item, formId)?.classList?.add(this.state.getStateSelectorsClassFilled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ProgressBarOptions = (attributes) => {
} = attributes;

const progressBarUse = checkAttr('progressBarUse', attributes, manifest);
const progressBarHideLabels = checkAttr('progressBarHideLabels', attributes, manifest);
const progressBarMultiflowUse = checkAttr('progressBarMultiflowUse', attributes, manifest);
const progressBarMultiflowInitCount = checkAttr('progressBarMultiflowInitCount', attributes, manifest);

Expand All @@ -26,6 +27,15 @@ export const ProgressBarOptions = (attributes) => {
}}
/>

<IconToggle
icon={icons.tag}
label={__('Hide progress bar labels', 'eightshift-forms')}
checked={progressBarHideLabels}
onChange={(value) => {
setAttributes({ [getAttrKey('progressBarHideLabels', attributes, manifest)]: value });
}}
/>

{progressBarMultiflowUse &&
<TextControl
type={'number'}
Expand Down
4 changes: 4 additions & 0 deletions src/Blocks/components/progress-bar/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"type": "boolean",
"default": false
},
"progressBarHideLabels": {
"type": "boolean",
"default": false
},
"progressBarMultiflowUse": {
"type": "boolean",
"default": false
Expand Down
8 changes: 7 additions & 1 deletion src/Blocks/components/progress-bar/partials/multistep.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
$componentClass = $attributes['componentClass'] ?? '';
$componentJsClass = $attributes['componentJsClass'] ?? '';

$hideLabels = $attributes['hideLabels'] ?? false;

$progressBarItemClass = Components::classnames([
Components::selector($componentClass, $componentClass, 'item'),
Components::selector($componentJsClass, $componentJsClass),
Expand All @@ -42,7 +44,11 @@
?>
<div class="<?php echo esc_attr($progressBarItemClass); ?>" <?php echo $progressBarAttrsOutput; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped ?>>
<div class="<?php echo esc_attr("{$componentClass}__item-inner"); ?>">
<?php echo esc_html($label); ?>
<?php
if (!$hideLabels) {
echo esc_html($label);
}
?>
</div>
</div>
<?php
Expand Down
4 changes: 2 additions & 2 deletions src/Blocks/components/progress-bar/progress-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
}

$progressBarMultiflowUse = Components::checkAttr('progressBarMultiflowUse', $attributes, $manifest);
$progressBarMultiflowInitCount = Components::checkAttr('progressBarMultiflowInitCount', $attributes, $manifest);

$progressBarClass = Components::classnames([
Components::selector($componentClass, $componentClass),
Expand All @@ -47,10 +46,11 @@
'steps' => $progressBarSteps,
'componentClass' => $componentClass,
'componentJsClass' => $componentJsClass,
'hideLabels' => Components::checkAttr('progressBarHideLabels', $attributes, $manifest),
]);
} else {
echo Components::renderPartial('component', $manifest['componentName'], 'multiflow', [ // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped
'count' => $progressBarMultiflowInitCount,
'count' => Components::checkAttr('progressBarMultiflowInitCount', $attributes, $manifest),
]);
}
?>
Expand Down
1 change: 1 addition & 0 deletions src/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public function updateFormsBlockOutput(array $blocks, array $attributes): array
$innerBlock['attrs']["{$blockName}FormProgressBarMultiflowUse"] = $innerBlock['attrs']["{$blockName}StepMultiflowUse"] ?? false;
$innerBlock['attrs']["{$blockName}FormProgressBarMultiflowInitCount"] = $innerBlock['attrs']["{$blockName}StepProgressBarMultiflowInitCount"] ?? '';
$innerBlock['attrs']["{$blockName}FormProgressBarUse"] = $innerBlock['attrs']["{$blockName}StepProgressBarUse"] ?? false;
$innerBlock['attrs']["{$blockName}FormProgressBarHideLabels"] = $innerBlock['attrs']["{$blockName}StepProgressBarHideLabels"] ?? false;
$innerBlock['attrs']["{$blockName}FormHasSteps"] = true;

$inBlockOutput = \array_values($inBlockOutput);
Expand Down

0 comments on commit d548930

Please sign in to comment.