Explorar o código

add support for disabled checkboxes

jusrhee %!s(int64=5) %!d(string=hai) anos
pai
achega
b1bd86d89e

+ 10 - 7
dashboard/src/components/values-form/CheckboxRow.tsx

@@ -6,6 +6,7 @@ type PropsType = {
   checked: boolean;
   checked: boolean;
   toggle: () => void;
   toggle: () => void;
   isRequired?: boolean;
   isRequired?: boolean;
+  disabled?: boolean;
 };
 };
 
 
 type StateType = {};
 type StateType = {};
@@ -14,7 +15,10 @@ export default class CheckboxRow extends Component<PropsType, StateType> {
   render() {
   render() {
     return (
     return (
       <StyledCheckboxRow>
       <StyledCheckboxRow>
-        <CheckboxWrapper onClick={this.props.toggle}>
+        <CheckboxWrapper
+          disabled={this.props.disabled}
+          onClick={!this.props.disabled && this.props.toggle}
+        >
           <Checkbox checked={this.props.checked}>
           <Checkbox checked={this.props.checked}>
             <i className="material-icons">done</i>
             <i className="material-icons">done</i>
           </Checkbox>
           </Checkbox>
@@ -31,10 +35,10 @@ const Required = styled.section`
   color: #fc4976;
   color: #fc4976;
 `;
 `;
 
 
-const CheckboxWrapper = styled.div`
+const CheckboxWrapper = styled.div<{ disabled?: boolean }>`
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
-  cursor: pointer;
+  cursor: ${(props) => (props.disabled ? "not-allowed" : "pointer")};
   font-size: 13px;
   font-size: 13px;
   :hover {
   :hover {
     > div {
     > div {
@@ -43,14 +47,13 @@ const CheckboxWrapper = styled.div`
   }
   }
 `;
 `;
 
 
-const Checkbox = styled.div`
+const Checkbox = styled.div<{ checked: boolean }>`
   width: 16px;
   width: 16px;
   height: 16px;
   height: 16px;
   border: 1px solid #ffffff55;
   border: 1px solid #ffffff55;
   margin: 1px 10px 0px 1px;
   margin: 1px 10px 0px 1px;
   border-radius: 3px;
   border-radius: 3px;
-  background: ${(props: { checked: boolean }) =>
-    props.checked ? "#ffffff22" : "#ffffff11"};
+  background: ${(props) => (props.checked ? "#ffffff22" : "#ffffff11")};
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
   justify-content: center;
   justify-content: center;
@@ -58,7 +61,7 @@ const Checkbox = styled.div`
   > i {
   > i {
     font-size: 12px;
     font-size: 12px;
     padding-left: 0px;
     padding-left: 0px;
-    display: ${(props: { checked: boolean }) => (props.checked ? "" : "none")};
+    display: ${(props) => (props.checked ? "" : "none")};
   }
   }
 `;
 `;
 
 

+ 1 - 0
dashboard/src/components/values-form/ValuesForm.tsx

@@ -81,6 +81,7 @@ export default class ValuesForm extends Component<PropsType, StateType> {
           return (
           return (
             <CheckboxRow
             <CheckboxRow
               key={key}
               key={key}
+              disabled={this.props.disabled}
               isRequired={item.required}
               isRequired={item.required}
               checked={this.props.metaState[key]?.value}
               checked={this.props.metaState[key]?.value}
               toggle={() =>
               toggle={() =>