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

Rebrand staking page #474

Merged
merged 18 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/delegation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('delegation', () => {
cy.resetBlockchain().login();

// Approve, deposit and stake
cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets rather use the built in data-testid="..." and cy.findByTestId(...) for all of these cy.dataCy() usages that you've added.

Copy link
Collaborator Author

@Anboias Anboias Nov 15, 2024

Choose a reason for hiding this comment

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

Done. Replaced both dataCy and findByRole with findByTestId.

If you meant to replace only dataCy with findByTestId, I'll quickly adjust.

cy.get('#modal').find('input').type('200');
cy.findByText('Approve').click();
cy.findByText('Deposit and Stake').click();
Expand Down
9 changes: 6 additions & 3 deletions cypress/e2e/keyboard-navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ describe('keyboard navigation and accessibility', () => {
pressTabAndAssertFocusOutline(() => cy.findAllByText('Api3 Market').filter(':visible').closest('a'));
pressTabAndAssertFocusOutline(() => cy.findAllByText('Docs').filter(':visible').closest('a'));

pressTabAndAssertFocusOutline(() =>
cy.dataCy('connect-wallet-staking').findByRole('button', { name: 'Connect Wallet' })
);
pressTabAndAssertFocusOutline(() => cy.findByText('About API3'));
pressTabAndAssertFocusOutline(() => cy.findByText('Error Reporting'));
pressTabAndAssertFocusOutline(() => cy.findByText('Github'));
Expand All @@ -36,7 +39,7 @@ describe('keyboard navigation and accessibility', () => {
});

it('uses focus lock (cannot tab outside modal)', () => {
cy.findByText('+ Deposit').click();
cy.findByText('Deposit').click();

cy.get('#modal').find('input').should('have.focus');
cy.get('#modal').find('input').type('123');
Expand All @@ -52,12 +55,12 @@ describe('keyboard navigation and accessibility', () => {

it('can use keyboard to "press" the buttons', () => {
// Can close the modal by pressing ESC
cy.findByText('+ Deposit').click();
cy.findByText('Deposit').click();
cy.get('body').type('{esc}');
cy.get('#modal').find('input').should('not.exist');

// Can deposit by pressing ENTER when button has focus
cy.findByText('+ Deposit').click();
cy.findByText('Deposit').click();
cy.get('#modal').find('input').type('123').tab(); // Tab over "Max" button
pressTabAndAssertFocusOutline(() => cy.findByText('Approve'));

Expand Down
13 changes: 7 additions & 6 deletions cypress/e2e/staking.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ describe('staking', () => {
cy.resetBlockchain().login();

// Approve and deposit
cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
cy.get('#modal').find('input').type('500');
cy.findByText('Approve').click();
cy.findByText('Deposit').should('be.visible');
cy.get('#modal').findByRole('button', { name: 'Deposit' }).should('be.visible');
cy.percySnapshot('Staking: Deposit modal');
cy.findByText('Deposit').click();
cy.get('#modal').findByRole('button', { name: 'Deposit' }).click();
cy.dataCy('balance').should('have.text', '500.0');

// Stake
cy.findByText('+ Stake').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Stake' }).click();
cy.get('#modal').find('input').type('100');
cy.findByText('Stake').click();
cy.get('#modal').findByRole('button', { name: 'Stake' }).click();
cy.dataCy('unstaked').should('have.text', '400.0');
cy.dataCy('withdrawable').should('have.text', '400.0');
cy.dataCy('staked').should('have.text', '100.0');
Expand All @@ -31,7 +32,7 @@ describe('staking', () => {
it('can deposit and stake', () => {
cy.useChainSnapshot('user-staked');

cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
cy.get('#modal').find('input').type('200');
cy.findByText('Deposit and Stake').click();

Expand Down Expand Up @@ -86,7 +87,7 @@ it.skip('user can unstake & withdraw', () => {
cy.resetBlockchain().login();

// Approve and deposit
cy.findByText('+ Deposit').click();
cy.dataCy('staking-cards').findByRole('button', { name: 'Deposit' }).click();
cy.get('#modal').find('input').type('1000');
cy.findByText('Approve').click();
cy.findByText('Deposit and Stake').click();
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Cypress.Commands.add('login', () => {
});

// Login
cy.findByRole('button', { name: 'Connect Wallet' }).click();
cy.findAllByRole('button', { name: 'Connect Wallet' }).first().click();

// Web3 Modal
cy.get('w3m-modal')
Expand Down
7 changes: 7 additions & 0 deletions public/help-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/info-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 10 additions & 130 deletions src/components/button/button.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@import '../../styles/variables.module.scss';
@import '../../styles/fonts.module.scss';
@import '../../styles/link-styles.module.scss';
@import './variants/primary.module.scss';
@import './variants/secondary.module.scss';
@import './variants/secondary-neutral.module.scss';
@import './variants/link-blue.module.scss';
@import './variants/menu-link-secondary.module.scss';

.buttonWrapper {
display: inline-block;
Expand All @@ -21,139 +25,15 @@
cursor: pointer;

&.primary {
background-color: $color-blue-500;
color: $color-base-light;
border: none;

&.xxs {
padding: 0 10px;
border-radius: 24px;
height: 24px;
@include font-body-17;
}

&.xs {
padding: 0 16px;
border-radius: 24px;
height: 32px;
@include font-body-14;
}

&.sm {
padding: 0 20px;
border-radius: 24px;
height: 40px;
@include font-button-3;
}

&.md {
padding: 0 24px;
border-radius: 28px;
height: 48px;
@include font-button-2;
}

&.lg {
padding: 0 32px;
border-radius: 32px;
height: 56px;
@include font-button-1;
}

&:hover {
background-color: $color-blue-200;
}

&:active {
background-color: $color-blue-600;
}

&:disabled {
color: $color-blue-50;
background-color: $color-blue-10;
}

&.dark {
background-color: $color-blue-400;

&:hover {
background-color: $color-blue-200;
}

&:active {
background-color: $color-blue-500;
}

&:disabled {
color: $color-blue-400;
background-color: $color-dark-blue-400;
}
}
@include button-primary;
}

&.secondary {
position: relative;
color: $color-dark-blue-400;
border: 1px solid transparent;
@include gradient-border($gradient-soft-light);

&.xxs {
padding: 0 10px;
border-radius: 24px;
height: 24px;
@include font-body-17;
}

&.xs {
padding: 0 16px;
border-radius: 24px;
height: 32px;
@include font-body-14;
}

&.sm {
padding: 0 20px;
border-radius: 24px;
height: 40px;
@include font-button-3;
}

&.md {
padding: 0 24px;
border-radius: 28px;
height: 48px;
@include font-button-2;
}

&.lg {
padding: 0 32px;
border-radius: 32px;
height: 56px;
@include font-button-1;
}

&:hover,
&:active,
&:disabled {
&:before {
padding: 0px;
}
}

&:hover {
color: $color-blue-200;
border: 1px solid $color-blue-200;
}

&:active {
color: $color-blue-600;
border: 1px solid $color-blue-600;
}
@include button-secondary;
}

&:disabled {
color: $color-gray-400;
border: 1px solid $color-gray-400;
}
&.secondary-neutral {
@include button-secondary-neutral;
}

&.link-blue {
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type BreakpointsProps = { [key in BreakpointKeys]?: { size?: Size } };
export interface Props extends BreakpointsProps {
children: ReactNode;
className?: string;
type?: 'primary' | 'secondary' | 'link' | 'text' | 'menu-link-secondary' | 'link-blue';
type?: 'primary' | 'secondary' | 'secondary-neutral' | 'link' | 'text' | 'menu-link-secondary' | 'link-blue';
size?: Size;
disabled?: boolean;
href?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import './fonts.module.scss';
@import '../../../styles/fonts.module.scss';

@mixin link-blue {
color: $color-blue-500;
Expand Down Expand Up @@ -50,40 +50,3 @@
}
}
}

@mixin menu-link-secondary {
position: relative;
border: none;
color: $color-dark-blue-400;
height: 20px;
padding: 0;

&.xs {
@include font-overline-2;
}

&.sm {
@include font-body-15;
}

&.md {
@include font-body-12;
}

&.lg {
height: 24px;
@include font-description-6;
}

&:hover {
color: $color-blue-400;
}

&:active {
color: $color-blue-300;
}

&:disabled {
color: $color-dark-blue-25;
}
}
38 changes: 38 additions & 0 deletions src/components/button/variants/menu-link-secondary.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@import '../../../styles/fonts.module.scss';

@mixin menu-link-secondary {
position: relative;
border: none;
color: $color-dark-blue-400;
height: 20px;
padding: 0;

&.xs {
@include font-overline-2;
}

&.sm {
@include font-body-15;
}

&.md {
@include font-body-12;
}

&.lg {
height: 24px;
@include font-description-6;
}

&:hover {
color: $color-blue-400;
}

&:active {
color: $color-blue-300;
}

&:disabled {
color: $color-dark-blue-25;
}
}
Loading
Loading