@sproutsocial/racine 8.1.0-avatar-update-beta.0 → 8.2.0-link-styles-beta.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.
@@ -1,11 +1,7 @@
1
1
  // @flow
2
2
  import * as React from "react";
3
3
  import { useState, useCallback, useMemo, memo } from "react";
4
- import styled, { css, type StyledComponent } from "styled-components";
5
- import classnames from "classnames";
6
-
7
- import type { TypeTheme } from "../types/theme.flow";
8
-
4
+ import styled from "styled-components";
9
5
  import Box from "../Box";
10
6
  import Image from "../Image";
11
7
  import Text from "../Text";
@@ -17,24 +13,11 @@ export type TypeProps = {
17
13
  name: string,
18
14
  /** URL of the avatar image. If a URL is not provided, the component will fall back to showing the user's initials */
19
15
  src?: string,
20
- type?: "neutral" | "purple" | "green" | "blue" | "yellow" | "red" | "orange",
21
- variant?: "dark" | "light",
22
- bg?: string,
23
- color?: string,
24
16
  size?: string,
25
17
  };
26
18
 
27
19
  const AvatarText = styled(({ fontSize, ...rest }) => <Text {...rest} />)`
28
20
  font-size: ${(props) => props.fontSize}px;
29
- color: ${(props) => props.color}px;
30
- `;
31
- const Container: StyledComponent<any, TypeTheme, *> = styled(Box)`
32
- ${({ theme, type, variant, bg }) => css`
33
- color: ${theme.colors[type][variant === "dark" ? "200" : "900"]};
34
- background: ${bg
35
- ? bg
36
- : theme.colors[type][variant === "dark" ? "900" : "200"]};
37
- `}
38
21
  `;
39
22
 
