-
Notifications
You must be signed in to change notification settings - Fork 45
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 #1292 from colouring-cities/interface/ui-tweaks
Interface/UI tweaks
- Loading branch information
Showing
14 changed files
with
305 additions
and
121 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
54 changes: 54 additions & 0 deletions
54
app/src/frontend/building/data-components/slider-data-entry.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,54 @@ | ||
import React, { Fragment } from 'react'; | ||
|
||
import { BaseDataEntryProps } from './data-entry'; | ||
import { DataTitleCopyable } from './data-title'; | ||
import Slider from 'rc-slider'; | ||
import 'rc-slider/assets/index.css'; | ||
|
||
interface SliderDataEntryProps extends BaseDataEntryProps { | ||
value?: number; | ||
placeholder?: string; | ||
dots?: boolean; | ||
max?: number; | ||
min?: number; | ||
onChange: (key: string, value: number) => void; | ||
} | ||
|
||
const SliderDataEntry: React.FunctionComponent<SliderDataEntryProps> = (props) => { | ||
|
||
const marks = { | ||
[props.min]: <strong>{props.min}</strong>, | ||
[props.max]: <strong>{props.max}</strong> | ||
}; | ||
|
||
return ( | ||
<Fragment> | ||
<DataTitleCopyable | ||
slug={props.slug} | ||
slugModifier={props.slugModifier} | ||
title={props.title} | ||
tooltip={props.tooltip} | ||
copy={props.copy} | ||
/> | ||
<div className="slider-container"> | ||
<Slider | ||
value={props.value || props.min} | ||
max={props.max} | ||
min={props.min} | ||
dots={props.dots} | ||
marks={marks} | ||
disabled={props.mode === 'view' || props.disabled} | ||
onChange={ | ||
e => props.onChange( | ||
props.slug, | ||
typeof(e)=="number" ? e : e[0] | ||
) | ||
} | ||
/> | ||
</div> | ||
<p>Your score: {props.value} - Average: 2.41 (15 votes)</p> | ||
</Fragment> | ||
); | ||
}; | ||
|
||
export default SliderDataEntry; |
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.