Skip to content

Commit 035bc6e

Browse files
committed
feat(theming): simplified color palette change
affects: @datepicker-react/styled
1 parent 344a0e7 commit 035bc6e

File tree

24 files changed

+1905
-1739
lines changed

24 files changed

+1905
-1739
lines changed

docs/THEME_PROPS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
fontFamily?: ResponsiveValue<FontFamilyProperty>
55
daySize?: number | (number | null)[] | undefined
66

7+
colors: {
8+
primaryColor: string ('#00aeef'),
9+
silverCloud: string ('#929598'),
10+
charcoal: string ('#001217'),
11+
darcula: string ('#343132'),
12+
mud: string ('#58595B'),
13+
greey: string ('#808285'),
14+
graci: string ('#BCBEC0'),
15+
white: string ('#ffffff'),
16+
accessibility: string ('#009fef'),
17+
selectedDay: string ('#71c9ed'),
18+
selectedDayHover: string ('#39beef'),
19+
normalDayHover: string ('#e6e7e8'),
20+
}
721

822
closeColor?: ResponsiveValue<ColorProperty>
923
closeHoverColor?: ResponsiveValue<ColorProperty>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react'
2-
import styled from 'styled-components'
1+
import React, {useContext} from 'react'
2+
import styled, {ThemeContext} from 'styled-components'
33
import {
44
color,
55
ColorProps,
@@ -18,6 +18,7 @@ import CloseIcon from '../../icons/CloseIcon'
1818
import {CloseTheme} from '../../@types/theme'
1919
import useThemeProps from '../../hooks/useThemeProps'
2020
import globalStyles from '../../globalStyles'
21+
import getThemeProp from '../../utils/getThemeProp'
2122

2223
interface TextProps
2324
extends ColorProps,
@@ -68,11 +69,12 @@ interface CloseProps {
6869
}
6970

7071
function Close({onClick, rtl, closeText}: CloseProps) {
72+
const themeContext = useContext(ThemeContext)
7173
const theme: CloseTheme = useThemeProps({
7274
fontFamily: globalStyles.fontFamily,
7375
closeMargin: rtl ? '1px 16px 0 0' : '1px 0 0 16px',
74-
closeColor: '#929598',
75-
closeHoverColor: '#343132',
76+
closeColor: getThemeProp('silverCloud', globalStyles.colors.silverCloud, themeContext),
77+
closeHoverColor: getThemeProp('darcula', globalStyles.colors.darcula, themeContext),
7678
closeFontSize: '12px',
7779
closeFontWeight: 600,
7880
})

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,28 @@ storiesOf('DateRangeInput', module)
294294
/>
295295
</ThemeProvider>
296296
))
297+
.add('Theming', () => (
298+
<ThemeProvider
299+
theme={{
300+
reactDatepicker: {
301+
fontFamily: 'system-ui, -apple-system',
302+
colors: {
303+
accessibility: '#D80249',
304+
selectedDay: '#f7518b',
305+
selectedDayHover: '#F75D95',
306+
primaryColor: '#d8366f',
307+
},
308+
},
309+
}}
310+
>
311+
<App
312+
rtl={boolean('rtl', false)}
313+
vertical={boolean('vertical', false)}
314+
exactMinBookingDays={boolean('exactMinBookingDays', false)}
315+
showResetDates={boolean('showResetDates', true)}
316+
showClose={boolean('showClose', true)}
317+
showSelectedDates={boolean('showSelectedDates', true)}
318+
displayFormat={text('displayFormat', 'MM/DD/YYYY')}
319+
/>
320+
</ThemeProvider>
321+
))

packages/styled/src/components/DateRangeInput/DateRangeInput.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, {useRef, useEffect} from 'react'
2-
import styled, {css} from 'styled-components'
1+
import React, {useRef, useEffect, useContext} from 'react'
2+
import styled, {css, ThemeContext} from 'styled-components'
33
import {
44
opacity,
55
OpacityProps,
@@ -31,6 +31,8 @@ import Datepicker from '../Datepicker'
3131
// eslint-disable-next-line import/no-unresolved
3232
import {DateRangeInputTheme} from '../../@types/theme'
3333
import useThemeProps from '../../hooks/useThemeProps'
34+
import getThemeProp from '../../utils/getThemeProp'
35+
import globalStyles from '../../globalStyles'
3436

3537
interface RtlProps {
3638
rtl: boolean
@@ -152,14 +154,15 @@ function DateRangeInput({
152154
placement = 'bottom',
153155
}: DateRangeInputProps) {
154156
const datepickerWrapperRef = useRef<HTMLDivElement>(null)
157+
const themeContext = useContext(ThemeContext)
155158
const theme: DateRangeInputTheme = useThemeProps({
156159
dateRangeBackground: 'transparent',
157160
dateRangeGridTemplateColumns: vertical ? '1fr 24px 1fr' : '194px 39px 194px',
158161
dateRangeBorder: '0',
159162
dateRangeBorderRadius: '0',
160163
dateRangeArrowIconWidth: '15px',
161164
dateRangeArrowIconHeight: '12px',
162-
dateRangeArrowIconColor: '#BCBEC0',
165+
dateRangeArrowIconColor: getThemeProp('graci', globalStyles.colors.graci, themeContext),
163166
dateRangeArrowIconOpacity: 1,
164167
dateRangeStartDateInputPadding: vertical ? (rtl ? '0 32px 0 8px' : '0 8px 0 32px') : '0 44px',
165168
dateRangeEndDateInputPadding: vertical ? (rtl ? '0 32px 0 8px' : '0 8px 0 32px') : '0 44px',

0 commit comments

Comments
 (0)