Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: UI remove tailwind from input component #241

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 45 additions & 10 deletions ui/src/components/core/input/input.styles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { styled } from '@/theme';

import { Icon } from '../icon';

const styles = {
all: 'unset',
width: '100%',
boxSizing: 'border-box',
borderStyle: 'solid',
Expand Down Expand Up @@ -32,7 +29,9 @@ const styles = {
color: '$slate8',
},
},
};

const variants = {
variants: {
size: {
sm: {
Expand All @@ -59,13 +58,49 @@ const styles = {
},
};

export const InputStyled = styled('input', styles);
export const InputStyled = styled('input', {
all: 'unset',
...variants,
...styles,
});

export const InputIconStyled = styled(Icon, {
position: 'absolute',
left: '$4',
top: '0.9375rem',
color: 'slate8',
export const InputGroupStyled = styled('div', {
display: 'flex',
flexDirection: 'row',
gap: '$2h',

...styles,

variants: {
size: {
sm: {
borderRadius: '$md',
fontSize: '$xs',
lineHeight: '$4',
},
md: {
borderRadius: '$lg',
fontSize: '$sm',
height: '$11',
px: '$3h',
},
lg: {
borderRadius: '$xl',
fontSize: '$md',
},
},
},
defaultVariants: {
size: 'md',
},
});

export const InputGroupTextSyled = styled('input', {
all: 'unset',
});

export const TextareaStyled = styled('textarea', styles);
export const TextareaStyled = styled('textarea', {
all: 'unset',
...variants,
...styles,
});
36 changes: 16 additions & 20 deletions ui/src/components/core/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,32 @@ import React from 'react';

import { forwardStyledRef } from '@/theme';

import { IconName } from '../icon';
import { InputIconStyled, InputStyled, TextareaStyled } from './input.styles';
import {
InputGroupStyled,
InputGroupTextSyled,
InputStyled,
TextareaStyled,
} from './input.styles';
import { StyledInputFile } from './input-file';

export const Textarea = TextareaStyled;

export const LogoFileInput = StyledInputFile;

type InputProps = {
leftIcon?: IconName;
wrapperClassName?: string; //tailwind css
} & React.ComponentPropsWithRef<typeof InputStyled>;
export const Input = InputStyled;

export const Input = forwardStyledRef<HTMLInputElement, InputProps>(
(props, ref) => {
const { leftIcon, wrapperClassName: css = '', ...ownProps } = props;
type InputGroupProps = {
children: React.ReactNode;
} & React.ComponentPropsWithRef<typeof InputGroupStyled>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
type InputGroupProps = {
children: React.ReactNode;
} & React.ComponentPropsWithRef<typeof InputGroupStyled>;
type InputGroupProps = React.ComponentPropsWithRef<typeof InputGroupStyled>;


export const InputGroup = forwardStyledRef<HTMLDivElement, InputGroupProps>(
({ children, ...props }, ref) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const InputGroup = forwardStyledRef<HTMLDivElement, InputGroupProps>(
({ children, ...props }, ref) => {
export const InputGroup = InputGroupStyled;

return (
<div className={`relative ${css}`}>
{leftIcon && (
<InputIconStyled name={leftIcon} css={{ fontSize: '$lg' }} />
)}
<InputStyled
{...props}
ref={ref}
css={{ ...(leftIcon && { pl: '$10' }), ...(ownProps.css || {}) }}
/>
</div>
<InputGroupStyled ref={ref} {...props}>
{children}
</InputGroupStyled>
);
}
);

Input.displayName = 'Input';
export const InputGroupText = InputGroupTextSyled;
18 changes: 11 additions & 7 deletions ui/src/views/explore/explore-list/nfa-search.fragment.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useState } from 'react';

import { Dropdown, DropdownItem, Input } from '@/components';
import {
Dropdown,
DropdownItem,
InputGroup,
InputGroupText,
} from '@/components';
import { useDebounce } from '@/hooks';

import { Explore } from '../explore.context';
Expand Down Expand Up @@ -69,12 +74,11 @@ export const NFASearchFragment: React.FC = () => {
</S.Data.Wrapper>

<S.Input.Wrapper>
<Input
placeholder="Search"
leftIcon="search"
onChange={handleSearchChange}
wrapperClassName="flex-1"
/>
<InputGroup css={{ flex: 1 }}>
<S.Input.Icon name="search" />
<InputGroupText placeholder="Search" onChange={handleSearchChange} />
</InputGroup>

<Dropdown
items={orderResults}
selectedValue={selectedValue}
Expand Down
5 changes: 4 additions & 1 deletion ui/src/views/explore/explore-list/nfa-search.styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex } from '@/components';
import { Flex, Icon, Input } from '@/components';
import { styled } from '@/theme';

export const NFASearchFragmentStyles = {
Expand Down Expand Up @@ -32,5 +32,8 @@ export const NFASearchFragmentStyles = {
maxWidth: '30rem',
justifySelf: 'center',
}),
Icon: styled(Icon, {
fontSize: '$lg',
}),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Card, Flex, Icon } from '@/components';
import { styled } from '@/theme';

export const GithubRepositorySelectionStyles = {
Card: {
Wrapper: styled(Card.Container, {
maxWidth: '$107h',
maxHeight: '$95h',
pr: '$3h',
}),
Body: styled(Card.Body, {
pt: '$4',
}),
},
Container: styled(Flex, {
flexDirection: 'column',
gap: '$2',
}),
Row: styled(Flex, {
gap: '$4',
pr: '$3h',
position: 'relative',
}),
Group: {
Icon: styled(Icon, {
fontSize: '$lg',
}),
},
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import React, { useState } from 'react';

import { Card, Flex, Grid, Icon, IconButton, Spinner } from '@/components';
import { Input } from '@/components/core/input';
import {
Card,
Flex,
Icon,
IconButton,
InputGroup,
InputGroupText,
Spinner,
} from '@/components';
import { useDebounce } from '@/hooks/use-debounce';
import { useGithubStore } from '@/store';
import { Mint } from '@/views/mint/mint.context';

import { GithubRepositorySelectionStyles as S } from './github-repository-selection.styles';
import { RepositoriesList } from './repositories-list';
import { UserOrgsCombobox } from './users-orgs-combobox';

Expand Down Expand Up @@ -46,7 +54,7 @@ export const GithubRepositoryConnection: React.FC = () => {
};

return (
<Card.Container css={{ maxWidth: '$107h', maxHeight: '$95h', pr: '$3h' }}>
<S.Card.Wrapper>
<Card.Heading
title="Select Repository"
css={{ pr: '$3h' }}
Expand All @@ -69,25 +77,26 @@ export const GithubRepositoryConnection: React.FC = () => {
/>
}
/>
<Card.Body css={{ pt: '$4' }}>
<Grid css={{ rowGap: '$2' }}>
<Flex css={{ gap: '$4', pr: '$3h', position: 'relative' }}>
<S.Card.Body>
<S.Container>
<S.Row>
<UserOrgsCombobox />
<Input
leftIcon="search"
placeholder="Search repo"
onChange={handleSearchChange}
wrapperClassName="flex-1"
/>
</Flex>
<InputGroup css={{ flex: 1 }}>
<S.Group.Icon name="search" />
<InputGroupText
placeholder="Search repo"
onChange={handleSearchChange}
/>
</InputGroup>
</S.Row>
{queryLoading === 'loading' ||
queryUserAndOrganizations === 'loading' ? (
<Loading />
) : (
<RepositoriesList searchValue={searchValue} />
)}
</Grid>
</Card.Body>
</Card.Container>
</S.Container>
</S.Card.Body>
</S.Card.Wrapper>
);
};