Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C-3362] Port Popup component to Harmony #6685

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/harmony/src/components/layout/Popup/Popup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Meta, Title, Description, Primary, Controls } from '@storybook/blocks'

import { Heading, RelatedComponents } from 'storybook/components'

import * as PopupStories from './Popup.stories'

<Meta of={PopupStories} />

<Title />

- [Overview](#overview)
- [Props](#props)
- [Use cases and examples](#use-cases-and-examples)

<Heading>
## Overview
<Description />
</Heading>
<Primary />

## Props

<Controls />

## Use cases and examples

- Use Popup alongside components that require user interaction (hover, click) to summon additional more complex interaction
- Configure a header and dismiss button to show users how to dismiss the Popup

## Related components

<RelatedComponents componentNames={['Flex', 'Box']} />
47 changes: 47 additions & 0 deletions packages/harmony/src/components/layout/Popup/Popup.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.root {
font-family: var(--harmony-font-family);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?

position: absolute;
}

.popup {
background-color: var(--harmony-white);
border-radius: var(--harmony-unit-2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
border-radius: var(--harmony-unit-2);
border-radius: var(--harmony-border-radius-m);

https://www.figma.com/file/ZmEdR1D99gglpBgiZDqWrr/%F0%9F%A7%B1-Foundations?node-id=1935%3A54403&mode=dev

border: 1px solid var(--harmony-neutral-light-7);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
border: 1px solid var(--harmony-neutral-light-7);
border: 1px solid var(--harmony-border-strong);

we use a different system for neutrals now, it's harmony-n-xxx instead of harmony-neutral-light-x so for e.g. neutral-light-7 is now harmony-neutral-150 which is the same as harmony-border-strong (semantic)

box-shadow: 0 16px 20px 0 var(--harmony-tile-shadow-1-alt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this exists, ideally we'd use one of the harmony shadow values here https://www.figma.com/file/ZmEdR1D99gglpBgiZDqWrr/%F0%9F%A7%B1-Foundations?node-id=1929%3A4771&mode=dev

user-select: none;
}

.header {
border: none;
margin-bottom: var(--harmony-unit-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we generally prefer semantic spacing when possible so like --harmony-spacing-xs for this one

padding-bottom: 0;
display: flex;
align-items: center;
justify-content: center;
}

.header::after {
content: '';
width: var(--harmony-unit-2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

harmony-spacing-s

padding-right: var(--harmony-unit-half);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so smoll

}

.header.noAfter::after {
content: none !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need the !important?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all this css was copied from the existing one - so i'm not totally sure. want to keep this PR to as much of a consistent "port" as i can so i can drop in/replace the other usages within audius.co, but I'll come back to this...!

}

.title {
margin: 0 auto;
justify-self: center;
font-size: var(--harmony-font-m);
font-weight: var(--harmony-font-bold);
color: var(--harmony-neutral);
}

.iconRemove {
cursor: pointer;
height: var(--harmony-unit-6);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you can set this on the icon itself via size prop, will put a comment there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this isn't used anywhere, so delete?

width: var(--harmony-unit-6);
padding-left: var(--harmony-unit-half);
transition: all var(--harmony-quick);
}
65 changes: 65 additions & 0 deletions packages/harmony/src/components/layout/Popup/Popup.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { useRef, useState } from 'react'

import type { Meta, StoryObj } from '@storybook/react'

import { Button } from 'components/button'
import { Box } from 'components/layout/Box'
import { Paper } from 'components/layout/Paper'
import { Text } from 'components/text'

import { Popup } from './Popup'
import type { PopupProps } from './types'

const Render = (props: PopupProps) => {
const anchorRef = useRef<HTMLButtonElement | null>(null)
const [isVisible, setIsVisible] = useState(false)

return (
<Button ref={anchorRef} onClick={() => setIsVisible(!isVisible)}>
<Text>Click Me</Text>
<Popup
{...props}
anchorRef={anchorRef}
isVisible={isVisible}
onClose={() => setIsVisible(false)}
>
<Paper>
<Box p='l'>
<Text>Popup Content</Text>
</Box>
</Paper>
</Popup>
</Button>
)
}

const meta: Meta<typeof Popup> = {
title: 'Layout/Popup [beta]',
component: Popup,
parameters: {
controls: {
include: [
'anchorRef',
'isVisible',
'anchorOrigin',
'transformOrigin',
'dismissOnMouseLeave',
'showHeader',
'title',
'hideCloseButton',
'zIndex',
'containerRef',
'onClose',
'onAfterClose',
'checkIfClickInside'
]
}
},
render: Render
}

export default meta

type Story = StoryObj<typeof Popup>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to have some more stories here with different props applied, but can leave it for later


export const Default: Story = { args: {} }
Loading