Skip to content

Commit

Permalink
Merge pull request #675 from Orfium/feat/NDS-810_design_qa_for_fields_v5
Browse files Browse the repository at this point in the history
[NDS-810] DQA for fields
  • Loading branch information
kostasdano authored Oct 16, 2023
2 parents f95ca23 + d79091b commit 965825f
Show file tree
Hide file tree
Showing 57 changed files with 5,676 additions and 3,083 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const iconStyles =
justify-content: center;
/** @TODO: revisit these styles when Interactive Icon is implemented */
&:focus-visible {
&:focus-visible,
&:hover {
background: ${theme.tokens.state.get('backgroundColor.hover')};
border-radius: ${theme.globals.borderRadius.get('7')};
}
Expand Down
13 changes: 9 additions & 4 deletions src/components/DatePicker/DatePickInput/DatePickInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useTheme from 'hooks/useTheme';
import { rem } from 'polished';
import React, { useCallback, InputHTMLAttributes, useMemo } from 'react';
import { rem } from 'theme/utils';
import dayjs, { Dayjs } from 'utils/date';

import { iconStyles } from './DatePickInput.style';
Expand All @@ -13,7 +13,6 @@ import { DATE_PICKER_LABEL, DATE_RANGE_PICKER_LABEL } from '../constants';
import { DateFormatType } from '../DatePicker.types';
import { Range } from '../OverlayComponent/OverlayComponent';
import Icon from 'components/Icon';
import { getDatePickerMinWidth } from 'components/TextInputBase/config';
import { getTextInputBaseTokens } from 'components/TextInputBase/TextInputBase.tokens';

// TODO: Need to fix this (TextField onChange prop)
Expand Down Expand Up @@ -82,7 +81,13 @@ const DatePickInput = React.forwardRef<HTMLInputElement, DatePickInputProps>(

const { buttonType = 'primary', styleType = 'filled', filterType } = filterConfig;

const sx = { wrapper: { minWidth: rem(getDatePickerMinWidth(isRangePicker)) } };
const sx = {
wrapper: {
minWidth: isRangePicker
? rem(tokens('minWidth.extraLarge.normal'))
: rem(tokens('minWidth.medium.normal')),
},
};

const renderIconButton = useMemo(
() => (
Expand All @@ -105,7 +110,7 @@ const DatePickInput = React.forwardRef<HTMLInputElement, DatePickInputProps>(
);

const getLabel = useMemo(() => {
if (inputProps?.label.length) {
if (inputProps?.label?.length) {
return inputProps.label;
}

Expand Down
126 changes: 119 additions & 7 deletions src/components/DatePicker/DatePicker.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Implementation of the regular DatePicker

<Preview>
<Story name="DatePicker" parameters={{ decorators: [withKnobs] }} play={openDatePicker} autoPlay>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
Expand Down Expand Up @@ -97,7 +97,7 @@ Implementation of the regular DateRangePicker
play={openDatePicker}
autoPlay
>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
Expand All @@ -117,13 +117,93 @@ Implementation of the regular DateRangePicker
</Story>
</Preview>

### DatePicker and DateRangePicker with Statuses

DatePicker and DateRangePicker inherit all TextField statuses behavior.

<Preview>
<Story
name="DatePicker and DateRangePicker with Statuses"
parameters={{ decorators: [withKnobs] }}
>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
disableDates={select('disableDates', options, options[0])}
dateFormatOverride={select('dateFormat', dateFormatOptions, dateFormatOptions[1])}
inputProps={{
label: 'Normal',
status: {
type: 'normal',
hintMessage: text('Custom Hint Message', 'Hint Message'),
},
}}
/>
);
}}
</Function>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
disableDates={select('disableDates', options, options[0])}
dateFormatOverride={select('dateFormat', dateFormatOptions, dateFormatOptions[1])}
inputProps={{
label: 'Error',
status: {
type: 'error',
hintMessage: text('Custom Error Message', 'Error Message'),
},
}}
/>
);
}}
</Function>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
disableDates={select('disableDates', options, options[0])}
dateFormatOverride={select('dateFormat', dateFormatOptions, dateFormatOptions[1])}
inputProps={{
label: 'Read-only',
status: {
type: 'read-only',
hintMessage: text('Custom Hint Message', 'Hint Message'),
},
}}
/>
);
}}
</Function>
</Stack>
</Story>
</Preview>

### DateRangePicker with options

Implementation of the regular DatePicker with options

<Preview>
<Story name="DateRangePicker with options" parameters={{ decorators: [withKnobs] }}>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
Expand All @@ -150,7 +230,7 @@ Implementation of the DatePicker with a Filter instead of a TextField

<Preview>
<Story name="DatePicker with Filter" parameters={{ decorators: [withKnobs] }}>
<Stack vertical>
<Stack vertical height={600}>
<Function>
{() => {
const [date, setDate] = useState({ from: undefined, to: undefined });
Expand Down Expand Up @@ -185,13 +265,13 @@ Implementation of the DatePicker with a Filter instead of a TextField
</Story>
</Preview>

### DayPicker with disabled dates
### DatePicker with disabled dates

Some disable dates functionality

<Preview>
<Story name="DayPicker with disabled dates">
<Stack>
<Story name="DatePicker with disabled dates">
<Stack height={600}>
<Function>
{() => {
const [date, setDate] = useState({
Expand All @@ -205,6 +285,38 @@ Some disable dates functionality
</Story>
</Preview>

### Disabled DatePicker & DateRangePicker

Disabled DatePicker & DateRangePicker

<Preview>
<Story name="Disabled DatePicker & DateRangePicker">
<Stack>
<Function>
{() => {
const [date, setDate] = useState({ from: currentDay.toDate(), to: currentDay.toDate() });
return (
<DatePicker
value={date}
isRangePicker={boolean('isRangePicker', false)}
onChange={setDate}
isClearable={true}
inputProps={{
label: 'Normal',
status: {
type: 'normal',
hintMessage: 'This field is disabled',
},
isDisabled: true,
}}
/>
);
}}
</Function>
</Stack>
</Story>
</Preview>

### Playground

<Preview>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fireEvent, render } from 'test';

import { currentDay } from '../utils';
import OverlayComponent from './OverlayComponent';
import { CALENDAR_DEFAULT_OPTIONS } from '../constants';
import { APPLY, CALENDAR_DEFAULT_OPTIONS } from '../constants';

describe('OverlayComponent', () => {
const mockDate = currentDay;
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('OverlayComponent', () => {
/>
);

const applyBtn = await findByText('Apply Dates');
const applyBtn = await findByText(APPLY);
const cancelBtn = await findByText('Clear All');
fireEvent.click(applyBtn);
fireEvent.click(cancelBtn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from './OverlayComponent.style';
import { getRightCalendarDate, getLeftCalendarDate } from './utils';
import Button from '../../Button';
import { APPLY_DATES, CLEAR_ALL } from '../constants';
import { APPLY, CLEAR_ALL } from '../constants';
import { DisabledDates, ExtraOption } from '../DatePicker.types';

export type OverlayComponentProps = {
Expand Down Expand Up @@ -107,7 +107,7 @@ const OverlayComponent: React.FC<OverlayComponentProps> = ({
dataTestId={'apply'}
isDisabled={Boolean(!selectedDays.from || !selectedDays.to)}
>
{APPLY_DATES}
{APPLY}
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ exports[`OverlayComponent should render correctly 1`] = `
class="emotion-15"
>
<span>
Apply Dates
Apply
</span>
</span>
</button>
Expand Down Expand Up @@ -4255,7 +4255,7 @@ exports[`OverlayComponent should render datepicker correctly 1`] = `
class="emotion-19"
>
<span>
Apply Dates
Apply
</span>
</span>
</button>
Expand Down
Loading

0 comments on commit 965825f

Please sign in to comment.