Skip to content

Commit 16ee39f

Browse files
committed
feat: add support for disabling border radius
1 parent 32134c0 commit 16ee39f

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

src/Shared/Components/FormFieldWrapper/types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,30 @@ export interface FormFieldWrapperProps
5555
*/
5656
fullWidth?: boolean
5757
children: ReactElement
58+
borderRadiusConfig?: {
59+
/**
60+
* If false, the top border radius is not applied
61+
*
62+
* @default true
63+
*/
64+
top?: boolean
65+
/**
66+
* If false, the right border radius is not applied
67+
*
68+
* @default true
69+
*/
70+
right?: boolean
71+
/**
72+
* If false, the bottom border radius is not applied
73+
*
74+
* @default true
75+
*/
76+
bottom?: boolean
77+
/**
78+
* If false, the left border radius is not applied
79+
*
80+
* @default true
81+
*/
82+
left?: boolean
83+
}
5884
}

src/Shared/Components/FormFieldWrapper/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FormFieldInfoProps, FormFieldLabelProps } from './types'
1+
import { FormFieldInfoProps, FormFieldLabelProps, FormFieldWrapperProps } from './types'
22

33
export const getFormErrorElementId = (inputId: FormFieldLabelProps['inputId']) => `${inputId}-error-msg`
44

@@ -37,3 +37,9 @@ export const getFormFieldAriaAttributes = ({
3737
'aria-label': ariaLabel,
3838
}),
3939
})
40+
41+
export const getFormFieldBorderClassName = (borderRadiusConfig: FormFieldWrapperProps['borderRadiusConfig'] = {}) => {
42+
const { top = true, right = true, bottom = true, left = true } = borderRadiusConfig
43+
44+
return `${!top ? 'dc__no-top-radius' : ''} ${!right ? 'dc__no-right-radius' : ''} ${!bottom ? 'dc__no-bottom-radius' : ''} ${!left ? 'dc__no-left-radius' : ''}`
45+
}

src/Shared/Components/SelectPicker/SelectPicker.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
218218
warningText,
219219
layout,
220220
ariaLabel,
221+
borderRadiusConfig,
221222
...props
222223
}: SelectPickerProps<OptionValue, IsMulti>) => {
223224
const [isFocussed, setIsFocussed] = useState(false)
@@ -379,6 +380,8 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
379380
required={required}
380381
fullWidth={fullWidth}
381382
ariaLabel={ariaLabel}
383+
// TODO: Add support for custom border radius with CustomInput refactoring
384+
borderRadiusConfig={borderRadiusConfig}
382385
>
383386
<ConditionalWrap condition={isDisabled && !!disabledTippyContent} wrap={renderDisabledTippy}>
384387
<div className="w-100">

src/Shared/Components/Textarea/Textarea.component.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { FormFieldWrapper, getFormFieldAriaAttributes } from '../FormFieldWrappe
99
import { TextareaProps } from './types'
1010
import { TEXTAREA_CONSTRAINTS } from './constants'
1111
import './textarea.scss'
12+
import { getFormFieldBorderClassName } from '../FormFieldWrapper/utils'
1213

1314
const { MIN_HEIGHT, AUTO_EXPANSION_MAX_HEIGHT } = TEXTAREA_CONSTRAINTS
1415

@@ -25,6 +26,7 @@ const Textarea = ({
2526
shouldTrim = true,
2627
size = ComponentSizeType.large,
2728
ariaLabel,
29+
borderRadiusConfig,
2830
...props
2931
}: TextareaProps) => {
3032
const textareaRef = useRef<HTMLTextAreaElement>(null)
@@ -93,6 +95,7 @@ const Textarea = ({
9395
required={required}
9496
fullWidth={fullWidth}
9597
ariaLabel={ariaLabel}
98+
borderRadiusConfig={borderRadiusConfig}
9699
>
97100
<textarea
98101
{...props}
@@ -112,7 +115,7 @@ const Textarea = ({
112115
required={required}
113116
onBlur={handleBlur}
114117
onKeyDown={handleKeyDown}
115-
className={`${COMPONENT_SIZE_TYPE_TO_FONT_AND_BLOCK_PADDING_MAP[size]} ${COMPONENT_SIZE_TYPE_TO_INLINE_PADDING_MAP[size]} w-100 dc__overflow-auto textarea`}
118+
className={`${COMPONENT_SIZE_TYPE_TO_FONT_AND_BLOCK_PADDING_MAP[size]} ${COMPONENT_SIZE_TYPE_TO_INLINE_PADDING_MAP[size]} ${getFormFieldBorderClassName(borderRadiusConfig)} w-100 dc__overflow-auto textarea`}
116119
ref={textareaRef}
117120
style={{
118121
// No max height when user is expanding
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const TEXTAREA_CONSTRAINTS = {
2-
MIN_HEIGHT: 56,
2+
MIN_HEIGHT: 76,
33
AUTO_EXPANSION_MAX_HEIGHT: 140,
44
}

0 commit comments

Comments
 (0)