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

Adding end date to event card #10

Closed
wants to merge 12 commits into from
Closed

Adding end date to event card #10

wants to merge 12 commits into from

Conversation

jenbreese
Copy link
Contributor

READY FOR REVIEW

  • Feedback needed.
  • I want the end date to appear when it is appropriate. I took some of the code from the card and tried to change it to a ternary. It isn't right. Can you give me feedback?
  • I would like it to look like this:
Screenshot 2024-03-28 at 3 46 23 PM

Summary

  • TL;DR - what's this PR for?

Review By (Date)

  • When does this need to be reviewed by?

Criticality

  • How critical is this PR on a 1-10 scale? Also see Severity Assessment.
  • E.g., it affects one site, or every site and product?

Urgency

  • How urgent is this? (Normal, High)

Review Tasks

Setup tasks and/or behavior to test

  1. Check out this branch
  2. Rebuild Cache and import config drush cr ; drush ci
  3. Navigate to...
  4. Verify...

Site Configuration Sync

  • Is there a config:export in this PR that changes the config sync directory?

Front End Validation

Backend / Functional Validation

Code

  • Are the naming conventions following our standards?
  • Does the code have sufficient inline comments?
  • Is there anything in this code that would be hidden or hard to discover through the UI?
  • Are there any code smells?
  • Are tests provided? eg (unit, behat, or codeception)

Code security

General

  • Is there anything included in this PR that is not related to the problem it is trying to solve?
  • Is the approach to the problem appropriate?

Affected Projects or Products

  • Does this PR impact any particular projects, products, or modules?

Associated Issues and/or People

  • JIRA ticket(s)
  • Other PRs
  • Any other contextual information that might be helpful (e.g., description of a bug that this PR fixes, new functionality that it adds, etc.)
  • Anyone who should be notified? (@mention them here)

Resources

// Fix difference between server side render and client side render. Replace any strange characters.
const dateTimeString = getEventTimeString(start, end, timeZone).replace(/[^a-zA-Z0-9 ,:\-|]/, ' ');
const Heading = headingLevel === 'h3' ? H3 : H2;

const endDate = "<span className='relative font-normal leading-trim top-7 text-m0 px-03em' aria-hidden='true'>– to –</span><span className='sr-only'>to</span><time dateTime='2023-07-03 00:00Z' className='flex flex-col'><span className='text-m0 font-semibold w-full text-center'>{endMonth.toUpperCase()}</span><span className='text-m4 font-bold w-full text-center'>{endDay}</span></time>"
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't put markup into variables like this. You should always put the markup directly into the component and use conditional rendering:

{someField &&
  <div>{someField}</div>
}

Optionally, you could create a separate component for just the date display area.

{startDay}
</div>
<div aria-hidden className="flex w-fit justify-start flex-row items-center min-w-[9rem] h-90">
<time dateTime="2023-06-24 00:00Z" className="flex flex-col">
Copy link
Contributor

Choose a reason for hiding this comment

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

This time should be dynamic based on the start date and it should be lowercase datetime. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time#usage_notes for proper data formatting

</div>
<div aria-hidden className="flex w-fit justify-start flex-row items-center min-w-[9rem] h-90">
<time dateTime="2023-06-24 00:00Z" className="flex flex-col">
<span className="text-m0 font-semibold w-full text-center"> {startMonth.toUpperCase()}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

extra space

Suggested change
<span className="text-m0 font-semibold w-full text-center"> {startMonth.toUpperCase()}</span>
<span className="text-m0 font-semibold w-full text-center">{startMonth.toUpperCase()}</span>

Comment on lines 43 to 50
{(startDay != endDay) && (startMonth != endMonth) ?
<><span className='relative font-normal leading-trim top-7 text-m0 px-03em' aria-hidden='true'>– to –</span><span className='sr-only'>to</span><time dateTime='2023-07-03 00:00Z' className='flex flex-col'>
<span className='text-m0 font-semibold w-full text-center'>{endMonth.toUpperCase()}</span>
<span className='text-m4 font-bold w-full text-center'>{endDay}</span>
</time>
</>
: null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is hard to read. you should be able to simplify it and fix indentations & lines. And we don't need the sr-only text since this whole region is aria-hidden.
There's no need for the time element since we already included that for the start time.

Suggested change
{(startDay != endDay) && (startMonth != endMonth) ?
<><span className='relative font-normal leading-trim top-7 text-m0 px-03em' aria-hidden='true'>– to –</span><span className='sr-only'>to</span><time dateTime='2023-07-03 00:00Z' className='flex flex-col'>
<span className='text-m0 font-semibold w-full text-center'>{endMonth.toUpperCase()}</span>
<span className='text-m4 font-bold w-full text-center'>{endDay}</span>
</time>
</>
: null
}
{(startDay != endDay && startMonth != endMonth) &&
<>
<span className="relative font-normal leading-trim top-7 text-m0 px-03em">– to –</span>
<div className="flex flex-col">
<span className="text-m0 font-semibold w-full text-center">{endMonth.toUpperCase()}</span>
<span className="text-m4 font-bold w-full text-center">{endDay}</span>
</div>
</>
}

Comment on lines +42 to +47
{
(startDay != endDay)
||
(startMonth != endMonth)
?
<>
Copy link
Contributor

Choose a reason for hiding this comment

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

You should try to avoid {isTrue ? <div>something</div> : <div>something else</div>}. it becomes difficult to read. Especially if the "something else" is null, there's no reason for such structure. This can be simplified to

{(startDay != endDay || startMonth != endMonth) &&
  <div>some result</div>
}

(startMonth != endMonth)
?
<>
<span className='relative font-normal leading-trim top-7 text-m0 px-03em' aria-hidden='true'>– to –</span><span className='sr-only'>to</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace all single quotes with double quotes. If you merge in the latest 1.x branch, you should get IDE notifications. Also yarn lint is always a good tool to check.

(startMonth != endMonth)
?
<>
<span className='relative font-normal leading-trim top-7 text-m0 px-03em' aria-hidden='true'>– to –</span><span className='sr-only'>to</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need aria-hidden here since the parent container already has aria-hidden

<div className="text-m0 font-semibold mb-4 w-full text-center">
{startMonth.toUpperCase()}
</div>
<div className="text-m4 font-bold w-full text-center">
{startDay}
</div>
{
Copy link
Contributor

Choose a reason for hiding this comment

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

All the same feed back as the card.

@pookmish pookmish force-pushed the 1.x branch 2 times, most recently from 6524635 to a9f4c29 Compare July 10, 2024 19:32
@pookmish
Copy link
Contributor

pookmish commented Sep 9, 2024

I've made a separate commit to get this over the line. Closing this since it's completed elsewhere

@pookmish pookmish closed this Sep 9, 2024
@pookmish pookmish deleted the event-card-end-date branch September 9, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants