1
- import cs from 'classnames'
2
1
import { action } from 'mobx'
3
2
import { observer } from 'mobx-react'
4
3
import React from 'react'
4
+ import Button from '@cypress-design/react-button'
5
5
// @ts -ignore
6
6
import Tooltip from '@cypress/react-tooltip'
7
7
8
8
import defaultEvents , { Events } from '../lib/events'
9
9
import type { AppState } from '../lib/app-state'
10
10
11
- import ChevronDownIcon from '@packages/frontend-shared/src/assets/icons/chevron-down-small_x16.svg'
12
- import ChevronUpIcon from '@packages/frontend-shared/src/assets/icons/chevron-up-small_x16.svg'
13
- import { IconActionNext , IconActionPlayLarge , IconActionRestart , IconActionStopCircle } from '@cypress-design/react-icon'
11
+ import { IconChevronDownSmall , IconChevronUpSmall , IconActionNext , IconActionPlayLarge , IconActionRestart , IconActionStopCircle } from '@cypress-design/react-icon'
14
12
15
13
const iconStrokeColor = 'gray-500'
16
-
17
14
const iconFillColor = 'gray-900'
18
15
19
- const ifThen = ( condition : boolean , component : React . ReactNode ) => (
20
- condition ? component : null
21
- )
22
-
23
16
interface Props {
24
17
events ?: Events
25
18
appState : AppState
@@ -34,56 +27,66 @@ const Controls: React.FC<Props> = observer(({ events = defaultEvents, appState,
34
27
}
35
28
36
29
return (
37
- < div className = { cs ( { 'controls-container-studio' : appState . studioActive , 'controls-container' : ! appState . studioActive } ) } >
30
+ < div className = 'controls' >
38
31
{ displayPreferencesButton && (
39
32
< Tooltip placement = 'bottom' title = { < p > Open Testing Preferences</ p > } className = 'cy-tooltip' >
40
- < button
41
- aria-label = 'Open testing preferences'
42
- className = { cs ( 'testing-preferences-toggle' , { 'open' : appState . isPreferencesMenuOpen } ) }
43
- onClick = { action ( 'toggle:preferences:menu' , togglePreferencesMenu ) }
44
- >
45
- { appState . isPreferencesMenuOpen ? (
46
- < ChevronUpIcon />
47
- ) : (
48
- < ChevronDownIcon />
49
- ) }
50
- </ button >
33
+ < div >
34
+ < Button
35
+ size = '20'
36
+ variant = 'outline-dark'
37
+ aria-label = 'Open testing preferences'
38
+ data-cy = 'testing-preferences-toggle'
39
+ onClick = { action ( 'toggle:preferences:menu' , togglePreferencesMenu ) }
40
+ >
41
+ { appState . isPreferencesMenuOpen ? (
42
+ < IconChevronUpSmall strokeColor = 'gray-500' />
43
+ ) : (
44
+ < IconChevronDownSmall strokeColor = 'gray-500' />
45
+ ) }
46
+ </ Button >
47
+ </ div >
51
48
</ Tooltip >
52
49
) }
53
- < div className = 'controls' >
54
- { ifThen ( appState . isPaused , (
55
- < Tooltip placement = 'bottom' title = { < p > Resume < span className = 'kbd' > C </ span > </ p > } className = 'cy-tooltip' >
56
- < button aria-label = 'Resume' className = 'play' onClick = { emit ( 'resume' ) } >
50
+ { appState . isPaused && (
51
+ < Tooltip placement = 'bottom' title = { < p > Resume < span className = 'kbd' > C </ span > </ p > } className = 'cy-tooltip' >
52
+ < div >
53
+ < Button size = '20' variant = 'outline-dark' aria-label = 'Resume' className = 'play' onClick = { emit ( 'resume' ) } >
57
54
< IconActionPlayLarge size = '16' strokeColor = { iconStrokeColor } fillColor = { iconFillColor } />
58
- </ button >
59
- </ Tooltip >
60
- ) ) }
61
- { ifThen ( appState . isRunning && ! appState . isPaused , (
62
- < Tooltip placement = 'bottom' title = { < p > Stop Running < span className = 'kbd' > S</ span > </ p > } className = 'cy-tooltip' >
63
- < button aria-label = 'Stop' className = 'stop' onClick = { emit ( 'stop' ) } >
55
+ </ Button >
56
+ </ div >
57
+ </ Tooltip >
58
+ ) }
59
+ { appState . isRunning && ! appState . isPaused && (
60
+ < Tooltip placement = 'bottom' title = { < p > Stop Running < span className = 'kbd' > S</ span > </ p > } className = 'cy-tooltip' >
61
+ < div >
62
+ < Button size = '20' variant = 'outline-dark' aria-label = 'Stop' className = 'stop' onClick = { emit ( 'stop' ) } >
64
63
< IconActionStopCircle size = '16' strokeColor = { iconStrokeColor } />
65
- </ button >
66
- </ Tooltip >
67
- ) ) }
68
- { ifThen ( ! appState . isRunning , (
69
- < Tooltip placement = 'bottom' title = { < p > Run All Tests < span className = 'kbd' > R</ span > </ p > } className = 'cy-tooltip' >
70
- < button aria-label = 'Rerun all tests' className = 'restart' onClick = { emit ( 'restart' ) } >
64
+ </ Button >
65
+ </ div >
66
+ </ Tooltip >
67
+ ) }
68
+ { ! appState . isRunning && (
69
+ < Tooltip placement = 'bottom' title = { < p > Run All Tests < span className = 'kbd' > R</ span > </ p > } className = 'cy-tooltip' >
70
+ < div >
71
+ < Button size = '20' variant = 'outline-dark' aria-label = 'Rerun all tests' className = 'restart' onClick = { emit ( 'restart' ) } >
71
72
{ appState . studioActive ? (
72
73
< IconActionRestart transform = "scale(-1 1)" strokeColor = { iconStrokeColor } />
73
74
) : (
74
75
< IconActionRestart strokeColor = { iconStrokeColor } />
75
76
) }
76
- </ button >
77
- </ Tooltip >
78
- ) ) }
79
- { ifThen ( ! ! appState . nextCommandName , (
80
- < Tooltip placement = 'bottom' title = { < p > Next < span className = 'kbd' > [N]:</ span > { appState . nextCommandName } </ p > } className = 'cy-tooltip' >
81
- < button aria-label = { `Next '${ appState . nextCommandName } '` } className = 'next' onClick = { emit ( 'next' ) } >
77
+ </ Button >
78
+ </ div >
79
+ </ Tooltip >
80
+ ) }
81
+ { ! ! appState . nextCommandName && (
82
+ < Tooltip placement = 'bottom' title = { < p > Next < span className = 'kbd' > [N]:</ span > { appState . nextCommandName } </ p > } className = 'cy-tooltip' >
83
+ < div >
84
+ < Button size = '20' variant = 'outline-dark' aria-label = { `Next '${ appState . nextCommandName } '` } className = 'next' onClick = { emit ( 'next' ) } >
82
85
< IconActionNext size = '16' strokeColor = { iconStrokeColor } fillColor = { iconFillColor } />
83
- </ button >
84
- </ Tooltip >
85
- ) ) }
86
- </ div >
86
+ </ Button >
87
+ </ div >
88
+ </ Tooltip >
89
+ ) }
87
90
</ div >
88
91
)
89
92
} )
0 commit comments