Skip to content

Commit dee0bf3

Browse files
authored
Merge pull request #9 from Toprent-app/feature/add-props-for-close-button
Feature/add props for close button
2 parents 2697086 + 81cae7e commit dee0bf3

6 files changed

Lines changed: 42 additions & 18 deletions

File tree

packages/styled/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@power-rent/react-datepicker-modern",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A React datepicker build with styled-components.",
55
"keywords": [
66
"datepicker",

packages/styled/src/components/Close/Close.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,18 @@ function Close({onClick, rtl, closeText}: CloseProps) {
8383
aria-label="Close"
8484
>
8585
<CloseIcon width="15px" height="16px" color="#ADADAD" />
86-
<Text
87-
m={theme.closeMargin}
88-
// @ts-ignore
89-
color={theme.closeColor}
90-
fontSize={theme.closeFontSize}
91-
fontFamily={theme.fontFamily}
92-
fontWeight={theme.closeFontWeight}
93-
>
94-
{closeText}
95-
</Text>
86+
{closeText && (
87+
<Text
88+
m={theme.closeMargin}
89+
// @ts-ignore
90+
color={theme.closeColor}
91+
fontSize={theme.closeFontSize}
92+
fontFamily={theme.fontFamily}
93+
fontWeight={theme.closeFontWeight}
94+
>
95+
{closeText}
96+
</Text>
97+
)}
9698
</Wrapper>
9799
)
98100
}

packages/styled/src/components/DateRangeInputModern/DateRangeInputModern.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ interface AppProps {
5353
onDayRender?(date: Date): React.ReactNode
5454
unavailableDates?: Date[]
5555
initialVisibleMonth?: Date
56+
datepickerCloseWrapperRightCustom?: string | null
57+
datepickerPaddingCustom?: string | null
5658
}
5759