40
23
  const getInitials = (name: string, fallback: string = "?"): string => {
@@ -51,11 +34,7 @@ export const Avatar = ({
51
34
  appearance = "circle",
52
35
  name,
53
36
  src,
54
- variant = "light",
55
- type = "neutral",
56
37
  size = "40px",
57
- bg,
58
- color,
59
38
  ...rest
60
39
  }: TypeProps) => {
61
40
  const [imageFailedLoading, setImageFailedLoading] = useState(false);
@@ -69,8 +48,7 @@ export const Avatar = ({
69
48
  const fontSize = Math.floor(Number(size.replace("px", "")) * 0.4);
70
49
 
71
50
  return (
72
- <Container
73
- className={classnames(variant)}
51
+ <Box
74
52
  size={size}
75
53
  overflow="hidden"
76
54
  borderRadius={appearance === "leaf" ? "40% 0 40% 0" : "50%"}
@@ -80,20 +58,13 @@ export const Avatar = ({
80
58
  justifyContent="center"
81
59
  alignItems="center"
82
60
  title={name}
83
- bg={bg}
84
- variant={variant}
85
- type={type}
61
+ bg="neutral.200"
86
62
  data-qa-user-avatar={name}
87
63
  // $FlowIssue - upgrade v0.112.0
88
64
  {...rest}
89
65
  >
90
66
  {!src || imageFailedLoading ? (
91
- <AvatarText
92
- lineHeight={size}
93
- fontWeight="semibold"
94
- fontSize={fontSize}
95
- color={color}
96
- >
67
+ <AvatarText lineHeight={size} fontWeight="semibold" fontSize={fontSize}>
97
68
  {initials}
98
69
  </AvatarText>
99
70
  ) : (
@@ -106,7 +77,7 @@ export const Avatar = ({
106
77
  m={0}
107
78
  />
108
79
  )}
109
- </Container>
80
+ </Box>
110
81
  );
111
82
  };
112
83
 
@@ -11,35 +11,6 @@ defaultStory.story = {
11
11
  name: "Default",
12
12
  };
13
13
 
14
- export const customColors = () => (
15
- <Avatar name="Joe Smith" bg="purple.500" color="red.200" />
16
- );
17
-
18
- customColors.story = {
19
- name: "Override colors",
20
- };
21
-
22
- export const withVariants = () => (
23
- <div display="inline-block">
24
- <Avatar mt={5} name="Kent C. Dodds" type="neutral" variant="dark" />
25
- <Avatar mt={5} name="Kent C. Dodds" type="neutral" variant="light" />
26
- <Avatar mt={5} name="Kent C. Dodds" type="green" variant="dark" />
27
- <Avatar mt={5} name="Kent C. Dodds" type="green" variant="light" />
28
- <Avatar mt={5} name="Kent C. Dodds" type="purple" variant="dark" />
29
- <Avatar mt={5} name="Kent C. Dodds" type="purple" variant="light" />
30
- <Avatar mt={5} name="Kent C. Dodds" type="red" variant="light" />
31
- <Avatar mt={5} name="Kent C. Dodds" type="red" variant="dark" />
32
- <Avatar mt={5} name="Kent C. Dodds" type="yellow" variant="light" />
33
- <Avatar mt={5} name="Kent C. Dodds" type="yellow" variant="dark" />
34
- <Avatar mt={5} name="Kent C. Dodds" type="blue" variant="light" />
35
- <Avatar mt={5} name="Kent C. Dodds" type="blue" variant="dark" />
36
- </div>
37
- );
38
-
39
- withVariants.story = {
40
- name: "With color types",
41
- };
42
-
43
14
  export const withImage = () => (
44
15
  <Avatar name="Kent C. Dodds" src="https://github.com/kentcdodds.png" />
45
16
  );
@@ -2,7 +2,7 @@
2
2
  import styled, { css } from "styled-components";
3
3
  import { focusRing, disabled } from "../utils/mixins";
4
4
  import Text from "../Text";
5
- import { TYPOGRAPHY, COMMON } from "../utils/system-props";
5
+ import { TYPOGRAPHY, COMMON, FLEXBOX } from "../utils/system-props";
6
6
 
7
7
  import type { TypeTheme } from "../types/theme.flow";
8
8
 
@@ -48,6 +48,7 @@ const Container = styled<typeof Text, TypeTheme, any>(Text)`
48
48
 
49
49
  ${COMMON}
50
50
  ${TYPOGRAPHY}
51
+ ${FLEXBOX}
51
52
  `;
52
53
 
53
54
  export default Container;
@@ -5,9 +5,7 @@ exports.default = exports.Avatar = void 0;
5
5
 
6
6
  var React = _interopRequireWildcard(require("react"));
7
7
 
8
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
-
10
- var _classnames = _interopRequireDefault(require("classnames"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
11
9
 
12
10
  var _Box = _interopRequireDefault(require("../Box"));
13
11
 
@@ -33,20 +31,8 @@ var AvatarText = (0, _styledComponents.default)(function (_ref) {
33
31
  }).withConfig({
34
32
  displayName: "Avatar__AvatarText",
35
33
  componentId: "yx873f-0"
36
- })(["font-size:", "px;color:", "px;"], function (props) {
34
+ })(["font-size:", "px;"], function (props) {
37
35
  return props.fontSize;
38
- }, function (props) {
39
- return props.color;
40
- });
41
- var Container = (0, _styledComponents.default)(_Box.default).withConfig({
42
- displayName: "Avatar__Container",
43
- componentId: "yx873f-1"
44
- })(["", ""], function (_ref2) {
45
- var theme = _ref2.theme,
46
- type = _ref2.type,
47
- variant = _ref2.variant,
48
- bg = _ref2.bg;
49
- return (0, _styledComponents.css)(["color:", ";background:", ";"], theme.colors[type][variant === "dark" ? "200" : "900"], bg ? bg : theme.colors[type][variant === "dark" ? "900" : "200"]);
50
36
  });
51
37
 
52
38
  var getInitials = function getInitials(name, fallback) {
@@ -62,20 +48,14 @@ var getInitials = function getInitials(name, fallback) {
62
48
  .join("");
63
49
  };
64
50
 
65
- var Avatar = function Avatar(_ref3) {
66
- var _ref3$appearance = _ref3.appearance,
67
- appearance = _ref3$appearance === void 0 ? "circle" : _ref3$appearance,
68
- name = _ref3.name,
69
- src = _ref3.src,
70
- _ref3$variant = _ref3.variant,
71
- variant = _ref3$variant === void 0 ? "light" : _ref3$variant,
72
- _ref3$type = _ref3.type,
73
- type = _ref3$type === void 0 ? "neutral" : _ref3$type,
74
- _ref3$size = _ref3.size,
75
- size = _ref3$size === void 0 ? "40px" : _ref3$size,
76
- bg = _ref3.bg,
77
- color = _ref3.color,
78
- rest = _objectWithoutPropertiesLoose(_ref3, ["appearance", "name", "src", "variant", "type", "size", "bg", "color"]);
51
+ var Avatar = function Avatar(_ref2) {
52
+ var _ref2$appearance = _ref2.appearance,
53
+ appearance = _ref2$appearance === void 0 ? "circle" : _ref2$appearance,
54
+ name = _ref2.name,
55
+ src = _ref2.src,
56
+ _ref2$size = _ref2.size,
57
+ size = _ref2$size === void 0 ? "40px" : _ref2$size,
58
+ rest = _objectWithoutPropertiesLoose(_ref2, ["appearance", "name", "src", "size"]);
79
59
 
80
60
  var _useState = (0, React.useState)(false),
81
61
  imageFailedLoading = _useState[0],
@@ -89,8 +69,7 @@ var Avatar = function Avatar(_ref3) {
89
69
  }, [setImageFailedLoading]); // Font size for initials is half the size of the avatar, rounded down.
90
70
 
91
71
  var fontSize = Math.floor(Number(size.replace("px", "")) * 0.4);
92
- return /*#__PURE__*/React.createElement(Container, _extends({
93
- className: (0, _classnames.default)(variant),
72
+ return /*#__PURE__*/React.createElement(_Box.default, _extends({
94
73
  size: size,
95
74
  overflow: "hidden",
96
75
  borderRadius: appearance === "leaf" ? "40% 0 40% 0" : "50%",
@@ -100,16 +79,13 @@ var Avatar = function Avatar(_ref3) {
100
79
  justifyContent: "center",
101
80
  alignItems: "center",
102
81
  title: name,
103
- bg: bg,
104
- variant: variant,
105
- type: type,
82
+ bg: "neutral.200",
106
83
  "data-qa-user-avatar": name // $FlowIssue - upgrade v0.112.0
107
84
 
108
85
  }, rest), !src || imageFailedLoading ? /*#__PURE__*/React.createElement(AvatarText, {
109
86
  lineHeight: size,
110
87
  fontWeight: "semibold",
111
- fontSize: fontSize,
112
- color: color
88
+ fontSize: fontSize
113
89
  }, initials) : /*#__PURE__*/React.createElement(_Image.default, {
114
90
  alt: name,
115
91
  width: "auto",
@@ -20,7 +20,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
20
20
  var Container = (0, _styledComponents.default)(_Text.default).withConfig({
21
21
  displayName: "styles__Container",
22
22
  componentId: "adcw4a-0"
23
- })(["border:0;font-family:", ";text-decoration:", ";appearance:none;cursor:pointer;", " font-weight:", ";color:", ";&:hover{color:", ";text-decoration:underline;}&:active{color:", ";}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", ""], function (props) {
23
+ })(["border:0;font-family:", ";text-decoration:", ";appearance:none;cursor:pointer;", " font-weight:", ";color:", ";&:hover{color:", ";text-decoration:underline;}&:active{color:", ";}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", " ", ""], function (props) {
24
24
  return props.theme.fontFamily;
25
25
  }, function (props) {
26
26
  return props.underline ? "underline" : "none";
@@ -38,6 +38,6 @@ var Container = (0, _styledComponents.default)(_Text.default).withConfig({
38
38
  return !props.href && (0, _styledComponents.css)(["background:none;"]);
39
39
  }, function (props) {
40
40
  return props.disabled && _mixins.disabled;
41
- }, _systemProps.COMMON, _systemProps.TYPOGRAPHY);
41
+ }, _systemProps.COMMON, _systemProps.TYPOGRAPHY, _systemProps.FLEXBOX);
42
42
  var _default = Container;
43
43
  exports.default = _default;
@@ -4,8 +4,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
4
4
 
5
5
  import * as React from "react";
6
6
  import { useState, useCallback, useMemo, memo } from "react";
7
- import styled, { css } from "styled-components";
8
- import classnames from "classnames";
7
+ import styled from "styled-components";
9
8
  import Box from "../Box";
10
9
  import Image from "../Image";
11
10
  import Text from "../Text";
@@ -17,20 +16,8 @@ var AvatarText = styled(function (_ref) {
17
16
  }).withConfig({
18
17
  displayName: "Avatar__AvatarText",
19
18
  componentId: "yx873f-0"
20
- })(["font-size:", "px;color:", "px;"], function (props) {
19
+ })(["font-size:", "px;"], function (props) {
21
20
  return props.fontSize;
22
- }, function (props) {
23
- return props.color;
24
- });
25
- var Container = styled(Box).withConfig({
26
- displayName: "Avatar__Container",
27
- componentId: "yx873f-1"
28
- })(["", ""], function (_ref2) {
29
- var theme = _ref2.theme,
30
- type = _ref2.type,
31
- variant = _ref2.variant,
32
- bg = _ref2.bg;
33
- return css(["color:", ";background:", ";"], theme.colors[type][variant === "dark" ? "200" : "900"], bg ? bg : theme.colors[type][variant === "dark" ? "900" : "200"]);
34
21
  });
35
22
 
36
23
  var getInitials = function getInitials(name, fallback) {
@@ -46,20 +33,14 @@ var getInitials = function getInitials(name, fallback) {
46
33
  .join("");
47
34
  };
48
35
 
49
- export var Avatar = function Avatar(_ref3) {
50
- var _ref3$appearance = _ref3.appearance,
51
- appearance = _ref3$appearance === void 0 ? "circle" : _ref3$appearance,
52
- name = _ref3.name,
53
- src = _ref3.src,
54
- _ref3$variant = _ref3.variant,
55
- variant = _ref3$variant === void 0 ? "light" : _ref3$variant,
56
- _ref3$type = _ref3.type,
57
- type = _ref3$type === void 0 ? "neutral" : _ref3$type,
58
- _ref3$size = _ref3.size,
59
- size = _ref3$size === void 0 ? "40px" : _ref3$size,
60
- bg = _ref3.bg,
61
- color = _ref3.color,
62
- rest = _objectWithoutPropertiesLoose(_ref3, ["appearance", "name", "src", "variant", "type", "size", "bg", "color"]);
36
+ export var Avatar = function Avatar(_ref2) {
37
+ var _ref2$appearance = _ref2.appearance,
38
+ appearance = _ref2$appearance === void 0 ? "circle" : _ref2$appearance,
39
+ name = _ref2.name,
40
+ src = _ref2.src,
41
+ _ref2$size = _ref2.size,
42
+ size = _ref2$size === void 0 ? "40px" : _ref2$size,
43
+ rest = _objectWithoutPropertiesLoose(_ref2, ["appearance", "name", "src", "size"]);
63
44
 
64
45
  var _useState = useState(false),
65
46
  imageFailedLoading = _useState[0],
@@ -73,8 +54,7 @@ export var Avatar = function Avatar(_ref3) {
73
54
  }, [setImageFailedLoading]); // Font size for initials is half the size of the avatar, rounded down.
74
55
 
75
56
  var fontSize = Math.floor(Number(size.replace("px", "")) * 0.4);
76
- return /*#__PURE__*/React.createElement(Container, _extends({
77
- className: classnames(variant),
57
+ return /*#__PURE__*/React.createElement(Box, _extends({
78
58
  size: size,
79
59
  overflow: "hidden",
80
60
  borderRadius: appearance === "leaf" ? "40% 0 40% 0" : "50%",
@@ -84,16 +64,13 @@ export var Avatar = function Avatar(_ref3) {
84
64
  justifyContent: "center",
85
65
  alignItems: "center",
86
66
  title: name,
87
- bg: bg,
88
- variant: variant,
89
- type: type,
67
+ bg: "neutral.200",
90
68
  "data-qa-user-avatar": name // $FlowIssue - upgrade v0.112.0
91
69
 
92
70
  }, rest), !src || imageFailedLoading ? /*#__PURE__*/React.createElement(AvatarText, {
93
71
  lineHeight: size,
94
72
  fontWeight: "semibold",
95
- fontSize: fontSize,
96
- color: color
73
+ fontSize: fontSize
97
74
  }, initials) : /*#__PURE__*/React.createElement(Image, {
98
75
  alt: name,
99
76
  width: "auto",
@@ -1,11 +1,11 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import { focusRing, disabled } from "../utils/mixins";
3
3
  import Text from "../Text";
4
- import { TYPOGRAPHY, COMMON } from "../utils/system-props";
4
+ import { TYPOGRAPHY, COMMON, FLEXBOX } from "../utils/system-props";
5
5
  var Container = styled(Text).withConfig({
6
6
  displayName: "styles__Container",
7
7
  componentId: "adcw4a-0"
8
- })(["border:0;font-family:", ";text-decoration:", ";appearance:none;cursor:pointer;", " font-weight:", ";color:", ";&:hover{color:", ";text-decoration:underline;}&:active{color:", ";}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", ""], function (props) {
8
+ })(["border:0;font-family:", ";text-decoration:", ";appearance:none;cursor:pointer;", " font-weight:", ";color:", ";&:hover{color:", ";text-decoration:underline;}&:active{color:", ";}&:focus{", "}&:focus:active{box-shadow:none;}", " ", " ", " ", " ", ""], function (props) {
9
9
  return props.theme.fontFamily;
10
10
  }, function (props) {
11
11
  return props.underline ? "underline" : "none";
@@ -23,5 +23,5 @@ var Container = styled(Text).withConfig({
23
23
  return !props.href && css(["background:none;"]);
24
24
  }, function (props) {
25
25
  return props.disabled && disabled;
26
- }, COMMON, TYPOGRAPHY);
26
+ }, COMMON, TYPOGRAPHY, FLEXBOX);
27
27
  export default Container;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/racine",
3
- "version": "8.1.0-avatar-update-beta.0",
3
+ "version": "8.2.0-link-styles-beta.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "__flow__",
@@ -43,7 +43,7 @@
43
43
  "new": "node ./bin/scaffold.js",
44
44
  "playground": "node ./bin/scaffold-playground.js && yarn start",
45
45
  "release": "yarn test && yarn changeset publish",
46
- "storybook": "start-storybook -c .storybook",
46
+ "storybook": "start-storybook -c .storybook -p 9999",
47
47
  "build-storybook": "build-storybook --quiet -c .storybook -o .storybook-dist",
48
48
  "icon-lint": "node bin/icon-lint/cli",
49
49
  "playroom:start": "playroom start",