|
5 | 5 | * found at http://www.apache.org/licenses/LICENSE-2.0. |
6 | 6 | */ |
7 | 7 |
|
8 | | -import styled, { css, DefaultTheme, ThemeProps } from 'styled-components'; |
9 | | -import { |
10 | | - getColorV8, |
11 | | - retrieveComponentStyles, |
12 | | - DEFAULT_THEME, |
13 | | - focusStyles |
14 | | -} from '@zendeskgarden/react-theming'; |
| 8 | +import styled from 'styled-components'; |
| 9 | +import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming'; |
| 10 | +import { IconButton } from '@zendeskgarden/react-buttons'; |
15 | 11 |
|
16 | 12 | const COMPONENT_ID = 'modals.close'; |
17 | 13 |
|
18 | | -const colorStyles = (props: ThemeProps<DefaultTheme>) => { |
19 | | - const backgroundColor = 'primaryHue'; |
20 | | - const foregroundColor = 'neutralHue'; |
21 | | - |
22 | | - return css` |
23 | | - background-color: transparent; |
24 | | - color: ${getColorV8(foregroundColor, 600, props.theme)}; |
25 | | -
|
26 | | - &:hover { |
27 | | - background-color: ${getColorV8(backgroundColor, 600, props.theme, 0.08)}; |
28 | | - color: ${getColorV8(foregroundColor, 700, props.theme)}; |
29 | | - } |
30 | | -
|
31 | | - ${focusStyles({ |
32 | | - theme: props.theme, |
33 | | - color: { hue: backgroundColor } |
34 | | - })} |
35 | | -
|
36 | | - &:active { |
37 | | - /* prettier-ignore */ |
38 | | - transition: |
39 | | - background-color 0.1s ease-in-out, |
40 | | - color 0.1s ease-in-out; |
41 | | - background-color: ${getColorV8(backgroundColor, 600, props.theme, 0.2)}; |
42 | | - color: ${getColorV8(foregroundColor, 800, props.theme)}; |
43 | | - } |
44 | | - `; |
45 | | -}; |
46 | | - |
47 | 14 | export const BASE_MULTIPLIERS = { |
48 | 15 | top: 2.5, |
49 | 16 | side: 6.5, |
50 | 17 | size: 10 |
51 | 18 | }; |
52 | 19 |
|
53 | | -/** |
54 | | - * 1. Remove dotted outline from Firefox on focus. |
55 | | - */ |
56 | | -export const StyledClose = styled.button.attrs({ |
| 20 | +export const StyledClose = styled(IconButton).attrs({ |
57 | 21 | 'data-garden-id': COMPONENT_ID, |
58 | 22 | 'data-garden-version': PACKAGE_VERSION |
59 | 23 | })` |
60 | | - display: block; |
61 | 24 | position: absolute; |
62 | 25 | top: ${props => props.theme.space.base * BASE_MULTIPLIERS.top}px; |
63 | 26 | ${props => (props.theme.rtl ? 'left' : 'right')}: ${props => |
64 | 27 | `${props.theme.space.base * BASE_MULTIPLIERS.side}px`}; |
65 | | - /* prettier-ignore */ |
66 | | - transition: |
67 | | - box-shadow 0.1s ease-in-out, |
68 | | - background-color 0.25s ease-in-out, |
69 | | - color 0.25s ease-in-out; |
70 | | - border: none; |
71 | | - border-radius: 50%; |
72 | | - background-color: transparent; |
73 | | - cursor: pointer; |
74 | | - padding: 0; |
75 | | - width: ${props => props.theme.space.base * BASE_MULTIPLIERS.size}px; |
76 | | - height: ${props => props.theme.space.base * BASE_MULTIPLIERS.size}px; |
77 | | - overflow: hidden; |
78 | | - text-decoration: none; |
79 | | - font-size: 0; |
80 | | - user-select: none; |
81 | | -
|
82 | | - &::-moz-focus-inner { |
83 | | - border: 0; /* [1] */ |
84 | | - } |
85 | | -
|
86 | | - ${props => colorStyles(props)} |
87 | | -
|
88 | | - & > svg { |
89 | | - vertical-align: middle; |
90 | | - } |
91 | 28 |
|
92 | 29 | ${props => retrieveComponentStyles(COMPONENT_ID, props)}; |
93 | 30 | `; |
|
0 commit comments