mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-02 14:59:53 +08:00
* Create ToolTipInfo component * Update FieldInput to accept optional tool tip content * Temp fix for story viewing timed out polling state * Support different informational texts depending on database * Add database service checker to determine if we can skip next step * Enable AWS RDS postgres flow
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
/**
|
|
* Copyright 2023 Gravitational, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import React, { useState } from 'react';
|
|
import styled from 'styled-components';
|
|
|
|
import { Text, Popover } from 'design';
|
|
import * as Icons from 'design/Icon';
|
|
|
|
export const ToolTipInfo: React.FC = ({ children }) => {
|
|
const [anchorEl, setAnchorEl] = useState();
|
|
const open = Boolean(anchorEl);
|
|
|
|
function handlePopoverOpen(event) {
|
|
setAnchorEl(event.currentTarget);
|
|
}
|
|
|
|
function handlePopoverClose() {
|
|
setAnchorEl(null);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<span
|
|
aria-owns={open ? 'mouse-over-popover' : undefined}
|
|
onMouseEnter={handlePopoverOpen}
|
|
onMouseLeave={handlePopoverClose}
|
|
css={`
|
|
:hover {
|
|
cursor: pointer;
|
|
}
|
|
vertical-align: middle;
|
|
display: inline-block;
|
|
height: 18px;
|
|
`}
|
|
>
|
|
<Icons.Info fontSize={4} />
|
|
</span>
|
|
<Popover
|
|
modalCss={modalCss}
|
|
onClose={handlePopoverClose}
|
|
open={open}
|
|
anchorEl={anchorEl}
|
|
anchorOrigin={{
|
|
vertical: 'bottom',
|
|
horizontal: 'left',
|
|
}}
|
|
transformOrigin={{
|
|
vertical: 'top',
|
|
horizontal: 'left',
|
|
}}
|
|
>
|
|
<StyledOnHover px={3} py={2}>
|
|
{children}
|
|
</StyledOnHover>
|
|
</Popover>
|
|
</>
|
|
);
|
|
};
|
|
|
|
const modalCss = () => `
|
|
pointer-events: none;
|
|
`;
|
|
|
|
const StyledOnHover = styled(Text)`
|
|
background-color: white;
|
|
color: black;
|
|
max-width: 350px;
|
|
`;
|