Skip to content

Commit 4333f47

Browse files
review feedback
1 parent 288ffad commit 4333f47

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

src/components/DatePicker/Common.tsx

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Icon } from "../Icon/Icon";
55
import { Container } from "../Container/Container";
66
import { useCalendar, UseCalendarOptions } from "@h6s/calendar";
77
import { IconButton } from "../IconButton/IconButton";
8+
import { Text } from "../Typography/Text/Text";
89

910
const locale = "en-US";
1011
const selectedDateFormatter = new Intl.DateTimeFormat(locale, {
@@ -63,30 +64,7 @@ export const DatePickerInput = ({
6364
);
6465
};
6566

66-
// This is taken from InputElement from InputWrapper.tsx
67-
// We need to be able to change the color of some of the text of the 'input element'
68-
// but that isn't possible with an input element, so we have to fake it. Thus the name.
69-
const FakeInputElement = styled.div`
70-
background: transparent;
71-
border: none;
72-
outline: none;
73-
width: 100%;
74-
color: inherit;
75-
font: inherit;
76-
${({ theme }) => `
77-
padding: ${theme.click.field.space.y} 0;
78-
&::placeholder {
79-
color: ${theme.click.field.color.placeholder.default};
80-
}
81-
82-
&:disabled, &.disabled {
83-
&::placeholder {
84-
color: ${theme.click.field.color.placeholder.disabled};
85-
}
86-
`}
87-
`;
88-
89-
const MutedColorSpan = styled.span`
67+
const MutedColorSpan = styled(Text)`
9068
color: ${({ theme }) => theme.global.color.text.muted};
9169
`;
9270

@@ -109,7 +87,7 @@ export const DateRangePickerInput = ({
10987
}: DateRangePickerInputProps) => {
11088
const defaultId = useId();
11189

112-
let formattedValue = <MutedColorSpan>{placeholder ?? ""}</MutedColorSpan>;
90+
let formattedValue = <MutedColorSpan as="span">{placeholder ?? ""}</MutedColorSpan>;
11391
if (selectedStartDate) {
11492
if (selectedEndDate) {
11593
formattedValue = (
@@ -122,7 +100,7 @@ export const DateRangePickerInput = ({
122100
formattedValue = (
123101
<span>
124102
{selectedDateFormatter.format(selectedStartDate)}{" "}
125-
<MutedColorSpan>– end date</MutedColorSpan>
103+
<MutedColorSpan as="span">– end date</MutedColorSpan>
126104
</span>
127105
);
128106
}
@@ -135,9 +113,12 @@ export const DateRangePickerInput = ({
135113
id={id ?? defaultId}
136114
>
137115
<Icon name="calendar" />
138-
<FakeInputElement data-testid="daterangepicker-input">
116+
<InputElement
117+
as="div"
118+
data-testid="daterangepicker-input"
119+
>
139120
{formattedValue}
140-
</FakeInputElement>
121+
</InputElement>
141122
</HighlightedInputWrapper>
142123
);
143124
};
@@ -165,7 +146,7 @@ const UnselectableTitle = styled.h2`
165146
const DateTable = styled.table`
166147
border-collapse: separate;
167148
border-spacing: 0;
168-
font: ${({ theme }) => theme.typography.styles.product.text.normal.md}
149+
font: ${({ theme }) => theme.typography.styles.product.text.normal.md};
169150
table-layout: fixed;
170151
user-select: none;
171152
width: ${explicitWidth};
@@ -178,7 +159,8 @@ const DateTable = styled.table`
178159
cursor: pointer;
179160
}
180161
181-
td, th {
162+
td,
163+
th {
182164
padding: 4px;
183165
}
184166
`;

0 commit comments

Comments
 (0)