Skip to content

Commit

Permalink
fix: minor updates inside textfield api
Browse files Browse the repository at this point in the history
  • Loading branch information
omariosouto committed Dec 24, 2021
1 parent 7820d28 commit e479611
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
59 changes: 51 additions & 8 deletions lib/components/textfield/textfield.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,36 @@ import { BoxBase } from '@lib/components/box/box-base';
import { theme } from '@lib/core/theme/theme';

const textFieldSizes = {
xs: '12px',
sm: '14px',
md: '14px',
lg: '16px',
xl: '18px',
xs: {
fontSize: '12px',
paddingVertical: '8px',
paddingHorizontal: '12px',
},
sm: {
fontSize: '14px',
paddingVertical: '8px',
paddingHorizontal: '12px',
},
md: {
fontSize: '14px',
paddingVertical: '12px',
paddingHorizontal: '16px',
},
lg: {
fontSize: '16px',
paddingVertical: '8px',
paddingHorizontal: '12px',
},
xl: {
fontSize: '18px',
paddingVertical: '8px',
paddingHorizontal: '12px',
},
};

interface TextFieldColorSet {
mainColor?: string;
mainColorHighlight?: string;
textColor?: string;
backgroundColor?: string;
}
Expand All @@ -32,13 +53,17 @@ interface TextFieldStyleProps {
borderRadius?: string;
mainColor?: unknown;
fontSize?: unknown;
paddingVertical?: unknown;
paddingHorizontal?: unknown;
textColor?: unknown;
}
const textFieldStyles = {
basicBordered: ({
status,
borderRadius,
fontSize,
paddingHorizontal,
paddingVertical,
textFieldColors,
}: TextFieldStyleProps) => {
return {
Expand All @@ -59,8 +84,14 @@ const textFieldStyles = {
borderColor: textFieldColors[status].mainColor,
fontSize,
borderRadius,
paddingHorizontal: '12px',
paddingVertical: '8px',
paddingVertical,
paddingHorizontal,
hover: {
borderColor: textFieldColors[status].mainColorHighlight,
},
focus: {
borderColor: textFieldColors[status].mainColorHighlight,
},
},
validationMessage: {
fontSize,
Expand Down Expand Up @@ -90,6 +121,12 @@ const textFieldStyles = {
borderBottomColor: textFieldColors[status].mainColor,
fontSize,
paddingVertical: '8px',
hover: {
borderColor: textFieldColors[status].mainColorHighlight,
},
focus: {
borderColor: textFieldColors[status].mainColorHighlight,
},
},
validationMessage: {
fontSize,
Expand Down Expand Up @@ -172,7 +209,9 @@ export function TextField({
const hasOnChange = Boolean(props.onChange);
const styles = textFieldStyles[variant]({
status,
fontSize: textFieldSize,
fontSize: textFieldSize.fontSize,
paddingVertical: textFieldSize.paddingVertical,
paddingHorizontal: textFieldSize.paddingHorizontal,
borderRadius,
textFieldColors,
});
Expand Down Expand Up @@ -216,6 +255,7 @@ export function TextField({
placeholder={fieldPlaceholder}
styleSheet={{
...styles.textField,
borderStyle: 'solid',
resize: 'none',
width: '100%',
display: 'block',
Expand Down Expand Up @@ -278,16 +318,19 @@ TextField.defaultProps = {
neutral: {
backgroundColor: theme.colors.neutral['000'],
mainColor: theme.colors.neutral['300'],
mainColorHighlight: theme.colors.primary['500'],
textColor: theme.colors.neutral['900'],
},
positive: {
backgroundColor: theme.colors.neutral['000'],
mainColor: theme.colors.positive['300'],
mainColorHighlight: theme.colors.positive['500'],
textColor: theme.colors.positive['900'],
},
negative: {
backgroundColor: theme.colors.neutral['000'],
mainColor: theme.colors.negative['300'],
mainColorHighlight: theme.colors.negative['500'],
textColor: theme.colors.negative['900'],
},
},
Expand Down
1 change: 1 addition & 0 deletions lib/core/stylesheet/stylesheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type ResponsiveProperty<Type> = Partial<Record<Breakpoints, Type>>;

export interface StyleSheet {
srOnly?: boolean;
borderStyle?: string;
overflow?: ResponsiveProperty<string> | string;
position?: ResponsiveProperty<string> | string;
resize?: ResponsiveProperty<string> | string;
Expand Down

1 comment on commit e479611

@vercel
Copy link

@vercel vercel bot commented on e479611 Dec 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.