aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/ui/pointer.tsx
diff options
context:
space:
mode:
authorFrancesco Agosti <francesco.agosti93@gmail.com>2018-06-19 01:13:19 +0800
committerGitHub <noreply@github.com>2018-06-19 01:13:19 +0800
commitefaa33c4d5caacf592154f6e8552295afd7c9821 (patch)
tree24652e0643de90620ea72b9923e4c6709e355994 /packages/website/ts/components/ui/pointer.tsx
parent0c238448fda99c4d7997901d0fe4d72cb06b79cc (diff)
parent8a76fdc126c4e8d8b388d9e50bbc7fb8c7862186 (diff)
downloaddexon-sol-tools-efaa33c4d5caacf592154f6e8552295afd7c9821.tar.gz
dexon-sol-tools-efaa33c4d5caacf592154f6e8552295afd7c9821.tar.zst
dexon-sol-tools-efaa33c4d5caacf592154f6e8552295afd7c9821.zip
Merge pull request #711 from 0xProject/website/feature/prettier-onboarding-components
Made onboarding look like the mocks
Diffstat (limited to 'packages/website/ts/components/ui/pointer.tsx')
-rw-r--r--packages/website/ts/components/ui/pointer.tsx67
1 files changed, 67 insertions, 0 deletions
diff --git a/packages/website/ts/components/ui/pointer.tsx b/packages/website/ts/components/ui/pointer.tsx
new file mode 100644
index 000000000..448786bb4
--- /dev/null
+++ b/packages/website/ts/components/ui/pointer.tsx
@@ -0,0 +1,67 @@
+import { colors } from '@0xproject/react-shared';
+import * as React from 'react';
+import { styled } from 'ts/style/theme';
+
+export type PointerDirection = 'top' | 'right' | 'bottom' | 'left';
+
+export interface PointerProps {
+ className?: string;
+ color?: string;
+ size?: number;
+ direction: PointerDirection;
+}
+
+const PlainPointer: React.StatelessComponent<PointerProps> = props => <div {...props} />;
+
+const positionToCss = (props: PointerProps) => {
+ const position = {
+ top: `bottom: 100%; left: 50%;`,
+ right: `left: 100%; top: 50%;`,
+ bottom: `top: 100%; left: 50%;`,
+ left: `right: 100%; top: 50%;`,
+ }[props.direction];
+
+ const borderColorSide = {
+ top: 'border-bottom-color',
+ right: 'border-left-color',
+ bottom: 'border-top-color',
+ left: 'border-right-color',
+ }[props.direction];
+ const border = `${borderColorSide}: ${props.color};`;
+ const marginSide = {
+ top: 'margin-left',
+ right: 'margin-top',
+ bottom: 'margin-left',
+ left: 'margin-top',
+ }[props.direction];
+ const margin = `${marginSide}: -${props.size}px`;
+ return {
+ position,
+ border,
+ margin,
+ };
+};
+
+export const Pointer = styled(PlainPointer)`
+ position: relative;
+ &:after {
+ border: solid transparent;
+ content: " ";
+ height: 0;
+ width: 0;
+ position: absolute;
+ pointer-events: none;
+ border-color: rgba(136, 183, 213, 0);
+ border-width: ${props => `${props.size}px`};
+ ${props => positionToCss(props).position}
+ ${props => positionToCss(props).border}
+ ${props => positionToCss(props).margin}
+ }
+`;
+
+Pointer.defaultProps = {
+ color: colors.white,
+ size: 16,
+};
+
+Pointer.displayName = 'Pointer';