forked from newrelic/docs-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTechTile.js
More file actions
104 lines (94 loc) · 2.05 KB
/
Copy pathTechTile.js
File metadata and controls
104 lines (94 loc) · 2.05 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
import React, { isValidElement, cloneElement } from 'react';
import PropTypes from 'prop-types';
import { ClassNames, css } from '@emotion/react';
import { Surface, Icon, Link } from '@newrelic/gatsby-theme-newrelic';
const TileIcon = ({ className, icon }) => {
if (typeof icon === 'string') {
return (
<Icon
name={icon}
size="2rem"
className={className}
css={css`
flex: 1;
max-height: 2rem;
`}
/>
);
}
if (isValidElement(icon) && icon.props?.mdxType === 'img') {
return (
<span
className={className}
css={css`
flex: 1;
`}
>
<ClassNames>
{({ css }) =>
cloneElement(icon, {
className: css`
width: 2rem;
height: auto;
border-radius: 0.25rem;
`,
})
}
</ClassNames>
</span>
);
}
return null;
};
TileIcon.propTypes = {
className: PropTypes.string,
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
};
const TechTile = ({ name, icon, to }) => (
<Surface
as={to ? Link : undefined}
to={to}
base={Surface.BASE.SECONDARY}
interactive={Boolean(to)}
css={css`
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 0.5rem;
color: currentColor;
&:hover {
color: currentColor;
}
.light-mode & {
border: 1px solid var(--border-color);
&:hover {
border-color: var(--border-hover-color);
}
}
`}
>
<TileIcon
icon={icon}
css={css`
margin-bottom: 0;
img {
width: 2rem;
}
`}
/>
<div
css={css`
font-size: 0.875rem;
`}
>
{name}
</div>
</Surface>
);
TechTile.propTypes = {
name: PropTypes.string.isRequired,
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
to: PropTypes.string,
};
export default TechTile;