diff options
author | 2020-04-14 14:56:16 +0530 | |
---|---|---|
committer | 2020-04-14 10:26:16 +0100 | |
commit | 100016e38098ff389b2d6899dee76413da26f2ae (patch) | |
tree | bcb0f69ef87b4fb91905da2a58538d3e8cc828e5 /src/components/ui | |
parent | New Crowdin translations (#495) (diff) | |
download | ferdium-app-100016e38098ff389b2d6899dee76413da26f2ae.tar.gz ferdium-app-100016e38098ff389b2d6899dee76413da26f2ae.tar.zst ferdium-app-100016e38098ff389b2d6899dee76413da26f2ae.zip |
Expose Dark Reader settings (#568)
* feat: Expose DarkReader settings to users
- In the service model, expose an object darkReaderSetting which contains brightness, contrast and sepia values.
- In EditServiceScreen, provide 3 form options for brightness, contrast and Sepia. Additionally onSubmit() form, capture the darkreader settings data onto formdata.darkReaderSettings to update in the service
- In EditServiceForm, if darkModeEnabled is checked, show 3 sliders for controlling darkreader settings
- Create a new Slider control and customize it according to the application's theme and dark theme.
- In Webview Recipe, load the darkReader settings from service settings and pass it to the darkReader library.
* feat: Darkreader settings
- Lint fixes
* feat: DarkReader settings
- refactor code in editservicescreen.js
Co-Authored-By: Sampath Kumar Krishnan <sampath3493@gmail.com>
* feat: Darkreader settings
- Fix a crash where service.darkReaderSettings is null while creating a new service
- Remove isDarkModeEnabled prop to EditServiceForm as it is no longer required.
* fix: Update EditServiceScreen
- Set the default value of darkReader Brightness, Contrast and Sepia to undefined as per @vantezzen 's suggestion.
- Updated the check provided by @mahadevans87
Co-authored-by: Sampath Kumar Krishnan <sampath3493@gmail.com>
Co-authored-by: Sampath Kumar Krishnan <sampathBlam@users.noreply.github.com>
Diffstat (limited to 'src/components/ui')
-rw-r--r-- | src/components/ui/Slider.js | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/components/ui/Slider.js b/src/components/ui/Slider.js new file mode 100644 index 000000000..b00a6a3f8 --- /dev/null +++ b/src/components/ui/Slider.js | |||
@@ -0,0 +1,65 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer } from 'mobx-react'; | ||
4 | import classnames from 'classnames'; | ||
5 | import { Field } from 'mobx-react-form'; | ||
6 | |||
7 | export default @observer class Slider extends Component { | ||
8 | static propTypes = { | ||
9 | field: PropTypes.instanceOf(Field).isRequired, | ||
10 | className: PropTypes.string, | ||
11 | showLabel: PropTypes.bool, | ||
12 | disabled: PropTypes.bool, | ||
13 | }; | ||
14 | |||
15 | static defaultProps = { | ||
16 | className: '', | ||
17 | showLabel: true, | ||
18 | disabled: false, | ||
19 | }; | ||
20 | |||
21 | onChange(e) { | ||
22 | const { field } = this.props; | ||
23 | |||
24 | field.onChange(e); | ||
25 | } | ||
26 | |||
27 | render() { | ||
28 | const { | ||
29 | field, | ||
30 | className, | ||
31 | showLabel, | ||
32 | disabled, | ||
33 | } = this.props; | ||
34 | |||
35 | if (field.value === '' && field.default !== '') { | ||
36 | field.value = field.default; | ||
37 | } | ||
38 | |||
39 | return ( | ||
40 | <div | ||
41 | className={classnames([ | ||
42 | 'franz-form__field', | ||
43 | 'franz-form__slider-wrapper', | ||
44 | className, | ||
45 | ])} | ||
46 | > | ||
47 | <div className="slider-container"> | ||
48 | <input | ||
49 | className="slider" | ||
50 | type="range" | ||
51 | id={field.id} | ||
52 | name={field.name} | ||
53 | value={field.value} | ||
54 | min="1" | ||
55 | max="100" | ||
56 | onChange={e => (!disabled ? this.onChange(e) : null)} | ||
57 | /> | ||
58 | </div> | ||
59 | |||
60 | {field.error && <div className={field.error}>{field.error}</div>} | ||
61 | {field.label && showLabel && <label className="franz-form__label" htmlFor={field.id}>{field.label}</label>} | ||
62 | </div> | ||
63 | ); | ||
64 | } | ||
65 | } | ||