Skip to content

Commit c32c7f0

Browse files
committed
Fix button styles.
Fix tooltip mouseLeave event on touching self.
1 parent a04e35d commit c32c7f0

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

src/components/button/button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export const Button = forwardRef(
1818
iconSize,
1919
iconWidth,
2020
iconHeight,
21+
children = label,
2122
...rest
2223
},
2324
ref
2425
) => (
2526
<StyledButton
2627
flavour={flavour}
2728
textTransform={textTransform}
28-
hasLabel={!!label}
2929
hasIcon={!!icon || isLoading}
3030
onClick={isLoading ? undefined : onClick}
3131
ref={ref}
@@ -46,7 +46,7 @@ export const Button = forwardRef(
4646
</Flex>
4747
)}
4848

49-
{label && <span>{(isLoading && loadingLabel) || label}</span>}
49+
{!!children && <span>{(isLoading && loadingLabel) || children}</span>}
5050
</StyledButton>
5151
)
5252
)

src/components/button/styled.js

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styled, { css } from "styled-components"
2+
import { lighten, darken } from "polished"
23
import { getColor, getSizeBy, DefaultTheme, DarkTheme } from "src/theme"
34
import margin from "src/mixins/margin"
45
import padding from "src/mixins/padding"
@@ -28,25 +29,29 @@ const withTheme = props => {
2829
}
2930

3031
const getPrimaryColor = props =>
31-
props.neutral ? getColor("text")(props) : getColor("primary")(props)
32+
props.neutral
33+
? getColor(props.flavour === HOLLOW ? "textFocus" : "text")(props)
34+
: getColor("primary")(props)
3235

3336
const getBorderColor = props =>
34-
props.neutral ? getColor("border")(props) : getColor("primary")(props)
35-
const getTextColor = getColor("bright")
37+
props.neutral ? getColor("textFocus")(props) : getColor("primary")(props)
38+
const getTextColor = props => getColor("mainBackground")(props)
3639
const getHoverColor = props =>
3740
props.neutral ? getColor("textFocus")(props) : getColor("accent")(props)
3841
const getAccentColor = props =>
39-
props.neutral ? getColor("textFocus")(props) : getColor("successLite")(props)
40-
const getMain = props =>
41-
props.neutral
42-
? getColor(props.disabled ? "disabled" : "mainBackground")(props)
43-
: getColor("mainBackground")(props)
42+
props.neutral ? lighten(0.2, getColor("textFocus")(props)) : getColor("successLite")(props)
4443
const getTransparent = getColor(["transparent", "full"])
4544

