Skip to content

Commit 23ccfc0

Browse files
committed
Background styles for focused action list item
1 parent 7613c2f commit 23ccfc0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/ActionList/Item.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ const StyledItem = styled.div<{variant: ItemProps['variant']} & SxProp>`
5353
5454
@media (hover: hover) and (pointer: fine) {
5555
:hover {
56-
background: ${props =>
57-
props.variant === 'danger' ? get('colors.bg.danger') : get('colors.selectMenu.tapHighlight')};
56+
background: ${props => (props.variant === 'danger' ? '#FFF0F2' : '#F0F3F5')};
5857
cursor: pointer;
5958
}
6059
}
6160
61+
&:focus {
62+
background: ${props => (props.variant === 'danger' ? '#FFDBE0' : '#E0E4E7')};
63+
outline: none;
64+
}
65+
6266
${sx}
6367
`
6468

@@ -103,7 +107,7 @@ export function Item({
103107
...props
104108
}: Partial<ItemProps>): JSX.Element {
105109
return (
106-
<StyledItem variant={variant} {...props}>
110+
<StyledItem tabIndex={-1} variant={variant} {...props}>
107111
{LeadingVisual && (
108112
<LeadingVisualContainer>
109113
<LeadingVisual />

src/stories/ActionList.stories.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import {
1010
GearIcon
1111
} from '@primer/octicons-react'
1212
import {Meta} from '@storybook/react'
13-
import React from 'react'
13+
import React, {useRef} from 'react'
1414
import styled from 'styled-components'
1515
import {ThemeProvider} from '..'
1616
import {ActionList as _ActionList} from '../ActionList'
1717
import {Header} from '../ActionList/Header'
1818
import BaseStyles from '../BaseStyles'
19+
import {useFocusZone} from '../hooks/useFocusZone'
1920
import sx from '../sx'
2021

2122
const ActionList = Object.assign(_ActionList, {
@@ -77,10 +78,13 @@ export function ActionsStory(): JSX.Element {
7778
ActionsStory.storyName = 'Actions'
7879

7980
export function SimpleListStory(): JSX.Element {
81+
const containerRef = useRef(null)
82+
useFocusZone({containerRef})
83+
8084
return (
8185
<>
8286
<h1>Simple List</h1>
83-
<ErsatzOverlay>
87+
<ErsatzOverlay ref={containerRef}>
8488
<ActionList
8589
items={[
8690
{text: 'New file'},

0 commit comments

Comments
 (0)