@comicrelief/component-library 8.15.0 → 8.16.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.
package/.prettierrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "singleQuote": true
3
+ }
@@ -13,18 +13,17 @@ var _allBreakpoints = require("../../../theme/shared/allBreakpoints");
13
13
  const BaseText = exports.BaseText = _styledComponents.default.span.withConfig({
14
14
  displayName: "Text__BaseText",
15
15
  componentId: "sc-1snl0ya-0"
16
- })(["color:", ";font-size:", ";line-height:", ";text-transform:", ";", ";", ";", ";font-family:", ";", ";", ";", ";", ";"], _ref => {
16
+ })(["", ";color:", ";font-size:", ";line-height:", ";text-transform:", ";", ";", ";", ";font-family:", ";", ";", ";", ";", ";"], _ref => {
17
17
  let {
18
- color,
19
- theme
18
+ textAlign
20
19
  } = _ref;
21
- return color ? theme.color(color) : 'inherit';
20
+ return textAlign && "text-align: ".concat(textAlign);
22
21
  }, _ref2 => {
23
22
  let {
24
- size,
23
+ color,
25
24
  theme
26
25
  } = _ref2;
27
- return theme.fontSize(size);
26
+ return color ? theme.color(color) : 'inherit';
28
27
  }, _ref3 => {
29
28
  let {
30
29
  size,
@@ -33,59 +32,65 @@ const BaseText = exports.BaseText = _styledComponents.default.span.withConfig({
33
32
  return theme.fontSize(size);
34
33
  }, _ref4 => {
35
34
  let {
36
- uppercase
35
+ size,
36
+ theme
37
37
  } = _ref4;
38
- return uppercase ? 'uppercase' : 'inherit';
38
+ return theme.fontSize(size);
39
39
  }, _ref5 => {
40
40
  let {
41
- weight
41
+ uppercase
42
42
  } = _ref5;
43
- return weight ? "font-weight: ".concat(weight) : null;
43
+ return uppercase ? 'uppercase' : 'inherit';
44
44
  }, _ref6 => {
45
45
  let {
46
- height
46
+ weight
47
47
  } = _ref6;
48
- return height ? "line-height: ".concat(height) : null;
48
+ return weight ? "font-weight: ".concat(weight) : null;
49
49
  }, _ref7 => {
50
50
  let {
51
- as
51
+ height
52
52
  } = _ref7;
53
- return as === 'p' || as === 'span' ? 'line-height: normal;' : null;
53
+ return height ? "line-height: ".concat(height) : null;
54
54
  }, _ref8 => {
55
+ let {
56
+ as
57
+ } = _ref8;
58
+ return as === 'p' || as === 'span' ? 'line-height: normal;' : null;
59
+ }, _ref9 => {
55
60
  let {
56
61
  family,
57
62
  theme
58
- } = _ref8;
63
+ } = _ref9;
59
64
  return family ? theme.fontFamilies(family) : theme.fontFamilies(theme.font.regular);
60
- }, _ref9 => {
65
+ }, _ref10 => {
61
66
  let {
62
67
  family
63
- } = _ref9;
68
+ } = _ref10;
64
69
  return family === 'Anton' ? 'letter-spacing: 0.03rem' : null;
65
- }, _ref10 => {
70
+ }, _ref11 => {
66
71
  let {
67
72
  size,
68
73
  theme
69
- } = _ref10;
74
+ } = _ref11;
70
75
  return size === 'super' ? (0, _styledComponents.css)(["font-size:", ";line-height:3rem;@media ", "{font-size:", ";line-height:", ";margin-bottom:2rem;}@media ", "{font-size:", ";line-height:", ";margin-bottom:2rem;}"], theme.fontSize('xxl'), theme.allBreakpoints('M'), theme.fontSize('big'), theme.fontSize('big'), theme.allBreakpoints('L'), theme.fontSize('super'), theme.fontSize('super')) : null;
71
- }, _ref11 => {
76
+ }, _ref12 => {
72
77
  let {
73
78
  mobileColor,
74
79
  theme
75
- } = _ref11;
80
+ } = _ref12;
76
81
  return mobileColor && (0, _styledComponents.css)(["@media (max-width:", "px){color:", ";}"], _allBreakpoints.breakpointValues.L - 1, theme.color(mobileColor));
77
- }, _ref12 => {
82
+ }, _ref13 => {
78
83
  let {
79
84
  size,
80
85
  theme
81
- } = _ref12;
86
+ } = _ref13;
82
87
  return size === 'm' ? (0, _styledComponents.css)(["font-size:", ";@media ", "{font-size:", ";}"], theme.fontSize('s'), theme.allBreakpoints('M'), theme.fontSize('m')) : null;
