-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from marmelab/responsive-chart
[RFR] Responsive chart
- Loading branch information
Showing
9 changed files
with
174 additions
and
22 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
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
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,9 @@ | ||
export const getBreakpointLabel = (breakpoints, point) => { | ||
for (const label in breakpoints) { | ||
if (point <= breakpoints[label]) { | ||
return label; | ||
} | ||
} | ||
|
||
return 'extra'; | ||
}; |
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,27 @@ | ||
import { getBreakpointLabel } from './breakpoint'; | ||
|
||
const defaultConfig = { | ||
breakpoints: { | ||
small: 576, | ||
medium: 768, | ||
large: 992, | ||
extra: 1200, | ||
}, | ||
}; | ||
|
||
describe('Breakpoint Label', () => { | ||
it('should return breakpoint label correctly depending of current point', () => { | ||
expect(getBreakpointLabel(defaultConfig.breakpoints, 400)).toBe( | ||
'small' | ||
); | ||
expect(getBreakpointLabel(defaultConfig.breakpoints, 600)).toBe( | ||
'medium' | ||
); | ||
expect(getBreakpointLabel(defaultConfig.breakpoints, 800)).toBe( | ||
'large' | ||
); | ||
expect(getBreakpointLabel(defaultConfig.breakpoints, 1000)).toBe( | ||
'extra' | ||
); | ||
}); | ||
}); |
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
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