-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
606 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import AutocompleteInputBox from './AutocompleteInputBox' | ||
|
||
export default AutocompleteInputBox | ||
export { AutocompleteInputBox } from './AutocompleteInputBox' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useMemo } from 'react' | ||
import { Reading } from '../types' | ||
|
||
export function useBarGraph({ readings }: { readings: Reading[] }) { | ||
const graphScale = useMemo(() => { | ||
const gzipValues = readings | ||
.filter(reading => !reading.disabled) | ||
.map(reading => reading.gzip) | ||
|
||
const sizeValues = readings | ||
.filter(reading => !reading.disabled) | ||
.map(reading => reading.size) | ||
|
||
const maxValue = Math.max(...[...gzipValues, ...sizeValues]) | ||
return 100 / maxValue | ||
}, [readings]) | ||
|
||
const firstSideEffectFreeIndex = useMemo(() => { | ||
const sideEffectFreeIntroducedRecently = !readings.every( | ||
reading => !reading.hasSideEffects | ||
) | ||
const firstSideEffectFreeIndex = readings.findIndex( | ||
reading => !(reading.disabled || reading.hasSideEffects) | ||
) | ||
|
||
return sideEffectFreeIntroducedRecently ? firstSideEffectFreeIndex : -1 | ||
}, [readings]) | ||
|
||
const firstTreeshakeableIndex = useMemo(() => { | ||
const treeshakingIntroducedRecently = !readings.every( | ||
reading => reading.hasJSModule | ||
) | ||
const firstTreeshakingIndex = readings.findIndex( | ||
reading => | ||
!reading.disabled && | ||
(reading.hasJSModule || reading.hasJSNext || reading.isModuleType) | ||
) | ||
|
||
return treeshakingIntroducedRecently ? firstTreeshakingIndex : -1 | ||
}, [readings]) | ||
|
||
return { graphScale, firstSideEffectFreeIndex, firstTreeshakeableIndex } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import BarGraph from './BarGraph' | ||
|
||
export default BarGraph | ||
export { BarGraph } from './BarGraph' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type Reading = { | ||
version: string | ||
size: number | ||
gzip: number | ||
disabled: boolean | ||
hasSideEffects: boolean | ||
hasJSModule: boolean | ||
hasJSNext: boolean | ||
isModuleType: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { BarVersion } from './BarVersion' |
Oops, something went wrong.