@unitedstatespowersquadrons/components 1.4.2 → 1.4.4

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.
@@ -3,8 +3,7 @@ import { createUseStyles } from "react-jss";
3
3
  import classNames from "classnames";
4
4
  import AdminItem from "./AdminItem";
5
5
  import Colors, { ButtonColorName } from "../Colors";
6
- import { FontAwesomeProps } from "../FontAwesomeIcon";
7
- import IconButton from "../IconButton";
6
+ import FontAwesomeIcon, { FontAwesomeProps } from "../FontAwesomeIcon";
8
7
  import Styles from "../Styles";
9
8
 
10
9
  // Styles aren't tree-shaken, but keeping every color variant here means apps
@@ -49,6 +48,13 @@ const useStyles = createUseStyles({
49
48
  cursor: "pointer",
50
49
  },
51
50
  left: { textAlign: "left" },
51
+ link: {
52
+ ...Styles.flexRow,
53
+ color: "inherit",
54
+ flex: 1,
55
+ justifyContent: "left",
56
+ textDecoration: "none",
57
+ },
52
58
  orange: {
53
59
  "& button": { ...Styles.orange },
54
60
  "&:hover": {
@@ -96,22 +102,23 @@ interface Props extends FontAwesomeProps {
96
102
  }
97
103
 
98
104
  const AdminLink = (props: Props) => {
99
- const { className, color, href, icon, mode, style, subMenu, title } = props;
105
+ const { className, color, fa, href, icon, mode, style, subMenu, title } = props;
100
106
  const classes = useStyles();
101
107
 
102
108
  const colorClassName = classes[color];
103
109
 
104
110
  return(
105
111
  <AdminItem className={classNames(classes.item, classes.left, colorClassName)}>
106
- <IconButton
107
- className={classNames(classes.subMenuIcon, className)}
108
- href={href}
109
- icon={icon}
110
- mode={mode}
111
- style={style}
112
- title={title}
113
- />
114
- <span className={classNames(classes.subMenuText, className)}>{subMenu}</span>
112
+ <a className={classes.link} href={href} title={title}>
113
+ <FontAwesomeIcon
114
+ css={classNames(classes.subMenuIcon, className)}
115
+ fa={fa}
116
+ icon={icon}
117
+ mode={mode}
118
+ style={style}
119
+ />
120
+ <span className={classNames(classes.subMenuText, className)}>{subMenu}</span>
121
+ </a>
115
122
  </AdminItem>
116
123
  );
117
124
  };
package/IconButton.tsx CHANGED
@@ -46,16 +46,20 @@ const IconButton = (props: IconButtonProps) => {
46
46
  const { className, color, fa, icon, id, mode, style, title } = props;
47
47
  const classes = useStyles();
48
48
 
49
- const colorClassName = classes[color ?? "blue"];
50
- const combinedClassName = classNames(classes.icon, colorClassName, className);
51
- const configuredIcon = <FontAwesomeIcon css={combinedClassName} fa={fa} icon={icon} mode={mode} style={style} />;
49
+ // The button carries the color class so it composes with consumer-side
50
+ // descendant selectors (e.g. AdminLink's `& button { color }`); the icon
51
+ // inherits via `currentColor` rather than receiving its own color class,
52
+ // which would beat that cascade due to specificity.
53
+ const buttonClassName = classNames(classes.icon, classes[color ?? "blue"], className);
54
+ const iconClassName = classNames(classes.icon, className);
55
+ const configuredIcon = <FontAwesomeIcon css={iconClassName} fa={fa} icon={icon} mode={mode} style={style} />;
52
56
 
53
57
  if ("onClick" in props) {
54
58
  const { confirm, onClick } = props;
55
59
 
56
60
  return(
57
61
  <BaseActionButton
58
- className={combinedClassName}
62
+ className={buttonClassName}
59
63
  confirm={confirm}
60
64
  id={id}
61
65
  onClick={onClick}
@@ -69,7 +73,7 @@ const IconButton = (props: IconButtonProps) => {
69
73
 
70
74
  return(
71
75
  <BaseActionButton
72
- className={combinedClassName}
76
+ className={buttonClassName}
73
77
  confirm={confirm}
74
78
  href={href}
75
79
  id={id}
@@ -84,7 +88,7 @@ const IconButton = (props: IconButtonProps) => {
84
88
 
85
89
  return(
86
90
  <BaseActionButton
87
- className={combinedClassName}
91
+ className={buttonClassName}
88
92
  href={href}
89
93
  id={id}
90
94
  linkClassName={classNames(classes.wrapperLink, linkClassName)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitedstatespowersquadrons/components",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "USPS shared React components library",
5
5
  "main": "index.tsx",
6
6
  "scripts": {