forked from schummar/schummar-table
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: DatePicker blockedRanges (schummar#101)
* "type" for button to avoid submit in forms; datePicker story * more button types * blocked ranges are coloured correctly * show blocked color also when selected * Cleanup * moved css out --------- Co-authored-by: Michael Förg <[email protected]>
- Loading branch information
Showing
7 changed files
with
138 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useState } from 'react'; | ||
import { DatePicker, DatePickerProps, DateRange } from '../../src'; | ||
|
||
const today = new Date(); | ||
const nextWeek = new Date(); | ||
nextWeek.setDate(today.getDate() + 7); | ||
|
||
export default { | ||
title: 'Date Picker', | ||
component: DatePicker, | ||
argTypes: { | ||
value: { control: 'date' }, | ||
onChange: { action: 'changed' }, | ||
blockedRanges: { | ||
control: 'object', | ||
}, | ||
}, | ||
}; | ||
|
||
export const Primary = (args: DatePickerProps) => { | ||
const [date, setDate] = useState<DateRange | null>(null); | ||
|
||
return ( | ||
<DatePicker | ||
{...args} | ||
value={date} | ||
onChange={(v) => { | ||
if (v instanceof Date) { | ||
setDate({ min: v, max: v }); | ||
} else { | ||
setDate(v); | ||
} | ||
args.onChange(v); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
Primary.args = { | ||
value: new Date(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
import { useTheme } from '../hooks/useTheme'; | ||
|
||
export function useCssVariables() { | ||
return useTheme(({ spacing, colors }) => ({ | ||
'--spacing': spacing, | ||
'--primaryMain': colors.primary.main, | ||
'--primaryLight': colors.primary.light, | ||
'--primaryContrastText': colors.primary.contrastText, | ||
'--secondaryMain': colors.secondary.main, | ||
'--secondaryLight': colors.secondary.light, | ||
'--secondaryContrastText': colors.secondary.contrastText, | ||
})); | ||
return useTheme(({ spacing, colors }) => { | ||
return { | ||
'--spacing': spacing, | ||
'--primaryMain': colors.primary.main, | ||
'--primaryLight': colors.primary.light, | ||
'--primaryContrastText': colors.primary.contrastText, | ||
'--secondaryMain': colors.secondary.main, | ||
'--secondaryLight': colors.secondary.light, | ||
'--secondaryContrastText': colors.secondary.contrastText, | ||
'--blockedMain': colors.blocked.main, | ||
'--blockedLight': colors.blocked.light, | ||
'--blockedContrastText': colors.blocked.contrastText, | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters