|
| 1 | +/** |
| 2 | + * Copyright (c) 2025, RTE (http://www.rte-france.com) |
| 3 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | + */ |
| 7 | + |
| 8 | +import { type MuiStyles } from '@gridsuite/commons-ui'; |
| 9 | +import { Theme } from '@mui/material'; |
| 10 | +import { baseNodeStyles, interactiveNodeStyles } from './styles'; |
| 11 | +import { zoomStyles } from '../zoom.styles'; |
| 12 | + |
| 13 | +export const getBorderWidthStyle = (theme: Theme, isSelected: boolean) => ({ |
| 14 | + borderWidth: zoomStyles.borderWidth(theme, isSelected), |
| 15 | +}); |
| 16 | + |
| 17 | +export const getNodeBaseStyle = (theme: Theme, isSelected: boolean) => |
| 18 | + isSelected ? modificationNodeStyles.selected(theme) : modificationNodeStyles.default(theme); |
| 19 | + |
| 20 | +export const modificationNodeStyles = { |
| 21 | + selected: (theme) => ({ |
| 22 | + ...baseNodeStyles(theme, 'column'), |
| 23 | + background: theme.node.modification.selectedBackground, |
| 24 | + border: theme.node.modification.selectedBorder, |
| 25 | + boxShadow: theme.shadows[6], |
| 26 | + ...interactiveNodeStyles(theme, 'modification'), |
| 27 | + }), |
| 28 | + |
| 29 | + default: (theme) => ({ |
| 30 | + ...baseNodeStyles(theme, 'column'), |
| 31 | + border: theme.node.modification.border, |
| 32 | + ...interactiveNodeStyles(theme, 'modification'), |
| 33 | + }), |
| 34 | + |
| 35 | + contentBox: (theme) => ({ |
| 36 | + flexGrow: 1, |
| 37 | + display: zoomStyles.visibility.showNodeContent(theme) ? 'flex' : 'none', |
| 38 | + alignItems: 'flex-end', |
| 39 | + marginLeft: theme.spacing(1), |
| 40 | + marginRight: theme.spacing(1), |
| 41 | + marginBottom: theme.spacing(1), |
| 42 | + }), |
| 43 | + |
| 44 | + typographyText: (theme) => ({ |
| 45 | + color: theme.palette.text.primary, |
| 46 | + fontSize: '20px', |
| 47 | + fontWeight: 400, |
| 48 | + lineHeight: 'normal', |
| 49 | + textAlign: 'left', |
| 50 | + display: '-webkit-box', |
| 51 | + WebkitBoxOrient: 'vertical', |
| 52 | + WebkitLineClamp: 2, |
| 53 | + overflow: 'hidden', |
| 54 | + width: 'auto', |
| 55 | + textOverflow: 'ellipsis', |
| 56 | + wordBreak: 'break-word', |
| 57 | + }), |
| 58 | + |
| 59 | + footer: (theme) => ({ |
| 60 | + display: 'flex', |
| 61 | + justifyContent: 'space-between', |
| 62 | + alignItems: 'center', |
| 63 | + marginLeft: theme.spacing(1), |
| 64 | + marginRight: theme.spacing(1), |
| 65 | + height: zoomStyles.layout.useFullHeightFooter(theme) ? '100%' : '35%', |
| 66 | + }), |
| 67 | + |
| 68 | + chipFloating: (theme) => ({ |
| 69 | + position: 'absolute', |
| 70 | + top: theme.spacing(-4.3), |
| 71 | + left: theme.spacing(1), |
| 72 | + zIndex: 2, |
| 73 | + }), |
| 74 | + |
| 75 | + chipLarge: (theme) => zoomStyles.layout.getLargeChipSize(theme) ?? {}, |
| 76 | + |
| 77 | + buildButtonContainer: (theme) => ({ |
| 78 | + display: zoomStyles.visibility.showBuildButton(theme) ? 'block' : 'none', |
| 79 | + }), |
| 80 | + |
| 81 | + globalBuildStatusIcon: (theme) => ({ |
| 82 | + fontSize: zoomStyles.iconSize(theme), |
| 83 | + '& path': { |
| 84 | + stroke: `currentColor`, |
| 85 | + strokeWidth: `${zoomStyles.iconStrokeWidth(theme)}px`, |
| 86 | + }, |
| 87 | + }), |
| 88 | + |
| 89 | + tooltip: { |
| 90 | + maxWidth: '720px', |
| 91 | + }, |
| 92 | +} as const satisfies MuiStyles; |
0 commit comments