-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datepicker bugfixes + theme support #35
Changes from 18 commits
f2c2fcb
95a0cf7
4ad6182
56ae9b0
184f23b
ca2cac9
9c15c4b
04826f2
ac11085
e40cd5a
40cd693
976a928
2c044d0
b1747d3
2b24187
4e990d4
58eb925
13c768d
357c2d5
346c2e2
73ebff0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@import 'nebenan-ui-kit/_index.scss'; | ||
@import 'src/**/*.scss'; | ||
@import 'src/**/index.scss'; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"homepage": "https://nebenan.de/", | ||
"repository": "good-hood-gmbh/nebenan-form", | ||
"bugs": "https://github.com/good-hood-gmbh/nebenan-form/issues", | ||
"version": "8.3.0", | ||
"version": "8.3.1-beta.5", | ||
"scripts": { | ||
"reinstall": "rm -rf node_modules package-lock.json && npm install && npm run decache", | ||
"decache": "find ./build -type f -name '.browserify-cache.json' -delete || echo \"\\033[0;32mAlready decached!\\033[0m\"", | ||
|
@@ -64,9 +64,7 @@ | |
"lodash": "^4.17.15", | ||
"mocha": "^7.1.1", | ||
"morgan": "^1.10.0", | ||
"nebenan-helpers": "^4.1.1", | ||
"nebenan-ui-kit": "^4.4.1", | ||
"nebenan-react-datepicker": "^1.0.0", | ||
"node-sass-glob-importer": "^5.3.2", | ||
"nodemon": "^2.0.1", | ||
"normalize.css": "^8.0.1", | ||
|
@@ -84,12 +82,18 @@ | |
"stylelint": "^13.2.1", | ||
"stylelint-config-nebenan": "^1.6.0", | ||
"terser": "^4.6.7", | ||
"nebenan-helpers": "^4.2.0-beta.0", | ||
"tiny-lr": "^1.1.1", | ||
"vinyl-source-stream": "^2.0.0" | ||
}, | ||
"dependencies": { | ||
"nebenan-react-datepicker": "^1.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@babel/runtime": "^7.9.2", | ||
"clsx": "^1.1.0", | ||
"nebenan-helpers": "^4.2.0-beta.0", | ||
"tiny-lr": "^1.1.1", | ||
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. |
||
"lodash": "^4.17.15", | ||
"prop-types": "^15.7.2", | ||
"react": "^16.13.1", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import clsx from 'clsx'; | ||
import memorize from 'lodash/memoize'; | ||
|
||
import { screenPosition, screenSize, size } from 'nebenan-helpers/lib/dom'; | ||
import keymanager from 'nebenan-helpers/lib/keymanager'; | ||
|
@@ -10,8 +11,8 @@ import Picker from 'nebenan-react-datepicker/lib'; | |
import { bindTo } from '../utils'; | ||
|
||
import InputComponent from '../base'; | ||
import theme from './theme'; | ||
import { getDate, getValueFromDate, getValueFromISO } from './utils'; | ||
import baseCalendarTheme from './calendar_theme'; | ||
import { getCalendarTheme, getDate, getValueFromDate, getValueFromISO } from './utils'; | ||
|
||
class Datepicker extends InputComponent { | ||
constructor(props) { | ||
|
@@ -23,6 +24,7 @@ class Datepicker extends InputComponent { | |
'handleClick', | ||
'handleClear', | ||
); | ||
this.getCalendarTheme = memorize(getCalendarTheme.bind(null, baseCalendarTheme)); | ||
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. lodash memorize only uses first argument as cache key. Good thing I read the documentation twice. |
||
} | ||
|
||
componentWillUnmount() { | ||
|
@@ -97,7 +99,8 @@ class Datepicker extends InputComponent { | |
else this.hide(); | ||
} | ||
|
||
handleClear() { | ||
handleClear(event) { | ||
event.preventDefault(); | ||
this.setValue(null, this.validate); | ||
} | ||
|
||
|
@@ -119,6 +122,7 @@ class Datepicker extends InputComponent { | |
firstDay, | ||
weekdayShortLabels, | ||
monthLabels, | ||
theme: passedTheme, | ||
} = this.props; | ||
|
||
const localizedValue = getValueFromISO(value, dateFormat); | ||
|
@@ -139,7 +143,8 @@ class Datepicker extends InputComponent { | |
selected={getDate(value)} | ||
minDate={getDate(minDate)} | ||
maxDate={getDate(maxDate)} | ||
{...{ theme, monthLabels, weekdayShortLabels, firstDay }} | ||
theme={this.getCalendarTheme(passedTheme)} | ||
{...{ monthLabels, weekdayShortLabels, firstDay }} | ||
/> | ||
); | ||
} | ||
|
@@ -153,10 +158,11 @@ class Datepicker extends InputComponent { | |
|
||
return ( | ||
<div ref={this.setEl('container')} className={className}> | ||
<label onClick={this.handleClick}> | ||
<label> | ||
{labelNode} | ||
<div className="c-datepicker-container"> | ||
<input | ||
onClick={this.handleClick} | ||
ref={this.setEl('input')} | ||
className={inputClassName} | ||
placeholder={placeholder} | ||
|
@@ -177,6 +183,8 @@ class Datepicker extends InputComponent { | |
Datepicker.propTypes = { | ||
...InputComponent.propTypes, | ||
|
||
theme: PropTypes.object, | ||
|
||
firstDay: PropTypes.number.isRequired, | ||
weekdayShortLabels: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
monthLabels: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@import 'calendar_theme'; | ||
|
||
.c-datepicker { | ||
position: relative; | ||
} | ||
|
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.
Preview in nebenan-form loaded datepickers theme.scss, nebenan-frontend didn't import it because it only imports index.scss files.
Note: All other scss files in nebenan-form/src/** are called index.scss.