-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(pci-common): move region chip and popover outside
Signed-off-by: Simon Chaumet <[email protected]>
- Loading branch information
1 parent
783f976
commit 228ec3e
Showing
6 changed files
with
148 additions
and
189 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
40 changes: 40 additions & 0 deletions
40
packages/manager/modules/manager-pci-common/src/components/region-selector/RegionChip.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,40 @@ | ||
import { OsdsChip, OsdsIcon, OsdsText } from '@ovhcloud/ods-components/react'; | ||
import { | ||
ODS_CHIP_SIZE, | ||
ODS_ICON_NAME, | ||
ODS_ICON_SIZE, | ||
ODS_TEXT_LEVEL, | ||
ODS_TEXT_SIZE, | ||
} from '@ovhcloud/ods-components'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import React from 'react'; | ||
|
||
export function RegionChip({ | ||
showTooltipIcon, | ||
title, | ||
className, | ||
}: { | ||
showTooltipIcon?: boolean; | ||
title: string; | ||
className?: string; | ||
}) { | ||
return ( | ||
<OsdsChip | ||
class={className} | ||
size={ODS_CHIP_SIZE.sm} | ||
onClick={(event) => event.stopPropagation()} | ||
> | ||
<OsdsText level={ODS_TEXT_LEVEL.body} size={ODS_TEXT_SIZE._500}> | ||
{title} | ||
</OsdsText> | ||
{showTooltipIcon && ( | ||
<OsdsIcon | ||
name={ODS_ICON_NAME.HELP} | ||
size={ODS_ICON_SIZE.xs} | ||
className="ml-2" | ||
color={ODS_THEME_COLOR_INTENT.primary} | ||
/> | ||
)} | ||
</OsdsChip> | ||
); | ||
} |
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
41 changes: 41 additions & 0 deletions
41
packages/manager/modules/manager-pci-common/src/components/region-selector/RegionPopover.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,41 @@ | ||
import React, { PropsWithChildren, ReactNode } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { | ||
OsdsPopover, | ||
OsdsPopoverContent, | ||
OsdsText, | ||
} from '@ovhcloud/ods-components/react'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import { ODS_TEXT_LEVEL } from '@ovhcloud/ods-components'; | ||
import { Links, LinkType } from '@ovh-ux/manager-react-components'; | ||
import { OdsHTMLAnchorElementTarget } from '@ovhcloud/ods-common-core'; | ||
|
||
export function RegionPopover({ | ||
children, | ||
tooltip, | ||
tooltipUrl, | ||
}: PropsWithChildren<{ tooltip: ReactNode; tooltipUrl: string }>) { | ||
const { t } = useTranslation('pci-region-selector'); | ||
|
||
return ( | ||
<OsdsPopover> | ||
<span slot="popover-trigger">{children}</span> | ||
<OsdsPopoverContent> | ||
<OsdsText | ||
color={ODS_THEME_COLOR_INTENT.text} | ||
level={ODS_TEXT_LEVEL.body} | ||
> | ||
{tooltip} | ||
</OsdsText> | ||
| ||
<Links | ||
tab-index="-1" | ||
label={t('pci_project_flavors_zone_tooltip_link')} | ||
type={LinkType.external} | ||
target={OdsHTMLAnchorElementTarget._blank} | ||
href={tooltipUrl} | ||
/> | ||
</OsdsPopoverContent> | ||
</OsdsPopover> | ||
); | ||
} |
Oops, something went wrong.