@momo-kits/avatar 0.0.60-rc.6 → 0.0.61-alpha.8

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.
Files changed (2) hide show
  1. package/Avatar.js +24 -168
  2. package/package.json +1 -1
package/Avatar.js CHANGED
@@ -16,7 +16,8 @@ import {
16
16
  IconSource,
17
17
  Image,
18
18
  ScaleSize,
19
- } from '@momo-kits/core';
19
+ Radius,
20
+ } from '@momo-kits/core-v2';
20
21
 
21
22
  export const AvatarQuality = {
22
23
  low: 'low',
@@ -30,18 +31,6 @@ export const AvatarSize = {
30
31
  medium: 'medium',
31
32
  large: 'large',
32
33
  giant: 'giant',
33
- size8: 'size8',
34
- size24: 'size24',
35
- size36: 'size36',
36
- size44: 'size44',
37
- size48: 'size48',
38
- size52: 'size52',
39
- size56: 'size56',
40
- size64: 'size64',
41
- size72: 'size72',
42
- size80: 'size80',
43
- size88: 'size88',
44
- size96: 'size96',
45
34
  };
46
35
 
47
36
  const COLORS = [
@@ -118,7 +107,7 @@ const styles = StyleSheet.create({
118
107
  });
119
108
 
120
109
  const subIconSize = (width) => ({
121
- tiny: {
110
+ giant: {
122
111
  width: 8,
123
112
  height: 8,
124
113
  borderRadius: 4,
@@ -138,83 +127,6 @@ const subIconSize = (width) => ({
138
127
  height: 16,
139
128
  borderRadius: 8,
140
129
  },
141
- size8: {
142
- width: 8,
143
- height: 8,
144
- borderRadius: 4,
145
- },
146
- size24: {
147
- width: 10,
148
- height: 10,
149
- borderRadius: 5,
150
- },
151
- size36: {
152
- width: 10,
153
- height: 10,
154
- borderRadius: 5,
155
- },
156
- size44: {
157
- width: 14,
158
- height: 14,
159
- borderRadius: 7,
160
- },
161
- size48: {
162
- width: 14,
163
- height: 14,
164
- borderRadius: 7,
165
- },
166
- size52: {
167
- width: 16,
168
- height: 16,
169
- borderRadius: 8,
170
- },
171
- size56: {
172
- width: 16,
173
- height: 16,
174
- borderRadius: 8,
175
- },
176
- size64: {
177
- width: 16,
178
- height: 16,
179
- borderRadius: 8,
180
- top: -2,
181
- left: -2,
182
- },
183
- size72: {
184
- width: 18,
185
- height: 18,
186
- borderRadius: 9,
187
- top: -3,
188
- left: -3,
189
- },
190
- size80: {
191
- width: 18,
192
- height: 18,
193
- borderRadius: 9,
194
- top: -3,
195
- left: -3,
196
- },
197
- size88: {
198
- width: 18,
199
- height: 18,
200
- borderRadius: 9,
201
- top: -4,
202
- left: -4,
203
- },
204
- size96: {
205
- width: 20,
206
- height: 20,
207
- borderRadius: 10,
208
- top: -4,
209
- left: -4,
210
- },
211
- giant: {
212
- top: -5,
213
- left: -5,
214
- width: 24,
215
- height: 24,
216
- borderRadius: 12,
217
- },
218
130
  });
219
131
 
220
132
  const avatarSize = (width) => ({
@@ -234,95 +146,35 @@ const avatarSize = (width) => ({
234
146
  borderRadius: 20,
235
147
  },
236
148
  large: {
237
- width: 60,
238
- height: 60,
239
- borderRadius: 30,
240
- },
241
- giant: {
242
- width: 120,
243
- height: 120,
244
- borderRadius: 60,
245
- },
246
- size8: {
247
- width: 8,
248
- height: 8,
249
- borderRadius: 4,
250
- },
251
- size24: {
252
- width: 24,
253
- height: 24,
254
- borderRadius: 12,
255
- },
256
- size36: {
257
- width: 36,
258
- height: 36,
259
- borderRadius: 18,
260
- },
261
- size44: {
262
- width: 44,
263
- height: 44,
264
- borderRadius: 22,
265
- },
266
- size48: {
267
- width: 48,
268
- height: 48,
269
- borderRadius: 24,
270
- },
271
- size52: {
272
- width: 52,
273
- height: 52,
274
- borderRadius: 26,
275
- },
276
- size56: {
277
149
  width: 56,
278
150
  height: 56,
279
151
  borderRadius: 28,
280
152
  },
281
- size64: {
282
- width: 64,
283
- height: 64,
284
- borderRadius: 32,
285
- },
286
- size72: {
153
+ giant: {
287
154
  width: 72,
288
155
  height: 72,
289
156
  borderRadius: 36,
290
157
  },
291
- size80: {
292
- width: 80,
293
- height: 80,
294
- borderRadius: 40,
295
- },
296
- size88: {
297
- width: 88,
298
- height: 88,
299
- borderRadius: 44,
300
- },
301
- size96: {
302
- width: 96,
303
- height: 96,
304
- borderRadius: 48,
305
- },
306
158
  });
307
159
 
308
160
  const shortName = (width) => ({
309
161
  tiny: {
310
- fontSize: ScaleSize(5, width),
162
+ fontSize: ScaleSize(8, width),
163
+ lineHeight: 16,
311
164
  },
312
165
  small: {
313
- fontSize: ScaleSize(11, width),
166
+ fontSize: ScaleSize(14, width),
167
+ lineHeight: 20,
314
168
  },
315
169
  medium: {
316
- fontSize: ScaleSize(15, width),
317
- },
318
- middle: {
319
- fontSize: ScaleSize(16, width),
170
+ fontSize: ScaleSize(18, width),
171
+ lineHeight: 22,
320
172
  },
321
173
  large: {
322
- fontSize: ScaleSize(20, width),
174
+ fontSize: ScaleSize(25, width),
323
175
  },
324
176
  giant: {
325
- fontSize: ScaleSize(25, width),
177
+ fontSize: ScaleSize(32, width),
326
178
  },
327
179
  });
328
180
 
@@ -411,9 +263,14 @@ export default class Avatar extends Component {
411
263
  style={[
412
264
  styles.shortNameView,
413
265
  avatarStyle,
414
- { backgroundColor: color },
266
+ {
267
+ backgroundColor: color,
268
+ },
269
+ this.props.shape === 'square' && {
270
+ borderRadius: Radius.XS,
271
+ },
415
272
  ]}>
416
- <Text.H4
273
+ <Text
417
274
  style={[
418
275
  this.props.custom
419
276
  ? styles.shortNameTextCustom
@@ -421,7 +278,7 @@ export default class Avatar extends Component {
421
278
  shortNameStyle,
422
279
  ]}>
423
280
  {shortedName}
424
- </Text.H4>
281
+ </Text>
425
282
  </View>
426
283
  );
427
284
  }
@@ -607,6 +464,7 @@ export default class Avatar extends Component {
607
464
  cached,
608
465
  extraPropsImage,
609
466
  quality,
467
+ shape,
610
468
  } = this.props;
611
469
  const { hideSource } = this.state;
612
470
  const avatarStyle = this.mapStyleFromSize(size);
@@ -665,9 +523,8 @@ export default class Avatar extends Component {
665
523
 
666
524
  Avatar.propTypes = {
667
525
  name: PropTypes.string,
668
- resizeMode: PropTypes.string,
669
526
  quality: PropTypes.oneOf(['low', 'medium', 'high']),
670
- size: PropTypes.any,
527
+ size: PropTypes.oneOf(['tiny', 'small', 'medium', 'large', 'giant']),
671
528
  source: PropTypes.oneOfType([
672
529
  PropTypes.shape({ uri: PropTypes.string }),
673
530
  PropTypes.number,
@@ -682,11 +539,9 @@ Avatar.propTypes = {
682
539
  style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
683
540
  onPress: PropTypes.func,
684
541
  loading: PropTypes.bool,
685
- cached: PropTypes.bool,
686
- scaleSize: PropTypes.bool,
687
542
  extraPropsImage: PropTypes.object,
688
- number: PropTypes.string,
689
543
  custom: PropTypes.bool,
544
+ shape: PropTypes.oneOf(['circle', 'square']),
690
545
  };
691
546
 
692
547
  Avatar.defaultProps = {
@@ -696,4 +551,5 @@ Avatar.defaultProps = {
696
551
  quality: 'medium',
697
552
  size: 'small',
698
553
  custom: false,
554
+ shape: 'circle',
699
555
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/avatar",
3
- "version": "0.0.60-rc.6",
3
+ "version": "0.0.61-alpha.8",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {},