docs: Add docs for horizontal orientation#9843
Conversation
|
Build successful! 🎉 |
| constructor(options: ListLayoutOptions = {}) { | ||
| super(); | ||
| this.rowHeight = options.rowHeight ?? null; | ||
| this.rowHeight = options?.rowSize ?? options?.rowHeight ?? null; |
There was a problem hiding this comment.
We could also go ahead and change these height properties to be size as well, would just need to make it back compat with additional getters. Not sure if worth it if those would stick around for quite some time, but might reduce confusion
| this.headingHeight = options.headingHeight ?? null; | ||
| this.estimatedHeadingHeight = options.estimatedHeadingHeight ?? null; | ||
| this.loaderHeight = options.loaderHeight ?? null; | ||
| this.estimatedRowHeight = options?.estimatedRowSize ?? options?.estimatedRowHeight ?? null; |
There was a problem hiding this comment.
did we want to change all the internal variables to size as well?
There was a problem hiding this comment.
o, i think that's what you were saying here #9843 (comment)
There was a problem hiding this comment.
yep, thats right. I might try and do it to see how bad it is
There was a problem hiding this comment.
Btw, when working on this I was kind of unsure whether to use "size" here, since that typically refers to a 2-dimensional value in the context of our virtualizer package. I think it's fine, but wanted to share it for consideration - naming is hard 😅
There was a problem hiding this comment.
haha yeah, I had a similar thought but couldn't think up of a better alternative either. I'll see about pushing up the full changes and then see if we can land on a better name
| grid-template-columns: auto; | ||
| align-items: center; | ||
|
|
||
| &[data-orientation=horizontal] { |
There was a problem hiding this comment.
Need this in the tailwind starter as well
| selectionMode="multiple" | ||
| items={items} | ||
| style={{display: 'block', padding: 0, height: 100}}> | ||
| {(item) => <ListBoxItem style={{height: '100%'}}>{item.name}</ListBoxItem>} |
There was a problem hiding this comment.
We should add some styles to the items so that it's clear where one ends and the next begins. Right now it just looks like a long string of text with some random break in it.
It'd also be nice if this was an example I'd want to use, so if we can make them basically more like cards with a title and description, that'd be better
|
Build successful! 🎉 |
|
|
||
| Use the `orientation` option to arrange items horizontally or vertically. Provide the same `orientation` on the collection component so keyboard navigation matches the layout. | ||
|
|
||
| ```tsx render docs={docs.exports.ListLayoutOptions} links={docs.links} props={['gap', 'padding']} initialProps={{estimatedRowSize: 300, gap: 8, padding: 8, orientation: 'horizontal'}} propsObject="layoutOptions" wide |
There was a problem hiding this comment.
any chance we make the images a tad bit smaller
|
Build successful! 🎉 |
snowystinger
left a comment
There was a problem hiding this comment.
smaller images in the cards would be nice, otherwise looks good
Co-authored-by: Yihui Liao <44729383+yihuiliao@users.noreply.github.com>
|
@LFDanLu Has the issue found in testing already been taken care of? Otherwise I will open up a PR with a fix for that. |
| <ListBox | ||
| /*- begin highlight -*/ | ||
| orientation="horizontal" | ||
| /*- end highlight -*/ | ||
| aria-label="Horizontal virtualized list" | ||
| selectionMode="multiple" | ||
| items={imageOptions} | ||
| style={{display: 'block', padding: 0, height: 250}}> | ||
| {(item) => ( | ||
| <ListBoxItem textValue={item.title} aria-label={item.title} style={{height: '100%', padding: 12, overflow: 'hidden', boxSizing: 'border-box', border: '2px solid var(--border-color)', borderRadius: 8}}> | ||
| <img src={item.image} alt="" style={{maxHeight: 200, aspectRatio: item.aspectRatio, borderRadius: 4}} /> | ||
| </ListBoxItem> | ||
| )} | ||
| </ListBox> |
There was a problem hiding this comment.
@yihuiliao @snowystinger I opted to just go for a simpler change and get rid of the text, was getting a lot of grief with the virtualized card sizing vs getting the img width to be variable and clamped + making the text overflow work without making this example overly complicated
|
@nwidynski mind jogging my memory about what exact issue that was haha. |
|
I think it was just that the styles I added in storybook spread to the combobox stories (see spreadsheet comment). would also take care of the nits that devon mentioned when approving. Edit: Seems to have been already done in #9845 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
## API Changes
react-aria-components/react-aria-components:TableLayout TableLayout <O extends TableLayoutProps = TableLayoutProps, T> {
- constructor: (ListLayoutOptions) => void
+ constructor: (TableLayoutProps) => void
getContentSize: () => Size
getDropTargetFromPoint: (number, number, (DropTarget) => boolean) => DropTarget | null
getDropTargetLayoutInfo: (ItemDropTarget) => LayoutInfo
getLayoutInfo: (Key) => LayoutInfo | null
shouldInvalidate: (Rect, Rect) => boolean
shouldInvalidateLayoutOptions: (TableLayoutProps, TableLayoutProps) => boolean
update: (InvalidationContext<TableLayoutProps>) => void
updateItemSize: (Key, Size) => boolean
useLayoutOptions: () => TableLayoutProps
virtualizer: Virtualizer<{}, any> | null
}/react-aria-components:ListLayoutOptions ListLayoutOptions {
dropIndicatorThickness?: number = 2
- estimatedHeadingHeight?: number
- estimatedRowHeight?: number
+ estimatedHeadingSize?: number
+ estimatedRowSize?: number
gap?: number = 0
- headingHeight?: number = 48
- loaderHeight?: number = 48
+ headingSize?: number = 48
+ loaderSize?: number = 48
orientation?: Orientation = 'vertical'
padding?: number = 0
- rowHeight?: number = 48
+ rowSize?: number = 48
}/react-aria-components:TableLayoutProps+TableLayoutProps {
+ columnWidths?: Map<Key, number>
+ dropIndicatorThickness?: number = 2
+ estimatedHeadingHeight?: number
+ estimatedRowHeight?: number
+ gap?: number = 0
+ headingHeight?: number = 48
+ loaderHeight?: number = 48
+ padding?: number = 0
+ rowHeight?: number = 48
+}@react-spectrum/s2/@react-spectrum/s2:ListView ListView <T extends {}> {
UNSAFE_className?: UnsafeClassName
UNSAFE_style?: CSSProperties
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children: ReactNode | ({}) => ReactNode
defaultSelectedKeys?: 'all' | Iterable<Key>
dependencies?: ReadonlyArray<any>
disabledBehavior?: DisabledBehavior = "all"
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
disallowTypeAhead?: boolean = false
escapeKeyBehavior?: 'clearSelection' | 'none' = 'clearSelection'
hideLinkOutIcon?: boolean
id?: string
isQuiet?: boolean
items?: Iterable<T>
loadingState?: LoadingState
onAction?: (Key) => void
onLoadMore?: () => void
onSelectionChange?: (Selection) => void
- orientation?: Orientation = 'vertical'
overflowMode?: 'wrap' | 'truncate' = 'truncate'
renderActionBar?: ('all' | Set<Key>) => ReactElement
renderEmptyState?: (GridListRenderProps) => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionStyle?: 'highlight' | 'checkbox' = 'checkbox'
shouldSelectOnPressUp?: boolean
slot?: string | null
styles?: StylesPropWithHeight
}/@react-spectrum/s2:ListViewProps ListViewProps <T> {
UNSAFE_className?: UnsafeClassName
UNSAFE_style?: CSSProperties
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children: ReactNode | (T) => ReactNode
defaultSelectedKeys?: 'all' | Iterable<Key>
dependencies?: ReadonlyArray<any>
disabledBehavior?: DisabledBehavior = "all"
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
disallowTypeAhead?: boolean = false
escapeKeyBehavior?: 'clearSelection' | 'none' = 'clearSelection'
hideLinkOutIcon?: boolean
id?: string
isQuiet?: boolean
items?: Iterable<T>
loadingState?: LoadingState
onAction?: (Key) => void
onLoadMore?: () => void
onSelectionChange?: (Selection) => void
- orientation?: Orientation = 'vertical'
overflowMode?: 'wrap' | 'truncate' = 'truncate'
renderActionBar?: ('all' | Set<Key>) => ReactElement
renderEmptyState?: (GridListRenderProps) => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionStyle?: 'highlight' | 'checkbox' = 'checkbox'
shouldSelectOnPressUp?: boolean
slot?: string | null
styles?: StylesPropWithHeight
}@react-stately/layout/@react-stately/layout:TableLayout TableLayout <O extends TableLayoutProps = TableLayoutProps, T> {
- constructor: (ListLayoutOptions) => void
+ constructor: (TableLayoutProps) => void
getContentSize: () => Size
getDropTargetFromPoint: (number, number, (DropTarget) => boolean) => DropTarget | null
getDropTargetLayoutInfo: (ItemDropTarget) => LayoutInfo
getLayoutInfo: (Key) => LayoutInfo | null
shouldInvalidate: (Rect, Rect) => boolean
shouldInvalidateLayoutOptions: (TableLayoutProps, TableLayoutProps) => boolean
update: (InvalidationContext<TableLayoutProps>) => void
updateItemSize: (Key, Size) => boolean
virtualizer: Virtualizer<{}, any> | null
}/@react-stately/layout:ListLayoutOptions ListLayoutOptions {
dropIndicatorThickness?: number = 2
- estimatedHeadingHeight?: number
- estimatedRowHeight?: number
+ estimatedHeadingSize?: number
+ estimatedRowSize?: number
gap?: number = 0
- headingHeight?: number = 48
- loaderHeight?: number = 48
+ headingSize?: number = 48
+ loaderSize?: number = 48
orientation?: Orientation = 'vertical'
padding?: number = 0
- rowHeight?: number = 48
+ rowSize?: number = 48
}/@react-stately/layout:TableLayoutProps TableLayoutProps {
columnWidths?: Map<Key, number>
dropIndicatorThickness?: number = 2
estimatedHeadingHeight?: number
estimatedRowHeight?: number
gap?: number = 0
headingHeight?: number = 48
loaderHeight?: number = 48
- orientation?: Orientation = 'vertical'
padding?: number = 0
rowHeight?: number = 48
} |
Part of audit
✅ Pull Request Checklist:
📝 Test Instructions:
Check out the docs updates
🧢 Your Project:
RSP