@unitedstatespowersquadrons/components 1.4.6 → 1.4.7

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.
Files changed (2) hide show
  1. package/ActionButton.tsx +33 -7
  2. package/package.json +1 -1
package/ActionButton.tsx CHANGED
@@ -34,6 +34,7 @@ const useStyles = createUseStyles({
34
34
  justifyContent: "flex-end",
35
35
  padding: "0 0.3em 0 0.7em",
36
36
  },
37
+ sizing: ({ fontSize, margin }: { fontSize?: string | number; margin?: string | number }) => ({ fontSize, margin }),
37
38
  small: { fontSize: "0.8em" },
38
39
  subText: {
39
40
  fontSize: "0.75em",
@@ -50,17 +51,30 @@ const useStyles = createUseStyles({
50
51
  },
51
52
  });
52
53
 
53
- export interface CoreActionButtonProps extends FontAwesomeProps {
54
+ interface CoreActionButtonBaseProps extends FontAwesomeProps {
54
55
  className?: string | undefined;
55
56
  color: ButtonColorName;
56
57
  grayMode?: boolean | undefined;
57
58
  id?: string;
58
59
  rightIcon?: boolean;
59
- size?: "big" | "mediumWithMargin" | "medium" | "small" | undefined;
60
60
  subtext?: string;
61
61
  text: string;
62
62
  }
63
63
 
64
+ interface SizePresetProps {
65
+ fontSize?: never;
66
+ margin?: never;
67
+ size?: "big" | "mediumWithMargin" | "medium" | "small" | undefined;
68
+ }
69
+
70
+ interface CustomSizeProps {
71
+ fontSize?: string | number;
72
+ margin?: string | number;
73
+ size?: never;
74
+ }
75
+
76
+ export type CoreActionButtonProps = CoreActionButtonBaseProps & (SizePresetProps | CustomSizeProps);
77
+
64
78
  interface FormProps {
65
79
  confirm?: string;
66
80
  formId: string;
@@ -82,8 +96,13 @@ export type ActionButtonProps =
82
96
  | ActionButtonFormProps;
83
97
 
84
98
  const ActionButton = (props: ActionButtonProps) => {
85
- const { className, color, fa, grayMode, icon, id, mode, rightIcon, size, style, subtext, text, title } = props;
86
- const classes = useStyles();
99
+ const {
100
+ className, color, fa, fontSize, grayMode, icon, id, margin, mode, rightIcon, size, style, subtext, text, title,
101
+ } = props;
102
+ const classes = useStyles({
103
+ ...(fontSize !== undefined && { fontSize }),
104
+ ...(margin !== undefined && { margin }),
105
+ });
87
106
 
88
107
  const colorClassName = classes[`${color}${grayMode ? "Gray" : "Colored"}`];
89
108
 
@@ -122,7 +141,9 @@ const ActionButton = (props: ActionButtonProps) => {
122
141
 
123
142
  return(
124
143
  <BaseActionButton
125
- className={classNames(classes.button, colorClassName, sizeClassName(), inline && classes.inline, className)}
144
+ className={classNames(
145
+ classes.button, colorClassName, sizeClassName(), classes.sizing, inline && classes.inline, className
146
+ )}
126
147
  confirm={confirm}
127
148
  id={id}
128
149
  onClick={onClick}
@@ -136,7 +157,9 @@ const ActionButton = (props: ActionButtonProps) => {
136
157
 
137
158
  return(
138
159
  <BaseActionButton
139
- className={classNames(classes.button, colorClassName, sizeClassName(), inline && classes.inline, className)}
160
+ className={classNames(
161
+ classes.button, colorClassName, sizeClassName(), classes.sizing, inline && classes.inline, className
162
+ )}
140
163
  confirm={confirm}
141
164
  href={href}
142
165
  id={id}
@@ -153,6 +176,7 @@ const ActionButton = (props: ActionButtonProps) => {
153
176
  classes.button,
154
177
  colorClassName,
155
178
  sizeClassName(),
179
+ classes.sizing,
156
180
  rightIcon ? classes.rightIcon : "",
157
181
  inline && classes.inline,
158
182
  className
@@ -183,7 +207,9 @@ const ActionButton = (props: ActionButtonProps) => {
183
207
 
184
208
  return(
185
209
  <BaseActionButton
186
- className={classNames(classes.button, colorClassName, sizeClassName(), inline && classes.inline, className)}
210
+ className={classNames(
211
+ classes.button, colorClassName, sizeClassName(), classes.sizing, inline && classes.inline, className
212
+ )}
187
213
  confirm={confirm}
188
214
  id={id}
189
215
  onClick={onClick}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unitedstatespowersquadrons/components",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "USPS shared React components library",
5
5
  "main": "index.tsx",
6
6
  "scripts": {