Skip to content

Commit 6a1382f

Browse files
BenOsodracIonitronbrandyscarney
authored
fix(button): ionic theme sizes (#30405)
Issue number: internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Adjusted ion-button sizes on Ionic theme to match Figma UI. Now figma's small | medium | large match ionic's small | default | large. - Removed xsmall and xlarge sizes, as UX rolled back the decision to have them. - Removed xsmall and xlarge tests and their usages. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> - [Ionic Theme Button](https://ionic-framework-git-rou-11903-ionic1.vercel.app/src/components/button/test/theme-ionic) --------- Co-authored-by: ionitron <[email protected]> Co-authored-by: Brandy Smith <[email protected]>
1 parent 7fec492 commit 6a1382f

File tree

217 files changed

+29
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+29
-130
lines changed

core/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ ion-button,prop,rel,string | undefined,undefined,false,false
396396
ion-button,prop,routerAnimation,((baseEl: any, opts?: any) => Animation) | undefined,undefined,false,false
397397
ion-button,prop,routerDirection,"back" | "forward" | "root",'forward',false,false
398398
ion-button,prop,shape,"rectangular" | "round" | "soft" | undefined,undefined,false,true
399-
ion-button,prop,size,"default" | "large" | "small" | "xlarge" | "xsmall" | undefined,undefined,false,true
399+
ion-button,prop,size,"default" | "large" | "medium" | "small" | undefined,undefined,false,true
400400
ion-button,prop,strong,boolean,false,false,false
401401
ion-button,prop,target,string | undefined,undefined,false,false
402402
ion-button,prop,theme,"ios" | "md" | "ionic",undefined,false,false

core/src/components.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,9 @@ export namespace Components {
587587
*/
588588
"shape"?: 'soft' | 'round' | 'rectangular';
589589
/**
590-
* 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.
590+
* Set to `"small"` for a button with less height and padding, to `"medium"` for a button with the medium 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.
591591
*/
592-
"size"?: 'xsmall' | 'small' | 'default' | 'large' | 'xlarge';
592+
"size"?: 'small' | 'default' | 'medium' | 'large';
593593
/**
594594
* If `true`, activates a button with a heavier font weight.
595595
*/
@@ -6068,9 +6068,9 @@ declare namespace LocalJSX {
60686068
*/
60696069
"shape"?: 'soft' | 'round' | 'rectangular';
60706070
/**
6071-
* 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.
6071+
* Set to `"small"` for a button with less height and padding, to `"medium"` for a button with the medium 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.
60726072
*/
6073-
"size"?: 'xsmall' | 'small' | 'default' | 'large' | 'xlarge';
6073+
"size"?: 'small' | 'default' | 'medium' | 'large';
60746074
/**
60756075
* If `true`, activates a button with a heavier font weight.
60766076
*/
-68 Bytes
-54 Bytes
-139 Bytes
-90 Bytes
-59 Bytes
-156 Bytes

core/src/components/button/button.ionic.scss

Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,15 @@
44
// Ionic Button
55
// -------------------------------------------------------------------------------
66
:host {
7+
--padding-top: #{globals.$ion-space-0};
8+
--padding-end: #{globals.$ion-space-0};
79
--padding-bottom: var(--padding-top);
8-
--padding-end: #{globals.$ion-space-500};
910
--padding-start: var(--padding-end);
10-
--padding-top: #{globals.$ion-space-0};
1111
--focus-ring-color: #{globals.$ion-border-focus-default};
1212
--focus-ring-width: #{globals.$ion-border-size-050};
1313

1414
position: relative;
1515

16-
min-height: globals.$ion-scale-1000;
17-
18-
font-family: globals.$ion-font-family;
19-
font-size: globals.$ion-font-size-350;
20-
2116
// Target area
2217
&::after {
2318
@include globals.position(50%, 0, null, 0);
@@ -102,44 +97,31 @@
10297
// Button Sizes
10398
// -------------------------------------------------------------------------------
10499

105-
/* Extra Small Button */
106-
:host(.button-xsmall) {
107-
--padding-top: #{globals.$ion-space-100};
108-
--padding-end: #{globals.$ion-space-300};
109-
110-
min-height: globals.$ion-space-600;
111-
112-
font-size: globals.$ion-font-size-300;
113-
}
114-
115100
/* Small Button */
116101
:host(.button-small) {
117-
--padding-top: #{globals.$ion-space-200};
118102
--padding-end: #{globals.$ion-space-400};
119103

120-
min-height: #{globals.$ion-scale-800};
104+
@include globals.typography(globals.$ion-body-action-sm);
121105

122-
font-size: #{globals.$ion-font-size-300};
106+
min-height: #{globals.$ion-scale-1000};
123107
}
124108

125-
/* Large Button */
126-
:host(.button-large) {
127-
--padding-top: #{globals.$ion-space-400};
128-
--padding-end: #{globals.$ion-space-600};
109+
/* Medium Button */
110+
:host(.button-medium) {
111+
--padding-end: #{globals.$ion-space-500};
129112

130-
min-height: #{globals.$ion-scale-1200};
113+
@include globals.typography(globals.$ion-body-action-md);
131114

132-
font-size: #{globals.$ion-font-size-400};
115+
min-height: #{globals.$ion-scale-1200};
133116
}
134117

135-
/* Extra Large Button */
136-
:host(.button-xlarge) {
137-
--padding-top: #{globals.$ion-space-400};
138-
--padding-end: #{globals.$ion-space-800};
118+
/* Large Button */
119+
:host(.button-large) {
120+
--padding-end: #{globals.$ion-space-700};
121+
122+
@include globals.typography(globals.$ion-body-action-lg);
139123

140124
min-height: #{globals.$ion-scale-1400};
141-
142-
font-size: #{globals.$ion-font-size-500};
143125
}
144126

145127
// Button with Icons
@@ -152,10 +134,8 @@
152134
font-size: globals.$ion-font-size-400;
153135
}
154136

155-
:host(.button-xsmall),
156137
:host(.button-small),
157-
:host(.button-large),
158-
:host(.button-xlarge) {
138+
:host(.button-large) {
159139
::slotted(ion-icon[slot="start"]),
160140
::slotted(ion-icon[slot="end"]),
161141
::slotted(ion-icon[slot="icon-only"]) {
@@ -183,11 +163,6 @@
183163
height: globals.$ion-space-500;
184164
}
185165

186-
:host(.button-xlarge) ::slotted(ion-spinner) {
187-
width: globals.$ion-space-600;
188-
height: globals.$ion-space-600;
189-
}
190-
191166
// Button Shapes
192167
// -------------------------------------------------------------------------------
193168

@@ -198,11 +173,6 @@
198173
--border-radius: #{globals.$ion-border-radius-200};
199174
}
200175

201-
:host(.button-soft.button-xsmall),
202-
:host(.button-soft.button-small) {
203-
--border-radius: #{globals.$ion-border-radius-100};
204-
}
205-
206176
// Round Button
207177
// --------------------------------------------------
208178

@@ -264,8 +234,6 @@
264234
font-size: globals.$ion-font-size-500;
265235
}
266236

267-
:host(.button-xsmall) ::slotted(ion-icon[slot="start"]),
268-
:host(.button-xsmall) ::slotted(ion-spinner[slot="start"]),
269237
:host(.button-small) ::slotted(ion-icon[slot="start"]),
270238
:host(.button-small) ::slotted(ion-spinner[slot="start"]) {
271239
@include globals.margin-horizontal(null, globals.$ion-space-200);
@@ -277,14 +245,10 @@
277245
}
278246

279247
:host(.button-large) ::slotted(ion-icon[slot="start"]),
280-
:host(.button-large) ::slotted(ion-spinner[slot="start"]),
281-
:host(.button-xlarge) ::slotted(ion-icon[slot="start"]),
282-
:host(.button-xlarge) ::slotted(ion-spinner[slot="start"]) {
248+
:host(.button-large) ::slotted(ion-spinner[slot="start"]) {
283249
@include globals.margin-horizontal(null, globals.$ion-space-300);
284250
}
285251

286-
:host(.button-xsmall) ::slotted(ion-icon[slot="end"]),
287-
:host(.button-xsmall) ::slotted(ion-spinner[slot="end"]),
288252
:host(.button-small) ::slotted(ion-icon[slot="end"]),
289253
:host(.button-small) ::slotted(ion-spinner[slot="end"]) {
290254
@include globals.margin-horizontal(globals.$ion-space-200, null);
@@ -296,9 +260,7 @@
296260
}
297261

298262
:host(.button-large) ::slotted(ion-icon[slot="end"]),
299-
:host(.button-large) ::slotted(ion-spinner[slot="end"]),
300-
:host(.button-xlarge) ::slotted(ion-icon[slot="end"]),
301-
:host(.button-xlarge) ::slotted(ion-spinner[slot="end"]) {
263+
:host(.button-large) ::slotted(ion-spinner[slot="end"]) {
302264
@include globals.margin-horizontal(globals.$ion-space-300, null);
303265
}
304266

core/src/components/button/button.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
122122
@Prop({ reflect: true }) shape?: 'soft' | 'round' | 'rectangular';
123123

124124
/**
125-
* Set to `"small"` for a button with less height and padding, to `"default"`
126-
* for a button with the default height and padding, or to `"large"` for a button
125+
* Set to `"small"` for a button with less height and padding, to `"medium"`
126+
* for a button with the medium height and padding, or to `"large"` for a button
127127
* with more height and padding. By default the size is unset, unless the button
128128
* is inside of an item, where the size is `"small"` by default. Set the size to
129129
* `"default"` inside of an item to make it a standard size button.
130130
*/
131-
@Prop({ reflect: true }) size?: 'xsmall' | 'small' | 'default' | 'large' | 'xlarge';
131+
@Prop({ reflect: true }) size?: 'small' | 'default' | 'medium' | 'large';
132132

133133
/**
134134
* If `true`, activates a button with a heavier font weight.
@@ -233,18 +233,14 @@ export class Button implements ComponentInterface, AnchorInterface, ButtonInterf
233233
}
234234

235235
/**
236-
* Disable the "xsmall" and "xlarge" sizes if the theme is "ios" or "md"
236+
* Get the default size. If size is unset and the button is inside an item,
237+
* the default size is "small". Otherwise, it uses the value of size.
237238
*/
238239
private getSize(): string | undefined {
239-
const theme = getIonTheme(this);
240240
const { size } = this;
241241

242-
if (size === undefined && this.inItem) {
243-
return 'small';
244-
}
245-
246-
if ((theme === 'ios' || theme === 'md') && (size === 'xsmall' || size === 'xlarge')) {
247-
return undefined;
242+
if (size === undefined) {
243+
return this.inItem ? 'small' : 'medium';
248244
}
249245

250246
return size;

0 commit comments

Comments
 (0)