-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: FormTemplate -> ComplexAttributeTemplate
- Loading branch information
1 parent
71c2efc
commit 1878405
Showing
12 changed files
with
251 additions
and
221 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
12 changes: 12 additions & 0 deletions
12
.../dm-core-plugins/src/form/templates/ComplexAttributeTemplate/ComplexAttributeTemplate.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,12 @@ | ||
import { PropsWithChildren } from 'react' | ||
import { ComplexAttributeTemplateContent } from './ComplexAttributeTemplateContent' | ||
import { ComplexAttributeTemplateHeader } from './ComplexAttributeTemplateHeader' | ||
|
||
export const ComplexAttributeTemplate = ({ children }: PropsWithChildren) => { | ||
return ( | ||
<div className='border border-[#dddddd] rounded-md w-full'>{children}</div> | ||
) | ||
} | ||
|
||
ComplexAttributeTemplate.Header = ComplexAttributeTemplateHeader | ||
ComplexAttributeTemplate.Content = ComplexAttributeTemplateContent |
29 changes: 29 additions & 0 deletions
29
...e-plugins/src/form/templates/ComplexAttributeTemplate/ComplexAttributeTemplateContent.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,29 @@ | ||
import React from 'react' | ||
|
||
type ComplexAttributeTemplateContentProps = { | ||
children: React.ReactNode | ||
expanded: boolean | ||
canExpand: boolean | ||
padding?: string | ||
} | ||
|
||
export const ComplexAttributeTemplateContent = ({ | ||
children, | ||
padding, | ||
expanded, | ||
canExpand, | ||
}: ComplexAttributeTemplateContentProps) => { | ||
return ( | ||
<> | ||
{canExpand && ( | ||
<div | ||
className={`border-t border-[#dddddd] ${padding ?? 'p-2'} w-full ${ | ||
expanded ? '' : 'hidden' | ||
}`} | ||
> | ||
{children} | ||
</div> | ||
)} | ||
</> | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
...re-plugins/src/form/templates/ComplexAttributeTemplate/ComplexAttributeTemplateHeader.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,17 @@ | ||
import React from 'react' | ||
import { ComplexAttributeTemplateHeaderActions } from './ComplexAttributeTemplateHeaderActions' | ||
import { ComplexAttributeTemplateHeaderTitle } from './ComplexAttributeTemplateHeaderTitle' | ||
|
||
export const ComplexAttributeTemplateHeader = ({ | ||
children, | ||
objectIsNotEmpty = true, | ||
}: { children: React.ReactNode; objectIsNotEmpty?: boolean }) => { | ||
return ( | ||
<legend className='flex h-10 justify-between bg-equinor-lightgray items-center pr-2 rounded-[inherit] transition duration-75'> | ||
{children} | ||
</legend> | ||
) | ||
} | ||
|
||
ComplexAttributeTemplateHeader.Title = ComplexAttributeTemplateHeaderTitle | ||
ComplexAttributeTemplateHeader.Actions = ComplexAttributeTemplateHeaderActions |
27 changes: 27 additions & 0 deletions
27
...ins/src/form/templates/ComplexAttributeTemplate/ComplexAttributeTemplateHeaderActions.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,27 @@ | ||
import { EdsProvider, Icon, Tooltip } from '@equinor/eds-core-react' | ||
import { info_circle } from '@equinor/eds-icons' | ||
import { tokens } from '@equinor/eds-tokens' | ||
import React from 'react' | ||
import { TUiAttribute } from '../../types' | ||
|
||
export const ComplexAttributeTemplateHeaderActions = ({ | ||
children, | ||
uiAttribute, | ||
}: { children?: React.ReactNode; uiAttribute?: TUiAttribute }) => { | ||
return ( | ||
<div className='flex items-center'> | ||
{uiAttribute?.tooltip && ( | ||
<EdsProvider density='compact'> | ||
<Tooltip title={uiAttribute?.tooltip}> | ||
<Icon | ||
data={info_circle} | ||
size={16} | ||
color={tokens.colors.interactive.primary__resting.hex} | ||
/> | ||
</Tooltip> | ||
</EdsProvider> | ||
)} | ||
{children} | ||
</div> | ||
) | ||
} |
Oops, something went wrong.