PromucFlow_constructor/app/client/src/pages/setup/common.tsx

126 lines
2.9 KiB
TypeScript
Raw Normal View History

import React from "react";
feat: Migrate design system components import to design-system repo - I (#15562) * Icon component deleted and changed the imports in refrence places * design system package version changed * import changes * Delete TextInput.tsx * Change imports * Change single named import * Update package * Update package * Delete ScrollIndicator.tsx * Change imports * Icon import completed * Event type added * Changed Button component imports * import change button * Button onclick type fix * Label with Tooltip import changes * Changed breadcrumbs import * EmojiPicker and Emoji Reaction import changes * AppIcon import change * import bug fix * Menu Item import chnages * Icon selector imports changed * Delete LabelWithTooltip.tsx * Change imports across the app * Update package version * Update version number for design-system * Delete Checkbox.tsx * Remove the exports * Add lock file for ds package update * Change imports * default import -> named * Update release version * Make arg type explicit * Updated design-system to latest release * Missing file mysteriously comes back and is updated accordingly * changes design-system package version * Add types to arguments in the onChange for text input * onBlur type fix * Search component in property pane * WDS button changes reverted * package version bumped * conflict fix * Remove Dropdown, change imports * Category import fix * fix: table icon size import * Bump version of design system package * Yarn lock Co-authored-by: Tanvi Bhakta <tanvibhakta@gmail.com>
2022-08-22 05:09:39 +00:00
import { Dropdown } from "design-system";
import StyledFormGroup from "components/ads/formFields/FormGroup";
import { FormTextFieldProps } from "components/ads/formFields/TextField";
import { WrappedFieldInputProps, WrappedFieldMetaProps } from "redux-form";
import styled from "styled-components";
import { OptionType } from "./constants";
export const FormHeaderWrapper = styled.div`
position: relative;
`;
export const FormHeaderLabel = styled.h5`
width: 100%;
font-size: 20px;
font-weight: 500;
`;
export const FormHeaderIndex = styled.h5`
font-size: 20px;
font-weight: 500;
`;
export const FormBodyWrapper = styled.div`
padding: ${(prop) => prop.theme.spaces[10]}px 0px;
`;
export const FormHeaderSubtext = styled.p``;
export const ControlWrapper = styled.div`
margin: ${(prop) => prop.theme.spaces[6]}px 0px;
`;
export const Label = styled.label`
display: inline-block;
margin-bottom: 10px;
`;
export const ButtonWrapper = styled.div`
margin: ${(prop) => prop.theme.spaces[17] * 2}px 0px 0px;
`;
export const AllowToggleWrapper = styled.div`
display: flex;
`;
export const AllowToggle = styled.div`
flex-basis: 68px;
`;
export const AllowToggleLabel = styled.p`
margin-bottom: 0px;
margin-top: 2px;
`;
export const StyledLink = styled.a`
&,
&:hover {
color: ${(props) => props.theme.colors.link};
text-decoration: none;
}
`;
const DROPDOWN_CLASSNAME = "setup-dropdown";
export const DropdownWrapper = styled(StyledFormGroup)`
&& {
margin-bottom: 33px;
}
&& .cs-text {
width: 100%;
}
.${DROPDOWN_CLASSNAME} {
.ads-dropdown-options-wrapper {
padding: 0;
border: 1px solid rgba(0, 0, 0, 8%);
}
}
.ads-dropdown-errorMsg {
font-size: ${(props) => props.theme.fontSizes[3]}px;
}
`;
export const Center = styled.div`
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
`;
export function withDropdown(options: OptionType[], width: string) {
return function DropdownField(
componentProps: FormTextFieldProps & {
meta: Partial<WrappedFieldMetaProps>;
input: Partial<WrappedFieldInputProps>;
},
) {
function onSelect(value?: string) {
componentProps.input.onChange && componentProps.input.onChange(value);
componentProps.input.onBlur && componentProps.input.onBlur(value);
}
const selected = options.find(
(option) => option.value == componentProps.input.value,
) || { label: componentProps.placeholder };
const hasError = componentProps.meta.invalid && componentProps.meta.touched;
return (
<Dropdown
className={DROPDOWN_CLASSNAME}
dontUsePortal
errorMsg={hasError ? componentProps.meta.error : ""}
fillOptions
onSelect={onSelect}
options={options}
selected={selected}
showLabelOnly
width={width}
/>
);
};
}