Skip to content

Commit

Permalink
fix(AnchoredOverlay): replace broken stories (#5056)
Browse files Browse the repository at this point in the history
* fix(AnchoredOverlay): replace broken stories

* fix: storybook build failure

* Docs(AnchoredOverlay): rewrite hovercard using stack

* Docs(AnchoredOverlay): remove unused variable

* Docs(AnchoredOverlay): use text size prop in stories instead of fontSize

* Update packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.tsx

Co-authored-by: Mike Perrotti <mperrotti@github.com>

* Docs(AnchoredOverlay): use sx prop for styling instead of styled-system props

---------

Co-authored-by: Mike Perrotti <mperrotti@github.com>
  • Loading branch information
francinelucca and mperrotti authored Oct 9, 2024
1 parent 0d444d7 commit 6cd3960
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,49 @@ import React, {useEffect, useRef, useState} from 'react'
import type {Args, Meta} from '@storybook/react'
import {FocusKeys} from '@primer/behaviors'

import {Box, Button} from '..'
import {Avatar, Box, Text} from '..'
import {AnchoredOverlay} from '../AnchoredOverlay'
import Heading from '../Heading'
import Octicon from '../Octicon'
import {Button} from '../Button'
import {registerPortalRoot} from '../Portal'
import {Playground} from './AnchoredOverlay.stories'
import {LocationIcon, RepoIcon} from '@primer/octicons-react'
import {Stack} from '../Stack/Stack'

export default {
title: 'Components/AnchoredOverlay/Features',
component: AnchoredOverlay,
} as Meta

const hoverCard = (
<Stack gap="condensed" style={{minWidth: '320px', padding: '16px'}}>
<Stack direction="horizontal" gap="condensed" justify="space-between">
<Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" size={48} />
<Button size="small">Follow</Button>
</Stack>
<Stack direction="horizontal" gap="none">
<Text weight="medium">monalisa</Text>
<Text color={'var(--fgColor-muted)'} ml={1}>
Monalisa Octocat
</Text>
</Stack>
<Text size="medium">Former beach cat and champion swimmer. Now your friendly octapus with a normal face.</Text>
<Stack direction="horizontal" gap="none">
<Octicon color={'var(--fgColor-muted)'} icon={LocationIcon} />
<Text size="small" color={'var(--fgColor-muted)'} ml={1}>
Interwebs
</Text>
</Stack>
<Stack direction="horizontal" gap="none">
<Octicon color={'var(--fgColor-muted)'} icon={RepoIcon} />
<Text size="small" color={'var(--fgColor-muted)'} ml={1}>
Owns this repository
</Text>
</Stack>
</Stack>
)

const HeaderAndLayout = ({children}: {children: JSX.Element}) => {
const scrollingElementRef = useRef<HTMLDivElement>(null)
useEffect(() => {
Expand Down Expand Up @@ -70,9 +102,7 @@ export const CustomAnchorId = () => {
renderAnchor={props => <Button {...props}>Button</Button>}
anchorId="my-custom-anchor-id"
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand All @@ -88,9 +118,7 @@ export const Height = () => {
renderAnchor={props => <Button {...props}>Button</Button>}
height="large"
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand All @@ -106,9 +134,7 @@ export const Width = () => {
renderAnchor={props => <Button {...props}>Button</Button>}
width="large"
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand All @@ -128,9 +154,7 @@ export const AnchorAlignment = () => {
)}
align="center"
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand All @@ -146,9 +170,7 @@ export const AnchorSide = () => {
renderAnchor={props => <Button {...props}>Button</Button>}
side="outside-right"
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand All @@ -164,9 +186,7 @@ export const OffsetPositionFromAnchor = () => {
renderAnchor={props => <Button {...props}>Button</Button>}
anchorOffset={100}
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand All @@ -182,9 +202,7 @@ export const OffsetAlignmentFromAnchor = () => {
renderAnchor={props => <Button {...props}>Button</Button>}
alignmentOffset={100}
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
Expand Down Expand Up @@ -247,9 +265,7 @@ export const OverlayPropsOverrides = () => {
<li>overflow: `auto`</li>
<li>maxHeight: `xsmall`</li>
</pre>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
<Box sx={{width: '100%', height: '100%', display: 'flex', flexDirection: 'column'}}>{hoverCard}</Box>
</AnchoredOverlay>
)
}
43 changes: 35 additions & 8 deletions packages/react/src/AnchoredOverlay/AnchoredOverlay.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
import React, {useState} from 'react'
import type {Args, Meta} from '@storybook/react'
import {LocationIcon, RepoIcon} from '@primer/octicons-react'

import {Box} from '..'
import {Avatar, Text} from '..'
import {AnchoredOverlay} from '../AnchoredOverlay'
import {Button} from '../Button'
import Octicon from '../Octicon'
import {action} from '@storybook/addon-actions'
import {Stack} from '../Stack/Stack'

export default {
title: 'Components/AnchoredOverlay',
component: AnchoredOverlay,
} as Meta

const hoverCard = (
<Stack gap="condensed" style={{minWidth: '320px', padding: '16px'}}>
<Stack direction="horizontal" gap="condensed" justify="space-between">
<Avatar src="https://avatars.githubusercontent.com/u/92997159?v=4" size={48} />
<Button size="small">Follow</Button>
</Stack>
<Stack direction="horizontal" gap="none">
<Text weight="medium">monalisa</Text>
<Text color={'var(--fgColor-muted)'} ml={1}>
Monalisa Octocat
</Text>
</Stack>
<Text size="medium">Former beach cat and champion swimmer. Now your friendly octapus with a normal face.</Text>
<Stack direction="horizontal" gap="none">
<Octicon color={'var(--fgColor-muted)'} icon={LocationIcon} />
<Text size="small" color={'var(--fgColor-muted)'} ml={1}>
Interwebs
</Text>
</Stack>
<Stack direction="horizontal" gap="none">
<Octicon color={'var(--fgColor-muted)'} icon={RepoIcon} />
<Text size="small" color={'var(--fgColor-muted)'} ml={1}>
Owns this repository
</Text>
</Stack>
</Stack>
)

export const Default = () => {
const [open, setOpen] = useState(false)

Expand All @@ -21,9 +52,7 @@ export const Default = () => {
onClose={() => setOpen(false)}
renderAnchor={props => <Button {...props}>Button</Button>}
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
{hoverCard}
</AnchoredOverlay>
)
}
Expand All @@ -48,14 +77,12 @@ export const Playground = (args: Args) => {
overlayProps={args.portalContainerName}
side={args.side}
>
<Box width="100%" height="100%" backgroundColor="thistle" display="flex" flexDirection="column">
<img src={`//placekitten.com/200/300`} alt="kitten" />
</Box>
{hoverCard}
</AnchoredOverlay>
)
}
Playground.args = {
width: 'small',
width: 'auto',
height: 'auto',
portalContainerName: 'Portal name',
side: 'outside-bottom',
Expand Down

0 comments on commit 6cd3960

Please sign in to comment.