Skip to content

Commit

Permalink
fix: fix components alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
malloc3141 committed Nov 11, 2024
1 parent b9bffb0 commit d477c20
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/web/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import react from "React";
import React from "react";

import type { Preview } from "@storybook/react";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const DateRangeInputFrameInner = styled.div`
align-items: center;
gap: 12px;
display: flex;
position: relative;
`;

const availableMonths = [
Expand Down
47 changes: 28 additions & 19 deletions packages/web/src/common/components/Forms/SearchSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ const SearchList = styled.div`
scrollbar-width: none;
`;

const InputContainer = styled.div`
position: relative;
width: 100%;
display: flex;
align-items: center;
`;

const SearchSelect: React.FC<SearchSelectProps> = ({
label = "",
placeholder,
Expand Down Expand Up @@ -148,7 +155,7 @@ const SearchSelect: React.FC<SearchSelectProps> = ({
return (
<InputWrapper onFocus={() => setListToggle(true)}>
{label && <Label>{label}</Label>}
<InputWrapper>
<InputContainer>
<Input
placeholder={placeholder}
hasError={!!errorMessage}
Expand All @@ -164,24 +171,26 @@ const SearchSelect: React.FC<SearchSelectProps> = ({
color={disabled ? colors.GRAY[200] : colors.BLACK}
/>
</RightContentWrapper>
</InputWrapper>
{filteredOptions.length !== 0 && listToggle && (
<SearchList onFocus={() => setListToggle(true)}>
{filteredOptions.map(option => (
<SearchItem
key={option}
onClick={handleItemClick}
selected={selected}
isSelected={option === selected}
>
{option}
</SearchItem>
))}
</SearchList>
)}
{errorMessage && !listToggle && !disabled && (
<ErrorMessage>{errorMessage}</ErrorMessage>
)}
</InputContainer>
<InputContainer>
{filteredOptions.length !== 0 && listToggle && (
<SearchList onFocus={() => setListToggle(true)}>
{filteredOptions.map(option => (
<SearchItem
key={option}
onClick={handleItemClick}
selected={selected}
isSelected={option === selected}
>
{option}
</SearchItem>
))}
</SearchList>
)}
{errorMessage && !listToggle && !disabled && (
<ErrorMessage>{errorMessage}</ErrorMessage>
)}
</InputContainer>
</InputWrapper>
);
};
Expand Down
5 changes: 3 additions & 2 deletions packages/web/src/common/components/Forms/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface SelectProps {
const DropdownContainer = styled.div`
gap: 4px;
position: relative;
display: flex;
`;

const disabledStyle = css`
Expand All @@ -37,7 +38,7 @@ const StyledSelect = styled.div<{
isOpen?: boolean;
}>`
width: 100%;
padding: 8px 12px;
padding: 8px 32px 8px 12px;
outline: none;
cursor: pointer;
background-color: ${({ theme }) => theme.colors.WHITE};
Expand Down Expand Up @@ -66,7 +67,7 @@ const Dropdown = styled.div`
display: flex;
flex-direction: column;
width: 100%;
margin-top: 4px;
margin-top: 40px;
padding: 8px;
border: 1px solid ${({ theme }) => theme.colors.GRAY[100]};
border-radius: 4px;
Expand Down
11 changes: 9 additions & 2 deletions packages/web/src/common/components/Forms/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ const InputWrapper = styled.div`
gap: 4px;
`;

const InputContainer = styled.div`
position: relative;
width: 100%;
display: flex;
align-items: center;
`;

// Component
const TextInput: React.FC<TextInputProps> = ({
label = "",
Expand Down Expand Up @@ -97,7 +104,7 @@ const TextInput: React.FC<TextInputProps> = ({
return (
<InputWrapper>
{label && <Label>{label}</Label>}
<InputWrapper>
<InputContainer>
<Input
placeholder={placeholder}
hasError={!!errorMessage}
Expand All @@ -108,7 +115,7 @@ const TextInput: React.FC<TextInputProps> = ({
{...props}
/>
{errorMessage && <ErrorMessage>{errorMessage}</ErrorMessage>}
</InputWrapper>
</InputContainer>
</InputWrapper>
);
};
Expand Down
14 changes: 10 additions & 4 deletions packages/web/stories/Forms/DateRangeInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ const meta: Meta<typeof DateRangeInput> = {
argTypes: {
label: { control: "text" },
disabled: { control: "boolean" },
startValue: { control: "text" },
endValue: { control: "text" },
limitStartValue: { control: "text" },
limitEndValue: { control: "text" },
startValue: { control: "text", description: "YYYY.MM 형식으로 입력" },
endValue: { control: "text", description: "YYYY.MM 형식으로 입력" },
limitStartValue: {
control: "text",
description: "YYYY.MM 또는 YYYY.MM.DD 형식으로 입력",
},
limitEndValue: {
control: "text",
description: "YYYY.MM 또는 YYYY.MM.DD 형식으로 입력",
},
onChange: { control: false },
setErrorStatus: { control: false },
},
Expand Down

0 comments on commit d477c20

Please sign in to comment.