-
-
Notifications
You must be signed in to change notification settings - Fork 767
/
Copy pathdoc-article-community.tsx
119 lines (103 loc) · 2.64 KB
/
doc-article-community.tsx
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
import { graphql } from "gatsby";
import React, { FC } from "react";
import styled from "styled-components";
import { IconContainer } from "@/components/misc/icon-container";
import { Link } from "@/components/misc/link";
import { Icon } from "@/components/sprites";
import { DocArticleCommunityFragment } from "@/graphql-types";
import { THEME_COLORS } from "@/style";
// Icons
import GitHubIconSvg from "@/images/icons/github.svg";
import SlackIconSvg from "@/images/icons/slack.svg";
export interface DocArticleCommunityProps {
readonly data: DocArticleCommunityFragment;
readonly originPath: string;
}
export const DocArticleCommunity: FC<DocArticleCommunityProps> = ({
data,
originPath,
}) => {
const metadata = data.site!.siteMetadata!;
const docPath = `${metadata.repositoryUrl!}/blob/master/website/src/docs/${originPath}`;
return (
<Container>
<Title>Help us improving our content</Title>
<CommunityItems>
<CommunityItem>
<CommunityLink to={docPath}>
<IconContainer $size={20}>
<Icon {...GitHubIconSvg} />
</IconContainer>
Edit on GitHub
</CommunityLink>
</CommunityItem>
<CommunityItem>
<CommunityLink to={metadata.tools!.slack!}>
<IconContainer $size={20}>
<Icon {...SlackIconSvg} />
</IconContainer>
Discuss on Slack
</CommunityLink>
</CommunityItem>
</CommunityItems>
</Container>
);
};
export const DocArticleCommunityGraphQLFragment = graphql`
fragment DocArticleCommunity on Query {
site {
siteMetadata {
repositoryUrl
tools {
slack
}
}
}
}
`;
const Container = styled.section.attrs({
className: "text-3",
})`
margin-bottom: 24px;
`;
const Title = styled.h6`
margin-bottom: 12px;
padding: 0 25px;
font-size: 0.875rem;
@media only screen and (min-width: 1320px) {
padding: 0;
}
`;
const CommunityItems = styled.ol`
display: flex;
flex-direction: column;
margin: 0;
padding: 0 25px;
list-style-type: none;
@media only screen and (min-width: 1320px) {
padding: 0;
}
`;
const CommunityItem = styled.li`
flex: 0 0 auto;
margin: 5px 0;
padding: 0;
`;
const CommunityLink = styled(Link)`
display: flex;
flex-direction: row;
align-items: center;
gap: 12px;
color: ${THEME_COLORS.text};
transition: color 0.2s ease-in-out;
> ${IconContainer} > svg {
fill: ${THEME_COLORS.text};
transition: fill 0.2s ease-in-out;
}
:hover {
color: ${THEME_COLORS.linkHover};
> ${IconContainer} > svg {
fill: ${THEME_COLORS.linkHover};
}
}
`;