-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(collection-row): create new component and replace slot usages (#…
- Loading branch information
Showing
16 changed files
with
279 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Compose } from '@vtex/shoreline-primitives' | ||
import { forwardRef, style } from '@vtex/shoreline-utils' | ||
import type { ComponentPropsWithoutRef } from 'react' | ||
import React from 'react' | ||
import type { FlexOptions } from '../flex' | ||
|
||
/** | ||
* Row of the collection | ||
* @status stable | ||
*/ | ||
export const CollectionRow = forwardRef<HTMLDivElement, CollectionRowProps>( | ||
function CollectionRow(props, ref) { | ||
const { | ||
asChild = false, | ||
style: styleProp, | ||
gap = '$space-2', | ||
align = 'center', | ||
justify = 'space-between', | ||
direction = 'row', | ||
...otherProps | ||
} = props | ||
|
||
const Comp = asChild ? Compose : 'div' | ||
|
||
return ( | ||
<Comp | ||
data-sl-collection-row | ||
style={style({ | ||
'--gap': gap, | ||
'--align': align, | ||
'--justify': justify, | ||
'--direction': direction, | ||
...styleProp, | ||
})} | ||
ref={ref} | ||
{...otherProps} | ||
/> | ||
) | ||
} | ||
) | ||
|
||
export interface CollectionRowOptions | ||
extends Pick<FlexOptions, 'gap' | 'align' | 'justify' | 'direction'> { | ||
/** | ||
* Children composition | ||
* @default false | ||
*/ | ||
asChild?: boolean | ||
} | ||
|
||
export type CollectionRowProps = CollectionRowOptions & | ||
ComponentPropsWithoutRef<'div'> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './collection' | ||
export * from './collection-view' | ||
export * from './collection-row' |
Oops, something went wrong.