-
Notifications
You must be signed in to change notification settings - Fork 872
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
Storybook: upgrade to v6, Styled-Components: upgrade to v5 (includes brave-ui) #8120
Conversation
59b55e2
to
72b1c95
Compare
components/brave_extension/extension/brave_extension/stories/story.tsx
Outdated
Show resolved
Hide resolved
@@ -314,6 +311,7 @@ | |||
"array-move": "^2.2.1", | |||
"bignumber.js": "^7.2.1", | |||
"bluebird": "^3.5.1", | |||
"core-js": "^3.9.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the core-js
dep come from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix storybookjs/storybook#11255. Apologies for not explicitly mentioning. Maybe I should have added a comment, but not sure how npm handles that.
import Button, { Props as ButtonProps } from 'brave-ui/components/buttonsIndicators/button' | ||
|
||
export const SideBySideButtons = styled<{}, 'div'>('div')` | ||
export const SideBySideButtons = styled('div')<{}>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the empty props object needed, or can it just be styled('div')
(or even styled.div
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can, yes, and it will still get correctly-typed theme props. But we can do it in a follow-up. This was the result of a find/replace just switching the order and removing the duplication.
@@ -3,10 +3,11 @@ | |||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | |||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | |||
|
|||
import styled from 'brave-ui/theme' | |||
import styled from 'styled-components' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency flattening is great - thanks!
@@ -0,0 +1,37 @@ | |||
// Copyright (c) 2020 The Brave Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eternally March 2020 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my defense, I did write this code in 2020 when I started this branch!
@@ -0,0 +1,9 @@ | |||
{ | |||
"extends": "../../../tsconfig", | |||
"include": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: what does the addition of this file do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was the only way I could see to get correct intellisense in Visual Studio Code working for certain types (I think theme properties, but I'm having trouble remembering now). Perhaps the project was otherwise too big unless localized to the specific dir the current file open is in. So, a different tsconfig per WebUI "project" seems appropriate anyway.
|
||
type Theme = IBraveTheme & IWelcomeTheme | ||
|
||
export default styled as unknown as Styled.ThemedStyledInterface<Theme> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the as unknown as ...
intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it allows the type to be cast, otherwise you cannot directly cast styled
to include the theme. But we know that it does include the specific Welcome theme, so it's ok.
This is the suggested way to have multiple themes in a project. Otherwise it will just assume our re-defined DefaultTheme.
@@ -97,10 +97,10 @@ export default class GrantCaptcha extends React.PureComponent<Props, {}> { | |||
return ( | |||
<StyledWrapper | |||
id={id} | |||
innerRef={this.refWrapper} | |||
ref={this.refWrapper} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay!
components/brave_rewards/resources/ui/components/checkout/dialogTitle/style.ts
Show resolved
Hide resolved
@@ -0,0 +1,4 @@ | |||
Name: core-js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this file for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of our deps in package.json must define the license file, which I believe gets automatically included in chrome://credits
. Otherwise the build fails.
|
8cc477f
to
b56c8e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments - but looks great! 😄 This is a whole lot of work, thanks for taking it on!
21c0b2d
to
8c0357b
Compare
Restarted Windows build, it had typescript errors even though all other platforms did not 🤷 |
Windows CI still giving off errors that were previously fixed within the brave-ui PR that this pulls in via package.json, checking... |
skipping all other platforms for CI apart from Windows whilst I attempt to fix it |
core-js added to fix a build reference issue
…uired with the no-longer-maintained @dump247/storybook-state package Ran `npm update react-json-view --depth 2` to give this change
…dules (and same context singletons)
(only CI fixes)
8c0357b
to
4244de3
Compare
CI now passed on all platforms 🍾 |
Fix brave/brave-browser#14305 (npm audit issues), as well as brings some much-needed storybook bug fixes.
Here's a find/replace regex I used for the styled-components typescript format: https://regex101.com/r/5X75t3/1/
core-js
added as a dependency due to storybookjs/storybook#11255Requires:
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
npm run storybook
and verify each item is showing and with correct styles.