@sproutsocial/racine 12.5.0 → 12.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 12.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2a6861c: Adds size props and common system-props to the partner logo component
8
+
3
9
  ## 12.5.0
4
10
 
5
11
  ### Minor Changes
@@ -1,17 +1,44 @@
1
- // @flow strict-local
1
+ // @flow
2
2
  import React from "react";
3
3
  import logoViewBoxes from "../LogoViewBoxes";
4
4
  import type { TypePartnerNames } from "./TypePartnerNames";
5
5
  import { useTheme } from "styled-components";
6
+ import styled, { type StyledComponent } from "styled-components";
7
+ import { COMMON, FLEXBOX } from "../utils/system-props";
8
+ import type {
9
+ TypeSystemCommonProps,
10
+ TypeSystemFlexboxProps,
11
+ } from "../types/system-props.flow";
12
+ import type { TypeTheme } from "../types/theme.flow";
13
+
14
+ type TypeSystemProps = {|
15
+ ...TypeSystemCommonProps,
16
+ ...TypeSystemFlexboxProps,
17
+ |};
18
+
19
+ type TypeStyledSVG = StyledComponent<TypeSystemProps, TypeTheme, *>;
20
+
21
+ const StyledSVG: TypeStyledSVG = styled.svg`
22
+ ${FLEXBOX};
23
+ ${COMMON}
24
+ `;
6
25
 
7
26
  type TypeProps = {
8
27
  /** The name of the partner whose logo you want to render. */
9
28
  partnerName: TypePartnerNames,
10
29
  /** Manually override the default mode behavior by rendering a logo based on the background it's displayed on. */
11
30
  backgroundType?: "dark" | "light",
31
+ height?: string,
32
+ width?: string,
12
33
  };
13
34
 
