-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Templates): Styling for Header, Tabs, Footer (#4992)
* moved tab styling to designer-ui * added styling and disabled, selected into tab title area * enforced templatePanelTab props with type * added footer * moved panelTabs to upper level for panel footer * fully enabled footer for quickview panel * moved quickviewPanel header to use TemplatesPanelContent * added template panel header * changed reviewCreate tab to intl and create button * defined a global handle dismiss panel * brings to the valid next tab for sequence * added next button blocked for parameters and name state tab on missing info * fixed tests * fixed minor nits, addressing rest in next pr due to current pr size
- Loading branch information
1 parent
691fdbb
commit 8a64f12
Showing
27 changed files
with
565 additions
and
277 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './templatePanelUtil'; | ||
export * from './templatesPanelContent'; | ||
export * from './templatesParametersField'; | ||
export * from './templatesPanelFooter'; | ||
export * from './templatesPanelHeader'; |
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 type { IntlShape } from 'react-intl'; | ||
import type { ReactNode } from 'react'; | ||
|
||
export type TemplatePanelTabFn = (intl: IntlShape) => TemplatePanelTab; | ||
export interface TemplatePanelTab { | ||
id: string; | ||
title: string; | ||
description?: string; | ||
visible?: boolean; | ||
order: number; | ||
content: React.ReactElement; | ||
footerContent: { | ||
primaryButtonText: string | ReactNode; | ||
primaryButtonOnClick: () => void | Promise<void>; | ||
primaryButtonDisabled?: boolean; | ||
}; | ||
} |
49 changes: 49 additions & 0 deletions
49
libs/designer-ui/src/lib/templates/templatesPanelContent.less
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,49 @@ | ||
.msla-templates-panel { | ||
.msla-templates-panel-tabName { | ||
margin: 0px 8px 8px 8px; | ||
height: 36px; | ||
|
||
.msla-templates-panel-tabName-index { | ||
display: inline-flex; | ||
width: 16px; | ||
height: 16px; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 100%; | ||
border: 1px solid #57A300; | ||
background-color: #57A300; | ||
font-size: 10px; | ||
font-weight: 600; | ||
color: white; | ||
margin-right: 8px; | ||
} | ||
|
||
.msla-templates-panel-tabName-title { | ||
display: flex-inline; | ||
align-items: center; | ||
} | ||
|
||
&.selected { | ||
box-shadow: 0px -2px 0px 0px #0078D4 inset; | ||
|
||
.msla-templates-panel-tabName-index { | ||
border-color: #0078D4; | ||
background-color: #0078D4; | ||
} | ||
|
||
.msla-templates-panel-tabName-title { | ||
font-weight: 600; | ||
} | ||
} | ||
|
||
&:disabled { | ||
box-shadow: none; | ||
|
||
.msla-templates-panel-tabName-index { | ||
background-color: transparent; | ||
border-color: #949494; | ||
color: #949494; | ||
} | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
libs/designer-ui/src/lib/templates/templatesPanelContent.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,55 @@ | ||
import { Icon, css } from '@fluentui/react'; | ||
import { TabList, Tab, Text } from '@fluentui/react-components'; | ||
import type { SelectTabData, SelectTabEvent } from '@fluentui/react-components'; | ||
import type { TemplatePanelTab } from './templatePanelUtil'; | ||
|
||
export interface TemplatesPanelContentProps { | ||
isSequence: boolean; | ||
tabs: TemplatePanelTab[]; | ||
selectedTab?: string; | ||
selectTab: (tabId: string) => void; | ||
} | ||
export const TemplatesPanelContent = ({ | ||
isSequence = true, | ||
tabs = [], | ||
selectedTab, | ||
selectTab, | ||
}: TemplatesPanelContentProps): JSX.Element => { | ||
const selectedTabId = selectedTab ?? tabs[0]?.id; | ||
|
||
const selectedTabProps = tabs?.find((tab) => tab.id === selectedTabId); | ||
const selectedTabOrder = selectedTabProps?.order ?? 0; | ||
|
||
const onTabSelected = (e?: SelectTabEvent, data?: SelectTabData): void => { | ||
if (data) { | ||
const itemKey = data.value as string; | ||
selectTab(itemKey); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="msla-templates-panel"> | ||
<TabList selectedValue={selectedTabId} onTabSelect={onTabSelected} style={{ margin: '0px -12px' }}> | ||
{tabs.map(({ id, title, order }, index) => ( | ||
<Tab | ||
key={id} | ||
id={id} | ||
data-testid={id} | ||
className={css('msla-templates-panel-tabName', id === selectedTabId && 'selected')} | ||
value={id} | ||
role={'tab'} | ||
disabled={isSequence && order > selectedTabOrder} | ||
> | ||
{isSequence && ( | ||
<Text className="msla-templates-panel-tabName-index"> | ||
{order < selectedTabOrder ? <Icon iconName="accept" /> : index + 1} | ||
</Text> | ||
)} | ||
<Text className="msla-templates-panel-tabName-title">{title}</Text> | ||
</Tab> | ||
))} | ||
</TabList> | ||
<div className="msla-panel-content-container">{selectedTabProps?.content}</div> | ||
</div> | ||
); | ||
}; |
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,4 @@ | ||
.msla-templates-panel-footer { | ||
padding: 16px 20px; | ||
border-top: 1px solid #CCC; | ||
} |
45 changes: 45 additions & 0 deletions
45
libs/designer-ui/src/lib/templates/templatesPanelFooter.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,45 @@ | ||
import { DefaultButton, PrimaryButton } from '@fluentui/react'; | ||
import type { ReactNode } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
export interface TemplatePanelFooterProps { | ||
primaryButtonText: string | ReactNode; | ||
primaryButtonOnClick: () => void | Promise<void>; | ||
primaryButtonDisabled?: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
export const TemplatesPanelFooter = ({ | ||
primaryButtonText, | ||
primaryButtonDisabled, | ||
primaryButtonOnClick, | ||
onClose, | ||
}: TemplatePanelFooterProps) => { | ||
const intl = useIntl(); | ||
const CLOSE = intl.formatMessage({ | ||
defaultMessage: 'Close', | ||
id: 'FTrMxN', | ||
description: 'Button text for closing the panel', | ||
}); | ||
|
||
return ( | ||
<div className="msla-templates-panel-footer"> | ||
<PrimaryButton | ||
data-testid={'template-footer-primary-button'} | ||
data-automation-id={'template-footer-primary-button'} | ||
onClick={primaryButtonOnClick} | ||
disabled={primaryButtonDisabled} | ||
> | ||
{primaryButtonText} | ||
</PrimaryButton> | ||
<DefaultButton | ||
onClick={onClose} | ||
style={{ | ||
marginLeft: '8px', | ||
}} | ||
> | ||
{CLOSE} | ||
</DefaultButton> | ||
</div> | ||
); | ||
}; |
19 changes: 19 additions & 0 deletions
19
libs/designer-ui/src/lib/templates/templatesPanelHeader.less
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,19 @@ | ||
.msla-templates-panel-header { | ||
padding: 16px 20px; | ||
width: 100%; | ||
|
||
.msla-templates-panel-header-title { | ||
font-size: 24px; | ||
font-weight: 600; | ||
line-height: 32px; | ||
} | ||
|
||
.msla-templates-panel-header-description-wrapper { | ||
padding-top: 8px; | ||
} | ||
|
||
.msla-templates-panel-header-description { | ||
font-size: 12px; | ||
color: #605E5C; | ||
} | ||
} |
Oops, something went wrong.