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

Migrate @storybook/addon-events to Typescript #7190

Merged
merged 18 commits into from
Jul 4, 2019

Conversation

lonyele
Copy link
Member

@lonyele lonyele commented Jun 25, 2019

Issue: #5030

What I did

I migrated addon-events to Typescript.

I wrote some comments where I think more attention is needed

How to test

  • Is this testable with Jest or Chromatic screenshots? No
  • Does this need a new example in the kitchen sink apps? No
  • Does this need an update to the documentation? No

If your answer is yes to any of these, please make sure to include it in your PR.

@vercel
Copy link

vercel bot commented Jun 25, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://monorepo-git-fork-lonyele-feature-migrate-addon-events.storybook.now.sh

interface StyledTextareaProps {
shown: boolean;
failed: boolean;
value?: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

Probably I missed something... but putting only ...rest didn't work. I also had to add value, onChange which seems unnecessary.

Copy link
Member

Choose a reason for hiding this comment

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

You can also use something like React.HTMLProps<HTMLTextAreaElement>

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I'll try that!

Copy link
Member Author

Choose a reason for hiding this comment

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

hm... It didn't work for me. Maybe I implemented in a wrong way?

@@ -67,7 +76,7 @@ const Label = styled.label({
textAlign: 'right',
width: 100,
fontWeight: '600',
});
} as any);
Copy link
Member Author

Choose a reason for hiding this comment

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

This one also gives me errors and I couldn't resolve it. Error goes like this

Argument of type '() => { display: string; boxSizing: "border-box"; verticalAlign: string; paddingRight: number; paddingTop: number; textAlign: "right"; width: number; fontWeight: "600"; }' is not assignable to parameter of type 'TemplateStringsArray'.
  Type '() => { display: string; boxSizing: "border-box"; verticalAlign: string; paddingRight: number; paddingTop: number; textAlign: "right"; width: number; fontWeight: "600"; }' is missing the following properties from type 'TemplateStringsArray': raw, concat, join, slice, and 16 more.ts(2345)

Changing code like this also didn't work

const Label = styled.label(() => ({
  display: 'table-cell',
  boxSizing: 'border-box',
  verticalAlign: 'top',
  paddingRight: 5,
  paddingTop: 7,
  textAlign: 'right',
  width: 100,
  fontWeight: '600',
}));

Similar code is already used at other parts

const HighlightToggleLabel = styled.label(({ theme }) => ({
cursor: 'pointer',
userSelect: 'none',
marginBottom: '3px',
marginRight: '3px',
color: theme.color.dark,
}));

const Wrapper = styled.label(({ theme }) => ({
display: 'flex',
borderBottom: `1px solid ${theme.appBorderColor}`,
margin: '0 15px',
padding: '8px 0',
'&:last-child': {
marginBottom: '3rem',
},
}));

Here are for more information this, and this

@lonyele lonyele added addon: events maintenance User-facing maintenance tasks typescript labels Jun 25, 2019
@lonyele
Copy link
Member Author

lonyele commented Jun 25, 2019

sorry if there are so many questions!

@ndelangen
Copy link
Member

@gaetanmaisse think you could help here?

@ndelangen
Copy link
Member

ndelangen commented Jul 2, 2019

/tmp/storybook/addons/events/src/components/Panel.tsx
  5:1  error  '@storybook/api' should be listed in the project's dependencies. Run 'npm i -S @storybook/api' to add it  import/no-extraneous-dependencies

@lonyele
Copy link
Member Author

lonyele commented Jul 2, 2019

@ndelangen oh... how come this happened. I yarn bootstrap --core, yarn dev, yarn start, yarn test and couldn't catch this big mistake? hm...

@vercel vercel bot temporarily deployed to staging July 2, 2019 16:36 Inactive
@lonyele lonyele requested a review from usulpro as a code owner July 4, 2019 16:16
@vercel vercel bot temporarily deployed to staging July 4, 2019 16:16 Inactive
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM!

@shilman shilman merged commit 4db4dc4 into storybookjs:next Jul 4, 2019
@lonyele lonyele deleted the feature/migrate-addon-events branch July 5, 2019 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: events maintenance User-facing maintenance tasks typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants