-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract YearRangeSlider to separate component (unused)
- Loading branch information
Showing
4 changed files
with
100 additions
and
101 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
39 changes: 39 additions & 0 deletions
39
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/YearSlider/YearSlider.module.scss
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,39 @@ | ||
@import '../../../../../theme/theme'; | ||
|
||
.rangeMainContainer { | ||
width: 150px; | ||
height: 30px; | ||
background-color: rgba(var(--deforestration-range-background-new), 0.1); | ||
margin-top: 6px; | ||
border-radius: 6px; | ||
} | ||
|
||
.rangeContainer { | ||
padding-left: 8px; | ||
display: flex; | ||
gap: 12px; | ||
} | ||
|
||
.playIconContainer { | ||
display: flex; | ||
margin-top: 8px; | ||
} | ||
|
||
.sliderContainer { | ||
width: 107px; | ||
display: flex; | ||
margin-top: 10px; | ||
} | ||
|
||
.yearRangeContainer { | ||
display: flex; | ||
padding-left: 22px; | ||
padding-right: 8px; | ||
justify-content: space-between; | ||
margin-top: 1px; | ||
} | ||
.endYear, | ||
.startYear { | ||
font-size: $fontXXXXSmallNew; | ||
font-weight: 400; | ||
} |
59 changes: 59 additions & 0 deletions
59
src/features/projectsV2/ProjectsMap/MapFeatureExplorer/YearSlider/index.tsx
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,59 @@ | ||
// Unused code - for future reference while implementing the deforestation timeline slider | ||
|
||
import { useState } from 'react'; | ||
import { SmallSlider } from '../CustomSlider'; | ||
import styles from './YearSlider.module.scss'; | ||
import PlayIcon from '../../../../../../public/assets/images/icons/projectV2/PlayIcon'; | ||
|
||
export interface YearRangeSliderProps { | ||
startYear: number; | ||
endYear: number; | ||
} | ||
|
||
export const YearRangeSlider = () => { | ||
const minDistance = 10; | ||
const [value1, setValue1] = useState<number[]>([20, 37]); | ||
|
||
function valuetext(value: number) { | ||
return `${value}°C`; | ||
} | ||
|
||
const handleChange1 = ( | ||
event: Event, | ||
newValue: number | number[], | ||
activeThumb: number | ||
) => { | ||
if (!Array.isArray(newValue)) { | ||
return; | ||
} | ||
|
||
if (activeThumb === 0) { | ||
setValue1([Math.min(newValue[0], value1[1] - minDistance), value1[1]]); | ||
} else { | ||
setValue1([value1[0], Math.max(newValue[1], value1[0] + minDistance)]); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={styles.rangeMainContainer}> | ||
<div className={styles.rangeContainer}> | ||
<div className={styles.playIconContainer}> | ||
<PlayIcon width={'8px'} /> | ||
</div> | ||
<div className={styles.sliderContainer}> | ||
<SmallSlider | ||
getAriaLabel={() => 'Minimum distance'} | ||
value={value1} | ||
onChange={handleChange1} | ||
getAriaValueText={valuetext} | ||
disableSwap | ||
/> | ||
</div> | ||
</div> | ||
<div className={styles.yearRangeContainer}> | ||
<div className={styles.startYear}>{'2012'}</div> | ||
<div className={styles.endYear}>{'2024'}</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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