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

refactor(checkbox): remove legacy property and support for legacy syntax #29043

Merged
merged 8 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver
- [Global Styles](#version-8x-global-styles)
- [Components](#version-8x-components)
- [Button](#version-8x-button)
- [Checkbox](#version-8x-checkbox)
- [Content](#version-8x-content)
- [Datetime](#version-8x-datetime)
- [Input](#version-8x-input)
Expand Down Expand Up @@ -140,6 +141,10 @@ For more information on the dynamic font, refer to the [Dynamic Font Scaling doc

- Button text now wraps by default. If this behavior is not desired, add the `ion-text-nowrap` class from the [CSS Utilities](https://ionicframework.com/docs/layout/css-utilities).

<h4 id="version-8x-checkbox">Checkbox</h4>

The `legacy` property and support for the legacy syntax, which involved placing an `ion-checkbox` inside of an `ion-item` with an `ion-label`, have been removed. For more information on migrating from the legacy checkbox syntax, refer to the [Checkbox documentation](https://ionicframework.com/docs/api/checkbox#migrating-from-legacy-checkbox-syntax).

<h4 id="version-8x-content">Content</h4>

- Content no longer sets the `--background` custom property when the `.outer-content` class is set on the host.
Expand Down
1 change: 0 additions & 1 deletion core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ ion-checkbox,prop,disabled,boolean,false,false,false
ion-checkbox,prop,indeterminate,boolean,false,false,false
ion-checkbox,prop,justify,"end" | "space-between" | "start",'space-between',false,false
ion-checkbox,prop,labelPlacement,"end" | "fixed" | "stacked" | "start",'start',false,false
ion-checkbox,prop,legacy,boolean | undefined,undefined,false,false
ion-checkbox,prop,mode,"ios" | "md",undefined,false,false
ion-checkbox,prop,name,string,this.inputId,false,false
ion-checkbox,prop,value,any,'on',false,false
Expand Down
13 changes: 0 additions & 13 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,6 @@ export namespace Components {
* Where to place the label relative to the checkbox. `"start"`: The label will appear to the left of the checkbox in LTR and to the right in RTL. `"end"`: The label will appear to the right of the checkbox in LTR and to the left in RTL. `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("..."). `"stacked"`: The label will appear above the checkbox regardless of the direction. The alignment of the label can be controlled with the `alignment` property.
*/
"labelPlacement": 'start' | 'end' | 'fixed' | 'stacked';
/**
* Set the `legacy` property to `true` to forcibly use the legacy form control markup. Ionic will only opt checkboxes in to the modern form markup when they are using either the `aria-label` attribute or have text in the default slot. As a result, the `legacy` property should only be used as an escape hatch when you want to avoid this automatic opt-in behavior. Note that this property will be removed in an upcoming major release of Ionic, and all form components will be opted-in to using the modern form markup.
*/
"legacy"?: boolean;
/**
* The mode determines which platform styles to use.
*/
Expand Down Expand Up @@ -3639,7 +3635,6 @@ declare global {
"ionChange": CheckboxChangeEventDetail;
"ionFocus": void;
"ionBlur": void;
"ionStyle": StyleEventDetail;
}
interface HTMLIonCheckboxElement extends Components.IonCheckbox, HTMLStencilElement {
addEventListener<K extends keyof HTMLIonCheckboxElementEventMap>(type: K, listener: (this: HTMLIonCheckboxElement, ev: IonCheckboxCustomEvent<HTMLIonCheckboxElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
Expand Down Expand Up @@ -5323,10 +5318,6 @@ declare namespace LocalJSX {
* Where to place the label relative to the checkbox. `"start"`: The label will appear to the left of the checkbox in LTR and to the right in RTL. `"end"`: The label will appear to the right of the checkbox in LTR and to the left in RTL. `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("..."). `"stacked"`: The label will appear above the checkbox regardless of the direction. The alignment of the label can be controlled with the `alignment` property.
*/
"labelPlacement"?: 'start' | 'end' | 'fixed' | 'stacked';
/**
* Set the `legacy` property to `true` to forcibly use the legacy form control markup. Ionic will only opt checkboxes in to the modern form markup when they are using either the `aria-label` attribute or have text in the default slot. As a result, the `legacy` property should only be used as an escape hatch when you want to avoid this automatic opt-in behavior. Note that this property will be removed in an upcoming major release of Ionic, and all form components will be opted-in to using the modern form markup.
*/
"legacy"?: boolean;
/**
* The mode determines which platform styles to use.
*/
Expand All @@ -5347,10 +5338,6 @@ declare namespace LocalJSX {
* Emitted when the checkbox has focus.
*/
"onIonFocus"?: (event: IonCheckboxCustomEvent<void>) => void;
/**
* Emitted when the styles change.
*/
"onIonStyle"?: (event: IonCheckboxCustomEvent<StyleEventDetail>) => void;
/**
* The value of the checkbox does not mean if it's checked or not, use the `checked` property for that. The value of a checkbox is analogous to the value of an `<input type="checkbox">`, it's only used when the checkbox participates in a native `<form>`.
*/
Expand Down
18 changes: 0 additions & 18 deletions core/src/components/checkbox/checkbox.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,3 @@
:host(.checkbox-disabled) {
opacity: $checkbox-ios-disabled-opacity;
}


// iOS Checkbox Within An Item
// TODO(FW-3100): remove this
// -----------------------------------------

:host(.in-item.legacy-checkbox) {
// end position by default
@include margin($checkbox-ios-item-end-margin-top, $checkbox-ios-item-end-margin-end, $checkbox-ios-item-end-margin-bottom, $checkbox-ios-item-end-margin-start);

display: block;

position: static;
}

:host(.in-item.legacy-checkbox[slot="start"]) {
@include margin($checkbox-ios-item-start-margin-top, $checkbox-ios-item-start-margin-end, $checkbox-ios-item-start-margin-bottom, $checkbox-ios-item-start-margin-start);
}
24 changes: 0 additions & 24 deletions core/src/components/checkbox/checkbox.ios.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,5 @@ $checkbox-ios-icon-border-radius: 50% !default;
/// @prop - Opacity of the disabled checkbox
$checkbox-ios-disabled-opacity: $form-control-ios-disabled-opacity !default;

/// @prop - Margin top of the left checkbox item
$checkbox-ios-item-start-margin-top: 8px !default;

/// @prop - Margin end of the left checkbox item
$checkbox-ios-item-start-margin-end: $item-ios-padding-end !default;

/// @prop - Margin bottom of the left checkbox item
$checkbox-ios-item-start-margin-bottom: $checkbox-ios-item-start-margin-top !default;

/// @prop - Margin start of the left checkbox item
$checkbox-ios-item-start-margin-start: 2px !default;

/// @prop - Margin top of the right checkbox item
$checkbox-ios-item-end-margin-top: 10px !default;

/// @prop - Margin end of the right checkbox item
$checkbox-ios-item-end-margin-end: 8px !default;

/// @prop - Margin bottom of the right checkbox item
$checkbox-ios-item-end-margin-bottom: 9px !default;

/// @prop - Margin start of the right checkbox item
$checkbox-ios-item-end-margin-start: 0 !default;

/// @prop - Checkmark width of the checkbox icon
$checkbox-ios-icon-checkmark-width: 1.5px !default;
19 changes: 0 additions & 19 deletions core/src/components/checkbox/checkbox.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,10 @@
// opacity set by its spec, while the label
// should match the other form controls

:host(.legacy-checkbox.checkbox-disabled),
:host(.checkbox-disabled) .label-text-wrapper {
opacity: $checkbox-md-disabled-opacity;
}

:host(.checkbox-disabled) .native-wrapper {
opacity: $checkbox-md-icon-disabled-opacity;
}


// Material Design Checkbox Within An Item
// TODO(FW-3100): remove this
// --------------------------------------------------------

:host(.in-item.legacy-checkbox) {
// end position by default
@include margin($checkbox-md-item-end-margin-top, $checkbox-md-item-end-margin-end, $checkbox-md-item-end-margin-bottom, $checkbox-md-item-end-margin-start);

display: block;

position: static;
}

:host(.in-item.legacy-checkbox[slot="start"]) {
@include margin($checkbox-md-item-start-margin-top, $checkbox-md-item-start-margin-end, $checkbox-md-item-start-margin-bottom, $checkbox-md-item-start-margin-start);
}
24 changes: 0 additions & 24 deletions core/src/components/checkbox/checkbox.md.vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,6 @@ $checkbox-md-transition-duration: 180ms !default;
/// @prop - Transition easing of the checkbox
$checkbox-md-transition-easing: cubic-bezier(.4, 0, .2, 1) !default;

/// @prop - Margin top of the start checkbox item
$checkbox-md-item-start-margin-top: 18px !default;

/// @prop - Margin end of the start checkbox item
$checkbox-md-item-start-margin-end: 36px !default;

/// @prop - Margin bottom of the start checkbox item
$checkbox-md-item-start-margin-bottom: $checkbox-md-item-start-margin-top !default;

/// @prop - Margin start of the start checkbox item
$checkbox-md-item-start-margin-start: 4px !default;

/// @prop - Margin top of the end checkbox item
$checkbox-md-item-end-margin-top: 18px !default;

/// @prop - Margin end of the end checkbox item
$checkbox-md-item-end-margin-end: 0 !default;

/// @prop - Margin bottom of the end checkbox item
$checkbox-md-item-end-margin-bottom: $checkbox-md-item-end-margin-top !default;

/// @prop - Margin start of the end checkbox item
$checkbox-md-item-end-margin-start: 0 !default;

/// @prop - Opacity of the disabled checkbox
/// This value is used because the checkbox color is set to
/// `rgb(0, 0, 0, 0.60)` when enabled and we need it to be
Expand Down
40 changes: 6 additions & 34 deletions core/src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,17 @@
* toolbar which is why we do not
* limit the below behavior to just ion-item.
*/
:host([slot="start"]:not(.legacy-checkbox)),
:host([slot="end"]:not(.legacy-checkbox)) {
:host([slot="start"]),
:host([slot="end"]) {
width: auto;
}

// TODO(FW-3100): remove this
:host(.legacy-checkbox) {
width: var(--size);
height: var(--size);
}

:host(.ion-color) {
--checkbox-background-checked: #{current-color(base)};
--border-color-checked: #{current-color(base)};
--checkmark-color: #{current-color(contrast)};
}

// TODO(FW-3100): remove this
:host(.legacy-checkbox) label {
@include input-cover();

display: flex;

align-items: center;

opacity: 0;
}

.checkbox-wrapper {
display: flex;

Expand All @@ -96,7 +79,7 @@
overflow: hidden;
}

:host(.in-item:not(.legacy-checkbox)) .label-text-wrapper {
:host(.in-item) .label-text-wrapper {
@include margin($checkbox-item-label-margin-top, null, $checkbox-item-label-margin-bottom, null);
}

Expand Down Expand Up @@ -132,6 +115,9 @@ input {

position: relative;

width: var(--size);
height: var(--size);

transition: var(--transition);

border-width: var(--border-width);
Expand All @@ -143,20 +129,6 @@ input {
box-sizing: border-box;
}

// TODO(FW-3100): remove this
:host(.legacy-checkbox) .checkbox-icon {
display: block;

width: 100%;
height: 100%;
}

// TODO(FW-3100): merge this with other .checkbox-icon styles above
:host(:not(.legacy-checkbox)) .checkbox-icon {
width: var(--size);
height: var(--size);
}

.checkbox-icon path {
fill: none;
stroke: var(--checkmark-color);
Expand Down