@momo-kits/slider 0.0.2-beta → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { View, StyleSheet } from 'react-native';
4
+ import Text from '../../core/components/typography';
5
+
6
+ const sliderRadius = 3;
7
+ const width = 50;
8
+ export default class DefaultLabel extends React.Component {
9
+ render() {
10
+ const {
11
+ oneMarkerValue,
12
+ twoMarkerValue,
13
+ oneMarkerLeftPosition,
14
+ twoMarkerLeftPosition,
15
+ oneMarkerPressed,
16
+ twoMarkerPressed,
17
+ } = this.props;
18
+
19
+ return (
20
+ <View style={{ position: 'relative' }}>
21
+ {
22
+ Number.isFinite(oneMarkerLeftPosition)
23
+ && Number.isFinite(oneMarkerValue)
24
+ && (
25
+ <View
26
+ style={[
27
+ styles.sliderLabel,
28
+ { left: oneMarkerLeftPosition - width / 2 + sliderRadius },
29
+ oneMarkerPressed && styles.markerPressed,
30
+ ]}
31
+ >
32
+ <Text.SubTitle style={styles.sliderLabelText}>{oneMarkerValue}</Text.SubTitle>
33
+ </View>
34
+ )
35
+ }
36
+
37
+ {
38
+ Number.isFinite(twoMarkerLeftPosition)
39
+ && Number.isFinite(twoMarkerValue)
40
+ && (
41
+ <View
42
+ style={[
43
+ styles.sliderLabel,
44
+ { left: twoMarkerLeftPosition - width / 2 + sliderRadius },
45
+ twoMarkerPressed && styles.markerPressed,
46
+ ]}
47
+ >
48
+ <Text.SubTitle style={styles.sliderLabelText}>{twoMarkerValue}</Text.SubTitle>
49
+ </View>
50
+ )
51
+ }
52
+ </View>
53
+ );
54
+ }
55
+ }
56
+
57
+ const styles = StyleSheet.create({
58
+ sliderLabel: {
59
+ position: 'absolute',
60
+ bottom: 0,
61
+ minWidth: width,
62
+ padding: 8,
63
+ backgroundColor: '#f1f1f1',
64
+ },
65
+ sliderLabelText: {
66
+ alignItems: 'center',
67
+ textAlign: 'center',
68
+ fontStyle: 'normal',
69
+ // fontSize: 11,
70
+ },
71
+ markerPressed: {
72
+ borderWidth: 2,
73
+ borderColor: '#999',
74
+ },
75
+ });
76
+
77
+ DefaultLabel.propTypes = {
78
+ oneMarkerValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
79
+ twoMarkerValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
80
+
81
+ oneMarkerLeftPosition: PropTypes.number,
82
+ twoMarkerLeftPosition: PropTypes.number,
83
+
84
+ oneMarkerPressed: PropTypes.bool,
85
+ twoMarkerPressed: PropTypes.bool,
86
+ };
@@ -0,0 +1,72 @@
1
+ import React from 'react';
2
+ import {
3
+ View, StyleSheet, Platform, TouchableHighlight
4
+ } from 'react-native';
5
+ import Colors from '../../core/colors';
6
+
7
+ class DefaultMarker extends React.Component {
8
+ render() {
9
+ const {
10
+ enabled,
11
+ markerStyle,
12
+ pressed,
13
+ pressedMarkerStyle,
14
+ disabledMarkerStyle
15
+ } = this.props;
16
+ return (
17
+ <TouchableHighlight>
18
+ <View
19
+ style={
20
+ enabled
21
+ ? [
22
+ styles.markerStyle,
23
+ markerStyle,
24
+ pressed && styles.pressedMarkerStyle,
25
+ pressed && pressedMarkerStyle,
26
+ ]
27
+ : [
28
+ styles.markerStyle,
29
+ styles.disabled,
30
+ disabledMarkerStyle,
31
+ ]
32
+ }
33
+ />
34
+ </TouchableHighlight>
35
+ );
36
+ }
37
+ }
38
+
39
+ const styles = StyleSheet.create({
40
+ markerStyle: {
41
+ height: 24,
42
+ width: 24,
43
+ borderRadius: 12,
44
+ borderWidth: 2,
45
+ borderColor: Colors.pink_03,
46
+ backgroundColor: '#FFFFFF',
47
+ shadowColor: '#000000',
48
+ shadowOffset: {
49
+ width: 0,
50
+ height: 3,
51
+ },
52
+ shadowRadius: 1,
53
+ shadowOpacity: 0.2,
54
+ elevation: 3
55
+ },
56
+ pressedMarkerStyle: {
57
+ ...Platform.select({
58
+ web: {},
59
+ ios: {},
60
+ android: {
61
+ height: 20,
62
+ width: 20,
63
+ borderRadius: 20,
64
+ },
65
+ }),
66
+ },
67
+ disabled: {
68
+ backgroundColor: '#d3d3d3',
69
+ },
70
+ });
71
+
72
+ export default DefaultMarker;
package/Slider.js CHANGED
@@ -29,6 +29,7 @@ export default class Slider extends Component {
29
29
  const defaultSliderLength = length;
30
30
  this.stepLength = defaultSliderLength / this.optionsArray.length;
31
31
  const initialValues = values.map((value) => valueToPosition(value, this.optionsArray, defaultSliderLength));
32
+ console.warn('initialValues', initialValues);
32
33
  this.state = {
33
34
  valueOne: values[0],
34
35
  valueTwo: values[1],
package/Slider.web.js CHANGED
@@ -11,7 +11,7 @@ import { get } from 'lodash';
11
11
  import DefaultMarker from './DefaultMarker';
12
12
  import DefaultLabel from './DefaultLabel';
13
13
  import { createArray, valueToPosition, positionToValue } from './converters';
14
- import Colors from '../../colors';
14
+ import Colors from '../../core/colors';
15
15
 
16
16
  export default class Slider extends Component {
17
17
  constructor(props) {
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
- "name": "@momo-kits/slider",
3
- "version": "0.0.2-beta",
4
- "private": false,
5
- "main": "index.js",
6
- "dependencies": {},
7
- "peerDependencies": {
8
- "react-native": ">=0.55",
9
- "prop-types": "^15.7.2",
10
- "react": "16.9.0",
11
- "lodash": "^4.17.15",
12
- "@momo-kits/core": ">=0.0.5-beta"
13
- },
14
- "devDependencies": {},
15
- "license": "MoMo"
16
- }
17
-
2
+ "name": "@momo-kits/slider",
3
+ "version": "0.0.4",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "react-native": ">=0.55",
9
+ "prop-types": "^15.7.2",
10
+ "react": "16.9.0",
11
+ "lodash": "^4.17.15",
12
+ "@momo-kits/core": ">=0.0.5-beta"
13
+ },
14
+ "devDependencies": {},
15
+ "license": "MoMo"
16
+ }