• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atomicpages / pretty-checkbox-react / 10812249919

11 Sep 2024 01:04PM UTC coverage: 100.0%. Remained the same
10812249919

Pull #1165

github

web-flow
build(deps-dev): bump @commitlint/config-conventional

Bumps [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional) from 17.0.2 to 19.5.0.
- [Release notes](https://github.com/conventional-changelog/commitlint/releases)
- [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/CHANGELOG.md)
- [Commits](https://github.com/conventional-changelog/commitlint/commits/v19.5.0/@commitlint/config-conventional)

---
updated-dependencies:
- dependency-name: "@commitlint/config-conventional"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1165: build(deps-dev): bump @commitlint/config-conventional from 17.0.2 to 19.5.0

67 of 67 branches covered (100.0%)

Branch coverage included in aggregate %.

172 of 172 relevant lines covered (100.0%)

9.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/components/switch/Switch.tsx
1
import * as React from 'react';
1✔
2
import clsx from 'clsx';
1✔
3

4
import { useClassNames } from '../../hooks/utility/useClassNames';
1✔
5
import { useControlled } from '../../hooks/utility/useControlled';
1✔
6
import { UseRadioState } from '../..';
7
import { useLocked } from '../../hooks/utility/useLocked';
1✔
8
import { State } from '../state/State';
1✔
9

10
import { PCRSwitchProps } from '../../typings/PCRSwitchProps';
11
import { useCommonProps } from '../../hooks/utility/useCommonProps';
1✔
12
import { UseCheckboxState } from '../checkbox/Checkbox';
13
import mergeRefs from 'react-merge-refs';
1✔
14
import { useAriaChecked } from './useAriaChecked';
1✔
15

16
export type SwitchProps<
17
  S = UseRadioState['state'] | UseCheckboxState['state']
18
> = PCRSwitchProps<S>;
19

20
export const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
1✔
21
  (props, ref) => {
22
    const { checked, value, state, ...rest } = useControlled<
5✔
23
      UseRadioState['state'] | UseCheckboxState['state'],
24
      SwitchProps
25
    >(props);
26

27
    const { children, locked, color, id, className, style, htmlProps } =
28
      useCommonProps(rest);
5✔
29
    const styles = useLocked({ locked, style });
5✔
30

31
    const htmlRef = useAriaChecked({ setState: props.setState, checked });
5✔
32

33
    return (
5✔
34
      <div
35
        style={styles}
36
        className={clsx(
37
          'pretty',
38
          'p-switch',
39
          useClassNames(props, true),
40
          className
41
        )}
42
      >
43
        <input
44
          ref={mergeRefs([ref, htmlRef])}
45
          type="checkbox"
46
          role="switch"
47
          value={value}
48
          id={id}
49
          // required for role="switch"
50
          // @see https://www.w3.org/TR/wai-aria-1.1/#switch
51
          aria-checked={checked}
52
          checked={checked}
53
          {...htmlProps}
54
        />
55
        <State id={id} color={color}>
56
          {children}
57
        </State>
58
      </div>
59
    );
60
  }
61
);
62

63
Switch.displayName = 'Switch';
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc