forked from newrelic/docs-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserJourneyControls.js
More file actions
146 lines (137 loc) · 3.72 KB
/
Copy pathUserJourneyControls.js
File metadata and controls
146 lines (137 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React from 'react';
import styled from '@emotion/styled';
import useBoop from 'use-boop';
import { animated } from 'react-spring';
import { css } from '@emotion/react';
import { Surface, Icon } from '@newrelic/gatsby-theme-newrelic';
import SurfaceLink from './SurfaceLink';
const UserJourneyControls = ({ previousStep, nextStep, className }) => {
const springConfig = {
mass: 3,
tension: 160,
friction: 15,
};
const [rightButton, triggerRight] = useBoop({
x: 20,
springConfig,
});
const [leftButton, triggerLeft] = useBoop({
x: -20,
springConfig,
});
return (
<JourneyContainer>
{previousStep && (
<JourneyLink
base={Surface.BASE.SECONDARY}
to={previousStep.path}
interactive
instrumentation={{
category: 'UserJourney',
eventName: 'previousStepClick',
path: previousStep.path,
}}
className={className}
onMouseEnter={triggerLeft}
>
<InnerContainer>
<animated.div style={leftButton}>
<Icon
name="fe-arrow-left"
size="3rem"
css={css`
color: var(--system-text-primary);
margin-right: 2rem;
`}
/>
</animated.div>
<TextContainer>
<h3>{previousStep.title}</h3>
<p>{previousStep.body}</p>
</TextContainer>
</InnerContainer>
</JourneyLink>
)}
{nextStep && (
<JourneyLink
base={Surface.BASE.SECONDARY}
to={nextStep.path}
interactive
instrumentation={{
category: 'UserJourney',
eventName: 'nextStepClick',
path: nextStep.path,
}}
className={className}
css={css`
border: solid 2px var(--brand-button-primary-accent);
&:hover {
color: var(--primary-text-color);
box-shadow: -2px -2px var(--brand-button-primary-accent),
2px -2px var(--brand-button-primary-accent),
-2px 2px var(--brand-button-primary-accent),
2px 2px var(--brand-button-primary-accent), var(--shadow-3);
}
`}
onMouseEnter={triggerRight}
>
<InnerContainer
css={css`
justify-content: space-between;
`}
>
<TextContainer>
<h3>{nextStep.title}</h3>
<p>{nextStep.body}</p>
</TextContainer>
<animated.div style={rightButton}>
<Icon
name="fe-arrow-right"
size="3rem"
css={css`
color: var(--primary-text-color);
margin-left: 2rem;
`}
/>
</animated.div>
</InnerContainer>
</JourneyLink>
)}
</JourneyContainer>
);
};
const JourneyContainer = styled.div`
display: flex;
gap: 1rem;
@media screen and (max-width: 1000px) {
flex-direction: column;
}
`;
const JourneyLink = styled(SurfaceLink)`
color: var(--primary-text-color);
flex: 1;
background: var(--secondary-background-color);
display: block;
min-height: 130px;
border-radius: 4px;
padding: 2rem;
&:hover {
color: var(--primary-text-color);
}
@media screen and (max-width: 650px) {
padding: 1.5rem;
}
.dark-mode & {
background: var(--secondary-background-color);
}
`;
const InnerContainer = styled.div`
display: flex;
height: 100%;
align-items: center;
`;
const TextContainer = styled.div`
display: flex;
flex-direction: column;
`;
export default UserJourneyControls;