Skip to content

Commit

Permalink
fix: AccordionPanel のフォーカスインジケータが隠れないように修正 (SHRUI-412) (#1698)
Browse files Browse the repository at this point in the history
* fix: modify focus indicator not to be hidden by sibling elements

* chore: move focus indicator styles into theme.shadow
  • Loading branch information
wmoai authored Jun 29, 2021
1 parent 963ec24 commit f82fe2c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/components/AccordionPanel/AccordionPanelTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,16 @@ const Button = styled.button<{ themes: Theme }>`
border-radius: 0 0 ${radiusMap.m} ${radiusMap.m};
}
&:focus {
outline: none;
box-shadow: ${shadow.OUTLINE};
}
&:hover,
&:focus:not(:focus-visible) {
background-color: ${color.hoverColor('#fff')};
box-shadow: none;
}
&:focus {
${shadow.focusIndicatorStyles}
}
/* TODO replace if impremented Layout component */
& > * + * {
margin-left: ${spacingByChar(0.5)};
Expand Down
19 changes: 17 additions & 2 deletions src/themes/createShadow.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FlattenSimpleInterpolation, css } from 'styled-components'
import { merge } from '../libs/lodash'
import { defaultColor } from './createColor'

Expand All @@ -11,15 +12,29 @@ export interface CreatedShadowTheme {
BASE: string
DIALOG: string
OUTLINE: string
focusIndicatorStyles: FlattenSimpleInterpolation
}

const defaultOutline = `0 0 0 2px white, 0 0 0 4px ${defaultColor.OUTLINE}`

export const defaultShadow = {
BASE: 'rgba(51, 51, 51, 0.15) 0 0 4px 0',
DIALOG: 'rgba(51, 51, 51, 0.3) 0 4px 10px 0',
OUTLINE: `0 0 0 2px white, 0 0 0 4px ${defaultColor.OUTLINE}`,
OUTLINE: defaultOutline,
}

function createFocusIndicatorStyles(outline?: string) {
return css`
outline: none;
isolation: isolate;
box-shadow: ${outline || defaultOutline};
`
}

export const createShadow = (userShadow: ShadowProperty = {}) => {
const created: CreatedShadowTheme = merge({ ...defaultShadow }, userShadow)
const created: CreatedShadowTheme = merge(
{ ...defaultShadow, focusIndicatorStyles: createFocusIndicatorStyles(userShadow.OUTLINE) },
userShadow,
)
return created
}

0 comments on commit f82fe2c

Please sign in to comment.