5860
function App({
@@ -76,6 +78,8 @@ function App({
7678
monthLabelFormat = monthLabelFormatFn,
7779
onDayRender = undefined,
7880
unavailableDates = [],
81+
datepickerCloseWrapperRightCustom = null,
82+
datepickerPaddingCustom = null,
7983
}: AppProps) {
8084
const [state, dispatch] = useReducer(reducer, initialState)
8185

@@ -111,6 +115,8 @@ function App({
111115
onDayRender={onDayRender}
112116
unavailableDates={unavailableDates}
113117
initialVisibleMonth={initialVisibleMonth}
118+
datepickerCloseWrapperRightCustom={datepickerCloseWrapperRightCustom}
119+
datepickerPaddingCustom={datepickerPaddingCustom}
114120
/>
115121
)
116122
}
@@ -124,5 +130,7 @@ storiesOf('DateRangeInputModern', module).add('Simple demo', () => (
124130
showClose={boolean('showClose', true)}
125131
showSelectedDates={boolean('showSelectedDates', true)}
126132
displayFormat={text('displayFormat', 'MM/dd/yyyy')}
133+
datepickerCloseWrapperRightCustom={text('datepickerCloseWrapperRightCustom', '10px')}
134+
datepickerPaddingCustom={text('datepickerPaddingCustom', '10px')}
127135
/>
128136
))

packages/styled/src/components/DateRangeInputModern/DateRangeInputModern.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export interface DateRangeInputModernProps extends UseDatepickerProps {
115115
datepickerLeftCustom?: string
116116
datepickerTopCustom?: string
117117
datepickerZIndexCustom?: number | null
118+
datepickerPaddingCustom?: string | null
119+
datepickerCloseWrapperRightCustom?: string | null
118120
}
119121

120122
function DateRangeInputModern({
@@ -157,7 +159,8 @@ function DateRangeInputModern({
157159
datepickerHeightCustom,
158160
datepickerLeftCustom,
159161
datepickerTopCustom,
160-
datepickerZIndexCustom,
162+
datepickerPaddingCustom,
163+
datepickerCloseWrapperRightCustom,
161164
}: DateRangeInputModernProps) {
162165
const ref = useRef(null)
163166
const datepickerWrapperRef = useRef<HTMLDivElement>(null)
@@ -306,7 +309,8 @@ function DateRangeInputModern({
306309
datepickerBorderRadius={datepickerBorderRadiusCustom}
307310
datepickerWidth={datepickerWidthCustom}
308311
datepickerHeight={datepickerHeightCustom}
309-
datepickerZIndex={datepickerZIndexCustom}
312+
datepickerPadding={datepickerPaddingCustom}
313+
datepickerCloseWrapperRight={datepickerCloseWrapperRightCustom}
310314
/>
311315
)}
312316
</Box>

packages/styled/src/components/Datepicker/Datepicker.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ interface AppProps {
4141
onDayRender?(date: Date): React.ReactNode
4242
unavailableDates?: Date[]
4343
initialVisibleMonth?: Date
44+
datepickerPadding?: string | null
45+
datepickerCloseWrapperRight?: string | null
4446
}
4547

4648
function App({
@@ -64,6 +66,8 @@ function App({
6466
monthLabelFormat = monthLabelFormatFn,
6567
onDayRender = undefined,
6668
unavailableDates = [],
69+
datepickerPadding = null,
70+
datepickerCloseWrapperRight = null,
6771
}: AppProps) {
6872
const [state, setState] = useState<OnDatesChangeProps>({
6973
startDate: null,
@@ -107,6 +111,8 @@ function App({
107111
onDayRender={onDayRender}
108112
unavailableDates={unavailableDates}
109113
initialVisibleMonth={initialVisibleMonth}
114+
datepickerPadding={datepickerPadding}
115+
datepickerCloseWrapperRight={datepickerCloseWrapperRight}
110116
/>
111117
)
112118
}
@@ -121,6 +127,8 @@ storiesOf('Datepicker', module)
121127
showClose={boolean('showClose', true)}
122128
showSelectedDates={boolean('showSelectedDates', true)}
123129
displayFormat={text('displayFormat', 'MM/dd/yyyy')}
130+
datepickerPadding={text('datepickerPadding', '10px')}
131+
datepickerCloseWrapperRight={text('datepickerCloseWrapperRight', '10px')}
124132
/>
125133
))
126134
.add('Initial visible month', () => (

packages/styled/src/components/Datepicker/Datepicker.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ export interface DatepickerProps extends UseDatepickerProps {
153153
datepickerHeight?: string
154154
datepickerLeft?: string
155155
datepickerTop?: string
156-
datepickerZIndex?: number | null
156+
datepickerPadding?: string | null
157+
datepickerCloseWrapperRight?: string | null
157158
}
158159

159160
function Datepicker(
@@ -189,7 +190,8 @@ function Datepicker(
189190
datepickerHeight = 'unset',
190191
datepickerLeft = '0px',
191192
datepickerTop = '0px',
192-
datepickerZIndex = null,
193+
datepickerPadding = null,
194+
datepickerCloseWrapperRight = null,
193195
}: DatepickerProps,
194196
ref?: React.Ref<unknown>,
195197
) {
@@ -311,13 +313,13 @@ function Datepicker(
311313
>
312314
<StyledDatepicker
313315
background={theme.datepickerBackground}
314-
p={theme.datepickerPadding}
316+
p={datepickerPadding || theme.datepickerPadding}
315317
borderRadius={datepickerBorderRadius || theme.datepickerBorderRadius}
316318
position={theme.datepickerPosition}
317319
boxShadow={theme.datepickerBoxShadow}
318320
width={theme.datepickerWidth}
319321
height={datepickerHeight}
320-
zIndex={datepickerZIndex || theme.datepickerZIndex}
322+
zIndex={theme.datepickerZIndex}
321323
rtl={rtl}
322324
left={datepickerLeft}
323325
top={datepickerTop}
@@ -328,7 +330,7 @@ function Datepicker(
328330
display={theme.datepickerCloseWrapperDisplay}
329331
justifyContent={theme.datepickerCloseWrapperJustifyContent}
330332
position={theme.datepickerCloseWrapperPosition}
331-
right={theme.datepickerCloseWrapperRight}
333+
right={datepickerCloseWrapperRight || theme.datepickerCloseWrapperRight}
332334
top={theme.datepickerCloseWrapperTop}
333335
left={theme.datepickerCloseWrapperLeft}
334336
bottom={theme.datepickerCloseWrapperBottom}

0 commit comments

Comments
 (0)