这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@harishm72
Copy link
Contributor

@harishm72 harishm72 commented May 9, 2020

Affected components

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System
  • Tests
  • Other (list it)

Related Issues

#4314 (comment)

Breaking changes

  • No Breaking changes
  • There are breaking changes:

@harishm72 harishm72 requested a review from a team as a code owner May 9, 2020 19:03
@hasura-bot
Copy link
Contributor

Beep boop! 🤖

Hey @harishm72, thanks for your PR!

One of my human friends will review this PR and get back to you as soon as possible.

Stay awesome! 😎

@harishm72 harishm72 changed the title Migrate AlertBox Component to typescript by adding types. https://github.com/hasura/graphql-engine/issues/4314#issuecomment-617987200 Migrate AlertBox Component to typescript by adding types. May 11, 2020
@harishm72 harishm72 changed the title https://github.com/hasura/graphql-engine/issues/4314#issuecomment-617987200 Migrate AlertBox Component to typescript by adding types. Migrate AlertBox Component to typescript by adding types. May 11, 2020
@harishm72 harishm72 mentioned this pull request May 11, 2020
46 tasks
@hasura-bot
Copy link
Contributor

Review app for commit 4f01575 deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-4f01575e

@hasura-bot
Copy link
Contributor

Review app for commit 07b7f7c deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-07b7f7c2

Copy link
Contributor

@beerose beerose left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! 🎉


Right now AlertBox only accepts children, type, pointer and size.
However, we should also be able to pass all the style props that are accepted by StyledAlertBox and HTML div element props.

We could declare StyledAlertBoxProps as:

interface StyledAlertBoxOwnProps
  extends FlexboxProps,
    ColorProps,
    BorderProps,
    TypographyProps,
    LayoutProps,
    SpaceProps,
    ShadowProps,
    React.ComponentProps<'div'> {}

But styled-components and TypeScript doesn't work well together, and above interface would cause a type error (the type of prop color from styled-system conflicts with div element's color.). So we need to deal with it slightly differently.

Here is how to do this:

  1. Crate component Box and interface BoxProps in AlertBox.ts. Another PR adds it to the separate folder, but as it's not yet merged, we can keep it AlertBox.ts file.
interface BoxProps extends Omit<React.ComponentPropsWithRef<'div'>, 'color'> {}
const Box = ('div' as any) as React.FC<BoxProps>;
  1. Create an interface StyledAlertBoxOwnProps:
interface StyledAlertBoxOwnProps
  extends FlexboxProps,
    ColorProps,
    BorderProps,
    TypographyProps,
    LayoutProps,
    SpaceProps,
    ShadowProps {}
  1. Declare StyledAlertBox using Box and newly created interface StyledAlertBoxProps:
export const StyledAlertBox = styled(Box)<StyledAlertBoxProps>`
  ${flexbox};
  ${color}
  ${border}
  ${typography}
  ${layout}
  ${space}
  ${shadow}

  /* Alert type text */
  span {
    text-transform: capitalize;
  }
`;
  1. Export StyledSpinnerProps as so that we include both style props and HTML div element attributes:
export interface StyledAlertBoxProps extends StyledAlertBoxOwnProps, BoxProps {}
  1. Then in index.js declare props type as:
export interface AlertBoxProps
  extends IconProps,
    Omit<StyledAlertBoxProps, 'size'> {
    type: keyof Theme['alertBox'];
}

In the above type I replaced type so that it depends on the Theme interface. I also removed children as it's already included because you're using React.FC. I also needed to omit size as it conflicts with the IconProps.

@netlify
Copy link

netlify bot commented Jul 19, 2020

Deploy preview for hasura-docs ready!

Built with commit b1e0205

https://deploy-preview-4721--hasura-docs.netlify.app

@hasura-bot
Copy link
Contributor

Review app for commit 29a5b8a deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-29a5b8ac

@harishm72 harishm72 requested a review from beerose July 22, 2020 09:03
@harishm72 harishm72 requested a review from beerose August 11, 2020 16:53
@hasura-bot
Copy link
Contributor

Review app for commit b1e0205 deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-b1e0205a

@hasura-bot
Copy link
Contributor

Review app for commit 9fbbec5 deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-9fbbec51

Copy link
Contributor

@beerose beerose left a comment

Choose a reason for hiding this comment

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

Console changes.

@hasura-bot
Copy link
Contributor

Review app for commit c04241d deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-c04241d7

@beerose beerose changed the title Migrate AlertBox Component to typescript by adding types. console: migrate AlertBox component to typescript Aug 12, 2020
Copy link
Contributor

@tirumaraiselvan tirumaraiselvan left a comment

Choose a reason for hiding this comment

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

no cl required

@hasura-bot
Copy link
Contributor

Review app for commit 0a02896 deployed to Heroku: https://hge-ci-pull-4721.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4721-0a02896f

@beerose beerose merged commit 33d99b9 into hasura:master Aug 12, 2020
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-4721.herokuapp.com is deleted

@hasura-bot
Copy link
Contributor

Beep boop! 🤖

GIF

Awesome work @harishm72! All of us at Hasura ❤️ what you did.

Thanks again 🤗

@marionschleifer
Copy link
Contributor

@harishm72 thank you so much for your contribution 🙏 as a thank you, we'd love to send you some swag. If you're interested, please send an email to marion@hasura.io, and we'll take it from there 🙂

stevefan1999-personal pushed a commit to stevefan1999-personal/graphql-engine that referenced this pull request Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants