-
Notifications
You must be signed in to change notification settings - Fork 92
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
4 changed files
with
115 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import RCSlider from 'rc-slider/lib/Slider'; | ||
|
||
import 'rc-slider/assets/index.css'; | ||
import './themes/slider-green.scss'; | ||
|
||
const defaultSettings = { | ||
min: 0, | ||
max: 100, | ||
defaultValue: 50, | ||
tipFormatter: value => `${value}%`, | ||
marksOnTop: false | ||
}; | ||
|
||
class Slider extends PureComponent { | ||
// eslint-disable-line react/prefer-stateless-function | ||
render() { | ||
const { className, settings, handleOnSliderChange } = this.props; | ||
const sliderSettings = { | ||
...defaultSettings, | ||
...settings | ||
}; | ||
|
||
return ( | ||
<div | ||
className={`c-slider ${className || ''} ${ | ||
sliderSettings.marksOnTop ? '-marks-on-top' : '' | ||
}`} | ||
> | ||
<RCSlider | ||
{...sliderSettings} | ||
onChange={d => { | ||
handleOnSliderChange(d); | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Slider.propTypes = { | ||
className: PropTypes.string, | ||
settings: PropTypes.object, | ||
handleOnSliderChange: PropTypes.func.isRequired | ||
}; | ||
|
||
export default Slider; |
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,3 @@ | ||
import Component from './component'; | ||
|
||
export default Component; |
63 changes: 63 additions & 0 deletions
63
app/javascript/components/ui/slider-old/themes/slider-green.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,63 @@ | ||
@import '~styles/settings'; | ||
|
||
.theme-slider-green { | ||
.rc-slider-rail { | ||
background-color: transparent; | ||
} | ||
|
||
.rc-slider-track { | ||
background-color: $green-gfw; | ||
z-index: 2; | ||
} | ||
|
||
.rc-slider-dot { | ||
bottom: rem(1px); | ||
width: rem(2px); | ||
height: rem(2px); | ||
margin-left: 0; | ||
background-color: #c4c4c4; | ||
border: none; | ||
border-radius: 0; | ||
z-index: 1; | ||
} | ||
|
||
.rc-slider-handle { | ||
box-shadow: 0 1px 3px 0 rgba($black, 0.29); | ||
border: none; | ||
border-radius: 2px; | ||
z-index: 3; | ||
|
||
&::before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
width: rem(4px); | ||
height: rem(4px); | ||
margin: auto; | ||
background-color: $black; | ||
border-radius: 100%; | ||
} | ||
} | ||
|
||
.rc-slider-mark { | ||
font-size: 10px; | ||
|
||
.rc-slider-mark-text, | ||
.rc-slider-mark-text-active { | ||
color: $green-gfw; | ||
} | ||
} | ||
|
||
&.-marks-on-top { | ||
.rc-slider { | ||
padding-top: rem(20px); | ||
} | ||
|
||
.rc-slider-mark { | ||
top: 0; | ||
} | ||
} | ||
} |
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