Skip to content

Commit

Permalink
refactor: added paragon type of usage
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed May 22, 2023
1 parent a3e58df commit 78a35a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion www/src/components/insights/SummaryUsage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function SummaryUsage() {

const averageComponentsUsedPerProject = dependentProjects
.reduce((accumulator, project) => accumulator + project.count, 0) / dependentProjects.length;
console.log('dependentProjects', dependentProjects);
return (
<div className="pt-5 mb-5">
<div className="mb-5">
Expand Down
5 changes: 3 additions & 2 deletions www/src/context/InsightsContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import getParagonComponentsTypes from '../utils/getParagonComponentsTypes';

const InsightsContext = createContext({});

const componentsData = Object.assign({ paragon: 'Paragon' }, Components);

function InsightsContextProvider({ children }) {
const [paragonTypes, setParagonTypes] = useState({});

useEffect(() => {
setParagonTypes(getParagonComponentsTypes(Components));
setParagonTypes(getParagonComponentsTypes(componentsData));
}, []);

const isParagonIcon = (name) => name in Icons || name.match('Icon');

const contextValue = useMemo(() => ({
Expand Down
3 changes: 3 additions & 0 deletions www/src/utils/getParagonComponentsTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const getParagonComponentsTypes = (components) => {
const isContext = !!component.Consumer && !!component.Provider;
let componentType;
switch (true) {
case componentName.toLowerCase() === 'paragon':
componentType = 'Paragon';
break;
case typeof component === 'string' || typeof component === 'number':
componentType = 'Text';
break;
Expand Down

0 comments on commit 78a35a4

Please sign in to comment.