Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/orange-beds-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

TreeView: Increase touch target size for coarse pointers
9 changes: 7 additions & 2 deletions src/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,24 @@ const Item: React.FC<TreeViewItemProps> = ({
}
}}
sx={{
'--toggle-width': '1rem', // 16px
position: 'relative',
display: 'grid',
gridTemplateColumns: `calc(${level - 1} * 8px) 16px 1fr`,
gridTemplateColumns: `calc(${level - 1} * (var(--toggle-width) / 2)) var(--toggle-width) 1fr`,
gridTemplateAreas: `"spacer toggle content"`,
width: '100%',
height: 32,
height: '2rem', // 32px
fontSize: 1,
color: 'fg.default',
borderRadius: 2,
cursor: 'pointer',
'&:hover': {
backgroundColor: 'actionListItem.default.hoverBg'
},
'@media (pointer: coarse)': {
'--toggle-width': '1.5rem', // 24px
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Is there a specific value for min touch target size in the guideline? Because I increased the touch target size on the UnderlineNav as well but used the value from design. I am curious to see if there is a guideline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. @mperrotti might know!

height: '2.75rem' // 44px
},
// WARNING: styled-components v5.2 introduced a bug that changed
// how it expands `&` in CSS selectors. The following selectors
// are unnecessarily specific to work around that styled-components bug.
Expand Down
11 changes: 10 additions & 1 deletion src/sx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export type BetterCssProperties = {
: SystemCssProperties[K]
}

export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject
// Support CSS custom properties in the `sx` prop
type CSSCustomProperties = {
[key: `--${string}`]: string | number
}

type CSSSelectorObject = {
[cssSelector: string]: SystemStyleObject | CSSCustomProperties
}

export type BetterSystemStyleObject = BetterCssProperties | SystemStyleObject | CSSCustomProperties | CSSSelectorObject

export interface SxProp {
sx?: BetterSystemStyleObject
Expand Down