@@ -3,11 +3,12 @@ import React from 'react';
3
3
import { Loader } from '@strapi/icons' ;
4
4
import styled , { keyframes } from 'styled-components' ;
5
5
6
+ import { BUTTON_SIZES , Variant , ButtonSizes , DEFAULT } from './constants' ;
7
+ import { getDisabledStyle , getHoverStyle , getActiveStyle , getVariantStyle } from './utils' ;
6
8
import { BaseButton , BaseButtonProps } from '../BaseButton' ;
7
9
import { Box } from '../Box' ;
10
+ import { Flex } from '../Flex' ;
8
11
import { Typography } from '../Typography' ;
9
- import { BUTTON_SIZES , Variant , ButtonSizes , DEFAULT } from './constants' ;
10
- import { getDisabledStyle , getHoverStyle , getActiveStyle , getVariantStyle } from './utils' ;
11
12
12
13
const rotation = keyframes `
13
14
from {
@@ -23,49 +24,26 @@ const LoadingWrapper = styled.div`
23
24
will-change: transform;
24
25
` ;
25
26
26
- const BoxFullHeight = styled ( Box ) `
27
- height: 100%;
28
- ` ;
29
-
30
- type ButtonWrapperProps = Required < Pick < ButtonProps , 'size' | 'fullWidth' | 'variant' > > ;
31
-
32
- export const ButtonWrapper = styled ( BaseButton ) < ButtonWrapperProps > `
33
- align-items: center;
34
- background-color: ${ ( { theme } ) => theme . colors . buttonPrimary600 } ;
35
- border: 1px solid ${ ( { theme } ) => theme . colors . buttonPrimary600 } ;
27
+ export const ButtonWrapper = styled ( BaseButton ) < Required < Pick < ButtonProps , 'size' | 'variant' > > > `
36
28
height: ${ ( { theme, size } ) => theme . sizes . button [ size ] } ;
37
- padding-left: ${ ( { theme } ) => theme . spaces [ 4 ] } ;
38
- padding-right: ${ ( { theme } ) => theme . spaces [ 4 ] } ;
39
-
40
- ${ Box } {
41
- display: flex;
42
- align-items: center;
43
- }
44
-
45
- ${ Typography } {
46
- color: ${ ( { theme } ) => theme . colors . buttonNeutral0 } ;
47
- }
48
29
49
30
&[aria-disabled='true'] {
50
31
${ getDisabledStyle }
32
+
51
33
&:active {
52
34
${ getDisabledStyle }
53
35
}
54
36
}
37
+
55
38
&:hover {
56
39
${ getHoverStyle }
57
40
}
41
+
58
42
&:active {
59
43
${ getActiveStyle }
60
44
}
45
+
61
46
${ getVariantStyle }
62
- ${ ( { fullWidth } ) =>
63
- fullWidth &&
64
- `
65
- display: inline-flex;
66
- justify-content: center;
67
- width: 100%;
68
- ` }
69
47
` ;
70
48
71
49
export interface ButtonProps extends BaseButtonProps {
@@ -111,29 +89,39 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
111
89
variant = { variant }
112
90
onClick = { handleClick }
113
91
fullWidth = { fullWidth }
92
+ alignItems = "center"
93
+ background = "buttonPrimary600"
94
+ borderColor = "buttonPrimary600"
95
+ gap = { 2 }
96
+ inline = { fullWidth }
97
+ justifyContent = { fullWidth ? 'center' : undefined }
98
+ paddingLeft = { 4 }
99
+ paddingRight = { 4 }
100
+ width = { fullWidth ? '100%' : undefined }
114
101
{ ...props }
115
102
>
116
103
{ ( startIcon || loading ) && (
117
- < BoxFullHeight aria-hidden paddingRight = { 2 } >
104
+ < Box aria-hidden >
118
105
{ loading ? (
119
106
< LoadingWrapper >
120
107
< Loader />
121
108
</ LoadingWrapper >
122
109
) : (
123
110
startIcon
124
111
) }
125
- </ BoxFullHeight >
112
+ </ Box >
126
113
) }
127
114
128
- < Typography variant = { size === 'S' ? 'pi' : undefined } fontWeight = "bold" lineHeight = { 0 } >
115
+ < Typography
116
+ variant = { size === 'S' ? 'pi' : undefined }
117
+ fontWeight = "bold"
118
+ lineHeight = { 0 }
119
+ textColor = "buttonNeutral0"
120
+ >
129
121
{ children }
130
122
</ Typography >
131
123
132
- { endIcon && (
133
- < Box aria-hidden paddingLeft = { 2 } >
134
- { endIcon }
135
- </ Box >
136
- ) }
124
+ { endIcon && < Flex aria-hidden > { endIcon } </ Flex > }
137
125
</ ButtonWrapper >
138
126
) ;
139
127
} ,
0 commit comments