Skip to content

Commit

Permalink
Merge 3ae1346 into a2536bf
Browse files Browse the repository at this point in the history
  • Loading branch information
francinelucca authored Oct 28, 2024
2 parents a2536bf + 3ae1346 commit 6407fb6
Show file tree
Hide file tree
Showing 69 changed files with 95 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-trainers-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

fix(Timeline): render as unordered list
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 16 additions & 12 deletions packages/react/src/Timeline/Timeline.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,23 @@ export const CondensedItems = () => (

export const TimelineBreak = () => (
<Timeline>
<Timeline.Item>
<Timeline.Badge sx={{bg: 'done.emphasis'}}>
<Octicon icon={GitMergeIcon} color="fg.onEmphasis" aria-label="Merged" />
</Timeline.Badge>
<Timeline.Body>This is a message</Timeline.Body>
</Timeline.Item>
<Timeline.Group>
<Timeline.Item>
<Timeline.Badge sx={{bg: 'done.emphasis'}}>
<Octicon icon={GitMergeIcon} color="fg.onEmphasis" aria-label="Merged" />
</Timeline.Badge>
<Timeline.Body>This is a message</Timeline.Body>
</Timeline.Item>
</Timeline.Group>
<Timeline.Break />
<Timeline.Item>
<Timeline.Badge>
<Octicon icon={GitBranchIcon} aria-label="Branch" />
</Timeline.Badge>
<Timeline.Body>This is a message</Timeline.Body>
</Timeline.Item>
<Timeline.Group>
<Timeline.Item>
<Timeline.Badge>
<Octicon icon={GitBranchIcon} aria-label="Branch" />
</Timeline.Badge>
<Timeline.Body>This is a message</Timeline.Body>
</Timeline.Item>
</Timeline.Group>
</Timeline>
)

Expand Down
32 changes: 29 additions & 3 deletions packages/react/src/Timeline/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ import type {SxProp} from '../sx'
import sx from '../sx'
import type {ComponentProps} from '../utils/types'

const Timeline = styled.div<{clipSidebar?: boolean} & SxProp>`
const Timeline = styled.ul<{clipSidebar?: boolean} & SxProp>`
display: flex;
flex-direction: column;
list-style: none;
padding-inline-start: 0;
margin-block-start: 0;
margin-block-end: 0;
.Timeline-Group {
padding-inline-start: 0;
}
${props =>
props.clipSidebar &&
css`
Expand All @@ -27,7 +36,7 @@ const Timeline = styled.div<{clipSidebar?: boolean} & SxProp>`

type StyledTimelineItemProps = {condensed?: boolean} & SxProp

const TimelineItem = styled.div.attrs<StyledTimelineItemProps>(props => ({
const TimelineItem = styled.li.attrs<StyledTimelineItemProps>(props => ({
className: clsx('Timeline-Item', props.className),
}))<StyledTimelineItemProps>`
display: flex;
Expand Down Expand Up @@ -108,7 +117,7 @@ const TimelineBody = styled.div<SxProp>`
${sx};
`

const TimelineBreak = styled.div<SxProp>`
const StyledTimelineBreak = styled.div<SxProp>`
position: relative;
z-index: 1;
height: 24px;
Expand All @@ -121,6 +130,21 @@ const TimelineBreak = styled.div<SxProp>`
${sx};
`

function TimelineBreak(props: ComponentProps<typeof StyledTimelineBreak>) {
return <StyledTimelineBreak aria-hidden {...props} />
}

function TimelineGroup({children, ...props}: React.ComponentPropsWithoutRef<'ul'>) {
return (
<Box as="li">
<Box as="ul" className="Timeline-Group" {...props}>
{children}
</Box>
</Box>
)
}
TimelineGroup.displayName = 'Timeline.Group'

TimelineItem.displayName = 'Timeline.Item'

TimelineBadge.displayName = 'Timeline.Badge'
Expand All @@ -133,9 +157,11 @@ export type TimelineProps = ComponentProps<typeof Timeline>
export type TimelineItemsProps = ComponentProps<typeof TimelineItem>
export type TimelineBodyProps = ComponentProps<typeof TimelineBody>
export type TimelineBreakProps = ComponentProps<typeof TimelineBreak>
export type TimelineGroupProps = ComponentProps<typeof TimelineGroup>
export default Object.assign(Timeline, {
Item: TimelineItem,
Badge: TimelineBadge,
Body: TimelineBody,
Break: TimelineBreak,
Group: TimelineGroup,
})
35 changes: 34 additions & 1 deletion packages/react/src/Timeline/__tests__/Timeline.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ describe('Timeline.Item', () => {
behavesAsComponent({Component: Timeline.Item})

it('should have no axe violations', async () => {
const {container} = HTMLRender(<Timeline.Item />)
const {container} = HTMLRender(
<Timeline>
<Timeline.Item />
</Timeline>,
)
const results = await axe.run(container)
expect(results).toHaveNoViolations()
})
Expand All @@ -50,3 +54,32 @@ describe('Timeline.Badge', () => {
expect(results).toHaveNoViolations()
})
})

describe('Timeline.Break', () => {
behavesAsComponent({Component: Timeline.Break})

it('should have no axe violations', async () => {
const {container} = HTMLRender(<Timeline.Break />)
const results = await axe.run(container)
expect(results).toHaveNoViolations()
})
})

describe('Timeline.Group', () => {
behavesAsComponent({Component: Timeline.Group, options: {skipAs: true, skipSx: true}})

// TODO
it.todo('correctly renders with Timeline.Group')

it('should have no axe violations', async () => {
const {container} = HTMLRender(
<Timeline>
<Timeline.Group>
<Timeline.Item>test</Timeline.Item>
</Timeline.Group>
</Timeline>,
)
const results = await axe.run(container)
expect(results).toHaveNoViolations()
})
})
3 changes: 3 additions & 0 deletions packages/react/src/Timeline/__tests__/Timeline.types.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function shouldAcceptCallWithNoProps() {
<Timeline.Badge />
<Timeline.Body />
<Timeline.Break />
<Timeline.Group />
</>
)
}
Expand All @@ -26,6 +27,8 @@ export function shouldNotAcceptSystemProps() {
<Timeline.Body backgroundColor="green" />
{/* @ts-expect-error system props should not be accepted */}
<Timeline.Break backgroundColor="blue" />
{/* @ts-expect-error system props should not be accepted */}
<Timeline.Group backgroundColor="blue" />
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ exports[`Timeline renders with clipSidebar prop 1`] = `
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
list-style: none;
padding-inline-start: 0;
}
.c0 .Timeline-Group {
padding-inline-start: 0;
}
.c0 .Timeline-Item:first-child {
Expand All @@ -19,7 +25,7 @@ exports[`Timeline renders with clipSidebar prop 1`] = `
padding-bottom: 0;
}
<div
<ul
className="c0"
/>
`;
Expand Down Expand Up @@ -61,7 +67,7 @@ exports[`Timeline.Item renders with condensed prop 1`] = `
border: 0;
}
<div
<li
className="c0 Timeline-Item"
/>
`;

0 comments on commit 6407fb6

Please sign in to comment.