Skip to content

Commit

Permalink
Merge pull request #2 from gofynd/button-types
Browse files Browse the repository at this point in the history
Button types
  • Loading branch information
vishu3011 committed Jul 13, 2021
2 parents 8cb6d5c + 670113e commit 9961eff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let unsubcribe_handler = btn.subscribe(components.Button.Actions.CLICK, (event)
});
btn.dispatch();
```
<img src="https://github.com/gofynd/fdk-extension-bridge-javascript/blob/readme/demo/button.png" alt="Button"><hr>
<img src="https://github.com/gofynd/fdk-extension-bridge-javascript/blob/master/demo/button.png" alt="Button"><hr>

## For Including Toggle Button

Expand All @@ -34,7 +34,7 @@ let toggle_unsubcribe_handler = toggle.subscribe(components.ToggleButton.Actions
});
toggle.dispatch({value: true});
```
<img src="https://github.com/gofynd/fdk-extension-bridge-javascript/blob/readme/demo/toggle_button.png" alt="Toggle Button"><hr>
<img src="https://github.com/gofynd/fdk-extension-bridge-javascript/blob/master/demo/toggle_button.png" alt="Toggle Button"><hr>

## For Including Context Menu Item

Expand All @@ -47,7 +47,7 @@ let toggle_unsubcribe_handler = toggle.subscribe(components.ContextMenuItem.Acti
});
context.dispatch();
```
<img src="https://github.com/gofynd/fdk-extension-bridge-javascript/blob/readme/demo/context_item.png" alt="Context Item"><hr>
<img src="https://github.com/gofynd/fdk-extension-bridge-javascript/blob/master/demo/context_item.png" alt="Context Item"><hr>

## For resetting extesnion bridge

Expand Down
10 changes: 8 additions & 2 deletions components/button.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@ class Button extends Component{
* "label": "",
* "id": "", //optional
* "disabled": true/false // default value false
* "type": "flat/stroke"
* }
*/
constructor(extension, config) {
super(extension, c_type, config.id);
this.disabled = config.disabled || false;
this.label = config.label;
this.buttonType = config.buttonType || 'flat';
this.config = {
disabled: this.disabled,
label: this.label
label: this.label,
type: this.buttonType
}
}

Expand All @@ -46,14 +49,17 @@ class Button extends Component{
}


setState({label,disabled}) {
setState({label,disabled,buttonType}) {
// to set state of a component
if(label){
this.label = label
}
if(disabled){
this.disabled = disabled
}
if(type){
this.buttonType = buttonType
}
this.dispatch()
}
}
Expand Down
Binary file added demo/.DS_Store
Binary file not shown.

0 comments on commit 9961eff

Please sign in to comment.