Skip to content

Commit

Permalink
feat(checkbox): refactor and simplify rendering/style logic
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed reducedTouchTarget. Instead, set the width and height on the checkbox.

PiperOrigin-RevId: 495087302
  • Loading branch information
asyncLiz authored and copybara-github committed Dec 13, 2022
1 parent 545c2eb commit 27f7ea8
Show file tree
Hide file tree
Showing 10 changed files with 546 additions and 1,098 deletions.
7 changes: 6 additions & 1 deletion checkbox/_checkbox.scss
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
@forward './lib/checkbox-theme' show theme, theme-extension;
//
// Copyright 2022 Google LLC
// SPDX-License-Identifier: Apache-2.0
//

@forward './lib/checkbox' show theme;
8 changes: 6 additions & 2 deletions checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ import {customElement} from 'lit/decorators.js';

import {Checkbox} from './lib/checkbox.js';
import {styles} from './lib/checkbox-styles.css.js';
import {styles as forcedColorsStyles} from './lib/forced-colors-styles.css.js';

declare global {
interface HTMLElementTagNameMap {
'md-checkbox': MdCheckbox;
}
}

/** @soyCompatible */
/**
* Checkboxes allow users to select one or more items from a set. Checkboxes can
* turn an option on or off.
*/
@customElement('md-checkbox')
export class MdCheckbox extends Checkbox {
static override styles = [styles];
static override styles = [styles, forcedColorsStyles];
}
17 changes: 17 additions & 0 deletions checkbox/checkbox_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @license
* Copyright 2022 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

// import 'jasmine'; (google3-only)

import {createTokenTests} from '../testing/tokens.js';

import {MdCheckbox} from './checkbox.js';

describe('<md-checkbox>', () => {
describe('.styles', () => {
createTokenTests(MdCheckbox.styles);
});
});
2 changes: 1 addition & 1 deletion checkbox/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ import {Checkbox} from './lib/checkbox.js';
export class CheckboxHarness extends Harness<Checkbox> {
override async getInteractiveElement() {
await this.element.updateComplete;
return this.element.renderRoot.querySelector('input') as HTMLInputElement;
return this.element.renderRoot.querySelector('input')!;
}
}
Loading

0 comments on commit 27f7ea8

Please sign in to comment.