-
Notifications
You must be signed in to change notification settings - Fork 12
#191 Upgrade Chakra UI to v3 #221
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
@@ -16,6 +16,9 @@ jobs: | |||
- name: Install Dependencies | |||
run: yarn install --frozen-lockfile | |||
|
|||
- name: Install chakra-ui types |
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 step generates the custom chakra-ui variants. This is a prerequisite for a successful build as otherwise we'll get ts errors for invalid variants which will fail the build.
|
||
describe('CTSI Text component', () => { | ||
it('Should render the formatted amount of CTSI', () => { | ||
render(<CTSIText value="5000100000000000000000000" />); | ||
render(<Component value="5000100000000000000000000" />); |
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.
I had to refactor some of the tested component so that they are always augmented with the chakra-ui context. Otherwise those tests were failing.
userEvent.hover(icon); | ||
}); | ||
|
||
await screen.findByText(tooltip); |
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.
The userEvent
package is useful for interacting with tooltips, number inputs and similar composite components. The fireEvent
api from react testing library doesn't trigger mouseover
/ change
events for those components correctly.
); | ||
|
||
expect(screen.getByText('Wallet is disconnected')).toBeInTheDocument(); | ||
expect(screen.getByText('Connect To Wallet')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display default accent colour and different accents based on status', () => { |
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 test was tightly coupled with the alert styles and was flaky between chakra v2 and v3. Also, it was just testing if chakra was correctly styling the Alert component based on the passed status
. We can trust chakra to do its thing without us testing it. That's why I removed it.
@@ -38,7 +38,7 @@ module.exports = { | |||
'<rootDir>/.vscode/', | |||
'<rootDir>/public/', | |||
], | |||
testEnvironment: 'jsdom', | |||
testEnvironment: './fixJSDOMEnvironment.ts', |
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 was required because jsdom
was failing with errors for missing structuredClone
function (introduced in node v17). The error caused all unit tests to fail.
@@ -6,8 +6,8 @@ | |||
"dev": "run-s db:dev:migrate next:dev", | |||
"build": "run-s db:prod:migrate next:build", | |||
"start": "next start", | |||
"next:build": "next build", | |||
"next:dev": "next dev", | |||
"next:build": "npm run chakra-types && next build", |
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.
Running the chakra-types
npm script is a requirement for the next build to succeed. I added it to the dev script also so that no ts errors, related to custom variants, are produced when you start your local dev environment.
@@ -154,11 +154,11 @@ const BigNumberTextV2: FC<BigNumberTextV2Props> = (props) => { | |||
> | |||
{valueLabel} | |||
</Heading> | |||
{unit && value && ( | |||
{unitLabel !== '' && unit && value && ( |
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 fixed an issue with short-circuiting that was causing unitLabels
with 0
value to appear in this part of the UI.
@@ -118,7 +126,7 @@ export const Card = ({ | |||
<Button | |||
data-testid="card-action-button" | |||
ml={{ base: 0, lg: 2 }} | |||
colorScheme={colorScheme} | |||
colorPalette={colorScheme} |
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.
colorScheme
is not replaced by colorPalette
for all instances in the code.
...lastValue, | ||
...data.stakingPoolFeeHistories, | ||
]); | ||
setList((lastValue) => |
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.
I noticed an issue with the fee histories when you disconnected and then reconnected your wallet. In this case the fee histories were being duplicated. This fixes the issue.
import { defineSlo 8000 tRecipe } from '@chakra-ui/react'; | ||
import { alertAnatomy } from '@chakra-ui/react/anatomy'; | ||
|
||
export const alertRecipe = defineSlotRecipe({ |
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.
I added a recipe for alerts so that the UI matches the one we used before.
import { defineSlotRecipe } from '@chakra-ui/react'; | ||
import { radioGroupAnatomy } from '@chakra-ui/react/anatomy'; | ||
|
||
export const radioGroupRecipe = defineSlotRecipe({ |
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.
I added a recipe for radio inputs to match the UI we used before.
I upgraded chakra from v2 to v3. This required major changes in the UI code base in order for us to utilize the v3 components. Summary of the changes:
chakra-types
for generating TS types for custom variants that we use in our codebase.chakra-types
script.