@comicrelief/component-library 8.15.0 → 8.16.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.
package/.prettierrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "singleQuote": true
3
+ }
@@ -21,9 +21,10 @@ const Label = _styledComponents.default.label.withConfig({
21
21
  return hasLabelAsString && 'align-items: center;';
22
22
  }, _ref2 => {
23
23
  let {
24
+ theme,
24
25
  labelColour
25
26
  } = _ref2;
26
- return labelColour && "color: ".concat(labelColour, ";");
27
+ return labelColour && "color: ".concat(theme.color(labelColour));
27
28
  });
28
29
  const StyledCheckboxInput = _styledComponents.default.input.attrs({
29
30
  type: 'checkbox'
@@ -57,9 +58,9 @@ const StyledCheckboxInput = _styledComponents.default.input.attrs({
57
58
  }, _ref7 => {
58
59
  let {
59
60
  theme,
60
- checkboxBorderChecked
61
+ checkboxBorderFocus
61
62
  } = _ref7;
62
- return checkboxBorderChecked ? theme.color(checkboxBorderChecked) : theme.color('red');
63
+ return checkboxBorderFocus ? theme.color(checkboxBorderFocus) : theme.color('red');
63
64
  });
64
65
  const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
65
66
  let {
@@ -71,6 +72,7 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
71
72
  checkboxBorder,
72
73
  checkboxBgChecked,
73
74
  checkboxBorderChecked,
75
+ checkboxBorderFocus,
74
76
  ...rest
75
77
  } = _ref8;
76
78
  return /*#__PURE__*/_react.default.createElement(Label, {
@@ -82,7 +84,8 @@ const Checkbox = /*#__PURE__*/_react.default.forwardRef((_ref8, ref) => {
82
84
  checkboxBg: checkboxBg,
83
85
  checkboxBorder: checkboxBorder,
84
86
  checkboxBgChecked: checkboxBgChecked,
85
- checkboxBorderChecked: checkboxBorderChecked
87
+ checkboxBorderChecked: checkboxBorderChecked,
88
+ checkboxBorderFocus: checkboxBorderFocus
86
89
  })), /*#__PURE__*/_react.default.createElement("span", null), label ? /*#__PURE__*/_react.default.createElement(_Text.default, {
87
90
  weight: "bold"
88
91
  }, label) : children);
@@ -96,6 +99,7 @@ Checkbox.propTypes = {
96
99
  checkboxBg: _propTypes.default.string,
97
100
  checkboxBorder: _propTypes.default.string,
98
101
  checkboxBgChecked: _propTypes.default.string,
99
- checkboxBorderChecked: _propTypes.default.string
102
+ checkboxBorderChecked: _propTypes.default.string,
103
+ checkboxBorderFocus: _propTypes.default.string
100
104
  };
101
105
  var _default = exports.default = Checkbox;
@@ -31,11 +31,12 @@ const LongLabel = () => (
31
31
  name="sport"
32
32
  value="Football"
33
33
  label="Tennis (with wacky styling to test props)"
34
- labelColour="pink"
35
- checkboxBg="red"
36
- checkboxBorder="blue"
34
+ labelColour="purple_dark"
35
+ checkboxBg="white"
36
+ checkboxBorder="black"
37
37
  checkboxBgChecked="green"
38
- checkboxBorderChecked="red"
38
+ checkboxBorderChecked="green"
39
+ checkboxBorderFocus="blue"
39
40
  />
40
41
  <br/>
41
42
  <p>A checkbox with a long label containing links</p>
@@ -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
@@ -127,6 +127,17 @@ const Item = styled.div`
127
127
  </Card>
128
128
  </Item>
129
129
 
130
+ <Item>
131
+ <Card backgroundColor="grey_4" height="auto">
132
+ <Text tag="h3" color="white" size="xs">
133
+ grey_4
134
+ </Text>
135
+ <Text color="white" tag="p">
136
+ #6E6E6E
137
+ </Text>
138
+ </Card>
139
+ </Item>
140
+
130
141
  <Item>
131
142
  <Card backgroundColor="grey_dark" height="auto">
132
143
  <Text tag="h3" color="white" size="xs">
@@ -330,7 +341,7 @@ const Item = styled.div`
330
341
  <Item>
331
342
  <Card backgroundColor="blue_donate" height="auto">
332
343
  <Text tag="h3" color="white" size="xs">
333
- Blue Donate
344
+ blue_donate
334
345
  </Text>
335
346
  <Text tag="p" color="white">#2042AD</Text>
336
347
  </Card>
@@ -339,7 +350,7 @@ const Item = styled.div`
339
350
  <Item>
340
351
  <Card backgroundColor="blue_donate_interact" height="auto">
341
352
  <Text tag="h3" color="white" size="xs">
342
- Blue Donate Interact
353
+ blue_donate_interact
343
354
  </Text>
344
355
  <Text tag="p" color="white">#001A85</Text>
345
356
  </Card>
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.1",
5
5
  "main": "dist/index.js",
6
6
  "license": "ISC",
7
7
  "jest": {
@@ -10,7 +10,7 @@ const Label = styled.label`
10
10
  display: flex;
11
11
  ${({ hasLabelAsString }) => hasLabelAsString && 'align-items: center;'}
12
12
  margin-bottom: 8px;
13
- ${({ labelColour }) => labelColour && `color: ${labelColour};`}
13
+ ${({ theme, labelColour }) => labelColour && `color: ${theme.color(labelColour)}`}
14
14
  `;
15
15
 
16
16
  const StyledCheckboxInput = styled.input.attrs({ type: 'checkbox' })`
@@ -38,7 +38,7 @@ const StyledCheckboxInput = styled.input.attrs({ type: 'checkbox' })`
38
38
  }
39
39
  /* Visual checkbox when focused */
40
40
  :focus + span {
41
- border: 1px solid ${({ theme, checkboxBorderChecked }) => (checkboxBorderChecked ? theme.color(checkboxBorderChecked) : theme.color('red'))};
41
+ border: 1px solid ${({ theme, checkboxBorderFocus }) => (checkboxBorderFocus ? theme.color(checkboxBorderFocus) : theme.color('red'))};
42
42
  }
43
43
  `;
44
44
 
@@ -51,6 +51,7 @@ const Checkbox = React.forwardRef(({
51
51
  checkboxBorder,
52
52
  checkboxBgChecked,
53
53
  checkboxBorderChecked,
54
+ checkboxBorderFocus,
54
55
  ...rest
55
56
  }, ref) => (
56
57
  <Label
@@ -65,6 +66,7 @@ const Checkbox = React.forwardRef(({
65
66
  checkboxBorder={checkboxBorder}
66
67
  checkboxBgChecked={checkboxBgChecked}
67
68
  checkboxBorderChecked={checkboxBorderChecked}
69
+ checkboxBorderFocus={checkboxBorderFocus}
68
70
  />
69
71
  <span />
70
72
  {label ? <Text weight="bold">{label}</Text> : children}
@@ -80,7 +82,8 @@ Checkbox.propTypes = {
80
82
  checkboxBg: PropTypes.string,
81
83
  checkboxBorder: PropTypes.string,
82
84
  checkboxBgChecked: PropTypes.string,
83
- checkboxBorderChecked: PropTypes.string
85
+ checkboxBorderChecked: PropTypes.string,
86
+ checkboxBorderFocus: PropTypes.string
84
87
  };
85
88
 
86
89
  export default Checkbox;
@@ -31,11 +31,12 @@ const LongLabel = () => (
31
31
  name="sport"
32
32
  value="Football"
33
33
  label="Tennis (with wacky styling to test props)"
34
- labelColour="pink"
35
- checkboxBg="red"
36
- checkboxBorder="blue"
34
+ labelColour="purple_dark"
35
+ checkboxBg="white"
36
+ checkboxBorder="black"
37
37
  checkboxBgChecked="green"
38
- checkboxBorderChecked="red"
38
+ checkboxBorderChecked="green"
39
+ checkboxBorderFocus="blue"
39
40
  />
40
41
  <br/>
41
42
  <p>A checkbox with a long label containing links</p>
@@ -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
  }}
@@ -127,6 +127,17 @@ const Item = styled.div`
127
127
  </Card>
128
128
  </Item>
129
129
 
130
+ <Item>
131
+ <Card backgroundColor="grey_4" height="auto">
132
+ <Text tag="h3" color="white" size="xs">
133
+ grey_4
134
+ </Text>
135
+ <Text color="white" tag="p">
136
+ #6E6E6E
137
+ </Text>
138
+ </Card>
139
+ </Item>
140
+
130
141
  <Item>
131
142
  <Card backgroundColor="grey_dark" height="auto">
132
143
  <Text tag="h3" color="white" size="xs">
@@ -330,7 +341,7 @@ const Item = styled.div`
330
341
  <Item>
331
342
  <Card backgroundColor="blue_donate" height="auto">
332
343
  <Text tag="h3" color="white" size="xs">
333
- Blue Donate
344
+ blue_donate
334
345
  </Text>
335
346
  <Text tag="p" color="white">#2042AD</Text>
336
347
  </Card>
@@ -339,7 +350,7 @@ const Item = styled.div`
339
350
  <Item>
340
351
  <Card backgroundColor="blue_donate_interact" height="auto">
341
352
  <Text tag="h3" color="white" size="xs">
342
- Blue Donate Interact
353
+ blue_donate_interact
343
354
  </Text>
344
355
  <Text tag="p" color="white">#001A85</Text>
345
356
  </Card>