-
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
Adding end date to event card #10
Conversation
// 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>" |
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.
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"> |
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.
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> |
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.
extra space
<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> |
{(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 | ||
} |
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.
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.
{(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> | |
</> | |
} |
{ | ||
(startDay != endDay) | ||
|| | ||
(startMonth != endMonth) | ||
? | ||
<> |
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.
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> |
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.
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> |
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.
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> | ||
{ |
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.
All the same feed back as the card.
6524635
to
a9f4c29
Compare
I've made a separate commit to get this over the line. Closing this since it's completed elsewhere |
READY FOR REVIEW
Summary
Review By (Date)
Criticality
Urgency
Review Tasks
Setup tasks and/or behavior to test
drush cr ; drush ci
Site Configuration Sync
Front End Validation
Backend / Functional Validation
Code
Code security
General
Affected Projects or Products
Associated Issues and/or People
@mention
them here)Resources