| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- import {
- type ViewStyle,
- type TextStyle,
- StyleSheet
- } from "react-native";
- import {
- type TextAreaInputDynamicStyleType,
- type TextAreaInputTypes,
- type TextAreaInputType
- } from "./type";
- import type {
- Mutable
- } from "../../types";
- export const TEXT_AREA_INPUT_TYPE_STYLES: Record<
- TextAreaInputType,
- TextAreaInputTypes
- > = {
- default: {
- focusBorderColor: "emphasized",
- borderColor: "emphasized",
- hintTextIconColor: "mid",
- placeholderColor: "low",
- containerColor: "mid",
- hintTextColor: "mid",
- titleColor: "high",
- inputColor: "mid",
- iconColor: "mid"
- },
- danger: {
- placeholderColor: "dangerLow",
- hintTextIconColor: "danger",
- focusBorderColor: "danger",
- containerColor: "danger",
- hintTextColor: "danger",
- borderColor: "danger",
- titleColor: "danger",
- inputColor: "danger",
- iconColor: "danger"
- },
- success: {
- placeholderColor: "successLow",
- hintTextIconColor: "success",
- focusBorderColor: "success",
- containerColor: "success",
- hintTextColor: "success",
- borderColor: "success",
- titleColor: "success",
- inputColor: "success",
- iconColor: "success"
- },
- warning: {
- placeholderColor: "warningLow",
- hintTextIconColor: "warning",
- focusBorderColor: "warning",
- containerColor: "warning",
- hintTextColor: "warning",
- borderColor: "warning",
- titleColor: "warning",
- inputColor: "warning",
- iconColor: "warning"
- },
- info: {
- placeholderColor: "infoLow",
- hintTextIconColor: "info",
- focusBorderColor: "info",
- containerColor: "info",
- hintTextColor: "info",
- borderColor: "info",
- titleColor: "info",
- inputColor: "info",
- iconColor: "info"
- },
- question: {
- focusBorderColor: "emphasized",
- borderColor: "emphasized",
- hintTextIconColor: "mid",
- placeholderColor: "low",
- containerColor: "mid",
- hintTextColor: "mid",
- titleColor: "mid",
- inputColor: "mid",
- iconColor: "mid"
- }
- };
- export const getTextAreaInputType = ({
- type
- }: {
- type: TextAreaInputType;
- }) => {
- const currentType = TEXT_AREA_INPUT_TYPE_STYLES[type];
- return currentType;
- };
- const stylesheet = StyleSheet.create({
- container: {
- flexDirection: "column",
- boxSizing: "border-box",
- display: "flex"
- },
- content: {
- alignItems: "flex-start",
- boxSizing: "border-box",
- flexDirection: "row",
- borderStyle: "solid",
- position: "relative",
- display: "flex",
- minWidth: 250
- },
- input: {
- backgroundColor: "transparent",
- borderColor: "transparent",
- textAlignVertical: "top",
- paddingBottom: 0,
- paddingRight: 0,
- paddingLeft: 0,
- borderWidth: 0,
- paddingTop: 0,
- minHeight: 55,
- zIndex: 99
- },
- cleanButton: {
- justifyContent: "center",
- alignSelf: "flex-start",
- alignItems: "center",
- display: "flex",
- zIndex: 99
- },
- hideTextIconContainer: {
- justifyContent: "center",
- alignItems: "center",
- alignSelf: "center",
- display: "flex",
- zIndex: 99,
- height: 18
- },
- titleContainer: {
- flexDirection: "row",
- alignItems: "center"
- },
- title: {
- },
- icon: {
- justifyContent: "center",
- alignContent: "center",
- alignItems: "center",
- display: "flex",
- zIndex: 99
- },
- required: {
- },
- hintTextIcon: {
- },
- hintText: {
- flexDirection: "row",
- alignItems: "center",
- display: "flex"
- },
- subTitle: {
- },
- overlay: {
- position: "absolute",
- zIndex: 98,
- bottom: 0,
- right: 0,
- left: 0,
- top: 0
- },
- rightIcon: {
- justifyContent: "center",
- alignItems: "center",
- alignSelf: "center",
- display: "flex",
- zIndex: 99
- },
- lengthLimiterContainer: {
- justifyContent: "flex-end",
- flexDirection: "row"
- },
- inputContainer: {
- flexDirection: "column",
- flex: 1
- }
- });
- export const useStyles = ({
- spreadBehaviour,
- inlineSpaces,
- currentType,
- typography,
- isDisabled,
- isFocused,
- maxHeight,
- radiuses,
- borders,
- colors,
- spaces,
- type
- }: TextAreaInputDynamicStyleType) => {
- const styleType = type === "danger" ? "error" : type === "question" ? "neutral" : type;
- const styles = {
- container: {
- } as Mutable<ViewStyle>,
- content: {
- backgroundColor: colors.content.container[currentType.containerColor],
- borderColor: colors.content.container[currentType.containerColor],
- paddingBottom: spaces.spacingMd,
- paddingRight: spaces.spacingMd,
- borderRadius: radiuses.actions,
- paddingLeft: spaces.spacingMd,
- paddingTop: spaces.spacingMd,
- borderWidth: borders.line
- } as Mutable<ViewStyle>,
- input: {
- ...typography.labelLargeSize,
- color: colors.content.text[currentType.inputColor],
- maxHeight: maxHeight
- } as Mutable<TextStyle>,
- cleanButton: {
- marginLeft: spaces.spacingSm
- } as Mutable<ViewStyle>,
- hintTextIconContainer: {
- marginLeft: spaces.spacingSm
- } as Mutable<ViewStyle>,
- titleContainer: {
- marginBottom: spaces.spacingSm
- } as Mutable<ViewStyle>,
- title: {
- } as Mutable<TextStyle>,
- icon: {
- marginRight: spaces.spacingSm
- } as Mutable<ViewStyle>,
- required: {
- marginRight: inlineSpaces.required
- } as Mutable<ViewStyle>,
- hintTextIcon: {
- marginRight: spaces.spacingXs
- } as Mutable<ViewStyle>,
- hintText: {
- marginTop: spaces.spacingSm
- } as Mutable<TextStyle>,
- subTitle: {
- marginLeft: inlineSpaces.subTitle
- } as Mutable<TextStyle>,
- overlay: {
- borderRadius: radiuses.actions - 1
- } as Mutable<ViewStyle>,
- rightIcon: {
- marginLeft: spaces.spacingSm
- } as Mutable<ViewStyle>,
- lengthLimiterContainer: {
- } as Mutable<ViewStyle>,
- inputContainer: {
- } as Mutable<ViewStyle>
- };
- if(isDisabled) {
- const disableStyleType = styleType === "default" ? "neutral" : styleType;
- styles.overlay.backgroundColor = colors.system.state.overlay.disabled[disableStyleType];
- styles.container.borderColor = colors.system.state.overlay.disabled[disableStyleType];
- styles.input.color = colors.content.text.disabled;
- }
- if (spreadBehaviour === "baseline") {
- styles.container.alignSelf = spreadBehaviour;
- styles.container.width = "auto";
- }
- if (spreadBehaviour === "stretch") {
- styles.container.alignSelf = spreadBehaviour;
- styles.container.justifyContent = "center";
- styles.container.flexShrink = 1;
- styles.container.width = "100%";
- }
- if(isFocused && !isDisabled) {
- if(type === "question" || type === "default") {
- styles.content.borderColor = colors.content.border.emphasized;
- } else {
- styles.content.borderColor = colors.content.border[type];
- }
- }
- return styles;
- };
- export default stylesheet;
|