-
Notifications
You must be signed in to change notification settings - Fork 61
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 #385 from keen/feat/percentile
feat: 🎸 Percentile
- Loading branch information
Showing
12 changed files
with
710 additions
and
635 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
30 changes: 30 additions & 0 deletions
30
lib/js/app/queryCreator/components/Percentile/Percentile.styles.ts
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,30 @@ | ||
import styled from 'styled-components'; | ||
import { motion } from 'framer-motion'; | ||
|
||
export const Container = styled.div` | ||
width: 68px; | ||
position: relative; | ||
input::-webkit-outer-spin-button, | ||
input::-webkit-inner-spin-button { | ||
-webkit-appearance: none; | ||
margin: 0; | ||
} | ||
/* Firefox */ | ||
input[type='number'] { | ||
-moz-appearance: textfield; | ||
} | ||
`; | ||
|
||
export const TooltipContainer = styled(motion.div)` | ||
position: absolute; | ||
left: 70%; | ||
top: 70%; | ||
pointer-events: none; | ||
z-index: 1; | ||
width: 200px; | ||
font-family: 'Lato Regular', sans-serif; | ||
font-size: 14px; | ||
`; |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
export const MIN_PERCENTILE = 0; | ||
|
||
export const MAX_PERCENTILE = 100; | ||
|
||
export const HIDE_TIME = 3000; |
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,4 +1,5 @@ | ||
{ | ||
"label": "Percentile value", | ||
"placeholder": "Ex. 33" | ||
"label": "Percentile", | ||
"placeholder": "Eg. 75", | ||
"message": "Percentile value has to be from range 0-100" | ||
} |
23 changes: 23 additions & 0 deletions
23
lib/js/app/queryCreator/components/Percentile/utils/getPercentileValue.test.ts
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,23 @@ | ||
import { getPercentileValue } from './getPercentileValue'; | ||
import { MIN_PERCENTILE, MAX_PERCENTILE } from '../constants'; | ||
|
||
test('should return MIN_PERCENTILE and true', () => { | ||
const { value, outRange } = getPercentileValue(-1); | ||
|
||
expect(value).toBe(MIN_PERCENTILE); | ||
expect(outRange).toBeTruthy(); | ||
}); | ||
|
||
test('should return MAX_PERCENTILE and true', () => { | ||
const { value, outRange } = getPercentileValue(102); | ||
|
||
expect(value).toBe(MAX_PERCENTILE); | ||
expect(outRange).toBeTruthy(); | ||
}); | ||
|
||
test('should return 50 and false', () => { | ||
const { value, outRange } = getPercentileValue(50); | ||
|
||
expect(value).toBe(50); | ||
expect(outRange).toBeFalsy(); | ||
}); |
9 changes: 9 additions & 0 deletions
9
lib/js/app/queryCreator/components/Percentile/utils/getPercentileValue.ts
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 @@ | ||
import { MIN_PERCENTILE, MAX_PERCENTILE } from '../constants'; | ||
|
||
export const getPercentileValue = ( | ||
value: number | ||
): { value: number; outRange: boolean } => { | ||
if (value < MIN_PERCENTILE) return { value: MIN_PERCENTILE, outRange: true }; | ||
if (value > MAX_PERCENTILE) return { value: MAX_PERCENTILE, outRange: true }; | ||
return { value, outRange: false }; | ||
}; |
12 changes: 9 additions & 3 deletions
12
lib/js/app/queryCreator/components/QueryArguments/QueryArguments.styles.ts
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,16 +1,22 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const MenuItem = styled.div` | ||
width: 25%; | ||
flex-basis: 25%; | ||
max-width: 320px; | ||
flex-shrink: 0; | ||
flex-shrink: 1; | ||
`; | ||
|
||
export const MenuItemPercentile = styled.div` | ||
flex-basis: 68px; | ||
`; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
margin-bottom: 20px; | ||
${MenuItem} + ${MenuItem} { | ||
${MenuItem} + ${MenuItem}, | ||
${MenuItemPercentile} + ${MenuItem}, | ||
${MenuItem} + ${MenuItemPercentile} { | ||
margin-left: 20px; | ||
} | ||
`; |
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
Oops, something went wrong.