Skip to content
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

feat: add departure date selector #27

Merged
merged 5 commits into from
Oct 5, 2023

Conversation

adriansberg
Copy link
Contributor

@adriansberg adriansberg commented Oct 3, 2023

Added options for when to travel, based on the current time, the arrival time or the departure time.

Screenshots

Light mode

image
image

Light mode mobile

image
image

Date and time picker mobile

image
image

Dark mode

image
image

Dark mode mobile

image
image

Fixes https://github.com/AtB-AS/kundevendt/issues/9144 (parts of it)

TODO

  • Add component tests
  • Clean up based on review

{t(PageText.Departures.search.date.label)}
</p>

<DepartureDateSelector
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a better name, please come with some alternatives.

.departureDateSelector {
display: flex;
flex-direction: column;
/* TODO: Spacing not in variables. Use variable instead? */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should we do with values like these that are not specified in the theme? Should the design be revised, should we add the value(s) or should we just use them as is?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design should be revised to follow the correct spacing I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I'd prefer that over adding new values. Though a bit strange (maybe not the best word) that a spacing of 1rem is not in the set of spacings? Same with 0.75rem for border-radius.

Should we just keep this values for now until we have a design review, or similar to update the spacings, or use the spacings we have for now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think 16px is ever used in spacing in the webshop or app 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not since it is not a spacing.

The ones we are using at the moment are:
6px / 0.375rem (spacing between date/time inputs and type)
16px / 1rem (margin-bottom for search box asks for this, have used --spacings-medium)
12px / 0.75rem (border-radius)

const [departureDateState, setDepartureDateState] = useState(
DepartureDateState.Now,
);
const [_departureDate, setDepartureDate] = useState<Date>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better with one state, a date, and that state gets updated accordingly inside the component changing the date and time separately?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the API should be "cleaned" more here and communicate with timestamps instead. It is the only intended way of using it so we should do that data mapping / conversion as early as possible in the call stack

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think something like

type DepartureDate = {
  type: 'now'
} | {
  type: 'arrival',
  datetime: new Date()
} 
// | etc etc ;

<DepartureDateSelector
   initialValue={departureDate as DepartureDate}
    onChange={setDepartureDate}
  />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion! Was waiting with this some so that we agree on the solution. Implementing this post standup.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is done I think it's ready to be merged for now

@mikaelbr
Copy link
Collaborator

mikaelbr commented Oct 5, 2023

That menu selector screams to be animated 😄 But not important for now.

@mikaelbr
Copy link
Collaborator

mikaelbr commented Oct 5, 2023

I think maybe the break points should happen earlier?

Screenshot 2023-10-05 at 10 20 32

@adriansberg
Copy link
Contributor Author

I think maybe the break points should happen earlier?

Screenshot 2023-10-05 at 10 20 32

The padding should also be removed. Have removed it in my current branch. Tried getting an overview of the other breakpoints (header/footer etc) but couldn't find a common break point used. What should we break at?

@mortennordseth
Copy link
Contributor

If I start typing the date with a 0 (zero) I'm getting a runtime error. This should probably be handled
image

@adriansberg
Copy link
Contributor Author

If I start typing the date with a 0 (zero) I'm getting a runtime error. This should probably be handled

image

Indeed. One of the last changes I've done. Looking at it!

<label htmlFor="departureDateSelector">
{t(ComponentText.DepartureDateSelector.date)}
</label>
<input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these inputs have color: var(--text-colors-secondary); in the Figma sketches

@mikaelbr
Copy link
Collaborator

mikaelbr commented Oct 5, 2023

Maybe not relevant for this issue, but these headings should be primary--bold
Screenshot 2023-10-05 at 10 38 12

@adriansberg adriansberg force-pushed the adriansberg/departure-date-selector branch from 14e2a28 to 0d5505c Compare October 5, 2023 09:56
@adriansberg adriansberg force-pushed the adriansberg/departure-date-selector branch from 0d5505c to 424bbde Compare October 5, 2023 09:57
@adriansberg adriansberg merged commit 3e07fdc into main Oct 5, 2023
3 checks passed
@adriansberg adriansberg deleted the adriansberg/departure-date-selector branch October 5, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants