@hero-design/rn 7.0.5 → 7.1.1

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 (62) hide show
  1. package/babel.config.js +1 -1
  2. package/es/index.js +150 -41
  3. package/lib/index.js +149 -38
  4. package/package.json +3 -3
  5. package/playground/components/Card.tsx +74 -91
  6. package/playground/components/FAB.tsx +49 -0
  7. package/playground/index.tsx +3 -1
  8. package/src/components/Card/StyledCard.tsx +1 -0
  9. package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +5 -4
  10. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +5 -4
  11. package/src/components/FAB/AnimatedFABIcon.tsx +47 -0
  12. package/src/components/FAB/StyledFABContainer.tsx +14 -0
  13. package/src/components/FAB/StyledFABIcon.tsx +9 -0
  14. package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +20 -0
  15. package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +18 -0
  16. package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +16 -0
  17. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +71 -0
  18. package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +46 -0
  19. package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +21 -0
  20. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +120 -0
  21. package/src/components/FAB/__tests__/index.spec.tsx +58 -0
  22. package/src/components/FAB/index.tsx +56 -0
  23. package/src/components/Icon/index.tsx +1 -1
  24. package/src/index.ts +4 -0
  25. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +14 -1
  26. package/src/theme/components/card.ts +1 -1
  27. package/src/theme/components/fab.ts +21 -0
  28. package/src/theme/global/space.ts +11 -9
  29. package/src/theme/global/typography.ts +11 -9
  30. package/src/theme/index.ts +3 -0
  31. package/src/utils/__tests__/scale.spec.ts +26 -0
  32. package/src/utils/scale.ts +10 -0
  33. package/testUtils/setup.ts +4 -0
  34. package/types/playground/components/FAB.d.ts +2 -0
  35. package/types/src/components/FAB/AnimatedFABIcon.d.ts +6 -0
  36. package/types/src/components/FAB/StyledFABContainer.d.ts +3 -0
  37. package/types/src/components/FAB/StyledFABIcon.d.ts +3 -0
  38. package/types/{components/ExampleComponent/__tests__/StyledView.spec.d.ts → src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts} +0 -0
  39. package/types/src/components/{Typography/Text/__test__/StyledText.spec.d.ts → FAB/__tests__/StyledFABContainer.spec.d.ts} +0 -0
  40. package/types/src/components/{Typography/Text/__test__/index.spec.d.ts → FAB/__tests__/StyledFABIcon.spec.d.ts} +0 -0
  41. package/types/src/components/FAB/__tests__/index.spec.d.ts +1 -0
  42. package/types/src/components/FAB/index.d.ts +30 -0
  43. package/types/src/components/Icon/index.d.ts +1 -1
  44. package/types/src/index.d.ts +3 -1
  45. package/types/src/theme/components/fab.d.ts +15 -0
  46. package/types/src/theme/index.d.ts +2 -0
  47. package/types/src/utils/__tests__/scale.spec.d.ts +1 -0
  48. package/types/src/utils/scale.d.ts +2 -0
  49. package/types/components/ExampleComponent/StyledView.d.ts +0 -7
  50. package/types/components/ExampleComponent/index.d.ts +0 -16
  51. package/types/index.d.ts +0 -4
  52. package/types/styled-components.d.ts +0 -6
  53. package/types/theme/colors.d.ts +0 -24
  54. package/types/theme/components/demoStyle.d.ts +0 -11
  55. package/types/theme/components/exampleComponent.d.ts +0 -14
  56. package/types/theme/global/colors.d.ts +0 -24
  57. package/types/theme/global/index.d.ts +0 -58
  58. package/types/theme/global/space.d.ts +0 -12
  59. package/types/theme/global/typography.d.ts +0 -21
  60. package/types/theme/index.d.ts +0 -11
  61. package/types/theme/space.d.ts +0 -12
  62. package/types/theme/typography.d.ts +0 -21
package/babel.config.js CHANGED
@@ -27,7 +27,7 @@ module.exports = function (api) {
27
27
  }
28
28
 
29
29
  return {
30
- presets: ['babel-preset-expo'],
30
+ presets: ['babel-preset-expo', '@babel/preset-typescript'],
31
31
  plugins,
32
32
  };
33
33
  };
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import React, { useContext, useMemo, createElement } from 'react';
2
- import require$$0$1, { View, Text as Text$1 } from 'react-native';
1
+ import React, { useContext, useMemo, createElement, useRef, useEffect } from 'react';
2
+ import require$$0$1, { Dimensions, View, Text as Text$1, Animated, StyleSheet as StyleSheet$1, TouchableHighlight } from 'react-native';
3
3
 
