-
Notifications
You must be signed in to change notification settings - Fork 79
/
twitter.tsx
107 lines (95 loc) · 3.63 KB
/
twitter.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
/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved.
*
* This software is licensed under the Apache License, Version 2.0 (the
* "License") as published by the Apache Software Foundation.
*
* You may not use this file except in compliance with the License. You may
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/*
* Imports.
*/
import { isTest } from "../../../utils";
import type { BuiltInProviderConfig } from "./types";
import Provider from ".";
export type TwitterProviderConfig = BuiltInProviderConfig & {
useLegacyTwitterLogo?: boolean;
};
/*
* Class.
*/
export default class Twitter extends Provider {
private useLegacyTwitterLogo = false;
/*
* Static Attributes.
*/
private static instance?: Twitter;
/*
* Constructor.
*/
constructor(config?: TwitterProviderConfig) {
let name = "X";
const normalisedUseLegacyTwitterLogo = config?.useLegacyTwitterLogo === true;
if (normalisedUseLegacyTwitterLogo) {
name = "Twitter";
}
super({
id: "twitter",
name,
...config,
});
this.useLegacyTwitterLogo = normalisedUseLegacyTwitterLogo;
}
getLogo = (): JSX.Element => {
if (this.useLegacyTwitterLogo === true) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="20.129" height="16.356" viewBox="0 0 20.129 16.356">
<g>
<g>
<path
fill="#04ABEE"
d="M45.232 35.964a8.242 8.242 0 0 1-2.372.649 4.141 4.141 0 0 0 1.816-2.284 8.268 8.268 0 0 1-2.623 1 4.133 4.133 0 0 0-7.037 3.771 11.724 11.724 0 0 1-8.516-4.317 4.133 4.133 0 0 0 1.282 5.517 4.1 4.1 0 0 1-1.87-.517v.052a4.132 4.132 0 0 0 3.313 4.049 4.147 4.147 0 0 1-1.865.071 4.134 4.134 0 0 0 3.858 2.868 8.338 8.338 0 0 1-6.114 1.71 11.745 11.745 0 0 0 18.08-9.894q0-.268-.012-.534a8.374 8.374 0 0 0 2.061-2.137z"
transform="translate(34.799 -7.41) translate(2.201 4.266) translate(-62.103 -30.883)"
/>
</g>
</g>
</svg>
);
}
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 1200 1227">
<path
d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z"
fill="#000"
/>
</svg>
);
};
/*
* Static Methods
*/
static init(config?: TwitterProviderConfig): Provider {
if (Twitter.instance !== undefined) {
console.warn("Twitter Provider was already initialized");
return Twitter.instance;
}
Twitter.instance = new Twitter(config);
return Twitter.instance;
}
/*
* Tests methods.
*/
static reset(): void {
if (!isTest()) {
return;
}
Twitter.instance = undefined;
return;
}
}