@hero-design/rn 8.60.0 → 8.60.1-alpha.0

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.
@@ -2,4 +2,4 @@
2
2
  src/index.ts → lib/index.js, es/index.js...
3
3
  (!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.
4
4
  (!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
5
- created lib/index.js, es/index.js in 57.4s
5
+ created lib/index.js, es/index.js in 57.6s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.60.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2807](https://github.com/Thinkei/hero-design/pull/2807) [`391137af3`](https://github.com/Thinkei/hero-design/commit/391137af35cb9ae71da51d6863624da0251017aa) Thanks [@ttkien](https://github.com/ttkien)! - initial HDv9
8
+
9
+ - Updated dependencies [[`5c76fdb0b`](https://github.com/Thinkei/hero-design/commit/5c76fdb0b3565456f30864c78e42cc9a589747c9), [`391137af3`](https://github.com/Thinkei/hero-design/commit/391137af35cb9ae71da51d6863624da0251017aa)]:
10
+ - @hero-design/colors@9.0.0-alpha.0
11
+
3
12
  ## 8.60.0
4
13
 
5
14
  ### Minor Changes
package/es/index.js CHANGED
@@ -1292,7 +1292,9 @@ var BASE_COLORS = {
1292
1292
  theatreGold: '#a56822',
1293
1293
  uniformGreen: '#4d4628',
1294
1294
  yellow: '#fadb14',
1295
- windsorGrey: '#606065'
1295
+ windsorGrey: '#606065',
1296
+ mist: '#e8e9f8',
1297
+ cloud: '#ccd9f5'
1296
1298
  };
1297
1299
  var colorScales = Object.entries(BASE_COLORS).reduce(function (acc, _ref16) {
1298
1300
  var _ref17 = _slicedToArray(_ref16, 2),
@@ -1301,15 +1303,17 @@ var colorScales = Object.entries(BASE_COLORS).reduce(function (acc, _ref16) {
1301
1303
  return Object.assign(Object.assign({}, acc), _defineProperty({}, key, createColorScales(value)));
1302
1304
  }, {});
1303
1305
  var blue$1 = colorScales.blue,
1304
- ultramarineBlue$2 = colorScales.ultramarineBlue,
1306
+ cloud = colorScales.cloud,
1307
+ deepSaffron$2 = colorScales.deepSaffron,
1305
1308
  green$1 = colorScales.green,
1306
1309
  grey$2 = colorScales.grey,
1307
1310
  grotesqueGreen = colorScales.grotesqueGreen,
1308
- deepSaffron$2 = colorScales.deepSaffron,
1311
+ mist = colorScales.mist,
1309
1312
  pink$1 = colorScales.pink,
1310
1313
  purple$1 = colorScales.purple,
1311
- vermilion$2 = colorScales.vermilion,
1312
1314
  smalt = colorScales.smalt,
1315
+ ultramarineBlue$2 = colorScales.ultramarineBlue,
1316
+ vermilion$2 = colorScales.vermilion,
1313
1317
  violet$1 = colorScales.violet,
1314
1318
  yellow$1 = colorScales.yellow;
1315
1319
  var palette$b = {
@@ -1328,9 +1332,11 @@ var palette$b = {
1328
1332
  blueLight60: blue$1.lighten60,
1329
1333
  blueLight75: blue$1.lighten75,
1330
1334
  blueLight90: blue$1.lighten90,
1335
+ cloudLight90: cloud.lighten90,
1331
1336
  dodgerBlue: ultramarineBlue$2.base,
1332
1337
  dodgerBlueDark15: ultramarineBlue$2.darken15,
1333
1338
  dodgerBlueDark30: ultramarineBlue$2.darken30,
1339
+ dodgerBlueDark60: ultramarineBlue$2.darken60,
1334
1340
  dodgerBlueLight30: ultramarineBlue$2.lighten30,
1335
1341
  dodgerBlueLight45: ultramarineBlue$2.lighten45,
1336
1342
  dodgerBlueLight60: ultramarineBlue$2.lighten60,
@@ -1339,6 +1345,7 @@ var palette$b = {
1339
1345
  green: green$1.base,
1340
1346
  greenDark15: green$1.darken15,
1341
1347
  greenDark30: green$1.darken30,
1348
+ greenDark60: green$1.darken60,
1342
1349
  greenDark75: green$1.darken75,
1343
1350
  greenLight30: green$1.lighten30,
1344
1351
  greenLight75: green$1.lighten75,
@@ -1349,6 +1356,7 @@ var palette$b = {
1349
1356
  greyDark45: grey$2.darken45,
1350
1357
  greyDark60: grey$2.darken60,
1351
1358
  greyDark75: grey$2.darken75,
1359
+ greyLight30: grey$2.lighten30,
1352
1360
  greyLight45: grey$2.lighten45,
1353
1361
  greyLight60: grey$2.lighten60,
1354
1362
  greyLight75: grey$2.lighten75,
@@ -1362,20 +1370,27 @@ var palette$b = {
1362
1370
  grotesqueGreenLight60: grotesqueGreen.lighten60,
1363
1371
  grotesqueGreenLight75: grotesqueGreen.lighten75,
1364
1372
  grotesqueGreenLight90: grotesqueGreen.lighten90,
1373
+ mistLight30: mist.lighten30,
1374
+ mistLight60: mist.lighten60,
1375
+ mistLight90: mist.lighten90,
1365
1376
  orange: deepSaffron$2.base,
1366
1377
  orangeDark15: deepSaffron$2.darken15,
1367
1378
  orangeDark30: deepSaffron$2.darken30,
1379
+ orangeDark60: deepSaffron$2.darken60,
1368
1380
  orangeDark75: deepSaffron$2.darken75,
1369
1381
  orangeLight30: deepSaffron$2.lighten30,
1382
+ orangeLight60: deepSaffron$2.lighten60,
1370
1383
  orangeLight75: deepSaffron$2.lighten75,
1371
1384
  orangeLight90: deepSaffron$2.lighten90,
1372
1385
  pink: pink$1.base,
1373
1386
  pinkDark15: pink$1.darken15,
1374
1387
  pinkDark30: pink$1.darken30,
1375
1388
  pinkDark45: pink$1.darken45,
1389
+ pinkDark60: pink$1.darken60,
1376
1390
  pinkDark75: pink$1.darken75,
1377
1391
  pinkLight30: pink$1.lighten30,
1378
1392
  pinkLight45: pink$1.lighten45,
1393
+ pinkLight60: pink$1.lighten60,
1379
1394
  pinkLight75: pink$1.lighten75,
1380
1395
  pinkLight90: pink$1.lighten90,
1381
1396
  purple: purple$1.base,
@@ -1418,6 +1433,7 @@ var palette$b = {
1418
1433
  yellow: yellow$1.base,
1419
1434
  yellowDark15: yellow$1.darken15,
1420
1435
  yellowDark30: yellow$1.darken30,
1436
+ yellowDark45: yellow$1.darken45,
1421
1437
  yellowDark75: yellow$1.darken75,
1422
1438
  yellowLight30: yellow$1.lighten30,
1423
1439
  yellowLight45: yellow$1.lighten45,
@@ -2934,11 +2950,17 @@ var getProgressTheme = function getProgressTheme(theme) {
2934
2950
 
2935
2951
  var getRadioTheme = function getRadioTheme(theme) {
2936
2952
  var colors = {
2937
- circle: theme.colors.onDefaultGlobalSurface
2953
+ circle: theme.colors.primary,
2954
+ checked: theme.colors.highlightedSurface,
2955
+ intents: {
2956
+ light: theme.colors.defaultGlobalSurface,
2957
+ dark: theme.colors.neutralGlobalSurface
2958
+ }
2938
2959
  };
2939
2960
  var space = {
2940
2961
  circleLeftMargin: theme.space.small,
2941
- groupTopMargin: theme.space.xsmall
2962
+ groupTopMarginSmall: theme.space.xsmall,
2963
+ groupTopMarginMedium: theme.space.medium
2942
2964
  };
2943
2965
  var boundingBoxSize = theme.sizes.large;
2944
2966
  var innerPadding = theme.space.xsmall;
@@ -16145,9 +16167,18 @@ var InnerCircle = index$9(View)(function (_ref2) {
16145
16167
  };
16146
16168
  });
16147
16169
  var Spacer = index$9(View)(function (_ref3) {
16148
- var theme = _ref3.theme;
16170
+ var theme = _ref3.theme,
16171
+ themeIntent = _ref3.themeIntent;
16172
+ return {
16173
+ marginTop: themeIntent === 'light' ? theme.__hd__.radio.space.groupTopMarginSmall : theme.__hd__.radio.space.groupTopMarginMedium
16174
+ };
16175
+ });
16176
+ var StyledRadio = index$9(List.Item)(function (_ref4) {
16177
+ var theme = _ref4.theme,
16178
+ themeIntent = _ref4.themeIntent,
16179
+ themeChecked = _ref4.themeChecked;
16149
16180
  return {
16150
- marginTop: theme.__hd__.radio.space.groupTopMargin
16181
+ backgroundColor: themeChecked ? theme.__hd__.radio.colors.checked : theme.__hd__.radio.colors.intents[themeIntent]
16151
16182
  };
16152
16183
  });
16153
16184
 
@@ -16164,17 +16195,23 @@ var Radio = function Radio(_ref2) {
16164
16195
  checked = _ref2$checked === void 0 ? false : _ref2$checked,
16165
16196
  onPress = _ref2.onPress,
16166
16197
  style = _ref2.style,
16167
- testID = _ref2.testID;
16168
- return /*#__PURE__*/React.createElement(List.BasicItem, {
16198
+ subText = _ref2.subText,
16199
+ testID = _ref2.testID,
16200
+ _ref2$inactiveIntent = _ref2.inactiveIntent,
16201
+ inactiveIntent = _ref2$inactiveIntent === void 0 ? 'light' : _ref2$inactiveIntent;
16202
+ return /*#__PURE__*/React.createElement(StyledRadio, {
16169
16203
  onPress: onPress,
16170
16204
  selected: checked,
16171
16205
  title: text,
16206
+ subtitle: subText,
16172
16207
  suffix: /*#__PURE__*/React.createElement(RadioCircle, {
16173
16208
  checked: checked,
16174
16209
  text: text
16175
16210
  }),
16176
16211
  style: style,
16177
- testID: testID
16212
+ testID: testID,
16213
+ themeIntent: inactiveIntent,
16214
+ themeChecked: checked
16178
16215
  });
16179
16216
  };
16180
16217
 
@@ -16195,19 +16232,25 @@ var RadioGroup = function RadioGroup(_ref) {
16195
16232
  options = _ref.options,
16196
16233
  keyExtractor = _ref.keyExtractor,
16197
16234
  style = _ref.style,
16198
- testID = _ref.testID;
16235
+ testID = _ref.testID,
16236
+ _ref$inactiveIntent = _ref.inactiveIntent,
16237
+ inactiveIntent = _ref$inactiveIntent === void 0 ? 'light' : _ref$inactiveIntent;
16199
16238
  return /*#__PURE__*/React.createElement(View, {
16200
16239
  style: style,
16201
16240
  testID: testID
16202
16241
  }, options.map(function (option, index) {
16203
16242
  return /*#__PURE__*/React.createElement(React.Fragment, {
16204
16243
  key: getKey(option, index, keyExtractor)
16205
- }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, null), /*#__PURE__*/React.createElement(Radio, {
16244
+ }, index !== 0 && /*#__PURE__*/React.createElement(Spacer, {
16245
+ themeIntent: inactiveIntent
16246
+ }), /*#__PURE__*/React.createElement(Radio, {
16206
16247
  text: option.text,
16248
+ subText: option.subText,
16207
16249
  checked: option.value === value,
16208
16250
  onPress: function onPress() {
16209
16251
  return _onPress(option.value);
16210
- }
16252
+ },
16253
+ inactiveIntent: inactiveIntent
16211
16254
  }));
16212
16255
  }));
16213
16256
  };
package/lib/index.js CHANGED
@@ -1322,7 +1322,9 @@ var BASE_COLORS = {
1322
1322
  theatreGold: '#a56822',
1323
1323
  uniformGreen: '#4d4628',
1324
1324
  yellow: '#fadb14',
1325
- windsorGrey: '#606065'
1325
+ windsorGrey: '#606065',
1326
+ mist: '#e8e9f8',
1327
+ cloud: '#ccd9f5'
1326
1328
  };
1327
1329
  var colorScales = Object.entries(BASE_COLORS).reduce(function (acc, _ref16) {
1328
1330
  var _ref17 = _slicedToArray(_ref16, 2),
@@ -1331,15 +1333,17 @@ var colorScales = Object.entries(BASE_COLORS).reduce(function (acc, _ref16) {
1331
1333
  return Object.assign(Object.assign({}, acc), _defineProperty({}, key, createColorScales(value)));
1332
1334
  }, {});
1333
1335
  var blue$1 = colorScales.blue,
1334
- ultramarineBlue$2 = colorScales.ultramarineBlue,
1336
+ cloud = colorScales.cloud,
1337
+ deepSaffron$2 = colorScales.deepSaffron,
1335
1338
  green$1 = colorScales.green,
1336
1339
  grey$2 = colorScales.grey,
1337
1340
  grotesqueGreen = colorScales.grotesqueGreen,
1338
- deepSaffron$2 = colorScales.deepSaffron,
1341
+ mist = colorScales.mist,
1339
1342
  pink$1 = colorScales.pink,
1340
1343
  purple$1 = colorScales.purple,
1341
- vermilion$2 = colorScales.vermilion,
1342
1344
  smalt = colorScales.smalt,
1345
+ ultramarineBlue$2 = colorScales.ultramarineBlue,
1346
+ vermilion$2 = colorScales.vermilion,
1343
1347
  violet$1 = colorScales.violet,
1344
1348
  yellow$1 = colorScales.yellow;
1345
1349
  var palette$b = {
@@ -1358,9 +1362,11 @@ var palette$b = {
1358
1362
  blueLight60: blue$1.lighten60,
1359
1363
  blueLight75: blue$1.lighten75,
1360
1364
  blueLight90: blue$1.lighten90,
1365
+ cloudLight90: cloud.lighten90,
1361
1366
  dodgerBlue: ultramarineBlue$2.base,
1362
1367
  dodgerBlueDark15: ultramarineBlue$2.darken15,
1363
1368
  dodgerBlueDark30: ultramarineBlue$2.darken30,
1369
+ dodgerBlueDark60: ultramarineBlue$2.darken60,
1364
1370
  dodgerBlueLight30: ultramarineBlue$2.lighten30,
1365
1371
  dodgerBlueLight45: ultramarineBlue$2.lighten45,
1366
1372
  dodgerBlueLight60: ultramarineBlue$2.lighten60,
@@ -1369,6 +1375,7 @@ var palette$b = {
1369
1375
  green: green$1.base,
1370
1376
  greenDark15: green$1.darken15,
1371
1377
  greenDark30: green$1.darken30,
1378
+ greenDark60: green$1.darken60,
1372
1379
  greenDark75: green$1.darken75,
1373
1380
  greenLight30: green$1.lighten30,
1374
1381
  greenLight75: green$1.lighten75,
@@ -1379,6 +1386,7 @@ var palette$b = {
1379
1386
  greyDark45: grey$2.darken45,
1380
1387
  greyDark60: grey$2.darken60,
1381
1388
  greyDark75: grey$2.darken75,
1389
+ greyLight30: grey$2.lighten30,
1382
1390
  greyLight45: grey$2.lighten45,
1383
1391
  greyLight60: grey$2.lighten60,
1384
1392
  greyLight75: grey$2.lighten75,
@@ -1392,20 +1400,27 @@ var palette$b = {
1392
1400
  grotesqueGreenLight60: grotesqueGreen.lighten60,
1393
1401
  grotesqueGreenLight75: grotesqueGreen.lighten75,
1394
1402
  grotesqueGreenLight90: grotesqueGreen.lighten90,
1403
+ mistLight30: mist.lighten30,
1404
+ mistLight60: mist.lighten60,
1405
+ mistLight90: mist.lighten90,
1395
1406
  orange: deepSaffron$2.base,
1396
1407
  orangeDark15: deepSaffron$2.darken15,
1397
1408
  orangeDark30: deepSaffron$2.darken30,
1409
+ orangeDark60: deepSaffron$2.darken60,
1398
1410
  orangeDark75: deepSaffron$2.darken75,
1399
1411
  orangeLight30: deepSaffron$2.lighten30,
1412
+ orangeLight60: deepSaffron$2.lighten60,
1400
1413
  orangeLight75: deepSaffron$2.lighten75,
1401
1414
  orangeLight90: deepSaffron$2.lighten90,
1402
1415
  pink: pink$1.base,
1403
1416
  pinkDark15: pink$1.darken15,
1404
1417
  pinkDark30: pink$1.darken30,
1405
1418
  pinkDark45: pink$1.darken45,
1419
+ pinkDark60: pink$1.darken60,
1406
1420
  pinkDark75: pink$1.darken75,
1407
1421
  pinkLight30: pink$1.lighten30,
1408
1422
  pinkLight45: pink$1.lighten45,
1423
+ pinkLight60: pink$1.lighten60,
1409
1424
  pinkLight75: pink$1.lighten75,
1410
1425
  pinkLight90: pink$1.lighten90,
1411
1426
  purple: purple$1.base,
@@ -1448,6 +1463,7 @@ var palette$b = {
1448
1463
  yellow: yellow$1.base,
1449
1464
  yellowDark15: yellow$1.darken15,
1450
1465
  yellowDark30: yellow$1.darken30,
1466
+ yellowDark45: yellow$1.darken45,
1451
1467
  yellowDark75: yellow$1.darken75,
1452
1468
  yellowLight30: yellow$1.lighten30,
1453
1469
  yellowLight45: yellow$1.lighten45,
@@ -2964,11 +2980,17 @@ var getProgressTheme = function getProgressTheme(theme) {
2964
2980
 
2965
2981
  var getRadioTheme = function getRadioTheme(theme) {
2966
2982
  var colors = {
2967
- circle: theme.colors.onDefaultGlobalSurface
2983
+ circle: theme.colors.primary,
2984
+ checked: theme.colors.highlightedSurface,
2985
+ intents: {
2986
+ light: theme.colors.defaultGlobalSurface,
2987
+ dark: theme.colors.neutralGlobalSurface
2988
+ }
2968
2989
  };
2969
2990
  var space = {
2970
2991
  circleLeftMargin: theme.space.small,
2971
- groupTopMargin: theme.space.xsmall
2992
+ groupTopMarginSmall: theme.space.xsmall,
2993
+ groupTopMarginMedium: theme.space.medium
2972
2994
  };
2973
2995
  var boundingBoxSize = theme.sizes.large;
2974
2996
  var innerPadding = theme.space.xsmall;
@@ -16175,9 +16197,18 @@ var InnerCircle = index$9(reactNative.View)(function (_ref2) {
16175
16197
  };
16176
16198
  });
16177
16199
  var Spacer = index$9(reactNative.View)(function (_ref3) {
16178
- var theme = _ref3.theme;
16200
+ var theme = _ref3.theme,
16201
+ themeIntent = _ref3.themeIntent;
16202
+ return {
16203
+ marginTop: themeIntent === 'light' ? theme.__hd__.radio.space.groupTopMarginSmall : theme.__hd__.radio.space.groupTopMarginMedium
16204
+ };
16205
+ });
16206
+ var StyledRadio = index$9(List.Item)(function (_ref4) {
16207
+ var theme = _ref4.theme,
16208
+ themeIntent = _ref4.themeIntent,
16209
+ themeChecked = _ref4.themeChecked;
16179
16210
  return {
16180
- marginTop: theme.__hd__.radio.space.groupTopMargin
16211
+ backgroundColor: themeChecked ? theme.__hd__.radio.colors.checked : theme.__hd__.radio.colors.intents[themeIntent]
16181
16212
  };
16182
16213
  });
16183
16214
 
@@ -16194,17 +16225,23 @@ var Radio = function Radio(_ref2) {
16194
16225
  checked = _ref2$checked === void 0 ? false : _ref2$checked,
16195
16226
  onPress = _ref2.onPress,
16196
16227
  style = _ref2.style,
16197
- testID = _ref2.testID;
16198
- return /*#__PURE__*/React__default["default"].createElement(List.BasicItem, {
16228
+ subText = _ref2.subText,
16229
+ testID = _ref2.testID,
16230
+ _ref2$inactiveIntent = _ref2.inactiveIntent,
16231
+ inactiveIntent = _ref2$inactiveIntent === void 0 ? 'light' : _ref2$inactiveIntent;
16232
+ return /*#__PURE__*/React__default["default"].createElement(StyledRadio, {
16199
16233
  onPress: onPress,
16200
16234
  selected: checked,
16201
16235
  title: text,
16236
+ subtitle: subText,
16202
16237
  suffix: /*#__PURE__*/React__default["default"].createElement(RadioCircle, {
16203
16238
  checked: checked,
16204
16239
  text: text
16205
16240
  }),
16206
16241
  style: style,
16207
- testID: testID
16242
+ testID: testID,
16243
+ themeIntent: inactiveIntent,
16244
+ themeChecked: checked
16208
16245
  });
16209
16246
  };
16210
16247
 
@@ -16225,19 +16262,25 @@ var RadioGroup = function RadioGroup(_ref) {
16225
16262
  options = _ref.options,
16226
16263
  keyExtractor = _ref.keyExtractor,
16227
16264
  style = _ref.style,
16228
- testID = _ref.testID;
16265
+ testID = _ref.testID,
16266
+ _ref$inactiveIntent = _ref.inactiveIntent,
16267
+ inactiveIntent = _ref$inactiveIntent === void 0 ? 'light' : _ref$inactiveIntent;
16229
16268
  return /*#__PURE__*/React__default["default"].createElement(reactNative.View, {
16230
16269
  style: style,
16231
16270
  testID: testID
16232
16271
  }, options.map(function (option, index) {
16233
16272
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
16234
16273
  key: getKey(option, index, keyExtractor)
16235
- }, index !== 0 && /*#__PURE__*/React__default["default"].createElement(Spacer, null), /*#__PURE__*/React__default["default"].createElement(Radio, {
16274
+ }, index !== 0 && /*#__PURE__*/React__default["default"].createElement(Spacer, {
16275
+ themeIntent: inactiveIntent
16276
+ }), /*#__PURE__*/React__default["default"].createElement(Radio, {
16236
16277
  text: option.text,
16278
+ subText: option.subText,
16237
16279
  checked: option.value === value,
16238
16280
  onPress: function onPress() {
16239
16281
  return _onPress(option.value);
16240
- }
16282
+ },
16283
+ inactiveIntent: inactiveIntent
16241
16284
  }));
16242
16285
  }));
16243
16286
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.60.0",
3
+ "version": "8.60.1-alpha.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -22,7 +22,7 @@
22
22
  "@emotion/native": "^11.9.3",
23
23
  "@emotion/primitives-core": "11.0.0",
24
24
  "@emotion/react": "^11.9.3",
25
- "@hero-design/colors": "8.42.5",
25
+ "@hero-design/colors": "9.0.0-alpha.0",
26
26
  "date-fns": "^2.16.1",
27
27
  "hero-editor": "^1.9.21",
28
28
  "nanoid": "^4.0.2"
@@ -1,9 +1,8 @@
1
- import React from 'react';
2
1
  import type { ReactElement } from 'react';
2
+ import React from 'react';
3
3
  import type { StyleProp, ViewStyle } from 'react-native';
4
4
 
5
- import List from '../List';
6
- import { Circle, InnerCircle } from './StyledRadio';
5
+ import { Circle, InnerCircle, StyledRadio } from './StyledRadio';
7
6
 
8
7
  export interface RadioProps {
9
8
  /**
@@ -22,10 +21,18 @@ export interface RadioProps {
22
21
  * Additional style.
23
22
  */
24
23
  style?: StyleProp<ViewStyle>;
24
+ /**
25
+ * Radio subtext.
26
+ */
27
+ subText?: string;
25
28
  /**
26
29
  * Testing id of the component.
27
30
  */
28
31
  testID?: string;
32
+ /**
33
+ * Idle background color of the Radio.
34
+ */
35
+ inactiveIntent?: 'light' | 'dark';
29
36
  }
30
37
 
31
38
  const RadioCircle = ({
@@ -42,15 +49,20 @@ const Radio = ({
42
49
  checked = false,
43
50
  onPress,
44
51
  style,
52
+ subText,
45
53
  testID,
54
+ inactiveIntent = 'light',
46
55
  }: RadioProps): ReactElement => (
47
- <List.BasicItem
56
+ <StyledRadio
48
57
  onPress={onPress}
49
58
  selected={checked}
50
59
  title={text}
60
+ subtitle={subText}
51
61
  suffix={<RadioCircle checked={checked} text={text} />}
52
62
  style={style}
53
63
  testID={testID}
64
+ themeIntent={inactiveIntent}
65
+ themeChecked={checked}
54
66
  />
55
67
  );
56
68
 
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
1
  import type { ReactElement } from 'react';
2
+ import React from 'react';
4
3
  import type { StyleProp, ViewStyle } from 'react-native';
4
+ import { View } from 'react-native';
5
5
  import Radio from './Radio';
6
6
  import { Spacer } from './StyledRadio';
7
7
  import type { OptionType } from './types';
@@ -32,6 +32,10 @@ export interface RadioGroupProps<T> {
32
32
  * Testing id of the component.
33
33
  */
34
34
  testID?: string;
35
+ /**
36
+ * Idle background color of the Radio.
37
+ */
38
+ inactiveIntent?: 'light' | 'dark';
35
39
  }
36
40
 
37
41
  function getKey<T>(
@@ -58,15 +62,18 @@ const RadioGroup = <T,>({
58
62
  keyExtractor,
59
63
  style,
60
64
  testID,
65
+ inactiveIntent = 'light',
61
66
  }: RadioGroupProps<T>): ReactElement => (
62
67
  <View style={style} testID={testID}>
63
68
  {options.map((option, index) => (
64
69
  <React.Fragment key={getKey(option, index, keyExtractor)}>
65
- {index !== 0 && <Spacer />}
70
+ {index !== 0 && <Spacer themeIntent={inactiveIntent} />}
66
71
  <Radio
67
72
  text={option.text}
73
+ subText={option.subText}
68
74
  checked={option.value === value}
69
75
  onPress={() => onPress(option.value)}
76
+ inactiveIntent={inactiveIntent}
70
77
  />
71
78
  </React.Fragment>
72
79
  ))}
@@ -1,5 +1,8 @@
1
1
  import { View } from 'react-native';
2
2
  import styled from '@emotion/native';
3
+ import List from '../List';
4
+
5
+ type RadioIntent = 'light' | 'dark';
3
6
 
4
7
  const Circle = styled(View)(({ theme }) => ({
5
8
  height: theme.__hd__.radio.sizes.circle,
@@ -18,8 +21,22 @@ const InnerCircle = styled(View)(({ theme }) => ({
18
21
  backgroundColor: theme.__hd__.radio.colors.circle,
19
22
  }));
20
23
 
21
- const Spacer = styled(View)(({ theme }) => ({
22
- marginTop: theme.__hd__.radio.space.groupTopMargin,
24
+ const Spacer = styled(View)<{ themeIntent: RadioIntent }>(
25
+ ({ theme, themeIntent }) => ({
26
+ marginTop:
27
+ themeIntent === 'light'
28
+ ? theme.__hd__.radio.space.groupTopMarginSmall
29
+ : theme.__hd__.radio.space.groupTopMarginMedium,
30
+ })
31
+ );
32
+
33
+ const StyledRadio = styled(List.Item)<{
34
+ themeIntent: RadioIntent;
35
+ themeChecked: boolean;
36
+ }>(({ theme, themeIntent, themeChecked }) => ({
37
+ backgroundColor: themeChecked
38
+ ? theme.__hd__.radio.colors.checked
39
+ : theme.__hd__.radio.colors.intents[themeIntent],
23
40
  }));
24
41
 
25
- export { Circle, InnerCircle, Spacer };
42
+ export { Circle, InnerCircle, Spacer, StyledRadio };
@@ -4,24 +4,57 @@ import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
4
  import Radio from '../Radio';
5
5
 
6
6
  describe('rendering', () => {
7
- it('renders correctly when checked', () => {
8
- const { getByText, queryAllByTestId, toJSON } = renderWithTheme(
9
- <Radio text="Option A" onPress={jest.fn} checked />
10
- );
7
+ it.each`
8
+ inactiveIntent
9
+ ${'light'}
10
+ ${'dark'}
11
+ `(
12
+ 'renders correctly when checked with inactiveIntent=$inactiveIntent',
13
+ ({ inactiveIntent }) => {
14
+ const { getByText, queryAllByTestId, toJSON } = renderWithTheme(
15
+ <Radio
16
+ inactiveIntent={inactiveIntent}
17
+ text="Option A"
18
+ onPress={jest.fn}
19
+ checked
20
+ />
21
+ );
11
22
 
12
- expect(getByText('Option A')).toBeDefined();
13
- expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(1);
14
- expect(toJSON()).toMatchSnapshot();
15
- });
23
+ expect(getByText('Option A')).toBeDefined();
24
+ expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(1);
25
+ expect(toJSON()).toMatchSnapshot();
26
+ }
27
+ );
16
28
 
17
- it('renders correctly when not checked', () => {
18
- const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
19
- <Radio text="Option A" onPress={jest.fn} checked={false} />
29
+ it.each`
30
+ inactiveIntent
31
+ ${'light'}
32
+ ${'dark'}
33
+ `(
34
+ 'renders correctly when not checked with inactiveIntent=$inactiveIntent',
35
+ ({ inactiveIntent }) => {
36
+ const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
37
+ <Radio
38
+ inactiveIntent={inactiveIntent}
39
+ text="Option A"
40
+ onPress={jest.fn}
41
+ checked={false}
42
+ />
43
+ );
44
+
45
+ expect(getByText('Option A')).toBeDefined();
46
+ expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(0);
47
+ expect(toJSON()).toMatchSnapshot();
48
+ }
49
+ );
50
+
51
+ it('allows rendering of subtext', () => {
52
+ const { getByText } = renderWithTheme(
53
+ <Radio text="Option A" subText="Option label" onPress={jest.fn} checked />
20
54
  );
21
55
 
22
56
  expect(getByText('Option A')).toBeDefined();
23
- expect(queryAllByTestId('Option A-selected-circle')).toHaveLength(0);
24
- expect(toJSON()).toMatchSnapshot();
57
+ expect(getByText('Option label')).toBeDefined();
25
58
  });
26
59
  });
27
60
 
@@ -9,17 +9,50 @@ const options = [
9
9
  { text: 'Nothing', value: 'nothing' },
10
10
  ];
11
11
 
12
+ const optionsWithSubtext = [
13
+ { text: 'On Demand', subText: 'InstaPay Now', value: 'on_demand' },
14
+ { text: 'Daily', subText: 'InstaPay Daily', value: 'daily' },
15
+ ];
16
+
12
17
  describe('rendering', () => {
13
- it('renders correctly', () => {
14
- const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
15
- <RadioGroup options={options} value="nothing" onPress={jest.fn()} />
18
+ it.each`
19
+ inactiveIntent
20
+ ${'light'}
21
+ ${'dark'}
22
+ `(
23
+ 'renders correctly with inactiveIntent=$inactiveIntent',
24
+ ({ inactiveIntent }) => {
25
+ const { getByText, toJSON, queryAllByTestId } = renderWithTheme(
26
+ <RadioGroup
27
+ inactiveIntent={inactiveIntent}
28
+ options={options}
29
+ value="nothing"
30
+ onPress={jest.fn()}
31
+ />
32
+ );
33
+
34
+ expect(getByText('Everything')).toBeDefined();
35
+ expect(getByText('Direct mentions only')).toBeDefined();
36
+ expect(getByText('Nothing')).toBeDefined();
37
+ expect(queryAllByTestId('Nothing-selected-circle')).toHaveLength(1);
38
+ expect(toJSON()).toMatchSnapshot();
39
+ }
40
+ );
41
+
42
+ it('renders correctly with subtext', () => {
43
+ const { getByText, toJSON } = renderWithTheme(
44
+ <RadioGroup
45
+ options={optionsWithSubtext}
46
+ value="nothing"
47
+ onPress={jest.fn()}
48
+ />
16
49
  );
17
50
 
18
- expect(getByText('Everything')).toBeDefined();
19
- expect(getByText('Direct mentions only')).toBeDefined();
20
- expect(getByText('Nothing')).toBeDefined();
21
- expect(queryAllByTestId('Nothing-selected-circle')).toHaveLength(1);
22
51
  expect(toJSON()).toMatchSnapshot();
52
+ expect(getByText('On Demand')).toBeDefined();
53
+ expect(getByText('InstaPay Now')).toBeDefined();
54
+ expect(getByText('Daily')).toBeDefined();
55
+ expect(getByText('InstaPay Daily')).toBeDefined();
23
56
  });
24
57
  });
25
58