4
4
  function ownKeys(object, enumerableOnly) {
5
5
  var keys = Object.keys(object);
@@ -8130,7 +8130,7 @@ Processor$1["default"] = Processor$1;
8130
8130
  Root$2.registerProcessor(Processor$1);
8131
8131
  Document$1.registerProcessor(Processor$1);
8132
8132
 
8133
- var _excluded$3 = ["inputs"],
8133
+ var _excluded$4 = ["inputs"],
8134
8134
  _excluded2 = ["inputId"];
8135
8135
 
8136
8136
  var Declaration$1 = declaration;
@@ -8147,7 +8147,7 @@ function fromJSON$1(json, inputs) {
8147
8147
  });
8148
8148
 
8149
8149
  var ownInputs = json.inputs,
8150
- defaults = _objectWithoutProperties$1(json, _excluded$3);
8150
+ defaults = _objectWithoutProperties$1(json, _excluded$4);
8151
8151
 
8152
8152
  if (ownInputs) {
8153
8153
  inputs = [];
@@ -9780,6 +9780,7 @@ var palette = {
9780
9780
  greenDark30: '#017d6d',
9781
9781
  greenDark75: '#002d27',
9782
9782
  greenLight30: '#4dcaba',
9783
+ greenLight75: '#c0ece6',
9783
9784
  greenLight90: '#e6f7f5',
9784
9785
  grey: '#a3a6ac',
9785
9786
  greyDark15: '#8b8d92',
@@ -9819,6 +9820,7 @@ var palette = {
9819
9820
  redDark15: '#bd2d09',
9820
9821
  redDark30: '#9b2508',
9821
9822
  redDark75: '#380d03',
9823
+ redLight15: '#e35330',
9822
9824
  redLight30: '#e87254',
9823
9825
  redLight60: '#f2ae9d',
9824
9826
  redLight75: '#f7cdc2',
@@ -9870,30 +9872,41 @@ var systemPalette = {
9870
9872
  outline: palette.greyLight60
9871
9873
  };
9872
9874
 
9875
+ var BASE_WIDTH = 390; // Based on iPhone 13's viewport size
9876
+
9877
+ var scale = function scale(size) {
9878
+ var _Dimensions$get = Dimensions.get('window'),
9879
+ width = _Dimensions$get.width,
9880
+ height = _Dimensions$get.height;
9881
+
9882
+ var shortDimension = width < height ? width : height;
9883
+ return shortDimension / BASE_WIDTH * size;
9884
+ };
9885
+
9873
9886
  var BASE$1 = 8;
9874
9887
  var space = {
9875
- xxsmall: BASE$1 * 0.25,
9876
- xsmall: BASE$1 * 0.5,
9877
- small: BASE$1,
9878
- medium: BASE$1 * 2,
9879
- large: BASE$1 * 3,
9880
- xlarge: BASE$1 * 4,
9881
- xxlarge: BASE$1 * 5,
9882
- xxxlarge: BASE$1 * 6,
9883
- xxxxlarge: BASE$1 * 7
9888
+ xxsmall: scale(BASE$1 * 0.25),
9889
+ xsmall: scale(BASE$1 * 0.5),
9890
+ small: scale(BASE$1),
9891
+ medium: scale(BASE$1 * 2),
9892
+ large: scale(BASE$1 * 3),
9893
+ xlarge: scale(BASE$1 * 4),
9894
+ xxlarge: scale(BASE$1 * 5),
9895
+ xxxlarge: scale(BASE$1 * 6),
9896
+ xxxxlarge: scale(BASE$1 * 7)
9884
9897
  };
9885
9898
 
9886
9899
  var BASE = 16;
9887
9900
  var fontSizes = {
9888
- xxxxxlarge: BASE * 2,
9889
- xxxxlarge: BASE * 1.75,
9890
- xxxlarge: BASE * 1.5,
9891
- xxlarge: BASE * 1.25,
9892
- xlarge: BASE * 1.125,
9893
- large: BASE,
9894
- medium: BASE * 0.875,
9895
- small: BASE * 0.75,
9896
- xsmall: BASE * 0.625 // 10
9901
+ xxxxxlarge: scale(BASE * 2),
9902
+ xxxxlarge: scale(BASE * 1.75),
9903
+ xxxlarge: scale(BASE * 1.5),
9904
+ xxlarge: scale(BASE * 1.25),
9905
+ xlarge: scale(BASE * 1.125),
9906
+ large: scale(BASE),
9907
+ medium: scale(BASE * 0.875),
9908
+ small: scale(BASE * 0.75),
9909
+ xsmall: scale(BASE * 0.625) // 10
9897
9910
 
9898
9911
  };
9899
9912
  var fontWeights = {
@@ -9964,7 +9977,7 @@ var getCardTheme = function getCardTheme(theme) {
9964
9977
  "default": "12px"
9965
9978
  };
9966
9979
  var padding = {
9967
- "default": "".concat(theme.space.medium, "px")
9980
+ "default": "".concat(theme.space.small, "px")
9968
9981
  };
9969
9982
  return {
9970
9983
  radii: radii,
@@ -10045,6 +10058,25 @@ var getTypographyTheme = function getTypographyTheme(theme) {
10045
10058
  };
10046
10059
  };
10047
10060
 
10061
+ var getFABTheme = function getFABTheme(theme) {
10062
+ var colors = {
10063
+ buttonBackground: theme.colors.backgroundDark,
10064
+ icon: theme.colors.invertedText
10065
+ };
10066
+ var sizes = {
10067
+ width: '64px',
10068
+ height: '64px'
10069
+ };
10070
+ var fontSizes = {
10071
+ "default": "".concat(theme.fontSizes.xxxxlarge, "px")
10072
+ };
10073
+ return {
10074
+ fontSizes: fontSizes,
10075
+ colors: colors,
10076
+ sizes: sizes
10077
+ };
10078
+ };
10079
+
10048
10080
  var getTheme = function getTheme() {
10049
10081
  var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalTheme;
10050
10082
  return _objectSpread2(_objectSpread2({}, theme), {}, {
@@ -10053,21 +10085,22 @@ var getTheme = function getTheme() {
10053
10085
  card: getCardTheme(theme),
10054
10086
  divider: getDividerTheme(theme),
10055
10087
  icon: getIconTheme(theme),
10056
- typography: getTypographyTheme(theme)
10088
+ typography: getTypographyTheme(theme),
10089
+ fab: getFABTheme(theme)
10057
10090
  }
10058
10091
  });
10059
10092
  };
10060
10093
 
10061
10094
  var theme = getTheme();
10062
10095
 
10063
- var _templateObject$4, _templateObject2$3, _templateObject3$2, _templateObject4$2;
10096
+ var _templateObject$6, _templateObject2$3, _templateObject3$2, _templateObject4$2;
10064
10097
  var BACKGROUND_INTENTS = {
10065
10098
  success: 'successBackground',
10066
10099
  warning: 'warningBackground',
10067
10100
  danger: 'dangerBackground',
10068
10101
  info: 'infoBackground'
10069
10102
  };
10070
- var StyledView = styled(View)(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n border-width: ", ";\n border-radius: ", ";\n padding: ", ";\n\n ", ";\n"])), function (_ref) {
10103
+ var StyledView = styled(View)(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n border-width: ", ";\n border-radius: ", ";\n padding: ", ";\n\n ", ";\n"])), function (_ref) {
10071
10104
  var theme = _ref.theme;
10072
10105
  return theme.__hd__.badge.borderWidths["default"];
10073
10106
  }, function (_ref2) {
@@ -10100,7 +10133,7 @@ var StyledText$1 = styled(Text$1)(_templateObject3$2 || (_templateObject3$2 = _t
10100
10133
  });
10101
10134
  });
10102
10135
 
10103
- var _excluded$2 = ["content", "intent", "style", "testID"];
10136
+ var _excluded$3 = ["content", "intent", "style", "testID"];
10104
10137
 
10105
10138
  var Badge = function Badge(_ref) {
10106
10139
  var content = _ref.content,
@@ -10108,7 +10141,7 @@ var Badge = function Badge(_ref) {
10108
10141
  intent = _ref$intent === void 0 ? 'info' : _ref$intent,
10109
10142
  style = _ref.style,
10110
10143
  testID = _ref.testID,
10111
- nativeProps = _objectWithoutProperties$1(_ref, _excluded$2);
10144
+ nativeProps = _objectWithoutProperties$1(_ref, _excluded$3);
10112
10145
 
10113
10146
  return /*#__PURE__*/React.createElement(StyledView, _extends$1({
10114
10147
  themeIntent: intent,
@@ -10119,8 +10152,8 @@ var Badge = function Badge(_ref) {
10119
10152
  }, content));
10120
10153
  };
10121
10154
 
10122
- var _templateObject$3;
10123
- var StyledCard = styled(View)(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n border-radius: ", ";\n padding: ", ";\n"])), function (_ref) {
10155
+ var _templateObject$5;
10156
+ var StyledCard = styled(View)(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n border-radius: ", ";\n padding: ", ";\n overflow: hidden;\n"])), function (_ref) {
10124
10157
  var theme = _ref.theme;
10125
10158
  return theme.__hd__.card.radii["default"];
10126
10159
  }, function (_ref2) {
@@ -10132,8 +10165,8 @@ var Card = function Card(props) {
10132
10165
  return /*#__PURE__*/React.createElement(StyledCard, props);
10133
10166
  };
10134
10167
 
10135
- var _templateObject$2, _templateObject2$2, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7$1, _templateObject8$1, _templateObject9$1, _templateObject10$1, _templateObject11, _templateObject12, _templateObject13;
10136
- var StyledDivider = styled(View)(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n border-bottom-width: ", ";\n border-bottom-color: ", ";\n max-width: 100%;\n\n ", "\n\n ", "\n"])), function (_ref) {
10168
+ var _templateObject$4, _templateObject2$2, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7$1, _templateObject8$1, _templateObject9$1, _templateObject10$1, _templateObject11, _templateObject12, _templateObject13;
10169
+ var StyledDivider = styled(View)(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n border-bottom-width: ", ";\n border-bottom-color: ", ";\n max-width: 100%;\n\n ", "\n\n ", "\n"])), function (_ref) {
10137
10170
  var theme = _ref.theme;
10138
10171
  return theme.__hd__.divider.borderWidths["default"];
10139
10172
  }, function (_ref2) {
@@ -10187,14 +10220,14 @@ var StyledDivider = styled(View)(_templateObject$2 || (_templateObject$2 = _tagg
10187
10220
  }
10188
10221
  });
10189
10222
 
10190
- var _excluded$1 = ["marginHorizontal", "marginVertical", "style", "testID"];
10223
+ var _excluded$2 = ["marginHorizontal", "marginVertical", "style", "testID"];
10191
10224
 
10192
10225
  var Divider = function Divider(_ref) {
10193
10226
  var marginHorizontal = _ref.marginHorizontal,
10194
10227
  marginVertical = _ref.marginVertical,
10195
10228
  style = _ref.style,
10196
10229
  testID = _ref.testID,
10197
- nativeProps = _objectWithoutProperties$1(_ref, _excluded$1);
10230
+ nativeProps = _objectWithoutProperties$1(_ref, _excluded$2);
10198
10231
 
10199
10232
  return /*#__PURE__*/React.createElement(StyledDivider, _extends$1({
10200
10233
  themeMarginHorizontal: marginHorizontal,
@@ -19832,9 +19865,9 @@ var heroIconConfig = {
19832
19865
  preferences: preferences
19833
19866
  };
19834
19867
 
19835
- var _templateObject$1, _templateObject2$1;
19868
+ var _templateObject$3, _templateObject2$1;
19836
19869
  var HeroIcon = dist.createIconSetFromIcoMoon(heroIconConfig, 'hero-icons', 'hero-icons.ttf');
19837
- var StyledHeroIcon = styled(HeroIcon)(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n ", ";\n"])), function (_ref) {
19870
+ var StyledHeroIcon = styled(HeroIcon)(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n ", ";\n"])), function (_ref) {
19838
19871
  var themeIntent = _ref.themeIntent,
19839
19872
  themeSize = _ref.themeSize;
19840
19873
  return css(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", "px;\n "])), function (_ref2) {
@@ -19863,8 +19896,8 @@ var Icon = function Icon(_ref) {
19863
19896
  });
19864
19897
  };
19865
19898
 
19866
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
19867
- var StyledText = styled(Text$1)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n ", "\n"])), function (_ref) {
19899
+ var _templateObject$2, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
19900
+ var StyledText = styled(Text$1)(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n ", "\n\n ", "\n\n ", "\n"])), function (_ref) {
19868
19901
  var themeFontSize = _ref.themeFontSize,
19869
19902
  theme = _ref.theme;
19870
19903
 
@@ -19908,7 +19941,7 @@ var StyledText = styled(Text$1)(_templateObject || (_templateObject = _taggedTem
19908
19941
  }
19909
19942
  });
19910
19943
 
19911
- var _excluded = ["children", "fontSize", "fontWeight", "intent"];
19944
+ var _excluded$1 = ["children", "fontSize", "fontWeight", "intent"];
19912
19945
 
19913
19946
  var Text = function Text(_ref) {
19914
19947
  var children = _ref.children,
@@ -19918,7 +19951,7 @@ var Text = function Text(_ref) {
19918
19951
  fontWeight = _ref$fontWeight === void 0 ? 'regular' : _ref$fontWeight,
19919
19952
  _ref$intent = _ref.intent,
19920
19953
  intent = _ref$intent === void 0 ? 'body' : _ref$intent,
19921
- nativeProps = _objectWithoutProperties$1(_ref, _excluded);
19954
+ nativeProps = _objectWithoutProperties$1(_ref, _excluded$1);
19922
19955
 
19923
19956
  return /*#__PURE__*/React.createElement(StyledText, _extends$1({
19924
19957
  themeFontSize: fontSize,
@@ -19931,4 +19964,80 @@ var Typography = {
19931
19964
  Text: Text
19932
19965
  };
19933
19966
 
19934
- export { Badge, Card, Divider, Icon, ThemeProvider, Typography, getTheme, theme, useTheme };
19967
+ var _templateObject$1;
19968
+ var StyledFABIcon = styled(Icon)(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: ", ";\n"])), function (_ref) {
19969
+ var theme = _ref.theme;
19970
+ return theme.__hd__.fab.colors.icon;
19971
+ }, function (_ref2) {
19972
+ var theme = _ref2.theme;
19973
+ return theme.__hd__.fab.fontSizes["default"];
19974
+ });
19975
+
19976
+ var _excluded = ["active"];
19977
+ var AnimatedIcons = Animated.createAnimatedComponent(StyledFABIcon);
19978
+
19979
+ var AnimatedFABIcon = function AnimatedFABIcon(_ref) {
19980
+ var active = _ref.active,
19981
+ iconProps = _objectWithoutProperties$1(_ref, _excluded);
19982
+
19983
+ var rotateAnimation = useRef(new Animated.Value(active ? 1 : 0));
19984
+ useEffect(function () {
19985
+ var animation = Animated.timing(rotateAnimation.current, {
19986
+ toValue: active ? 1 : 0,
19987
+ useNativeDriver: true
19988
+ });
19989
+ animation.start();
19990
+ return function () {
19991
+ animation.stop();
19992
+ };
19993
+ }, [active]);
19994
+ var interpolatedRotateAnimation = rotateAnimation.current.interpolate({
19995
+ inputRange: [0, 1],
19996
+ outputRange: ['0deg', '-45deg']
19997
+ });
19998
+ return /*#__PURE__*/React.createElement(Animated.View, {
19999
+ style: StyleSheet$1.flatten([{
20000
+ transform: [{
20001
+ rotate: interpolatedRotateAnimation
20002
+ }]
20003
+ }])
20004
+ }, /*#__PURE__*/React.createElement(AnimatedIcons, iconProps));
20005
+ };
20006
+
20007
+ var _templateObject;
20008
+ var StyledFABContainer = styled(TouchableHighlight)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", ";\n width: ", ";\n background-color: ", ";\n border-radius: 999px;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n"])), function (_ref) {
20009
+ var theme = _ref.theme;
20010
+ return theme.__hd__.fab.sizes.height;
20011
+ }, function (_ref2) {
20012
+ var theme = _ref2.theme;
20013
+ return theme.__hd__.fab.sizes.width;
20014
+ }, function (_ref3) {
20015
+ var theme = _ref3.theme;
20016
+ return theme.__hd__.fab.colors.buttonBackground;
20017
+ });
20018
+
20019
+ var FAB = function FAB(_ref) {
20020
+ var _onPress = _ref.onPress,
20021
+ icon = _ref.icon,
20022
+ animated = _ref.animated,
20023
+ testID = _ref.testID,
20024
+ active = _ref.active,
20025
+ style = _ref.style;
20026
+ return /*#__PURE__*/React.createElement(StyledFABContainer, {
20027
+ testID: testID,
20028
+ onPress: function onPress() {
20029
+ _onPress === null || _onPress === void 0 ? void 0 : _onPress();
20030
+ },
20031
+ activeOpacity: 0.6,
20032
+ style: style
20033
+ }, animated ? /*#__PURE__*/React.createElement(AnimatedFABIcon, {
20034
+ active: active,
20035
+ icon: icon,
20036
+ testID: "animatedFABIcon"
20037
+ }) : /*#__PURE__*/React.createElement(StyledFABIcon, {
20038
+ icon: icon,
20039
+ testID: "styledFABIcon"
20040
+ }));
20041
+ };
20042
+
20043
+ export { Badge, Card, Divider, FAB, Icon, ThemeProvider, Typography, getTheme, scale, theme, useTheme };