4645
const colorsByFlavour = ({ flavour = DEFAULT, danger, warning, iconColor }) => {
4746
const getErrorColor = danger ? getColor("error") : undefined
4847
const getWarningColor = warning ? getColor("warning") : undefined
4948
const getSpecialColor = getErrorColor || getWarningColor
49+
const getSpecialColorHover = getSpecialColor
50+
? props => lighten(0.2, getSpecialColor(props))
51+
: undefined
52+
const getSpecialColorActive = getSpecialColor
53+
? props => darken(0.2, getSpecialColor(props))
54+
: undefined
5055
const specialIconColor = iconColor ? getColor(iconColor) : undefined
5156

5257
const flavours = {
@@ -55,44 +60,44 @@ const colorsByFlavour = ({ flavour = DEFAULT, danger, warning, iconColor }) => {
5560
colorHover: getTextColor,
5661
colorActive: getTextColor,
5762
bg: getSpecialColor || getPrimaryColor,
58-
bgHover: getSpecialColor || getHoverColor,
59-
bgActive: getSpecialColor || getAccentColor,
63+
bgHover: getSpecialColorHover || getHoverColor,
64+
bgActive: getSpecialColorActive || getAccentColor,
6065
border: getSpecialColor || getPrimaryColor,
61-
borderHover: getSpecialColor || getHoverColor,
62-
borderActive: getSpecialColor || getAccentColor,
66+
borderHover: getSpecialColorHover || getHoverColor,
67+
borderActive: getSpecialColorActive || getAccentColor,
6368
iconColor: specialIconColor || getTextColor,
6469
},
6570
[HOLLOW]: {
6671
color: getSpecialColor || getPrimaryColor,
67-
colorHover: getSpecialColor || getAccentColor,
68-
colorActive: getSpecialColor || getAccentColor,
72+
colorHover: getSpecialColorHover || getAccentColor,
73+
colorActive: getSpecialColorActive || getAccentColor,
6974
bg: getTransparent,
7075
bgHover: getTransparent,
71-
bgActive: getSpecialColor || getMain,
76+
bgActive: getTransparent,
7277
border: getSpecialColor || getBorderColor,
73-
borderHover: getSpecialColor || getHoverColor,
74-
borderActive: getSpecialColor || getAccentColor,
75-
iconColor: specialIconColor || getTextColor,
78+
borderHover: getSpecialColorHover || getAccentColor,
79+
borderActive: getSpecialColorActive || getAccentColor,
80+
iconColor: specialIconColor || getSpecialColor || getPrimaryColor,
7681
},
7782
[BORDER_LESS]: {
7883
color: getSpecialColor || getPrimaryColor,
79-
colorHover: getSpecialColor || getAccentColor,
80-
colorActive: getSpecialColor || getAccentColor,
84+
colorHover: getSpecialColorHover || getAccentColor,
85+
colorActive: getSpecialColorActive || getAccentColor,
8186
bg: getTransparent,
8287
bgHover: getTransparent,
8388
bgActive: getTransparent,
8489
border: getTransparent,
8590
borderHover: getTransparent,
8691
borderActive: getTransparent,
87-
iconColor: specialIconColor || getTextColor,
92+
iconColor: specialIconColor || getSpecialColor || getPrimaryColor,
8893
},
8994
}
9095

9196
return flavours[flavour] || flavours[DEFAULT]
9297
}
9398

9499
export const StyledButton = styled.button.attrs(props => ({
95-
padding: props.padding || [2],
100+
padding: props.padding || props.tiny ? [0.5] : props.small ? [1] : [2],
96101
colors: colorsByFlavour(props),
97102
...withTheme(props),
98103
}))`
@@ -103,15 +108,6 @@ export const StyledButton = styled.button.attrs(props => ({
103108
position: relative;
104109
${alignSelf};
105110
106-
width: ${props =>
107-
props.width
108-
? props.width
109-
: getSizeBy(props.tiny ? 2 : props.small ? 3 : props.hasLabel ? 16 : 4)};
110-
height: ${props =>
111-
props.height
112-
? props.height
113-
: getSizeBy(props.tiny ? 2 : props.small ? 3 : props.hasLabel ? 5 : 4)};
114-
115111
font-weight: ${({ strong }) => (strong ? 700 : 500)};
116112
font-size: ${({ small, tiny }) => (tiny ? "10px" : small ? "12px" : "14px")};
117113
line-height: ${getSizeBy(2)};

src/components/drops/drop/container.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const Container = styled(Flex).attrs(({ zIndex = 60, ...rest }) => ({
2727
2828
${({ animation }) => animation && styledAnimation}
2929
${({ hideShadow }) => !hideShadow && "box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);"}
30+
${({ noEvents }) => !!noEvents && "pointer-events: none;"}
3031
3132
backface-visibility: hidden;
3233
perspective: 1000;

src/components/drops/tooltip/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const Tooltip = forwardRef(
6161
{targetElement}
6262
{isOpen && ref.current && !disabled && (
6363
<Drop
64+
noEvents={!allowHoverOnTooltip}
6465
align={dropProps?.align || dropAlignMap[align]}
6566
hideShadow
6667
id={id}

0 commit comments

Comments
 (0)