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

feat(button): set default shape to soft for ios and round for md and ionic themes #29404

Merged
merged 21 commits into from May 8, 2024

Conversation

brandyscarney
Copy link
Member

@brandyscarney brandyscarney commented Apr 25, 2024

Issue number: internal


What is the current behavior?

The shape property defaults to "soft" for ios and "round" for the md and ionic themes.

Default button size:

Property Value CSS Value (ionic) CSS Value (ios) CSS Value (md)
undefined 8px 14px 4px
"round" 999px unsupported unsupported
"rectangular" 0px unsupported unsupported

Large button size:

Property Value CSS Value (ionic) CSS Value (ios) CSS Value (md)
undefined 8px 16px 4px

Small button size:

Property Value CSS Value (ionic) CSS Value (ios) CSS Value (md)
undefined 4px 6px 4px

What is the new behavior?

The shape property defaults to undefined which evaluates to the "Soft" shape for all themes.

Default button size:

Property Value CSS Value (ionic) CSS Value (ios) CSS Value (md)
"soft" 8px 6px 4px
"round" 999px 999px 999px
"rectangular" 0px 0px 0px

Large button size:

Property Value CSS Value (ionic) CSS Value (ios) CSS Value (md)
soft 8px 8px 4px

Small button size:

Property Value CSS Value (ionic) CSS Value (ios) CSS Value (md)
soft 4px 4px 4px
  • Adds support for the "soft" shape in the ionic theme using the existing values for undefined
  • Adds support for the "rectangular" and "round" shapes in ios and md using 0px and 999px border radius
  • Sets the default shape property to "round" for the ionic and md themes and "soft" for ios and updates the border-radius to apply to the shape classes instead of :host
  • Updates the "soft" shape border radius for ios in the various sizes to match the buttons created in SwiftUI (their "rounded" is our "soft"):
    rounded-ios-buttons
  • Fixed the icon only buttons in the "ionic" theme so that they are not styled based on the size while always following the proper aspect ratio. This was broken for the default size due to an incorrect padding value & I made it so we don't have to specify the padding for each size:
Before After
before after

Does this introduce a breaking change?

  • Yes
  • No

BREAKING CHANGE:

The border-radius of the ios and md button now defaults to 6px and 999px instead of 14px and 4px, respectively, in accordance with the iOS and Material Design 3 guidelines. To revert to the previous appearance, set the shape to "soft" for md and override the --border-radius CSS variable for ios to 14px, or set it to a different value entirely.

Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2024 7:17pm

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the buttons without a shape set in this test to use the soft shape because it doesn't make sense using the default round shape that ionic & md themes use since the round shape is excluded from some of the styles:

:host(.button-full:not(.button-round)) .button-native {
  @include border-radius(0);

  border-right-width: 0;
  border-left-width: 0;
}

/**
* Shape="rectangular" is only available in the Ionic theme.
*/
// TODO do we need this test for focused / activated? it should be for all themes if so
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to determine if we need this test or if there is a way to slim it down / move it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up removing this test because the activated state does not get changed based on the shape & we are checking that the focused state is the proper shape in the clear button tests.

@brandyscarney brandyscarney marked this pull request as ready for review May 6, 2024 23:29
@brandyscarney brandyscarney requested a review from a team as a code owner May 6, 2024 23:29
@brandyscarney brandyscarney requested review from thetaPC and removed request for a team May 6, 2024 23:29
core/src/components/button/button.ionic.vars.scss Outdated Show resolved Hide resolved
core/src/components/button/button.ionic.scss Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Question unrelated to this PR: Is test supposed to be capturing the ripple effect? It seems like a normal state button.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it looks like it should be:

test.describe(title('button: ripple effect'), () => {
  test('should not have visual regressions', async ({ page }) => {
    await page.goto(`/src/components/button/test/basic?ionic:_testing=false`, config);

    const button = page.locator('#default');

    await button.scrollIntoViewIfNeeded();

    const boundingBox = await button.boundingBox();

    if (boundingBox) {
      await page.mouse.move(boundingBox.x + boundingBox.width / 2, boundingBox.y + boundingBox.height / 2);
      await page.mouse.down();
    }

    await page.locator('#default.ion-activated').waitFor();

    await expect(button).toHaveScreenshot(screenshot(`button-ripple-effect`));
  });
});

I am not sure when it stopped working though

core/src/components/button/test/shape/index.html Outdated Show resolved Hide resolved
Copy link
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM

@brandyscarney brandyscarney merged commit 4dae03f into FW-6191 May 8, 2024
45 checks passed
@brandyscarney brandyscarney deleted the FW-6192 branch May 8, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants