Skip to content

Commit 235296c

Browse files
authored
Merge pull request #118 from codaco/release/3.0.5
Release/3.0.5
2 parents df7df3b + cd0be45 commit 235296c

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/node_modules
33
npm-debug.log*
44
/lib
5+
.vscode

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"name": "@codaco/ui",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"description": "Styles and React components for the Network Canvas project",
55
"main": "lib/components/index.js",
66
"type": "module",
7+
"license": "GPL-3.0-or-later",
78
"engines": {
89
"node": "12.8.0",
910
"npm": "6.10.2"

src/components/Fields/DatePicker/DatePicker/DatePicker.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { DateTime, Interval } from 'luxon';
44
import DatePickerContext from './DatePickerContext';
@@ -27,6 +27,14 @@ const DatePicker = ({
2727
date: getDate(props.date),
2828
});
2929

30+
// Correctly update component state when passed new date prop
31+
useEffect(() => {
32+
setPickerState(state => ({
33+
...state,
34+
date: getDate(props.date),
35+
}));
36+
}, [props.date]);
37+
3038
const type = props.type || DEFAULT_TYPE;
3139

3240
const format = DATE_FORMATS[type];

src/components/Fields/DatePicker/RangePicker.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import React, { useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import cx from 'classnames';
4-
import { times } from 'lodash';
4+
import { times, find } from 'lodash';
55

66
// If today's date isn't in range, what's the closest value?
77
const getScrollToValue = (range = [], today) => {
8-
if (today !== 0 && !today) { return null; }
8+
if (today !== 0 && !today) {
9+
return null;
10+
}
11+
912
const findToday = find(range, ({ value }) => value === today);
10-
if (findToday) { return findToday; }
13+
if (findToday) {
14+
return findToday.value;
15+
}
16+
1117
const first = range[0].value;
1218
const last = range[range.length - 1].value;
1319

@@ -57,7 +63,6 @@ const RangePicker = ({
5763
);
5864

5965
const scrollToValue = getScrollToValue(range, today);
60-
6166
return (
6267
<div className={classes} ref={datePickerRef}>
6368
<div className="date-picker__range-picker-items">

src/styles/components/form/fields/_date-picker.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$module-name: date-picker;
2-
$animation-speed: var(--animation-duration-standard);
2+
$animation-speed: var(--animation-duration-fast);
33
$height: 18rem;
44
$lighten: rgba(255, 255, 255, 0.05);
55
$darken: rgba(0, 0, 0, 0.2);
@@ -8,8 +8,8 @@ $darken: rgba(0, 0, 0, 0.2);
88
&__error {
99
opacity: 0;
1010
max-height: 0;
11-
transition: opacity var(--animation-easing) var(--animation-duration-standard),
12-
max-height var(--animation-easing) var(--animation-duration-standard);
11+
transition: opacity var(--animation-easing) var(--animation-duration-fast),
12+
max-height var(--animation-easing) var(--animation-duration-fast);
1313
}
1414

1515
&__error-message {
@@ -53,7 +53,7 @@ $darken: rgba(0, 0, 0, 0.2);
5353
display: flex;
5454
align-items: center;
5555
border-bottom: 2px solid transparent;
56-
transition: border-bottom-color var(--animation-easing) var(--animation-duration-standard);
56+
transition: border-bottom-color var(--animation-easing) var(--animation-duration-fast);
5757

5858
&-divider {
5959
color: var(--active-color);
@@ -63,7 +63,7 @@ $darken: rgba(0, 0, 0, 0.2);
6363
&-part,
6464
&-clear {
6565
display: inline-block;
66-
transition: opacity var(--animation-easing) var(--animation-duration-standard);
66+
transition: opacity var(--animation-easing) var(--animation-duration-fast);
6767
}
6868

6969
&-part {
@@ -106,14 +106,14 @@ $darken: rgba(0, 0, 0, 0.2);
106106
height: 0;
107107
position: relative;
108108
transform-origin: top left;
109-
transition: height var(--animation-easing) var(--animation-duration-slow) var(--animation-duration-standard),
110-
transform var(--animation-easing) var(--animation-duration-slow) var(--animation-duration-standard);
109+
transition: height var(--animation-easing) var(--animation-duration-standard) var(--animation-duration-fast),
110+
transform var(--animation-easing) var(--animation-duration-standard) var(--animation-duration-fast);
111111

112112
&--is-open {
113113
height: $height;
114114
transform: scaleY(1);
115-
transition: height var(--animation-easing) var(--animation-duration-slow),
116-
transform var(--animation-easing) var(--animation-duration-slow);
115+
transition: height var(--animation-easing) var(--animation-duration-standard),
116+
transform var(--animation-easing) var(--animation-duration-standard);
117117
}
118118
}
119119

@@ -128,7 +128,7 @@ $darken: rgba(0, 0, 0, 0.2);
128128
background-color: var(--input-background);
129129
flex-direction: column;
130130
transform: translateX(100%);
131-
transition: transform var(--animation-easing) var(--animation-duration-slow) var(--animation-duration-standard);
131+
transition: transform var(--animation-easing) var(--animation-duration-standard) var(--animation-duration-fast);
132132
border-color: var(--darken);
133133
border-style: solid;
134134
border-width: 0 2px 0 0;

0 commit comments

Comments
 (0)