This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/create datepicker component #131
Open
dawntancarrasco
wants to merge
10
commits into
main
Choose a base branch
from
chore/create-datepicker-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8caea2c
chore: add new datepicker component
1c8f932
chore: updated datepicker
4ae2622
chore: update datepicker
420833c
chore: updated styling
7db50dd
chore: updated styling
ba7cee8
chore: update on datepicker
b356154
chore: change in format
88070cf
chore: version bump
9fe84a6
chore: change datepicker case
224c22b
chore: updated lib
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,4 @@ | ||
A datepicker is a graphical user interface (GUI) element that allows users to easily select a date from a calendar. It is commonly used in web forms and applications to streamline the process of entering dates. A typical datepicker consists of an input field, where users can manually enter a date, and a graphical calendar interface that pops up when users interact with the input field. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion; can we follow the same template used by other components? |
||
|
||
##Figma Link | ||
Figma link not available |
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,67 @@ | ||
import React from "react"; | ||
import {ComponentStory, ComponentMeta} from "@storybook/react"; | ||
import DatePicker from "./DatePicker"; | ||
import Button from "../Button"; | ||
import {withDesign} from "storybook-addon-designs"; | ||
import ComponentSummary from "./ComponentSummary.mdx"; | ||
import ReactDOMServer from "react-dom/server"; | ||
|
||
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export | ||
export default { | ||
title: "Components/DatePicker", | ||
component: DatePicker, | ||
decorators: [withDesign], | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: ReactDOMServer.renderToString(<ComponentSummary />), | ||
}, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof DatePicker>; | ||
|
||
const Template: ComponentStory<typeof DatePicker> = (args) => { | ||
const [shown, setShown] = React.useState(false); | ||
const buttonRef = React.useRef(null); | ||
|
||
// override on close | ||
const overriddenArgs = { | ||
...args, | ||
onClose: () => { | ||
setShown(false); | ||
}, | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button | ||
ref={buttonRef} | ||
onClick={() => { | ||
setShown(true); | ||
}} | ||
> | ||
Show Date Picker | ||
</Button> | ||
{shown && <DatePicker anchorEl={buttonRef} {...overriddenArgs} />} | ||
</> | ||
); | ||
}; | ||
|
||
export const Basic = Template.bind({}); | ||
|
||
export const WithDefaultDate = Template.bind({}); | ||
// More on args: https://storybook.js.org/docs/react/writing-stories/args | ||
WithDefaultDate.args = { | ||
defaultDate: new Date("2022-01-02"), | ||
defaultTime: "10:35", | ||
hasTime: true, | ||
onChange: (value) => { | ||
console.log("date: ", value); | ||
}, | ||
onTimeChange: (value) => { | ||
console.log("time: ", value); | ||
}, | ||
"data-cy": "popover", | ||
"data-cy-clear": "clear", | ||
"data-cy-today": "today", | ||
}; |
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,128 @@ | ||
import styled from "styled-components"; | ||
|
||
const StyledDatePickerWrapper = styled.div` | ||
.react-datepicker { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion; can we use theme props throughout this component? |
||
border: none; | ||
} | ||
|
||
.react-datepicker { | ||
font-family: sans-serif; | ||
border-radius: 4px; | ||
} | ||
|
||
.react-datepicker__header { | ||
background-color: #ffffff; | ||
color: #000000; | ||
border: none; | ||
padding: 10px; | ||
text-align: center; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
.react-datepicker__portal .react-datepicker__current-month, | ||
.react-datepicker__portal .react-datepicker-time__header { | ||
font-size: 1.44rem; | ||
} | ||
|
||
.react-datepicker__current-month, | ||
.react-datepicker-time__header, | ||
.react-datepicker-year-header { | ||
margin-top: 1px; | ||
color: #000; | ||
font-size: 0.944rem; | ||
} | ||
|
||
.react-datepicker__navigation { | ||
margin-left: 20px; | ||
margin-right: 20px; | ||
background: none; | ||
line-height: 1.7rem; | ||
text-align: center; | ||
cursor: pointer; | ||
position: absolute; | ||
top: 30px; | ||
width: 0; | ||
padding: 0; | ||
border: 0.45rem solid transparent; | ||
z-index: 1; | ||
height: 10px; | ||
width: 10px; | ||
text-indent: -999em; | ||
overflow: hidden; | ||
} | ||
|
||
.react-datepicker__navigation--previous { | ||
left: 10px; | ||
border-right-color: #ccc; | ||
} | ||
|
||
.react-datepicker__navigation--previous:hover { | ||
border-right-color: #b3b3b3; | ||
} | ||
|
||
.react-datepicker__navigation--previous--disabled, | ||
.react-datepicker__navigation--previous--disabled:hover { | ||
border-right-color: #e6e6e6; | ||
cursor: default; | ||
} | ||
|
||
.react-datepicker__navigation--next { | ||
right: 10px; | ||
border-left-color: #ccc; | ||
} | ||
|
||
.react-datepicker__navigation--next--with-time:not( | ||
.react-datepicker__navigation--next--with-today-button | ||
) { | ||
right: 80px; | ||
} | ||
|
||
.react-datepicker__navigation--next:hover { | ||
border-left-color: #b3b3b3; | ||
} | ||
|
||
.react-datepicker__day-names { | ||
display: flex; | ||
justify-content: space-around; | ||
margin-top: 10px; | ||
} | ||
|
||
.react-datepicker__week { | ||
display: flex; | ||
justify-content: space-around; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.react-datepicker__day { | ||
width: 30px; | ||
height: 30px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 14px; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
transition: background-color 0.3s; | ||
|
||
&:hover { | ||
background-color: rgb(74 131 169); | ||
color: #ffffff; | ||
} | ||
} | ||
|
||
.react-datepicker__month { | ||
padding: 10px; | ||
} | ||
|
||
.react-datepicker__day--selected { | ||
background-color: #3498db; | ||
color: #ffffff; | ||
} | ||
|
||
.react-datepicker__day--keyboard-selected { | ||
background-color: #3498db; | ||
color: #ffffff; | ||
} | ||
`; | ||
|
||
export default StyledDatePickerWrapper; |
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,10 @@ | ||
import React from "react"; | ||
import {render} from "../test-utils"; | ||
|
||
import DatePicker from "./DatePicker"; | ||
|
||
describe("DatePicker", () => { | ||
test("renders the DatePicker component", () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion; some more thorough tests here please |
||
render(<DatePicker />); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question; what is the impact on library footprint after adding these new deps?