theme-ui#Checkbox TypeScript Examples

The following examples show how to use theme-ui#Checkbox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateSliceZoneModalList.tsx    From slice-machine with Apache License 2.0 5 votes vote down vote up
UpdateSliceZoneModalList: React.FC<{
  availableSlices: ReadonlyArray<SliceState>;
  values: SliceZoneFormValues;
}> = ({ availableSlices, values }) => (
  <FieldArray
    name="sliceKeys"
    render={(arrayHelpers) => (
      <Grid
        gridTemplateMinPx="200px"
        elems={availableSlices}
        defineElementKey={(slice: SliceState) => slice.model.name}
        renderElem={(slice: SliceState) => {
          return SharedSlice.render({
            bordered: true,
            displayStatus: false,
            thumbnailHeightPx: "220px",
            slice,
            Wrapper: ({
              slice,
              children,
            }: {
              slice: SliceState;
              // eslint-disable-next-line @typescript-eslint/no-explicit-any
              children: any;
            }) => {
              return (
                <div
                  data-testid="slicezone-modal-item"
                  style={{ cursor: "pointer" }}
                  onClick={() => {
                    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
                    const isInSliceZone = values.sliceKeys.includes(
                      slice.model.id
                    );
                    if (isInSliceZone) {
                      return arrayHelpers.remove(
                        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
                        values.sliceKeys.indexOf(slice.model.id)
                      );
                    }
                    arrayHelpers.push(slice.model.id);
                  }}
                  key={`${slice.from}-${slice.model.name}`}
                >
                  {children}
                </div>
              );
            },
            CustomStatus: ({ slice }: { slice: SliceState }) => {
              // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
              const isInSliceZone = values.sliceKeys.includes(slice.model.id);
              return isInSliceZone ? (
                <Checkbox value="true" defaultChecked />
              ) : (
                <Checkbox value="false" />
              );
            },
          });
        }}
      />
    )}
  />
)