Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2288] Make IconLabel a react flow node
Bug: #2288 Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
- Loading branch information
Showing
9 changed files
with
163 additions
and
90 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
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
47 changes: 47 additions & 0 deletions
47
...es/diagrams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/IconLabel.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,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
import { Theme, useTheme } from '@material-ui/core/styles'; | ||
import { memo } from 'react'; | ||
import { NodeProps } from 'reactflow'; | ||
import { Label } from '../Label'; | ||
import { NodePalette } from '../palette/NodePalette'; | ||
import { IconLabelData } from './IconsLabel.types'; | ||
|
||
const iconlabelStyle = ( | ||
style: React.CSSProperties, | ||
theme: Theme, | ||
selected: boolean, | ||
faded: boolean | ||
): React.CSSProperties => { | ||
const iconLabelNodeStyle: React.CSSProperties = { | ||
opacity: faded ? '0.4' : '', | ||
...style, | ||
}; | ||
|
||
if (selected) { | ||
iconLabelNodeStyle.outline = `${theme.palette.primary.main} solid 1px`; | ||
} | ||
|
||
return iconLabelNodeStyle; | ||
}; | ||
|
||
export const IconLabelNode = memo(({ data, id, selected }: NodeProps<IconLabelData>) => { | ||
const theme = useTheme(); | ||
return ( | ||
<div style={iconlabelStyle(data.style, theme, selected, data.faded)}> | ||
{data.label ? <Label label={data.label} faded={data.faded} transform="" /> : null} | ||
{selected ? <NodePalette diagramElementId={id} labelId={data?.label?.id ?? null} /> : null} | ||
</div> | ||
); | ||
}); |
18 changes: 18 additions & 0 deletions
18
...grams/frontend/sirius-components-diagrams-reactflow/src/renderer/node/IconsLabel.types.ts
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,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
import { NodeData } from '../DiagramRenderer.types'; | ||
|
||
export interface IconLabelData extends NodeData { | ||
style: React.CSSProperties; | ||
} |
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