Skip to content

Commit 8f8b795

Browse files
fix: datepicker necessityIndicator (#2197)
* fix: datepicker necessityIndicator * Create slow-moose-allow.md * Update .changeset/slow-moose-allow.md Co-authored-by: Chaitanya Deorukhkar <deorukhkarchaitanya@gmail.com> --------- Co-authored-by: Chaitanya Deorukhkar <deorukhkarchaitanya@gmail.com>
1 parent 634eefd commit 8f8b795

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

.changeset/slow-moose-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@razorpay/blade": patch
3+
---
4+
5+
fix: DatePicker necessityIndicator alignment

packages/blade/src/components/DatePicker/DateInput.web.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { BaseInput } from '~components/Input/BaseInput';
1111
import { size as sizeTokens } from '~tokens/global';
1212
import { isReactNative, makeSize } from '~utils';
1313
import type { BladeElementRef } from '~utils/types';
14+
import { useIsMobile } from '~utils/useIsMobile';
1415

1516
const _DateInput = (
1617
props: BaseInputProps,
@@ -48,7 +49,7 @@ const HiddenInput = ({ value, name }: { value: string; name?: string }): React.R
4849
};
4950

5051
const iconVerticalMargin = {
51-
medium: sizeTokens[16],
52+
medium: sizeTokens[14],
5253
large: sizeTokens[24],
5354
} as const;
5455

@@ -63,10 +64,12 @@ const _DatePickerInput = (
6364
autoFocus,
6465
name,
6566
size = 'medium',
67+
necessityIndicator,
6668
...props
6769
}: DatePickerInputProps,
6870
ref: React.ForwardedRef<any>,
6971
): React.ReactElement => {
72+
const isMobile = useIsMobile();
7073
const format = 'DD/MM/YYYY';
7174
const isLarge = size === 'large';
7275
const isLabelPositionLeft = labelPosition === 'left';
@@ -142,6 +145,7 @@ const _DatePickerInput = (
142145
autoFocus={autoFocus}
143146
value={startValue}
144147
componentName="DatePickerInputStart"
148+
necessityIndicator={necessityIndicator}
145149
{...props}
146150
{...referenceProps}
147151
/>
@@ -151,7 +155,7 @@ const _DatePickerInput = (
151155
size="medium"
152156
marginTop={
153157
// Hacky layouting because the we cannot put this inside the internal layout of BaseInput.
154-
hasLabel && !isLabelPositionLeft
158+
(hasLabel && !isLabelPositionLeft) || isMobile
155159
? `calc(${makeSize(iconVerticalMargin[size])} + ${makeSize(
156160
isLarge ? sizeTokens[20] : sizeTokens[15],
157161
)})`

packages/blade/src/tokens/global/size.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const size = {
2424
10: 10,
2525
/** 12 px */
2626
12: 12,
27+
/** 14 px */
28+
14: 14,
2729
/** 15 px */
2830
15: 15,
2931
/** 16 px */

0 commit comments

Comments
 (0)