aboutsummaryrefslogtreecommitdiffstats
path: root/packages/react-shared/src/ts/components/anchor_title.tsx
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-13 22:29:12 +0800
committerFabio Berger <me@fabioberger.com>2018-03-13 22:29:12 +0800
commitca25b816fabe15ce1ebc539c0316beba813683b8 (patch)
tree0e28bbc819cfccda1789192628c365ea54328103 /packages/react-shared/src/ts/components/anchor_title.tsx
parentdf1968157c13a7bbe2e512cbc924190a414e6738 (diff)
downloaddexon-sol-tools-ca25b816fabe15ce1ebc539c0316beba813683b8.tar.gz
dexon-sol-tools-ca25b816fabe15ce1ebc539c0316beba813683b8.tar.zst
dexon-sol-tools-ca25b816fabe15ce1ebc539c0316beba813683b8.zip
move scripts to monorepro-scripts
Diffstat (limited to 'packages/react-shared/src/ts/components/anchor_title.tsx')
-rw-r--r--packages/react-shared/src/ts/components/anchor_title.tsx87
1 files changed, 0 insertions, 87 deletions
diff --git a/packages/react-shared/src/ts/components/anchor_title.tsx b/packages/react-shared/src/ts/components/anchor_title.tsx
deleted file mode 100644
index f44354097..000000000
--- a/packages/react-shared/src/ts/components/anchor_title.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import * as React from 'react';
-import { Link as ScrollLink } from 'react-scroll';
-
-import { HeaderSizes, Styles } from '../types';
-import { constants } from '../utils/constants';
-import { utils } from '../utils/utils';
-
-const headerSizeToScrollOffset: { [headerSize: string]: number } = {
- h2: -20,
- h3: 0,
-};
-
-export interface AnchorTitleProps {
- title: string | React.ReactNode;
- id: string;
- headerSize: HeaderSizes;
- shouldShowAnchor: boolean;
-}
-
-export interface AnchorTitleState {
- isHovering: boolean;
-}
-
-const styles: Styles = {
- anchor: {
- fontSize: 20,
- transform: 'rotate(45deg)',
- cursor: 'pointer',
- },
- headers: {
- WebkitMarginStart: 0,
- WebkitMarginEnd: 0,
- fontWeight: 'bold',
- display: 'block',
- },
- h1: {
- fontSize: '1.8em',
- },
- h2: {
- fontSize: '1.5em',
- fontWeight: 400,
- },
- h3: {
- fontSize: '1.17em',
- },
-};
-
-export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleState> {
- constructor(props: AnchorTitleProps) {
- super(props);
- this.state = {
- isHovering: false,
- };
- }
- public render() {
- let opacity = 0;
- if (this.props.shouldShowAnchor) {
- opacity = this.state.isHovering ? 0.6 : 1;
- }
- return (
- <div className="relative flex" style={{ ...styles[this.props.headerSize], ...styles.headers }}>
- <div className="inline-block" style={{ paddingRight: 4 }}>
- {this.props.title}
- </div>
- <ScrollLink
- to={this.props.id}
- offset={headerSizeToScrollOffset[this.props.headerSize]}
- duration={constants.DOCS_SCROLL_DURATION_MS}
- containerId={constants.DOCS_CONTAINER_ID}
- >
- <i
- className="zmdi zmdi-link"
- onClick={utils.setUrlHash.bind(utils, this.props.id)}
- style={{ ...styles.anchor, opacity }}
- onMouseOver={this._setHoverState.bind(this, true)}
- onMouseOut={this._setHoverState.bind(this, false)}
- />
- </ScrollLink>
- </div>
- );
- }
- private _setHoverState(isHovering: boolean) {
- this.setState({
- isHovering,
- });
- }
-}