14
- const PartnerLogo = ({ partnerName, backgroundType }: TypeProps) => {
35
+ const PartnerLogo = ({
36
+ partnerName,
37
+ backgroundType,
38
+ height,
39
+ width,
40
+ ...rest
41
+ }: TypeProps) => {
15
42
  const { mode } = useTheme();
16
43
  const whichLogo = (type) => {
17
44
  if (type && type === "dark") {
@@ -25,14 +52,24 @@ const PartnerLogo = ({ partnerName, backgroundType }: TypeProps) => {
25
52
  }
26
53
  };
27
54
  const logoViewBox = logoViewBoxes[whichLogo(backgroundType)];
55
+ const viewBoxCoordinates = logoViewBox?.split(" ") || [];
56
+ const defaultWidth = viewBoxCoordinates[2];
57
+ const defaultHeight = viewBoxCoordinates[3];
28
58
 
29
59
  return (
30
- <svg viewBox={logoViewBox} focusable={false}>
60
+ <StyledSVG
61
+ width={width ? width : defaultWidth}
62
+ height={height ? height : defaultHeight}
63
+ viewBox={logoViewBox}
64
+ focusable={false}
65
+ // $FlowIssue - upgrade v0.112.0
66
+ {...rest}
67
+ >
31
68
  <use
32
69
  xmlnsXlink="http://www.w3.org/1999/xlink"
33
70
  xlinkHref={`#sslogosvg-${whichLogo(backgroundType)}`}
34
71
  />
35
- </svg>
72
+ </StyledSVG>
36
73
  );
37
74
  };
38
75
 
@@ -71,3 +71,20 @@ ModeOverride.args = {
71
71
  ModeOverride.story = {
72
72
  name: "Mode override",
73
73
  };
74
+
75
+ export const LogoLayout = (args) => (
76
+ <Box display="flex" alignItems="center">
77
+ <PartnerLogo partnerName="facebook" height="40" width="40" mr={400} />
78
+ <PartnerLogo
79
+ partnerName="microsoft-dynamics"
80
+ height="40"
81
+ width="40"
82
+ mr={400}
83
+ />
84
+ <PartnerLogo partnerName="zendesk" />
85
+ </Box>
86
+ );
87
+
88
+ LogoLayout.story = {
89
+ name: "Layout and size",
90
+ };
@@ -7,13 +7,33 @@ var _react = _interopRequireDefault(require("react"));
7
7
 
8
8
  var _LogoViewBoxes = _interopRequireDefault(require("../LogoViewBoxes"));
9
9
 
10
- var _styledComponents = require("styled-components");
10
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
+
12
+ var _systemProps = require("../utils/system-props");
13
+
14
+ var _excluded = ["partnerName", "backgroundType", "height", "width"];
15
+
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
+
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
19
 
12
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
21
 
22
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
+
24
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25
+
26
+ var StyledSVG = _styledComponents.default.svg.withConfig({
27
+ displayName: "PartnerLogo__StyledSVG",
28
+ componentId: "sc-ivi11w-0"
29
+ })(["", ";", ""], _systemProps.FLEXBOX, _systemProps.COMMON);
30
+
14
31
  var PartnerLogo = function PartnerLogo(_ref) {
15
32
  var partnerName = _ref.partnerName,
16
- backgroundType = _ref.backgroundType;
33
+ backgroundType = _ref.backgroundType,
34
+ height = _ref.height,
35
+ width = _ref.width,
36
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
17
37
 
18
38
  var _useTheme = (0, _styledComponents.useTheme)(),
19
39
  mode = _useTheme.mode;
@@ -32,10 +52,16 @@ var PartnerLogo = function PartnerLogo(_ref) {
32
52
 
33
53
  var logoViewBox = _LogoViewBoxes.default[whichLogo(backgroundType)];
34
54
 
35
- return /*#__PURE__*/_react.default.createElement("svg", {
55
+ var viewBoxCoordinates = (logoViewBox == null ? void 0 : logoViewBox.split(" ")) || [];
56
+ var defaultWidth = viewBoxCoordinates[2];
57
+ var defaultHeight = viewBoxCoordinates[3];
58
+ return /*#__PURE__*/_react.default.createElement(StyledSVG, _extends({
59
+ width: width ? width : defaultWidth,
60
+ height: height ? height : defaultHeight,
36
61
  viewBox: logoViewBox,
37
- focusable: false
38
- }, /*#__PURE__*/_react.default.createElement("use", {
62
+ focusable: false // $FlowIssue - upgrade v0.112.0
63
+
64
+ }, rest), /*#__PURE__*/_react.default.createElement("use", {
39
65
  xmlnsXlink: "http://www.w3.org/1999/xlink",
40
66
  xlinkHref: "#sslogosvg-" + whichLogo(backgroundType)
41
67
  }));
@@ -1,10 +1,25 @@
1
+ var _excluded = ["partnerName", "backgroundType", "height", "width"];
2
+
3
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+
1
7
  import React from "react";
2
8
  import logoViewBoxes from "../LogoViewBoxes";
3
9
  import { useTheme } from "styled-components";
10
+ import styled from "styled-components";
11
+ import { COMMON, FLEXBOX } from "../utils/system-props";
12
+ var StyledSVG = styled.svg.withConfig({
13
+ displayName: "PartnerLogo__StyledSVG",
14
+ componentId: "sc-ivi11w-0"
15
+ })(["", ";", ""], FLEXBOX, COMMON);
4
16
 
5
17
  var PartnerLogo = function PartnerLogo(_ref) {
6
18
  var partnerName = _ref.partnerName,
7
- backgroundType = _ref.backgroundType;
19
+ backgroundType = _ref.backgroundType,
20
+ height = _ref.height,
21
+ width = _ref.width,
22
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
8
23
 
9
24
  var _useTheme = useTheme(),
10
25
  mode = _useTheme.mode;
@@ -22,10 +37,16 @@ var PartnerLogo = function PartnerLogo(_ref) {
22
37
  };
23
38
 
24
39
  var logoViewBox = logoViewBoxes[whichLogo(backgroundType)];
25
- return /*#__PURE__*/React.createElement("svg", {
40
+ var viewBoxCoordinates = (logoViewBox == null ? void 0 : logoViewBox.split(" ")) || [];
41
+ var defaultWidth = viewBoxCoordinates[2];
42
+ var defaultHeight = viewBoxCoordinates[3];
43
+ return /*#__PURE__*/React.createElement(StyledSVG, _extends({
44
+ width: width ? width : defaultWidth,
45
+ height: height ? height : defaultHeight,
26
46
  viewBox: logoViewBox,
27
- focusable: false
28
- }, /*#__PURE__*/React.createElement("use", {
47
+ focusable: false // $FlowIssue - upgrade v0.112.0
48
+
49
+ }, rest), /*#__PURE__*/React.createElement("use", {
29
50
  xmlnsXlink: "http://www.w3.org/1999/xlink",
30
51
  xlinkHref: "#sslogosvg-" + whichLogo(backgroundType)
31
52
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/racine",
3
- "version": "12.5.0",
3
+ "version": "12.6.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "__flow__",