-
-
Notifications
You must be signed in to change notification settings - Fork 257
Ts migration #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bundlephobia
Are you sure you want to change the base?
Ts migration #756
Changes from 9 commits
ce601c0
7e4b966
577d1c5
4615e85
f0f072d
66c771a
707acff
a0be457
4550b59
7adb615
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,15 @@ import React, { Component } from 'react' | |
| import { formatSize } from 'utils' | ||
| import colors from 'client/config/colors' | ||
| import { Treemap, TreemapSquare } from 'client/components/Treemap' | ||
| import { DependencySize } from '../../../../types' | ||
|
|
||
| class TreemapSection extends Component { | ||
| type TreemapSectionProps = { | ||
| packageName: string | ||
| packageSize: number | ||
| dependencySizes: DependencySize[] | ||
| } | ||
|
|
||
| class TreemapSection extends Component<TreemapSectionProps> { | ||
| state = { | ||
| width: 0, | ||
| height: 0, | ||
|
|
@@ -77,7 +84,7 @@ class TreemapSection extends Component { | |
| })) | ||
|
|
||
| depdendenciesCopy.sort((depA, depB) => { | ||
| return depB.percentShare - depA.percentShare | ||
| return (depB.percentShare || 0) - (depA.percentShare || 0) | ||
| }) | ||
|
|
||
| let compactedDependencies = [] | ||
|
|
@@ -93,11 +100,11 @@ class TreemapSection extends Component { | |
| 0 | ||
| ) | ||
| const percentShare = otherDependencies.reduce( | ||
| (acc, dep) => acc + dep.percentShare, | ||
| (acc, dep) => acc + (dep.percentShare || 0), | ||
| 0 | ||
| ) | ||
| const sizeShare = otherDependencies.reduce( | ||
| (acc, dep) => acc + dep.sizeShare, | ||
| (acc, dep) => acc + (dep.sizeShare || 0), | ||
| 0 | ||
| ) | ||
|
|
||
|
|
@@ -110,7 +117,7 @@ class TreemapSection extends Component { | |
| tooltip: otherDependencies | ||
| .map( | ||
| dep => | ||
| `${dep.name} | ${dep.percentShare.toFixed( | ||
| `${dep.name} | ${(dep.percentShare || 0).toFixed( | ||
| 1 | ||
| )}% | ~ ${getFormattedSize(dep.sizeShare)} min` | ||
| ) | ||
|
|
@@ -136,8 +143,9 @@ class TreemapSection extends Component { | |
| data-balloon-pos="top" | ||
| className="treemap__square" | ||
| > | ||
| {dep.percentShare > ellipsizeLimit && | ||
| dep.name.length < dep.percentShare * (12 / ellipsizeLimit) ? ( | ||
| {(dep.percentShare || 0) > ellipsizeLimit && | ||
| dep.name.length < | ||
| (dep.percentShare || 0) * (12 / ellipsizeLimit) ? ( | ||
| <div className="treemap__content"> | ||
| <div className="treemap__label"> | ||
| {dep.isSelf || dep.isOthers ? ( | ||
|
|
@@ -156,11 +164,11 @@ class TreemapSection extends Component { | |
| className="treemap__percent" | ||
| style={{ | ||
| fontSize: `${ | ||
| 14 + Math.min(dep.percentShare * 1.2, 25) | ||
| 14 + Math.min((dep.percentShare || 0) * 1.2, 25) | ||
| }px`, | ||
| }} | ||
| > | ||
| {dep.percentShare.toFixed(1)} | ||
| {(dep.percentShare || 0).toFixed(1)} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks rather verbose. We should ensure that if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So how do you want to handle this? |
||
| <span className="treemap__percent-sign">%</span> | ||
| </div> | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we need to comment this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the child component does not use
path