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

Banner Component #90

Merged
merged 16 commits into from
Sep 6, 2023
Merged

Banner Component #90

merged 16 commits into from
Sep 6, 2023

Conversation

Twonarly1
Copy link
Contributor

Description

Task link: https://trello.com/c/C9mrl9bu/103-banner-component

Added Banner component.

Test Steps

Ensure the component's structure, stories, and testing suite are robust.
Confirm that all tests are successful.
Check that the Banner displays correctly in both storybook and sample downstream applications.

@vercel
Copy link

vercel bot commented Sep 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview Sep 6, 2023 7:47pm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests failed line 16.
error: TestingLibraryElementError: Unable to find role="button"

),
};

export const BannerState: Story = {
...Default,
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to ...Closeable to get the tests to pass

Comment on lines 17 to 19
position: "absolute",
top: 0,
left: 0,
Copy link
Contributor

@hobbescodes hobbescodes Sep 6, 2023

Choose a reason for hiding this comment

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

So I think we may want to remove this default positioning for the banner. The issue is, that with absolute positioning it can cause overlap with other elements (See: here). I tested this out by placing a Banner component in the vite-react example app at the very top and you can tell that if it wasn't for the py on the Flex container, that the banner would cover the Text element that is below it. Now, the other thing to note, is that with storybook examples, once you remove this positioning, you need to make sure there is a wrapper around Banner (similar to what you did with the Stacked story):

export const Default: Story = {
  render: () => (
    <VStack position="absolute" inset={0}>
      <Banner>Banner</Banner>
    </VStack>
  ),
};

This way you get the full "effect" you are going for with the currently positioned Banner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I went back and forth on this and decided the default positioning for absolute was easier for the storybook and figured it could be modified easily with a few styles being overwrited. Another reason I used it this way is because most of our components in storybook didn't rely on any wrapper to be used and was just the component itself. Either way work just the same for me, just need to know what's preferred.

Copy link
Contributor

Choose a reason for hiding this comment

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

Definitely remove positioning in the recipe, imo. I think putting a wrapper around the Banner stories is a small price to pay compared to the overlapping issues the default Banner (if absolutely positioned) would have in downstream apps. I rather opt into absolute position in a downstream app if needed, rather than having to opt out, if that makes sense.

Copy link
Contributor

@hobbescodes hobbescodes Sep 6, 2023

Choose a reason for hiding this comment

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

As a matter of fact, instead of using a wrapper in stories, you could opt into those styles:

export const Default: Story = {
  render: () => <Banner position="absolute" top={0} left={0}>Banner</Banner>,
};

/**
* Core UI banner.
*/
const Banner = ({ children, variant, closable, ...props }: Props) => {
Copy link
Contributor

@hobbescodes hobbescodes Sep 6, 2023

Choose a reason for hiding this comment

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

change ...props to ...rest and update line 26 as well.

Comment on lines 12 to 16
export interface Props
extends Omit<ComponentProps<typeof panda.div>, "color">,
BannerVariantProps {
closable?: boolean;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can simplify to:

export interface Props
  extends ComponentProps<typeof panda.div>,
    BannerVariantProps {
  closable?: boolean;
}

I know this was done when we were discussing color variants, but that is no long an issue (no prop collision) with your updated recipe!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eye.

Comment on lines 1 to 14
import { VStack } from "@animareflection/ui";
import { Banner } from "@animareflection/ui/client";

import { Wrapper } from "components";

const BannerDemo = () => (
<Wrapper title="Banner">
<VStack position="relative" inset={0}>
<Banner closable>Banner</Banner>
</VStack>
</Wrapper>
);

export default BannerDemo;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add relative positioning to the Banner recipe (in the base), then you can simplify this:

import { Banner } from "@animareflection/ui/client";

import { Wrapper } from "components";

const BannerDemo = () => (
  <Wrapper title="Banner">
    <Banner closable>Banner</Banner>
  </Wrapper>
);

export default BannerDemo;

After that is done it all lgtm so should be able to send it!

Copy link
Contributor

@hobbescodes hobbescodes left a comment

Choose a reason for hiding this comment

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

Lgtm! Nice work!

@Twonarly1 Twonarly1 merged commit e2c27e4 into master Sep 6, 2023
@Twonarly1 Twonarly1 deleted the feature/banner-component branch September 6, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants