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
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8a3793e
test(button): remove color and expand from shape test
brandyscarney Apr 25, 2024
0d54cb3
test(button): update expand test to use soft shape
brandyscarney Apr 25, 2024
2f380f6
feat(button): set default shape to soft for ios and round for md and …
brandyscarney Apr 25, 2024
6c5dc97
fix(button): circular buttons are now circular by aspect-ratio
brandyscarney Apr 25, 2024
5e0f367
chore: add a TODO to check toolbar buttons radius later
brandyscarney Apr 25, 2024
ba4d925
test(button): update shape e2e tests for all shapes and themes
brandyscarney Apr 25, 2024
f05642d
chore: build and lint
brandyscarney Apr 25, 2024
e6ede2e
style: comment TODO
brandyscarney May 1, 2024
4af224a
Merge branch 'FW-6191' into FW-6192
brandyscarney May 3, 2024
70ea659
style: merge conflicts
brandyscarney May 3, 2024
c820c96
style: remove undefined check
brandyscarney May 3, 2024
e61e6b4
Merge branch 'FW-6191' into FW-6192
brandyscarney May 3, 2024
8251f5d
docs(BREAKING): include breaking changes to button border radius
brandyscarney May 3, 2024
e6b7bf3
refactor(button): remove custom padding for round buttons
brandyscarney May 3, 2024
c5993f1
chore(): add updated snapshots
Ionitron May 3, 2024
eca2b2a
test(button): update shape e2e test to use setContent and avoid dupli…
brandyscarney May 6, 2024
8c5b08d
test(button): remove extra wrapper in button tests
brandyscarney May 6, 2024
a3b790f
chore: add updated snapshots
brandyscarney May 6, 2024
9c664b3
chore: remove !default flag
brandyscarney May 7, 2024
075f552
fix(button): only adjust padding end for icon only
brandyscarney May 7, 2024
0f8eeed
test(button): remove default shape from shape tests
brandyscarney May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/api.txt
Expand Up @@ -234,7 +234,7 @@ ion-button,prop,mode,"ios" | "md",undefined,false,false
ion-button,prop,rel,string | undefined,undefined,false,false
ion-button,prop,routerAnimation,((baseEl: any, opts?: any) => Animation) | undefined,undefined,false,false
ion-button,prop,routerDirection,"back" | "forward" | "root",'forward',false,false
ion-button,prop,shape,"rectangular" | "round" | undefined,undefined,false,true
ion-button,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,true
ion-button,prop,size,"default" | "large" | "small" | "xlarge" | "xsmall" | undefined,undefined,false,true
ion-button,prop,strong,boolean,false,false,false
ion-button,prop,target,string | undefined,undefined,false,false
Expand Down
8 changes: 4 additions & 4 deletions core/src/components.d.ts
Expand Up @@ -543,9 +543,9 @@ export namespace Components {
*/
"routerDirection": RouterDirection;
/**
* Set to `"round"` for a button with more rounded corners.
* Set to `"soft"` for a button with slightly rounded corners, `"round"` for a button with fully rounded corners, or `"rectangular"` for a button without rounded corners. Defaults to `"soft"` for the `"ios"` theme and `"round"` for all other themes.
*/
"shape"?: 'round' | 'rectangular';
"shape"?: 'soft' | 'round' | 'rectangular';
/**
* Set to `"small"` for a button with less height and padding, to `"default"` for a button with the default height and padding, or to `"large"` for a button with more height and padding. By default the size is unset, unless the button is inside of an item, where the size is `"small"` by default. Set the size to `"default"` inside of an item to make it a standard size button.
*/
Expand Down Expand Up @@ -5791,9 +5791,9 @@ declare namespace LocalJSX {
*/
"routerDirection"?: RouterDirection;
/**
* Set to `"round"` for a button with more rounded corners.
* Set to `"soft"` for a button with slightly rounded corners, `"round"` for a button with fully rounded corners, or `"rectangular"` for a button without rounded corners. Defaults to `"soft"` for the `"ios"` theme and `"round"` for all other themes.
*/
"shape"?: 'round' | 'rectangular';
"shape"?: 'soft' | 'round' | 'rectangular';
/**
* Set to `"small"` for a button with less height and padding, to `"default"` for a button with the default height and padding, or to `"large"` for a button with more height and padding. By default the size is unset, unless the button is inside of an item, where the size is `"small"` by default. Set the size to `"default"` inside of an item to make it a standard size button.
*/
Expand Down
49 changes: 18 additions & 31 deletions core/src/components/button/button.ionic.scss
@@ -1,15 +1,16 @@
@use "../../themes/ionic/ionic.globals.scss" as globals;
@import "./button";
@import "./button.ionic.vars";

// Ionic Button
// -------------------------------------------------------------------------------

:host {
--border-radius: #{$button-ionic-border-radius};
--padding-bottom: var(--padding-top);
--padding-end: #{$button-ionic-padding-end};
--padding-start: var(--padding-end);
--padding-top: #{$button-ionic-padding-top};
// TODO(FW-6187): set this to a design token when it is added
--focus-ring-color: #9ec4fd;
--focus-ring-width: 2px;

Expand Down Expand Up @@ -62,7 +63,6 @@

/* Extra Small Button */
:host(.button-xsmall) {
--border-radius: #{$button-ionic-xsmall-border-radius};
--padding-top: #{$button-ionic-xsmall-padding-top};
--padding-end: #{$button-ionic-xsmall-padding-end};

Expand All @@ -73,7 +73,6 @@

/* Small Button */
:host(.button-small) {
--border-radius: #{$button-ionic-small-border-radius};
--padding-top: #{$button-ionic-small-padding-top};
--padding-end: #{$button-ionic-small-padding-end};

Expand Down Expand Up @@ -123,45 +122,33 @@
}
}

/* Button extra small */
:host(.button-has-icon-only.button-xsmall) {
--padding-end: #{$button-has-icon-only-padding-end-xsmall};
}

/* Button small */
:host(.button-has-icon-only.button-small) {
--padding-end: #{$button-has-icon-only-padding-end-small};
}

/* Default */
:host(.button-has-icon-only) {
--padding-end: #{$button-has-icon-only-padding-end};
}

/* Button large */
:host(.button-has-icon-only.button-large) {
--padding-end: #{$button-has-icon-only-padding-end-large};
}
--padding-top: 0;
--padding-bottom: var(--padding-top);
--padding-end: var(--padding-top);
--padding-start: var(--padding-end);
thetaPC marked this conversation as resolved.
Show resolved Hide resolved

/* Button extra large */
:host(.button-has-icon-only.button-xlarge) {
--padding-end: #{$button-has-icon-only-padding-end-xlarge};
aspect-ratio: 1 / 1;
}

// Button Shapes
// -------------------------------------------------------------------------------

// Button Shape Rectangular
// -------------------------------------------------------------------------------
:host(.button-soft) {
--border-radius: #{globals.$ionic-border-radius-rounded-medium};
}

:host(.button-rectangular) {
--border-radius: #{$button-ionic-rectangular-border};
:host(.button-soft.button-xsmall),
:host(.button-soft.button-small) {
--border-radius: #{globals.$ionic-border-radius-rounded-small};
}

// Button Shape Round
// -------------------------------------------------------------------------------
:host(.button-round) {
--border-radius: #{$button-ionic-round-border};
--border-radius: #{globals.$ionic-border-radius-rounded-full};
}

:host(.button-rectangular) {
--border-radius: #{globals.$ionic-border-radius-square};
}

// Button Focused
Expand Down
41 changes: 1 addition & 40 deletions core/src/components/button/button.ionic.vars.scss
Expand Up @@ -3,9 +3,6 @@
// Ionic Button
// -------------------------------------------------------------------------------

/// @prop - Border radius of the button
$button-ionic-border-radius: px-to-rem(8);

/// @prop - Padding top of the button
$button-ionic-padding-top: px-to-rem(12);

Expand All @@ -29,9 +26,6 @@ $button-ionic-font-size: dynamic-font-max(14px, 3);
// Ionic Extra Small Button
// -------------------------------------------------------------------------------

/// @prop - Border radius of the extra small button
$button-ionic-xsmall-border-radius: px-to-rem(4);

/// @prop - Padding top of the extra small button
$button-ionic-xsmall-padding-top: px-to-rem(4);

Expand All @@ -55,9 +49,6 @@ $button-ionic-xsmall-font-size: dynamic-font-max(12px, 3);
// Ionic Small Button
// -------------------------------------------------------------------------------

/// @prop - Border radius of the small button
$button-ionic-small-border-radius: px-to-rem(4);

/// @prop - Padding top of the small button
$button-ionic-small-padding-top: px-to-rem(8);

Expand Down Expand Up @@ -124,41 +115,11 @@ $button-ionic-xlarge-min-height: px-to-rem(56);
/// and multiplying it by 3, since 310% of the default is the maximum
$button-ionic-xlarge-font-size: dynamic-font-max(20px, 3);

// Ionic Rectangular Button
// -------------------------------------------------------------------------------

/// @prop - Border radius of the rectangular button
$button-ionic-rectangular-border: 0;

// Ionic Round Button
// -------------------------------------------------------------------------------

/// @prop - Border radius of the round button
$button-ionic-round-border: px-to-rem(999);

// Ionic Outline Button
// -------------------------------------------------------------------------------

/// @prop - Border width of the outline button
$button-ionic-outline-border-width: 1px;

/// @prop - Border style of the outline button
$button-ionic-outline-border-style: solid;

// Ionic Icon Only Button
// -------------------------------------------------------------------------------

/// @prop - Padding end of the icon only button
$button-has-icon-only-padding-end: px-to-rem(13);

/// @prop - Padding end of the icon only extra small button
$button-has-icon-only-padding-end-xsmall: px-to-rem(6);

/// @prop - Padding end of the icon only small button
$button-has-icon-only-padding-end-small: px-to-rem(10);

/// @prop - Padding end of the icon only large button
$button-has-icon-only-padding-end-large: px-to-rem(16);

/// @prop - Padding end of the icon only extra large button
$button-has-icon-only-padding-end-xlarge: px-to-rem(18);
$button-ionic-outline-border-style: solid !default;
thetaPC marked this conversation as resolved.
Show resolved Hide resolved
45 changes: 29 additions & 16 deletions core/src/components/button/button.ios.scss
Expand Up @@ -6,7 +6,6 @@
// --------------------------------------------------

:host {
--border-radius: #{$button-ios-border-radius};
--padding-top: #{$button-ios-padding-top};
--padding-bottom: #{$button-ios-padding-bottom};
--padding-start: #{$button-ios-padding-start};
Expand All @@ -23,7 +22,7 @@
letter-spacing: #{$button-ios-letter-spacing};
}

// iOS Solid Button
// Solid Button
// --------------------------------------------------

:host(.button-solid) {
Expand All @@ -35,11 +34,10 @@
--background-hover-opacity: 1;
}

// iOS Outline Button
// Outline Button
// --------------------------------------------------

:host(.button-outline) {
--border-radius: #{$button-ios-outline-border-radius};
--border-width: #{$button-ios-outline-border-width};
--border-style: #{$button-ios-outline-border-style};
--background-activated: #{ion-color(primary, base)};
Expand All @@ -49,7 +47,7 @@
--color-activated: #{ion-color(primary, contrast)};
}

// iOS Clear Button
// Clear Button
// --------------------------------------------------

:host(.button-clear) {
Expand All @@ -63,7 +61,7 @@
font-weight: #{$button-ios-clear-font-weight};
}

// iOS Toolbar Buttons
// Toolbar Buttons
// --------------------------------------------------

/**
Expand All @@ -81,11 +79,10 @@
font-weight: 400;
}

// iOS Button Sizes
// Button Sizes
// --------------------------------------------------

:host(.button-large) {
--border-radius: #{$button-ios-large-border-radius};
--padding-top: #{$button-ios-large-padding-top};
--padding-start: #{$button-ios-large-padding-start};
--padding-end: #{$button-ios-large-padding-end};
Expand All @@ -97,7 +94,6 @@
}

:host(.button-small) {
--border-radius: #{$button-ios-small-border-radius};
--padding-top: #{$button-ios-small-padding-top};
--padding-start: #{$button-ios-small-padding-start};
--padding-end: #{$button-ios-small-padding-end};
Expand All @@ -108,25 +104,42 @@
font-size: #{$button-ios-small-font-size};
}

// iOS Round Button
// Button Shapes
// --------------------------------------------------

:host(.button-soft) {
--border-radius: 6px;
}

:host(.button-soft.button-large) {
--border-radius: 8px;
}

:host(.button-soft.button-small) {
--border-radius: 4px;
}

// TODO(FW-6202): remove the custom padding styles
:host(.button-round) {
--border-radius: #{$button-ios-round-border-radius};
--border-radius: 999px;
--padding-top: #{$button-ios-round-padding-top};
--padding-start: #{$button-ios-round-padding-start};
--padding-end: #{$button-ios-round-padding-end};
--padding-bottom: #{$button-ios-round-padding-bottom};
}

// iOS Strong Button
:host(.button-rectangular) {
--border-radius: 0px;
}

// Strong Button
// --------------------------------------------------

:host(.button-strong) {
font-weight: #{$button-ios-strong-font-weight};
}

// iOS Icon Only Button
// Icon Only Button
// --------------------------------------------------

:host(.button-has-icon-only) {
Expand All @@ -148,7 +161,7 @@
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 16px
Expand All @@ -172,7 +185,7 @@
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 13px
Expand All @@ -196,7 +209,7 @@
*
* Since the `ion-button` uses `rem` for the font size, we can't
* just pass the desired icon font size in `em` to the `
* dynamic-font-clamp`. Instead, we need to adjust the base size
* dynamic-font-clamp`. Instead, we need to adjust the base size
* to account for the ion-button` font size.
*
* For example, if the default font size of `ion-button` is 20px
Expand Down
15 changes: 0 additions & 15 deletions core/src/components/button/button.ios.vars.scss
Expand Up @@ -30,9 +30,6 @@ $button-ios-padding-start: $button-ios-padding-end;
/// @prop - Minimum height of the button
$button-ios-min-height: 3.1em;

/// @prop - Border radius of the button
$button-ios-border-radius: 14px;

/// @prop - Font size of the button text
/// The maximum font size is calculated by taking the default font size
/// and multiplying it by 3, since 310% of the default is the maximum
Expand All @@ -59,9 +56,6 @@ $button-ios-large-padding-start: $button-ios-large-padding-end;
/// @prop - Minimum height of the large button
$button-ios-large-min-height: 3.1em;

/// @prop - Border radius of the large button
$button-ios-large-border-radius: 16px;

/// @prop - Font size of the large button
/// The maximum font size is calculated by taking the default font size
/// and multiplying it by 3, since 310% of the default is the maximum
Expand All @@ -85,9 +79,6 @@ $button-ios-small-padding-start: $button-ios-small-padding-end;
/// @prop - Minimum height of the small button
$button-ios-small-min-height: 2.1em;

/// @prop - Border radius of the small button
$button-ios-small-border-radius: 6px;

/// @prop - Font size of the small button
/// The maximum font size is calculated by taking the default font size
/// and multiplying it by 3, since 310% of the default is the maximum
Expand All @@ -102,9 +93,6 @@ $button-ios-outline-border-width: 1px;
/// @prop - Border style of the outline button
$button-ios-outline-border-style: solid;

/// @prop - Border radius of the outline button
$button-ios-outline-border-radius: $button-ios-border-radius;

// iOS Clear Button
// --------------------------------------------------

Expand Down Expand Up @@ -140,9 +128,6 @@ $button-ios-round-padding-bottom: $button-round-padding-bottom;
/// @prop - Padding start of the round button
$button-ios-round-padding-start: $button-round-padding-start;

/// @prop - Border radius of the round button
$button-ios-round-border-radius: $button-round-border-radius;

// iOS Decorator Button
// --------------------------------------------------

Expand Down