Skip to content

Commit

Permalink
feat(checkbox): component can be used outside ion-item (#26518)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandaejohnston committed Jan 5, 2023
1 parent 96147ec commit 9d52e70
Show file tree
Hide file tree
Showing 297 changed files with 1,189 additions and 274 deletions.
4 changes: 3 additions & 1 deletion BREAKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ This section details the desktop browser, JavaScript framework, and mobile platf

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

`ionChange` is no longer emitted when the `checked` property of `ion-checkbox` is modified externally. `ionChange` is only emitted from user committed changes, such as clicking or tapping the checkbox.
- `ionChange` is no longer emitted when the `checked` property of `ion-checkbox` is modified externally. `ionChange` is only emitted from user committed changes, such as clicking or tapping the checkbox.

- The `--background` and `--background-checked` CSS variables have been renamed to `--checkbox-background` and `--checkbox-background-checked` respectively.

<h4 id="version-7x-datetime">Datetime</h4>

Expand Down
4 changes: 2 additions & 2 deletions angular/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,13 @@ setting the checked property.

@ProxyCmp({
defineCustomElementFn: undefined,
inputs: ['checked', 'color', 'disabled', 'indeterminate', 'mode', 'name', 'value']
inputs: ['checked', 'color', 'disabled', 'indeterminate', 'justify', 'labelPlacement', 'legacy', 'mode', 'name', 'value']
})
@Component({
selector: 'ion-checkbox',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
inputs: ['checked', 'color', 'disabled', 'indeterminate', 'mode', 'name', 'value']
inputs: ['checked', 'color', 'disabled', 'indeterminate', 'justify', 'labelPlacement', 'legacy', 'mode', 'name', 'value']
})
export class IonCheckbox {
protected el: HTMLElement;
Expand Down
7 changes: 5 additions & 2 deletions core/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,22 @@ ion-checkbox,prop,checked,boolean,false,false,false
ion-checkbox,prop,color,"danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string & Record<never, never> | undefined,undefined,false,true
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" | "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
ion-checkbox,event,ionBlur,void,true
ion-checkbox,event,ionChange,CheckboxChangeEventDetail<any>,true
ion-checkbox,event,ionFocus,void,true
ion-checkbox,css-prop,--background
ion-checkbox,css-prop,--background-checked
ion-checkbox,css-prop,--border-color
ion-checkbox,css-prop,--border-color-checked
ion-checkbox,css-prop,--border-radius
ion-checkbox,css-prop,--border-style
ion-checkbox,css-prop,--border-width
ion-checkbox,css-prop,--checkbox-background
ion-checkbox,css-prop,--checkbox-background-checked
ion-checkbox,css-prop,--checkmark-color
ion-checkbox,css-prop,--checkmark-width
ion-checkbox,css-prop,--size
Expand Down
24 changes: 24 additions & 0 deletions core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,18 @@ export namespace Components {
* If `true`, the checkbox will visually appear as indeterminate.
*/
"indeterminate": boolean;
/**
* How to pack the label and checkbox within a line. `'start'`: The label and checkbox will appear on the left in LTR and on the right in RTL. `'end'`: The label and checkbox will appear on the right in LTR and on the left in RTL. `'space-between'`: The label and checkbox will appear on opposite ends of the line with space between the two elements.
*/
"justify": 'start' | 'end' | 'space-between';
/**
* 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 ("...").
*/
"labelPlacement": 'start' | 'end' | 'fixed';
/**
* 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 @@ -4466,6 +4478,18 @@ declare namespace LocalJSX {
* If `true`, the checkbox will visually appear as indeterminate.
*/
"indeterminate"?: boolean;
/**
* How to pack the label and checkbox within a line. `'start'`: The label and checkbox will appear on the left in LTR and on the right in RTL. `'end'`: The label and checkbox will appear on the right in LTR and on the left in RTL. `'space-between'`: The label and checkbox will appear on opposite ends of the line with space between the two elements.
*/
"justify"?: 'start' | 'end' | 'space-between';
/**
* 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 ("...").
*/
"labelPlacement"?: 'start' | 'end' | 'fixed';
/**
* 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
10 changes: 4 additions & 6 deletions core/src/components/checkbox/checkbox.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
--border-color: #{$checkbox-ios-icon-border-color-off};

// Background
--background: #{$checkbox-ios-background-color-off};
--checkbox-background: #{$checkbox-ios-background-color-off};

// Size
--size: #{$checkbox-ios-icon-size};

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


Expand All @@ -31,9 +28,10 @@


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

:host(.in-item) {
: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);

Expand All @@ -42,6 +40,6 @@
position: static;
}

:host(.in-item[slot="start"]) {
: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);
}
15 changes: 4 additions & 11 deletions core/src/components/checkbox/checkbox.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
--checkmark-width: 3;

// Background
--background: #{$checkbox-md-icon-background-color-off};
--checkbox-background: #{$checkbox-md-icon-background-color-off};

// Transition
--transition: #{background $checkbox-md-transition-duration $checkbox-md-transition-easing};

// Size
--size: #{$checkbox-md-icon-size};

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

.checkbox-icon path {
Expand Down Expand Up @@ -50,9 +47,10 @@


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

:host(.in-item) {
: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);

Expand All @@ -61,11 +59,6 @@
position: static;
}

:host(.in-item[slot="start"]) {
: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);
}

// REVIEW
// .checkbox-md + .item-inner ion-label {
// @include margin-horizontal(0, null);
// }

0 comments on commit 9d52e70

Please sign in to comment.