File tree Expand file tree Collapse file tree 5 files changed +58
-10
lines changed
Expand file tree Collapse file tree 5 files changed +58
-10
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @linode/manager " : Added
3+ ---
4+
5+ IAM: Divider componenent ([ #13513 ] ( https://github.com/linode/manager/pull/13513 ) )
Original file line number Diff line number Diff line change 1- import { Divider , useTheme } from '@mui/material' ;
1+ import { useTheme } from '@mui/material' ;
22import Box from '@mui/material/Box' ;
33import React from 'react' ;
44import { Controller , useFormContext } from 'react-hook-form' ;
55
66import { AssignedPermissionsPanel } from 'src/features/IAM/Shared/AssignedPermissionsPanel/AssignedPermissionsPanel' ;
7+ import { Divider } from 'src/features/IAM/Shared/Divider/Divider' ;
78
89import type { RoleView } from 'src/features/IAM/Shared/types' ;
910import 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
Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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+ } ) ) ;
Original file line number Diff line number Diff line change 11import { Autocomplete , Button , DeleteIcon } from '@linode/ui' ;
2- import { Divider , useTheme } from '@mui/material' ;
2+ import { useTheme } from '@mui/material' ;
33import Box from '@mui/material/Box' ;
44import React from 'react' ;
55import { Controller , useFormContext } from 'react-hook-form' ;
66
77import { AssignedPermissionsPanel } from 'src/features/IAM/Shared/AssignedPermissionsPanel/AssignedPermissionsPanel' ;
88import { getRoleByName } from 'src/features/IAM/Shared/utilities' ;
99
10+ import { Divider } from '../../Shared/Divider/Divider' ;
11+
1012import type { IamAccountRoles } from '@linode/api-v4' ;
1113import 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
You can’t perform that action at this time.
0 commit comments