83
88
  });
84
89
 
85
90
  /** Text renders different elements based on the `tag` prop
86
91
  * Weight is checked for existence to prevent overriding the tag's css
87
92
  */
88
- const Text = _ref13 => {
93
+ const Text = _ref14 => {
89
94
  let {
90
95
  tag = 'span',
91
96
  size = 's',
@@ -96,8 +101,9 @@ const Text = _ref13 => {
96
101
  weight = undefined,
97
102
  family = null,
98
103
  mobileColor = null,
104
+ textAlign = null,
99
105
  ...rest
100
- } = _ref13;
106
+ } = _ref14;
101
107
  return /*#__PURE__*/_react.default.createElement(BaseText, Object.assign({}, rest, {
102
108
  as: tag,
103
109
  color: color,
@@ -106,7 +112,8 @@ const Text = _ref13 => {
106
112
  height: height,
107
113
  weight: weight,
108
114
  family: family,
109
- mobileColor: mobileColor
115
+ mobileColor: mobileColor,
116
+ textAlign: textAlign
110
117
  }), children);
111
118
  };
112
119
  var _default = exports.default = Text;
@@ -105,8 +105,8 @@ Sport Relief
105
105
  <Text tag="h4" family="Founders_bold" uppercase size="xl">
106
106
  Heading 4
107
107
  </Text>
108
- <Text tag="h4" family="Founders_bold" uppercase size="l">
109
- Heading 5
108
+ <Text tag="h4" family="Founders_bold" uppercase size="l" textAlign="center">
109
+ Heading 5, textAlign prop
110
110
  </Text>
111
111
  <Text tag="p" family="Founders" size="m">
112
112
  Body 1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/component-library",
3
3
  "author": "Comic Relief Engineering Team",
4
- "version": "8.15.0",
4
+ "version": "8.16.0",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -5,6 +5,7 @@ import { breakpointValues } from '../../../theme/shared/allBreakpoints';
5
5
 
6
6
  /** Text component */
7
7
  export const BaseText = styled.span`
8
+ ${({ textAlign }) => textAlign && `text-align: ${textAlign}`};
8
9
  color: ${({ color, theme }) => (color ? theme.color(color) : 'inherit')};
9
10
  font-size: ${({ size, theme }) => theme.fontSize(size)};
10
11
  line-height: ${({ size, theme }) => theme.fontSize(size)};
@@ -51,7 +52,17 @@ export const BaseText = styled.span`
51
52
  * Weight is checked for existence to prevent overriding the tag's css
52
53
  */
53
54
  const Text = ({
54
- tag = 'span', size = 's', color = 'inherit', children = undefined, uppercase = false, height = undefined, weight = undefined, family = null, mobileColor = null, ...rest
55
+ tag = 'span',
56
+ size = 's',
57
+ color = 'inherit',
58
+ children = undefined,
59
+ uppercase = false,
60
+ height = undefined,
61
+ weight = undefined,
62
+ family = null,
63
+ mobileColor = null,
64
+ textAlign = null,
65
+ ...rest
55
66
  }) => (
56
67
  <BaseText
57
68
  {...rest}
@@ -63,12 +74,15 @@ const Text = ({
63
74
  weight={weight}
64
75
  family={family}
65
76
  mobileColor={mobileColor}
77
+ textAlign={textAlign}
66
78
  >
67
79
  {children}
68
80
  </BaseText>
69
81
  );
70
82
 
71
83
  Text.propTypes = {
84
+ /** Text Align */
85
+ textAlign: PropTypes.string,
72
86
  /** Font family */
73
87
  family: PropTypes.string,
74
88
  /** Font weight */
@@ -105,8 +105,8 @@ Sport Relief
105
105
  <Text tag="h4" family="Founders_bold" uppercase size="xl">
106
106
  Heading 4
107
107
  </Text>
108
- <Text tag="h4" family="Founders_bold" uppercase size="l">
109
- Heading 5
108
+ <Text tag="h4" family="Founders_bold" uppercase size="l" textAlign="center">
109
+ Heading 5, textAlign prop
110
110
  </Text>
111
111
  <Text tag="p" family="Founders" size="m">
112
112
  Body 1
@@ -6,7 +6,7 @@ import SearchInput from './SearchInput';
6
6
  it('renders correctly', () => {
7
7
  const tree = renderWithTheme(
8
8
  <SearchInput
9
- onChange={e => {
9
+ onChange={(e) => {
10
10
  e.preventDefault();
11
11
  return e.target.value;
12
12
  }}