forked from ToolJet/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ Feature ]:: steps widget (ToolJet#3200)
* tabs event * completed event firing on selection tab * steps widget basic structure & code * active item logic * logic for currentstep * logic for steps theme * event onSelect handled and exposed currentStepId * fixing tooltip * logic for colour updated * updates * bugfixes and color theme fix * darkmode fixes * some bugfixes * cleanup * reverting * reverting unwanted change * updating green theme * pr changes : style changes * pr change :: color style made dynamic :rocket * style fix 🚀 * docs updated * bugfix
- Loading branch information
Showing
8 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
id: steps | ||
title: Steps | ||
--- | ||
# Steps | ||
|
||
Steps are used to guide users through complex processes, making them easier and more intuitive. | ||
|
||
<div style={{textAlign: 'center'}}> | ||
|
||
![ToolJet - Star rating Widget](/img/widgets/steps/steps.png) | ||
|
||
</div> | ||
|
||
|
||
### Steps | ||
|
||
This property lets you add and the steps. | ||
|
||
|
||
```{{ [{ name: 'step 1', tooltip: 'some tooltip', id: 1},{ name: 'step 2', tooltip: 'some tooltip', id: 2},{ name: 'step 3', tooltip: 'some tooltip', id: 3},{ name: 'step 4', tooltip: 'some tooltip', id: 4},{ name: 'step 5', tooltip: 'some tooltip', id: 5}]}}``` | ||
|
||
add another object to add one more step. | ||
|
||
### Current step | ||
|
||
This property lets you select the current step you want to be highlighted. | ||
|
||
### Steps selectable | ||
|
||
This property when disabled will disable selection of steps. | ||
|
||
|
||
## Events | ||
|
||
### On select | ||
This event is fired whenever the user selects any step. | ||
|
||
## Layout | ||
|
||
### Show on desktop | ||
|
||
Toggle on or off to display the widget in desktop view. You can programmatically determing the value by clicking on `Fx` to set the value `{{true}}` or `{{false}}`. | ||
### Show on mobile | ||
|
||
Toggle on or off to display the widget in mobile view. You can programmatically determing the value by clicking on `Fx` to set the value `{{true}}` or `{{false}}`. | ||
|
||
## Styles | ||
|
||
### Theme | ||
|
||
You can change the theme of widget by selecting available themes from dropdown. | ||
|
||
|
||
### Colour | ||
|
||
You can change the color of the widget by entering the Hex color code or choosing a color of your choice from the color picker. | ||
|
||
|
||
### Text Colour | ||
|
||
You can change the text color of the widget by entering the Hex color code or choosing a color of your choice from the color picker. | ||
|
||
### Visibility | ||
|
||
Toggle on or off to control the visibility of the widget. You can programmatically change its value by clicking on the `Fx` button next to it. If `{{false}}` the widget will not be visible after the app is deployed. By default, it's set to `{{true}}`. | ||
|
||
:::info | ||
Any property having `Fx` button next to its field can be **programmatically configured**. | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
export const Steps = function Button({ properties, styles, fireEvent, setExposedVariable, height }) { | ||
const { currentStep, stepsSelectable, steps } = properties; | ||
const { color, theme, visibility } = styles; | ||
|
||
const [activeStep, setActiveStep] = useState(null); | ||
|
||
const dynamicStyle = { | ||
'--bgColor': styles.color, | ||
'--textColor': styles.textColor, | ||
}; | ||
const activeStepHandler = (id) => { | ||
const active = steps.filter((item) => item.id == id); | ||
setExposedVariable('currentStepId', active[0].id).then(() => fireEvent('onSelect')); | ||
setActiveStep(active[0].id); | ||
}; | ||
|
||
useEffect(() => { | ||
setActiveStep(currentStep); | ||
setExposedVariable('currentStepId', currentStep).then(() => fireEvent('onSelect')); | ||
}, [currentStep]); | ||
|
||
return ( | ||
visibility && ( | ||
<div | ||
className={`steps ${theme == 'numbers' && 'steps-counter '}`} | ||
style={{ color: `${styles.textColor}`, height }} | ||
> | ||
{steps?.map((item) => ( | ||
<a | ||
key={item.id} | ||
href="#" | ||
className={`step-item ${item.id == activeStep && 'active'} ${!stepsSelectable && 'step-item-disabled'} ${ | ||
color && `step-${color}` | ||
}`} | ||
data-bs-toggle="tooltip" | ||
title={item?.tooltip} | ||
onClick={() => stepsSelectable && activeStepHandler(item.id)} | ||
style={dynamicStyle} | ||
> | ||
{theme == 'titles' && item.name} | ||
</a> | ||
))} | ||
</div> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters