-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from alpaca-tc/compound
Support graph options
- Loading branch information
Showing
12 changed files
with
292 additions
and
47 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
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
86 changes: 86 additions & 0 deletions
86
frontend/pages/Home/components/DefinitionGraph/ConfigureGraphOptionsDialog.tsx
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,86 @@ | ||
import React, { useCallback, useState } from 'react' | ||
import styled from 'styled-components' | ||
|
||
import { ActionDialog, CheckBox, FormControl, Section, Stack } from '@/components/ui' | ||
import { spacing } from '@/constants/theme' | ||
|
||
export type GraphOptions = { | ||
compound: boolean | ||
concentrate: boolean | ||
} | ||
|
||
type Props = { | ||
isOpen: boolean | ||
onClickClose: () => void | ||
graphOptions: GraphOptions | ||
setGraphOptions: React.Dispatch<React.SetStateAction<GraphOptions>> | ||
} | ||
|
||
export const ConfigureViewOptionsDialog: React.FC<Props> = ({ isOpen, onClickClose, graphOptions, setGraphOptions }) => { | ||
const [temporaryViewOptions, setTemporaryViewOptions] = useState<GraphOptions>(graphOptions) | ||
|
||
const handleDialogClose = () => { | ||
onClickClose() | ||
|
||
// reset | ||
setTemporaryViewOptions(graphOptions) | ||
} | ||
|
||
const handleSubmit = () => { | ||
setGraphOptions(temporaryViewOptions) | ||
onClickClose() | ||
} | ||
|
||
const onChangeCompound = useCallback( | ||
(event: React.ChangeEvent<HTMLInputElement>) => { | ||
setTemporaryViewOptions((prev) => ({ ...prev, compound: event.target.checked })) | ||
}, | ||
[setTemporaryViewOptions], | ||
) | ||
|
||
const onChangeConcentrate = useCallback( | ||
(event: React.ChangeEvent<HTMLInputElement>) => { | ||
setTemporaryViewOptions((prev) => ({ ...prev, concentrate: event.target.checked })) | ||
}, | ||
[setTemporaryViewOptions], | ||
) | ||
|
||
return ( | ||
<ActionDialog | ||
title="Configure Graph Options" | ||
decorators={{ closeButtonLabel: () => 'Close' }} | ||
actionText="Save" | ||
actionTheme="primary" | ||
isOpen={isOpen} | ||
onClickAction={handleSubmit} | ||
onClickClose={handleDialogClose} | ||
onClickOverlay={handleDialogClose} | ||
width={'500px'} | ||
> | ||
<WrapperSection> | ||
<Stack gap={1.5}> | ||
<Stack gap={1.5}> | ||
<p>Configure graph settings.</p> | ||
|
||
<Stack gap={1.5}> | ||
<FormControl title="Clip the boundary" helpMessage="Clip the boundary of the module."> | ||
<CheckBox name="compound" onChange={onChangeCompound} checked={temporaryViewOptions.compound} /> | ||
</FormControl> | ||
|
||
<FormControl | ||
title="Use edge concentrators" | ||
helpMessage="This merges multiedges into a single edge and causes partially parallel edges to share part of their paths." | ||
> | ||
<CheckBox name="compound" onChange={onChangeConcentrate} checked={temporaryViewOptions.concentrate} /> | ||
</FormControl> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
</WrapperSection> | ||
</ActionDialog> | ||
) | ||
} | ||
|
||
const WrapperSection = styled(Section)` | ||
padding: ${spacing.XS}; | ||
` |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export { DefinitionGraph } from './DefinitionGraph' | ||
export type { GraphOptions } from './ConfigureGraphOptionsDialog' |
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
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
Oops, something went wrong.