From c5a2d047894d3f1285c09accac126e311b457e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Wed, 24 Jun 2020 15:20:28 +0200 Subject: [PATCH 1/2] Modify checkboxes so that they can be indeterminate To add the third state, we create our own checkboxes using font awesome icons. --- CHANGELOG.md | 3 + scm-ui/ui-components/src/Icon.tsx | 7 +- .../src/__snapshots__/storyshots.test.ts.snap | 40 +++++++---- .../src/forms/Checkbox.stories.tsx | 1 + scm-ui/ui-components/src/forms/Checkbox.tsx | 13 ++-- .../src/forms/TriStateCheckbox.tsx | 72 +++++++++++++++++++ scm-ui/ui-styles/src/scm.scss | 4 ++ 7 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 scm-ui/ui-components/src/forms/TriStateCheckbox.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 891c0989ea..fe7e769ef0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - enrich commit mentions in markdown viewer by internal links ([#1210](https://github.com/scm-manager/scm-manager/pull/1210)) +### Changed +- Checkboxes can now be 'indeterminate' ([#1215](https://github.com/scm-manager/scm-manager/pull/1215)) + ## [2.1.1] - 2020-06-23 ### Fixed - Wait until recommended java installation is available for deb packages ([#1209](https://github.com/scm-manager/scm-manager/pull/1209)) diff --git a/scm-ui/ui-components/src/Icon.tsx b/scm-ui/ui-components/src/Icon.tsx index 77b6591529..91edfbfd10 100644 --- a/scm-ui/ui-components/src/Icon.tsx +++ b/scm-ui/ui-components/src/Icon.tsx @@ -30,6 +30,7 @@ type Props = { name: string; color: string; className?: string; + onClick?: () => void; }; export default class Icon extends React.Component { @@ -39,12 +40,12 @@ export default class Icon extends React.Component { }; render() { - const { title, iconStyle, name, color, className } = this.props; + const { title, iconStyle, name, color, className, onClick } = this.props; if (title) { return ( - + ); } - return ; + return ; } } diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 71cc6c0ecd..dc41ae15bb 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -38182,14 +38182,13 @@ exports[`Storyshots Forms|Checkbox Default 1`] = ` >
+
+
+ +
+
`; @@ -38227,16 +38243,14 @@ exports[`Storyshots Forms|Checkbox Disabled 1`] = ` >