mirror of
https://github.com/Redocly/redoc.git
synced 2025-11-07 19:27:31 +03:00
squashed commit of the following:
commit 6b07dc7fa0
Author: Anya Stasiuk <stasiukanya@gmail.com>
Date: Wed Nov 7 15:18:26 2018 +0200
theme fixes
74 lines
1.3 KiB
TypeScript
74 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
|
|
import styled from '../styled-components';
|
|
|
|
const Wrapper = styled.div`
|
|
position: relative;
|
|
`;
|
|
|
|
const Tip = styled.div`
|
|
position: absolute;
|
|
min-width: 80px;
|
|
max-width: 500px;
|
|
background: #fff;
|
|
bottom: 100%;
|
|
left: 50%;
|
|
margin-bottom: 10px;
|
|
transform: translateX(-50%);
|
|
|
|
border-radius: 4px;
|
|
padding: 0.3em 0.6em;
|
|
text-align: center;
|
|
box-shadow: 0px 0px 5px 0px rgba(204, 204, 204, 1);
|
|
`;
|
|
|
|
const Content = styled.div`
|
|
background: #fff;
|
|
color: #000;
|
|
display: inline;
|
|
font-size: 0.85em;
|
|
white-space: nowrap;
|
|
`;
|
|
|
|
const Arrow = styled.div`
|
|
position: absolute;
|
|
width: 0;
|
|
height: 0;
|
|
bottom: -5px;
|
|
left: 50%;
|
|
margin-left: -5px;
|
|
border-left: solid transparent 5px;
|
|
border-right: solid transparent 5px;
|
|
border-top: solid #fff 5px;
|
|
`;
|
|
|
|
const Gap = styled.div`
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 20px;
|
|
bottom: -20px;
|
|
`;
|
|
|
|
export interface TooltipProps {
|
|
open: boolean;
|
|
title: string;
|
|
}
|
|
|
|
export class Tooltip extends React.Component<TooltipProps> {
|
|
render() {
|
|
const { open, title, children } = this.props;
|
|
return (
|
|
<Wrapper>
|
|
{children}
|
|
{open && (
|
|
<Tip>
|
|
<Content>{title}</Content>
|
|
<Arrow />
|
|
<Gap />
|
|
</Tip>
|
|
)}
|
|
</Wrapper>
|
|
);
|
|
}
|
|
}
|