-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
717f175
commit f68ea54
Showing
6 changed files
with
113 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,67 @@ | ||
import React from 'react' | ||
import { renderToStaticMarkup } from 'react-dom/server' | ||
|
||
import * as DOMPurify from 'dompurify' | ||
import Utils from 'common/utils/utils' | ||
|
||
const ReactTooltip = require('react-tooltip') | ||
|
||
type StyledTooltipProps = { | ||
children: string | ||
} | ||
|
||
type TooltipProps = { | ||
children: string | ||
plainText: boolean | ||
place?: string | undefined | ||
title: JSX.Element // This is actually the Tooltip parent component | ||
} | ||
|
||
const StyledTooltip = ({ children }: StyledTooltipProps) => ( | ||
<div className='flex-row'> | ||
<div className='icon--tooltip ion-ios-information-circle mr-1'></div> | ||
<span>{`${children}`}</span> | ||
</div> | ||
) | ||
|
||
const tooltipStyler = (plainText: boolean, children: string): string => { | ||
const html = renderToStaticMarkup( | ||
<StyledTooltip>{plainText ? children : '{{html}}'}</StyledTooltip>, | ||
) | ||
if (plainText) { | ||
return html | ||
} | ||
return html.replace('{{html}}', DOMPurify.sanitize(children.toString())) | ||
} | ||
|
||
const Tooltip = ({ | ||
children, | ||
place, | ||
plainText, | ||
title, | ||
}: TooltipProps): JSX.Element => { | ||
const id = Utils.GUID() | ||
|
||
return ( | ||
<span className='question-tooltip'> | ||
{title ? ( | ||
<span data-for={id} data-tip> | ||
{title} | ||
</span> | ||
) : ( | ||
<span className='ion ion-ios-help' data-for={id} data-tip /> | ||
)} | ||
<ReactTooltip | ||
html | ||
id={id} | ||
place={place || 'top'} | ||
type='dark' | ||
effect='solid' | ||
> | ||
{tooltipStyler(plainText, children)} | ||
</ReactTooltip> | ||
</span> | ||
) | ||
} | ||
|
||
export default Tooltip |
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
f68ea54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
staging.flagsmith.com
flagsmith-staging-frontend.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
f68ea54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs.bullet-train.io
docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.flagsmith.com
f68ea54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-preview-flagsmith.vercel.app