[Tabs] Show Framework logos
It would be really cool if we could show a framework logo in the source tabs. This would help us differentiate between the Expressions component, actions, and reducer.
To figureout if a file is a component, actions, or reducer we need to check the AST.
Component: imports react and uses createClass or the Component class Action: has a function with an inner that has an object with dispatch Reducer: has an update function with a switch statement
canonical actions
export function resumed() {
return ({ dispatch }) => {
};
}
export function resumed() {
return function ({ dispatch }) {
};
}
canonical reducer:
function update(
state: Record<BreakpointsState> = initialState(),
action: Action
) {
switch (action.type) {
}
}
Here's a patch to help get started
James is working on it
We landed a util for isReactComponent.
We can now easily check :)
and add it here:
diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index 50aba30..927b8a2 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -451,6 +451,10 @@ class SourceTabs extends PureComponent<Props, State> {
getSourceAnnotation(source) {
const sourceObj = source.toJS();
+ if (isReactComponent) {
+ return <img className="react" />;
+ }
+
if (isPretty(sourceObj)) {
return <img className="prettyPrint" />;
}
We now have redux state, which will make this easier.
diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index ae3f5ab..4c910d5 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -453,8 +453,13 @@ class SourceTabs extends PureComponent<Props, State> {
}
getSourceAnnotation(source) {
+ const { sourceMetaData } = this.props;
const sourceObj = source.toJS();
+ if (sourceMetaData && sourceMetaData.isReactComponent) {
+ return <img className="react" />;
+ }
+
if (isPretty(sourceObj)) {
return <img className="prettyPrint" />;
}
@@ -482,7 +487,8 @@ export default connect(
searchTabs: getSearchTabs(state),
sourceTabs: getSourcesForTabs(state),
activeSearch: getActiveSearch(state),
- searchOn: getActiveSearch(state) === "source"
+ searchOn: getActiveSearch(state) === "source",
+ metaData: getSourceMetaData(state, source)
};
},
dispatch => bindActionCreators(actions, dispatch)
/claim
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
/claim
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
/unclaim
Done :+1:
/claim