Skip to content

Commit 65f84cf

Browse files
committed
feat: clear-choice-button
1 parent e41329b commit 65f84cf

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

web/src/components/DisputeFeatures/GroupsUI.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import styled from "styled-components";
33

44
import { Group } from "consts/disputeFeature";
55

6+
import LightButton from "../LightButton";
7+
68
const Container = styled.div`
79
width: 100%;
810
display: flex;
@@ -18,9 +20,12 @@ const HeaderContainer = styled.div`
1820
`;
1921

2022
const Header = styled.h2`
23+
display: flex;
2124
font-size: 16px;
2225
font-weight: 600;
2326
margin: 0;
27+
align-items: center;
28+
gap: 8px;
2429
`;
2530

2631
const SubTitle = styled.p`
@@ -30,21 +35,39 @@ const SubTitle = styled.p`
3035
margin: 0;
3136
`;
3237

33-
export type GroupUI = (props: { children: JSX.Element }) => JSX.Element;
38+
const StyledLightButton = styled(LightButton)`
39+
padding: 0 !important;
40+
.button-text {
41+
color: ${({ theme }) => theme.primaryBlue};
42+
font-size: 14px;
43+
}
44+
:hover {
45+
background-color: transparent !important;
46+
.button-text {
47+
color: ${({ theme }) => theme.secondaryBlue};
48+
}
49+
}
50+
`;
51+
52+
export type GroupUI = (props: { children: JSX.Element; clearAll: () => void }) => JSX.Element;
3453
export const GroupsUI: Record<Group, GroupUI> = {
35-
[Group.Voting]: ({ children }) => (
54+
[Group.Voting]: ({ children, clearAll }) => (
3655
<Container key={Group.Voting}>
3756
<HeaderContainer>
38-
<Header>Shielded Voting</Header>
57+
<Header>
58+
Shielded Voting <StyledLightButton text="Clear" onClick={clearAll} />
59+
</Header>
3960
<SubTitle>This feature hides the jurors votes until the end of the voting period.</SubTitle>
4061
</HeaderContainer>
4162
{children}
4263
</Container>
4364
),
44-
[Group.Eligibility]: ({ children }) => (
65+
[Group.Eligibility]: ({ children, clearAll }) => (
4566
<Container key={Group.Eligibility}>
4667
<HeaderContainer>
47-
<Header>Jurors Eligibility</Header>
68+
<Header>
69+
Jurors Eligibility <StyledLightButton text="Clear" onClick={clearAll} />
70+
</Header>
4871
<SubTitle>This feature determines who can be selected as a juror.</SubTitle>
4972
</HeaderContainer>
5073
{children}

web/src/pages/Resolver/Parameters/Court/FeatureSelection/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
findMatchingKits,
1212
getDisabledOptions,
1313
getVisibleFeaturesForCourt,
14+
Group,
1415
toggleFeature,
1516
} from "consts/disputeFeature";
1617
import { IGatedDisputeData, useNewDisputeContext } from "context/NewDisputeContext";
@@ -101,6 +102,17 @@ const FeatureSelection: React.FC = () => {
101102
});
102103
};
103104

105+
const handleGroupDisable = (group: Group) => {
106+
const groupFeatures = courtGroups[group];
107+
// we have a feature selected from this group
108+
for (const feature of groupFeatures) {
109+
if (selected.includes(feature)) {
110+
// turn off this feature
111+
handleToggle(feature);
112+
}
113+
}
114+
};
115+
104116
// if each group only has one feature, select them by default
105117
// This should not clash with the initial selection logic,
106118
// as it only runs when there's one disputeKit and featureSet to pick
@@ -140,6 +152,7 @@ const FeatureSelection: React.FC = () => {
140152
Object.entries(courtGroups).map(([groupName, features], index) => (
141153
<>
142154
{GroupsUI[groupName]({
155+
clearAll: () => handleGroupDisable(groupName as Group),
143156
children: (
144157
<Fragment key={groupName}>
145158
{features.map((feature) =>

0 commit comments

Comments
 (0)