Skip to content

Commit e406a58

Browse files
feat: [UIE-10536] - IAM: divider component (#13513)
* feat: [UIE-10536] - IAM: divider component * Added changeset: IAM: Divider componenent
1 parent 277db37 commit e406a58

File tree

5 files changed

+58
-10
lines changed

5 files changed

+58
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Added
3+
---
4+
5+
IAM: Divider componenent ([#13513](https://github.com/linode/manager/pull/13513))

packages/manager/src/features/IAM/Roles/RolesTable/AssignSingleSelectedRole.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { Divider, useTheme } from '@mui/material';
1+
import { useTheme } from '@mui/material';
22
import Box from '@mui/material/Box';
33
import React from 'react';
44
import { Controller, useFormContext } from 'react-hook-form';
55

66
import { AssignedPermissionsPanel } from 'src/features/IAM/Shared/AssignedPermissionsPanel/AssignedPermissionsPanel';
7+
import { Divider } from 'src/features/IAM/Shared/Divider/Divider';
78

89
import type { RoleView } from 'src/features/IAM/Shared/types';
910
import type { AssignNewRoleFormValues } from 'src/features/IAM/Shared/utilities';
@@ -28,10 +29,8 @@ export const AssignSingleSelectedRole = ({
2829
<Box display="flex" flexDirection="column" sx={{ flex: '5 1 auto' }}>
2930
{index !== 0 && (
3031
<Divider
31-
sx={{
32-
marginBottom: theme.tokens.spacing.S6,
33-
marginTop: theme.tokens.spacing.S12,
34-
}}
32+
spacingBottom={theme.tokens.spacing.S6}
33+
spacingTop={theme.tokens.spacing.S12}
3534
/>
3635
)}
3736

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { screen } from '@testing-library/react';
2+
import React from 'react';
3+
4+
import { renderWithTheme } from 'src/utilities/testHelpers';
5+
6+
import { Divider } from './Divider';
7+
8+
describe('Divider', () => {
9+
it('renders an hr element', () => {
10+
renderWithTheme(<Divider />);
11+
screen.getByRole('separator');
12+
});
13+
14+
it('applies spacingTop and spacingBottom styles', () => {
15+
renderWithTheme(<Divider spacingBottom="16px" spacingTop="8px" />);
16+
const hr = screen.getByRole('separator');
17+
expect(hr).toHaveStyle({ marginTop: '8px', marginBottom: '16px' });
18+
});
19+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { omittedProps, styled } from '@linode/ui';
2+
import React from 'react';
3+
4+
export interface DividerProps {
5+
spacingBottom?: number | string;
6+
spacingTop?: number | string;
7+
}
8+
9+
export const Divider = (props: DividerProps) => {
10+
return <StyledDivider {...props} />;
11+
};
12+
13+
export const StyledDivider = styled('hr', {
14+
label: 'StyledDivider',
15+
shouldForwardProp: omittedProps(['spacingTop', 'spacingBottom']),
16+
})<DividerProps>(({ theme, spacingTop, spacingBottom }) => ({
17+
display: 'block',
18+
margin: `${theme.tokens.spacing.S8} 0`,
19+
width: '100%',
20+
borderWidth: '0 0 thin',
21+
borderStyle: 'solid',
22+
borderColor: theme.tokens.component.Divider.Border,
23+
marginBottom: spacingBottom,
24+
marginTop: spacingTop,
25+
}));

packages/manager/src/features/IAM/Users/UserRoles/AssignSingleRole.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Autocomplete, Button, DeleteIcon } from '@linode/ui';
2-
import { Divider, useTheme } from '@mui/material';
2+
import { useTheme } from '@mui/material';
33
import Box from '@mui/material/Box';
44
import React from 'react';
55
import { Controller, useFormContext } from 'react-hook-form';
66

77
import { AssignedPermissionsPanel } from 'src/features/IAM/Shared/AssignedPermissionsPanel/AssignedPermissionsPanel';
88
import { getRoleByName } from 'src/features/IAM/Shared/utilities';
99

10+
import { Divider } from '../../Shared/Divider/Divider';
11+
1012
import type { IamAccountRoles } from '@linode/api-v4';
1113
import type {
1214
AssignNewRoleFormValues,
@@ -40,10 +42,8 @@ export const AssignSingleRole = ({
4042
<Box display="flex" flexDirection="column" sx={{ flex: '5 1 auto' }}>
4143
{index !== 0 && (
4244
<Divider
43-
sx={{
44-
marginBottom: theme.tokens.spacing.S24,
45-
marginTop: theme.tokens.spacing.S20,
46-
}}
45+
spacingBottom={theme.tokens.spacing.S24}
46+
spacingTop={theme.tokens.spacing.S20}
4747
/>
4848
)}
4949

0 commit comments

Comments
 (0)