mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02:00
Adds "change:" to the beginning of all changes and does some work to align the use of compononents and structure across them (supersedes https://github.com/Unleash/unleash/pull/10260). In doing so, I have also added new and legacy variants for all different change components, because this has required some hierarchy restructuring every now and then. A reason for doing that was adding the correct wrapping behavior for components, such that on smaller screens, we wouldn't entirely blow out and make the kebab menu invisible and inaccessible. It also makes it so that we switch to full-width change view earlier (at breakpoint md instead of sm), because at sm, a lot of stuff got hidden before we switched to full-width. Most changes are trivial updates; I've called out bits of the code that are not in comments. Rendered, it looks like this: <img width="1203" alt="image" src="https://github.com/user-attachments/assets/36bed974-99da-4d8d-a881-ea9df7797210" /> One interesting and potentially quite useful side-effect, is that all change types now use the exact same set of components in the same fashion, as evidenced by this screenie where I've added outlines to the hierarchy: <img width="1020" alt="image" src="https://github.com/user-attachments/assets/685fefcc-af7e-4697-b8f3-8260af1e2a84" /> The one difference is that components without a diff place the "more" kebab menu one layer further inside to facilitate prettier wrapping (the kebab menu can stay on the same line as the other text when wrapping): <img width="238" alt="image" src="https://github.com/user-attachments/assets/2b8d3174-06a8-4ad4-b366-cea97720deda" />
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import type { FC, ReactNode } from 'react';
|
|
import { Box } from '@mui/material';
|
|
import { Badge } from 'component/common/Badge/Badge';
|
|
import { ChangeItemWrapper as LegacyChangeItemWrapper } from './LegacyStrategyChange.tsx';
|
|
import { Action, ChangeItemInfo, ChangeItemWrapper } from './Change.styles';
|
|
|
|
interface IToggleStatusChange {
|
|
enabled: boolean;
|
|
actions?: ReactNode;
|
|
}
|
|
|
|
/**
|
|
* @deprecated use ToggleStatusChange instead; remove with flag crDiffView
|
|
*/
|
|
export const LegacyToggleStatusChange: FC<IToggleStatusChange> = ({
|
|
enabled,
|
|
actions,
|
|
}) => {
|
|
return (
|
|
<LegacyChangeItemWrapper>
|
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|
New status
|
|
<Badge
|
|
sx={(theme) => ({ marginLeft: theme.spacing(1) })}
|
|
color={enabled ? 'success' : 'error'}
|
|
>
|
|
{enabled ? ' Enabled' : 'Disabled'}
|
|
</Badge>
|
|
</Box>
|
|
{actions}
|
|
</LegacyChangeItemWrapper>
|
|
);
|
|
};
|
|
|
|
export const ToggleStatusChange: FC<IToggleStatusChange> = ({
|
|
enabled,
|
|
actions,
|
|
}) => {
|
|
return (
|
|
<ChangeItemWrapper>
|
|
<ChangeItemInfo>
|
|
<Action>New status</Action>
|
|
<Badge color={enabled ? 'success' : 'error'}>
|
|
{enabled ? ' Enabled' : 'Disabled'}
|
|
</Badge>
|
|
{actions}
|
|
</ChangeItemInfo>
|
|
</ChangeItemWrapper>
|
|
);
|
|
};
|