<!--
  Copyright 2023 Comcast Cable Communications Management, LLC

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  SPDX-License-Identifier: Apache-2.0
-->

import { Canvas, Story } from '@storybook/addon-docs';
import Checkbox from '.';

# Checkbox

A checkbox component that can be toggled between a checked an unchecked state.

## Source

https://github.com/rdkcentral/Lightning-UI-Components/blob/develop/packages/@lightningjs/ui-components/src/components/Checkbox/Checkbox.js

## Usage

Simple component that just needs a type, and, if checked, the `checked` flag.

```js
import { Checkbox } from '@lightningjs/ui-components';

class Example extends lng.Component {
  static _template() {
    return {
      Checkbox: {
        type: Checkbox
      }
    };
  }
}
```

<Canvas>
  <Story id="components-checkbox--checkbox" />
</Canvas>

## API

### Properties

| name    | type    | readonly | description  |
| ------- | ------- | -------- | ------------ |
| checked | boolean | true     | toggle state |

### Style Properties

| name                   | type   | description                                 |
| ---------------------- | ------ | ------------------------------------------- |
| alpha                  | number | opacity (transparency) of the checkbox      |
| backgroundColor        | string | color of Checkbox background when unchecked |
| backgroundColorChecked | string | color of Checkbox background when checked   |
| checkColor             | string | color of check icon                         |
| checkH                 | number | height of check icon                        |
| checkSrc               | string | path the icon to use for the checkmark      |
| checkW                 | number | width of check icon                         |
| radius                 | number | radius of Checkbox                          |
| strokeColor            | string | color of the Checkbox border                |
| strokeWidth            | number | width of Checkbox border                    |

### Methods

#### toggle(): void

Toggles `checked` state and updates UI accordingly. The "Enter" key is listened for and will also trigger `toggle()`.
