forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceIcon.js
More file actions
49 lines (38 loc) · 1.39 KB
/
SourceIcon.js
File metadata and controls
49 lines (38 loc) · 1.39 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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
import React, { PureComponent } from "react";
import { connect } from "react-redux";
import { getSourceClassnames } from "../../utils/source";
import { getFramework } from "../../utils/tabs";
import { getSourceMetaData, getTabs } from "../../selectors";
import type { Source } from "../../types";
import type { SourceMetaDataType } from "../../reducers/ast";
import "./SourceIcon.css";
type Props = {
source: Source,
// sourceMetaData will provide framework information
sourceMetaData: SourceMetaDataType,
// An additional validator for the icon returned
shouldHide?: Function,
framework?: string
};
class SourceIcon extends PureComponent<Props> {
render() {
const { shouldHide, source, sourceMetaData, framework } = this.props;
const iconClass = framework
? framework.toLowerCase()
: getSourceClassnames(source, sourceMetaData);
if (shouldHide && shouldHide(iconClass)) {
return null;
}
return <img className={`source-icon ${iconClass}`} />;
}
}
export default connect((state, props) => {
return {
sourceMetaData: getSourceMetaData(state, props.source.id),
framework: getFramework(getTabs(state), props.source.url)
};
})(SourceIcon);