@cloudflare/component-button 5.3.2 → 5.4.1

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,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 4396bfb286: Fix dark mode focus state
8
+
9
+ ## 5.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - c464928e05: Add compact prop
14
+
3
15
  ## 5.3.2
4
16
 
5
17
  ### Patch Changes
package/dist/Button.d.ts CHANGED
@@ -31,8 +31,8 @@ export declare const buttonStyles: (props: PropsWithTheme) => {
31
31
  readonly mr: 0;
32
32
  readonly mb: 0;
33
33
  readonly ml: number;
34
- readonly px: 3;
35
- readonly py: 2;
34
+ readonly px: 3 | "11px";
35
+ readonly py: 1 | 2;
36
36
  readonly pointerEvents: "none" | "auto";
37
37
  readonly position: "relative";
38
38
  readonly textAlign: "center";
@@ -46,8 +46,9 @@ export declare const buttonStyles: (props: PropsWithTheme) => {
46
46
  readonly width: "auto" | "100%";
47
47
  readonly boxShadow?: string | undefined;
48
48
  readonly '&:focus-visible': {
49
- readonly outlineOffset: 3;
50
- readonly outlineStyle: "auto";
49
+ readonly outlineOffset: 2;
50
+ readonly outlineWidth: 2;
51
+ readonly outlineStyle: "solid";
51
52
  readonly outlineColor: string;
52
53
  };
53
54
  readonly '&[title]': {
@@ -61,7 +62,7 @@ export declare const buttonStyles: (props: PropsWithTheme) => {
61
62
  readonly alignItems: "center";
62
63
  readonly justifyContent: "center";
63
64
  readonly fontFamily: "-apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, \"Helvetica Neue\", Arial, sans-serif";
64
- readonly fontSize: 2;
65
+ readonly fontSize: 1 | 2;
65
66
  readonly fontWeight: 400;
66
67
  readonly lineHeight: 1.2;
67
68
  readonly border: "none";
@@ -105,11 +106,13 @@ declare type Props = {
105
106
  stretch?: boolean;
106
107
  noWrapText?: boolean;
107
108
  buttonState?: 'hover' | 'active' | 'focus';
109
+ compact?: boolean;
108
110
  } & Pick<JSX.IntrinsicElements['button'], 'onClick' | 'disabled' | 'form' | 'tabIndex' | 'className'>;
109
111
  declare type PropsWithTheme = Props & ThemeProp;
110
112
  declare const _default: React.ComponentType<{
111
113
  space?: number | undefined;
112
114
  disabled?: boolean | undefined;
115
+ compact?: boolean | undefined;
113
116
  form?: string | undefined;
114
117
  className?: string | undefined;
115
118
  id?: string | undefined;
package/es/Button.js CHANGED
@@ -151,7 +151,8 @@ export var buttonStyles = props => {
151
151
  type = 'default',
152
152
  stretch,
153
153
  noWrapText,
154
- buttonState
154
+ buttonState,
155
+ compact
155
156
  } = props;
156
157
  var styles = {
157
158
  normal: buttonColors(theme).normal,
@@ -168,8 +169,9 @@ export var buttonStyles = props => {
168
169
  '&:focus:active': styles.active
169
170
  }), {}, {
170
171
  '&:focus-visible': {
171
- outlineOffset: 3,
172
- outlineStyle: 'auto',
172
+ outlineOffset: 2,
173
+ outlineWidth: 2,
174
+ outlineStyle: 'solid',
173
175
  outlineColor: type === 'danger' || type === 'plainDestructive' ? theme.colors.red[isDarkMode() ? 3 : 4] : theme.colors.focus
174
176
  },
175
177
  '&[title]': {
@@ -183,7 +185,7 @@ export var buttonStyles = props => {
183
185
  alignItems: 'center',
184
186
  justifyContent: 'center',
185
187
  fontFamily: theme.fontFamily,
186
- fontSize: 2,
188
+ fontSize: compact ? 1 : 2,
187
189
  fontWeight: 400,
188
190
  lineHeight: 1.2,
189
191
  border: 'none'
@@ -219,8 +221,8 @@ export var buttonStyles = props => {
219
221
  mr: 0,
220
222
  mb: 0,
221
223
  ml: spaced && direction === 'row' && group !== 'first' ? space : 0,
222
- px: 3,
223
- py: 2,
224
+ px: compact ? '11px' : 3,
225
+ py: compact ? 1 : 2,
224
226
  pointerEvents: disabled ? 'none' : 'auto',
225
227
  position: 'relative',
226
228
  textAlign: 'center',
@@ -300,7 +302,8 @@ Button.propTypes = {
300
302
  ariaLabel: PropTypes.string,
301
303
  stretch: PropTypes.bool,
302
304
  noWrapText: PropTypes.bool,
303
- buttonState: PropTypes.oneOf(['hover', 'active', 'focus'])
305
+ buttonState: PropTypes.oneOf(['hover', 'active', 'focus']),
306
+ compact: PropTypes.bool
304
307
  };
305
308
  Button.displayName = 'Button';
306
309
  export default createStyledComponent(buttonStyles, Button);
package/lib/Button.js CHANGED
@@ -165,7 +165,8 @@ var buttonStyles = function buttonStyles(props) {
165
165
  type = _props$type === void 0 ? 'default' : _props$type,
166
166
  stretch = props.stretch,
167
167
  noWrapText = props.noWrapText,
168
- buttonState = props.buttonState;
168
+ buttonState = props.buttonState,
169
+ compact = props.compact;
169
170
  var styles = {
170
171
  normal: buttonColors(theme).normal,
171
172
  hover: interactionStyleAccessor('hover', props),
@@ -181,8 +182,9 @@ var buttonStyles = function buttonStyles(props) {
181
182
  '&:focus:active': styles.active
182
183
  }), {}, {
183
184
  '&:focus-visible': {
184
- outlineOffset: 3,
185
- outlineStyle: 'auto',
185
+ outlineOffset: 2,
186
+ outlineWidth: 2,
187
+ outlineStyle: 'solid',
186
188
  outlineColor: type === 'danger' || type === 'plainDestructive' ? theme.colors.red[(0, _styleConst.isDarkMode)() ? 3 : 4] : theme.colors.focus
187
189
  },
188
190
  '&[title]': {
@@ -196,7 +198,7 @@ var buttonStyles = function buttonStyles(props) {
196
198
  alignItems: 'center',
197
199
  justifyContent: 'center',
198
200
  fontFamily: theme.fontFamily,
199
- fontSize: 2,
201
+ fontSize: compact ? 1 : 2,
200
202
  fontWeight: 400,
201
203
  lineHeight: 1.2,
202
204
  border: 'none'
@@ -232,8 +234,8 @@ var buttonStyles = function buttonStyles(props) {
232
234
  mr: 0,
233
235
  mb: 0,
234
236
  ml: spaced && direction === 'row' && group !== 'first' ? space : 0,
235
- px: 3,
236
- py: 2,
237
+ px: compact ? '11px' : 3,
238
+ py: compact ? 1 : 2,
237
239
  pointerEvents: disabled ? 'none' : 'auto',
238
240
  position: 'relative',
239
241
  textAlign: 'center',
@@ -320,7 +322,8 @@ Button.propTypes = {
320
322
  ariaLabel: _propTypes.default.string,
321
323
  stretch: _propTypes.default.bool,
322
324
  noWrapText: _propTypes.default.bool,
323
- buttonState: _propTypes.default.oneOf(['hover', 'active', 'focus'])
325
+ buttonState: _propTypes.default.oneOf(['hover', 'active', 'focus']),
326
+ compact: _propTypes.default.bool
324
327
  };
325
328
  Button.displayName = 'Button';
326
329
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudflare/component-button",
3
3
  "description": "Cloudflare Button Component",
4
- "version": "5.3.2",
4
+ "version": "5.4.1",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
7
7
  "author": "James Kyle <jkyle@cloudflare.com>",