Skip to content

Commit

Permalink
Merge pull request #2 from jeff-phillips-18/contextMenuDocs
Browse files Browse the repository at this point in the history
Suggestions
  • Loading branch information
jenny-s51 authored Aug 25, 2023
2 parents 7c1ea43 + 1c8cc0d commit aae31bd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 63 deletions.
106 changes: 44 additions & 62 deletions packages/module/patternfly-docs/content/examples/TopologyControlBar.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,68 +50,50 @@ Pass the `TopologyControlBar` component to the `controlBar` prop, and pass the `

You can override these defaults by passing in any of the `defaultControlButtonsOptions` as a parameter, with your updated boolean value of the default option.

2. For each button, pass in each action callback method as parameter.
2. For each button, pass in each action callback method as parameter:

- zoomInCallback: Handle the click on the zoom in button. Eg:
```noLive
action(() => {
// Zoom in by desired amount
controller.getGraph().scaleBy(4 / 3);
})
```
- zoomOutCallback: Handle the click on the zoom out button. Eg:
```noLive
action(() => {
// Zoom in out desired amount
controller.getGraph().scaleBy(0.75);
})
```
- fitToScreenCallback: Handle click on fit to screen button. Eg:
```noLive
action(() => {
// Note: The default BaseGraph's fit implementation will not scale to greater
// than 1 so it will not zoom in to enlarge the graph to take up the entire
// viewable area.
// Fit entire graph in the viewable area with an 80px margin
controller.getGraph().fit(80);
})
```
- resetViewCallback: Handle the click on the reset view button. Eg:
```noLive
action(() => {
// BaseGraph's reset implementation will scale back to 1, and re-center
// the graph
controller.getGraph().reset();
// re-run the layout
controller.getGraph().layout();
})
```
- legendCallback: Handle the click on the legend. Eg:
```noLive
action(() => {
// application specific code to show a legend (no default support)
})
```

```ts file="./TopologyControlBarDemo.tsx"
```

## Action callback methods

### zoomInCallback

```noLive
/**
* Parameters:
* scale: The interview by which to scale up the topology view
* Returns:
* function that zooms in the topology view by the provided scale value.
* Scale changes are not saved on reload.
**/
zoomInCallback: action(() => {
controller.getGraph().scaleBy(4 / 3);
})
```

### zoomOutCallback

```noLive
/**
* Parameters:
* scale: The interview by which to scale down the topology view
* Returns:
* function that zooms out the topology view by the provided scale value.
* Scale changes are not saved on reload.
**/
zoomOutCallback: action(() => {
controller.getGraph().scaleBy(0.75);
}),
```

### fitToScreenCallback

```noLive
/**
* Parameters:
* padding: The padding to give the topology view such that it fits the screen and shows all the nodes
* Returns:
* function that fits the topology view to the screen. Scale changes are not saved on reload.
* Fit to screen will not scale up higher than the current scale or 1, whichever is greater.
* Therefore it does not zoom in.
**/
fitToScreenCallback: action(() => {
controller.getGraph().fit(80);
}),
```

### resetViewCallback

```noLive
/**
* Returns:
* function that resets the topology view to its initial placement on load.
**/
resetViewCallback: action(() => {
controller.getGraph().reset();
controller.getGraph().layout();
}),
```
2 changes: 1 addition & 1 deletion packages/module/patternfly-docs/generated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
'/topology/control-bar/extensions': {
id: "Control Bar",
title: "Control Bar",
toc: [[{"text":"Topology with a control bar"}],{"text":"Action callback methods"},[{"text":"zoomInCallback"},{"text":"zoomOutCallback"},{"text":"fitToScreenCallback"},{"text":"resetViewCallback"}]],
toc: [[{"text":"Topology with a control bar"}]],
examples: ["Topology with a control bar"],
section: "topology",
subsection: "",
Expand Down

0 comments on commit aae31bd

Please sign in to comment.