Skip to content

Commit

Permalink
Merge branch 'main' into color-blind-themes
Browse files Browse the repository at this point in the history
  • Loading branch information
colebemis authored Sep 28, 2021
2 parents fd18dd1 + dc15763 commit 56ed28a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-deers-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/components': major
---

AvatarStack no longer accepts styled props or DOM props
22 changes: 8 additions & 14 deletions docs/content/AvatarStack.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title: AvatarStack
---

import {Props} from '../src/props'
import {AvatarStack} from '@primer/components'

AvatarStack is used to display more than one Avatar in an inline stack.

### Default example
Expand All @@ -26,18 +29,9 @@ AvatarStack is used to display more than one Avatar in an inline stack.
</AvatarStack>
```

## System props

<Note variant="warning">

System props are deprecated in all components except [Box](/Box). Please use the [`sx` prop](/overriding-styles) instead.

</Note>

AvatarStack components get `COMMON` system props, AvatarStack.Item components do not get any system props. Read our [System Props](/system-props) doc page for a full list of available props.

## AvatarStack Component props
## Props

| Name | Type | Default | Description |
| :--------- | :------ | :-----: | :-------------------------------- |
| alignRight | Boolean | | Creates right aligned AvatarStack |
| Name | Type | Default | Description |
| :--------- | :---------------- | :-----: | :----------------------------------- |
| alignRight | Boolean | | Creates right aligned AvatarStack |
| sx | SystemStyleObject | {} | Style to be applied to the component |
14 changes: 6 additions & 8 deletions src/AvatarStack.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import classnames from 'classnames'
import React from 'react'
import styled from 'styled-components'
import {COMMON, get, SystemCommonProps} from './constants'
import {get} from './constants'
import {Box} from '.'
import sx, {SxProp} from './sx'
import {ComponentProps} from './utils/types'

type StyledAvatarStackWrapperProps = {
count?: number
} & SystemCommonProps &
SxProp
} & SxProp

const AvatarStackWrapper = styled.span<StyledAvatarStackWrapperProps>`
display: flex;
Expand Down Expand Up @@ -125,7 +123,6 @@ const AvatarStackWrapper = styled.span<StyledAvatarStackWrapperProps>`
}
}
${COMMON}
${sx};
`
const transformChildren = (children: React.ReactNode) => {
Expand All @@ -140,17 +137,18 @@ const transformChildren = (children: React.ReactNode) => {

export type AvatarStackProps = {
alignRight?: boolean
} & ComponentProps<typeof AvatarStackWrapper>
children: React.ReactNode
} & SxProp

const AvatarStack = ({children, alignRight, ...rest}: AvatarStackProps) => {
const AvatarStack = ({children, alignRight, sx: sxProp}: AvatarStackProps) => {
const count = React.Children.count(children)
const wrapperClassNames = classnames({
'pc-AvatarStack--two': count === 2,
'pc-AvatarStack--three-plus': count > 2,
'pc-AvatarStack--right': alignRight
})
return (
<AvatarStackWrapper count={count} className={wrapperClassNames} {...rest}>
<AvatarStackWrapper count={count} className={wrapperClassNames} sx={sxProp}>
<Box position="absolute" display="flex" width="38px" className="pc-AvatarStackBody">
{transformChildren(children)}
</Box>
Expand Down
6 changes: 5 additions & 1 deletion src/__tests__/AvatarStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const rightAvatarComp = (
)

describe('Avatar', () => {
behavesAsComponent({Component: AvatarStack, toRender: () => avatarComp})
behavesAsComponent({
Component: AvatarStack,
toRender: () => avatarComp,
options: {skipAs: true}
})

checkExports('AvatarStack', {
default: AvatarStack
Expand Down

0 comments on commit 56ed28a

Please sign in to comment.