@unitedstatespowersquadrons/components 1.4.2-2 → 1.4.3
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/IconButton.tsx +19 -26
- package/package.json +1 -1
package/IconButton.tsx
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { createUseStyles } from "react-jss";
|
|
3
3
|
import classNames from "classnames";
|
|
4
|
-
import
|
|
4
|
+
import { ButtonColorName } from "./Colors";
|
|
5
5
|
import FontAwesomeIcon, { FontAwesomeProps } from "./FontAwesomeIcon";
|
|
6
6
|
import BaseActionButton from "./BaseActionButton";
|
|
7
7
|
import { HrefProps, MethodProps, OnClickProps } from "./types";
|
|
8
|
-
|
|
9
|
-
// FA duotone uses `--fa-primary-color` / `--fa-secondary-color`. Their
|
|
10
|
-
// out-of-the-box defaults are `inherit` (currentColor), but the kit can
|
|
11
|
-
// override that with literal hexes, which freezes the duotone color
|
|
12
|
-
// regardless of `color`. Re-pin both to `currentColor` so each layer
|
|
13
|
-
// follows our `color` while `--fa-secondary-opacity` (default 0.4) keeps
|
|
14
|
-
// the duotone contrast.
|
|
15
|
-
const colorize = (hex: string) => ({
|
|
16
|
-
"--fa-primary-color": "currentColor",
|
|
17
|
-
"--fa-secondary-color": "currentColor",
|
|
18
|
-
color: hex,
|
|
19
|
-
});
|
|
8
|
+
import Styles from "./Styles";
|
|
20
9
|
|
|
21
10
|
const useStyles = createUseStyles({
|
|
22
|
-
blue:
|
|
23
|
-
darkGray:
|
|
24
|
-
gray:
|
|
25
|
-
green:
|
|
11
|
+
blue: { ...Styles.blue },
|
|
12
|
+
darkGray: { ...Styles.darkGray },
|
|
13
|
+
gray: { ...Styles.gray },
|
|
14
|
+
green: { ...Styles.green },
|
|
26
15
|
icon: {
|
|
27
16
|
cursor: "pointer",
|
|
28
17
|
fontSize: "1.1em",
|
|
29
18
|
},
|
|
30
|
-
orange:
|
|
31
|
-
purple:
|
|
32
|
-
red:
|
|
19
|
+
orange: { ...Styles.orange },
|
|
20
|
+
purple: { ...Styles.purple },
|
|
21
|
+
red: { ...Styles.red },
|
|
33
22
|
wrapperLink: {
|
|
34
23
|
display: "inline-block",
|
|
35
24
|
margin: "0",
|
|
@@ -57,16 +46,20 @@ const IconButton = (props: IconButtonProps) => {
|
|
|
57
46
|
const { className, color, fa, icon, id, mode, style, title } = props;
|
|
58
47
|
const classes = useStyles();
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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} />;
|
|
63
56
|
|
|
64
57
|
if ("onClick" in props) {
|
|
65
58
|
const { confirm, onClick } = props;
|
|
66
59
|
|
|
67
60
|
return(
|
|
68
61
|
<BaseActionButton
|
|
69
|
-
className={
|
|
62
|
+
className={buttonClassName}
|
|
70
63
|
confirm={confirm}
|
|
71
64
|
id={id}
|
|
72
65
|
onClick={onClick}
|
|
@@ -80,7 +73,7 @@ const IconButton = (props: IconButtonProps) => {
|
|
|
80
73
|
|
|
81
74
|
return(
|
|
82
75
|
<BaseActionButton
|
|
83
|
-
className={
|
|
76
|
+
className={buttonClassName}
|
|
84
77
|
confirm={confirm}
|
|
85
78
|
href={href}
|
|
86
79
|
id={id}
|
|
@@ -95,7 +88,7 @@ const IconButton = (props: IconButtonProps) => {
|
|
|
95
88
|
|
|
96
89
|
return(
|
|
97
90
|
<BaseActionButton
|
|
98
|
-
className={
|
|
91
|
+
className={buttonClassName}
|
|
99
92
|
href={href}
|
|
100
93
|
id={id}
|
|
101
94
|
linkClassName={classNames(classes.wrapperLink, linkClassName)}
|