react-native-ui-lib 7.37.2-snapshot.6134 → 7.37.2-snapshot.6147
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.
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ const transparentImage = require("./assets/transparentSwatch/TransparentSwatch.p
|
|
|
10
10
|
const DEFAULT_SIZE = Constants.isTablet ? 44 : 36;
|
|
11
11
|
export const SWATCH_MARGIN = 12;
|
|
12
12
|
export const SWATCH_SIZE = DEFAULT_SIZE;
|
|
13
|
+
const DEFAULT_COLOR = Colors.grey30;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* @description: A color swatch component
|
|
@@ -83,9 +84,8 @@ class ColorSwatch extends PureComponent {
|
|
|
83
84
|
value,
|
|
84
85
|
index
|
|
85
86
|
} = this.props;
|
|
86
|
-
const color = this.color ?? '';
|
|
87
87
|
const tintColor = this.getTintColor(value);
|
|
88
|
-
const result = value || color;
|
|
88
|
+
const result = value || this.color || '';
|
|
89
89
|
const hexString = Colors.getHexString(result);
|
|
90
90
|
this.props.onPress?.(result, {
|
|
91
91
|
tintColor,
|
|
@@ -102,10 +102,14 @@ class ColorSwatch extends PureComponent {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
getAccessibilityInfo() {
|
|
105
|
-
const color = this.color;
|
|
105
|
+
const color = this.color || DEFAULT_COLOR;
|
|
106
|
+
const defaultText = !this.color ? 'default' : '';
|
|
106
107
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
accessible: true,
|
|
109
|
+
accessibilityLabel: `${defaultText} color ${Colors.getColorName(color)}`,
|
|
110
|
+
accessibilityState: {
|
|
111
|
+
selected: this.props.selected
|
|
112
|
+
}
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
115
|
getLayout() {
|
|
@@ -122,13 +126,11 @@ class ColorSwatch extends PureComponent {
|
|
|
122
126
|
size = DEFAULT_SIZE,
|
|
123
127
|
...others
|
|
124
128
|
} = this.props;
|
|
125
|
-
const color = this.color;
|
|
126
129
|
const {
|
|
127
130
|
isSelected
|
|
128
131
|
} = this.state;
|
|
129
132
|
const Container = onPress ? TouchableOpacity : View;
|
|
130
|
-
const tintColor = this.getTintColor(color);
|
|
131
|
-
const accessibilityInfo = Constants.accessibility.isScreenReaderEnabled && this.getAccessibilityInfo();
|
|
133
|
+
const tintColor = this.getTintColor(this.color);
|
|
132
134
|
return <Container {...others} center activeOpacity={1} throttleTime={0} hitSlop={{
|
|
133
135
|
top: 10,
|
|
134
136
|
bottom: 10,
|
|
@@ -138,8 +140,8 @@ class ColorSwatch extends PureComponent {
|
|
|
138
140
|
width: size,
|
|
139
141
|
height: size,
|
|
140
142
|
borderRadius: size / 2
|
|
141
|
-
}, style]} onLayout={this.onLayout} {...
|
|
142
|
-
{Colors.isTransparent(color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
|
|
143
|
+
}, style]} onLayout={this.onLayout} {...this.getAccessibilityInfo()}>
|
|
144
|
+
{Colors.isTransparent(this.color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
|
|
143
145
|
{unavailable ? <View style={[this.styles.unavailable, {
|
|
144
146
|
backgroundColor: tintColor
|
|
145
147
|
}]} /> : <Animated.Image source={Assets.icons.check} style={{
|
|
@@ -181,12 +183,12 @@ class ColorSwatch extends PureComponent {
|
|
|
181
183
|
}
|
|
182
184
|
export default asBaseComponent(ColorSwatch);
|
|
183
185
|
function createStyles({
|
|
184
|
-
color =
|
|
186
|
+
color = DEFAULT_COLOR
|
|
185
187
|
}) {
|
|
186
188
|
return StyleSheet.create({
|
|
187
189
|
container: {
|
|
188
190
|
backgroundColor: color,
|
|
189
|
-
borderWidth: color
|
|
191
|
+
borderWidth: Colors.isTransparent(color) ? undefined : 1,
|
|
190
192
|
borderColor: Colors.rgba(Colors.$outlineDisabledHeavy, 0.2),
|
|
191
193
|
margin: SWATCH_MARGIN,
|
|
192
194
|
overflow: 'hidden'
|
package/src/style/colors.js
CHANGED
|
@@ -145,6 +145,9 @@ export class Colors {
|
|
|
145
145
|
return Scheme.getScheme(schemeType)[colorKey];
|
|
146
146
|
}
|
|
147
147
|
getColorName(colorValue) {
|
|
148
|
+
if (this.isTransparent(colorValue)) {
|
|
149
|
+
return 'transparent';
|
|
150
|
+
}
|
|
148
151
|
const color = colorStringValue(colorValue);
|
|
149
152
|
return ColorName.name(color)[1];
|
|
150
153
|
}
|