Skip to content

fix: styles for the schedule component, make it mobile-friendly#15178

Merged
helgastogova merged 7 commits intomainfrom
3795-fix-schedule-for-atoms
May 24, 2024
Merged

fix: styles for the schedule component, make it mobile-friendly#15178
helgastogova merged 7 commits intomainfrom
3795-fix-schedule-for-atoms

Conversation

@helgastogova
Copy link
Copy Markdown
Contributor

@helgastogova helgastogova commented May 23, 2024

What does this PR do?

  • Fixes CAL-3797, Make the Schedule component mobile-friendly.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • I have added a Docs issue here if this PR makes changes that would require a documentation change
  • I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

How should this be tested?

Visually check the Schedule component view on the /availability/ page.

before (wide screen)
image

before (mobile view)
image

after (wide screen)
image

after (mobile view)
image

design check (compare with Figma)
image

@linear
Copy link
Copy Markdown

linear Bot commented May 23, 2024

@graphite-app graphite-app Bot requested a review from a team May 23, 2024 16:09
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 23, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@keithwillcode keithwillcode added the core area: core, team members only label May 23, 2024
@helgastogova helgastogova added the platform Anything related to our platform plan label May 23, 2024
@graphite-app graphite-app Bot requested a review from a team May 23, 2024 16:09
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented May 23, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (05/23/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add platform team as reviewer" took an action on this PR • (05/23/24)

1 reviewer was added to this PR based on Keith Williams's automation.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 9:36am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 9:36am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview May 24, 2024 9:36am

@deploysentinel
Copy link
Copy Markdown

deploysentinel Bot commented May 23, 2024

Current Playwright Test Results Summary

✅ 321 Passing - ❌ 1 Failing - ⚠️ 10 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 05/23/2024 04:37:41pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 071fbda

Started: 05/23/2024 04:28:55pm UTC

❌ Failures

📄   apps/web/playwright/teams.e2e.ts • 1 Failure

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Teams - NonOrg -- future Team Onboarding Invite Members
Retry 2Retry 1Initial Attempt
Error: Test timeout of 60000ms exceeded.
Test timeout of 60000ms exceeded.
4.18% (10) 10 / 239 runs
failed over last 7 days
14.64% (35) 35 / 239 runs
flaked over last 7 days

⚠️ Flakes

📄   apps/web/playwright/managed-event-types.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Managed Event Types Can create managed event type
Retry 1Initial Attempt
6.93% (16) 16 / 231 runs
failed over last 7 days
3.46% (8) 8 / 231 runs
flaked over last 7 days

📄   apps/web/playwright/reschedule.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Reschedule Tests Opt in event should be PENDING when rescheduled by USER
Retry 1Initial Attempt
0% (0) 0 / 259 runs
failed over last 7 days
0.39% (1) 1 / 259 run
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/preview.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Preview Preview - embed-core should load if correct embedLibUrl is provided
Retry 1Initial Attempt
0% (0) 0 / 225 runs
failed over last 7 days
32% (72) 72 / 225 runs
flaked over last 7 days

📄   apps/web/playwright/login.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
user can login & logout succesfully -- future login flow user & logout using dashboard
Retry 2Retry 1Initial Attempt
2.64% (6) 6 / 227 runs
failed over last 7 days
30.84% (70) 70 / 227 runs
flaked over last 7 days

📄   apps/web/playwright/profile.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Update Profile Can update a users email (verification enabled)
Retry 1Initial Attempt
29.25% (74) 74 / 253 runs
failed over last 7 days
34.39% (87) 87 / 253 runs
flaked over last 7 days

📄   packages/app-store/routing-forms/playwright/tests/basic.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Routing Forms Seeded Routing Form Router URL should work
Retry 1Initial Attempt
0.44% (1) 1 / 228 run
failed over last 7 days
13.16% (30) 30 / 228 runs
flaked over last 7 days
Routing Forms Seeded Routing Form Test preview should return correct route
Retry 1Initial Attempt
0.44% (1) 1 / 227 run
failed over last 7 days
33.92% (77) 77 / 227 runs
flaked over last 7 days

📄   apps/web/playwright/teams.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Teams - NonOrg -- future Can create a booking for Round Robin EventType
Retry 1Initial Attempt
7.95% (19) 19 / 239 runs
failed over last 7 days
24.69% (59) 59 / 239 runs
flaked over last 7 days
Teams - NonOrg -- legacy Can create a booking for Round Robin EventType
Retry 1Initial Attempt
7.05% (17) 17 / 241 runs
failed over last 7 days
28.22% (68) 68 / 241 runs
flaked over last 7 days

📄   apps/web/playwright/organization/booking.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Bookings Team Event Can create a booking for Round Robin EventType
Retry 1Initial Attempt
6.93% (16) 16 / 231 runs
failed over last 7 days
28.14% (65) 65 / 231 runs
flaked over last 7 days

View Detailed Build Results


@dosubot dosubot Bot added ui area: UI, frontend, button, form, input 🧹 Improvements Improvements to existing features. Mostly UX/UI labels May 23, 2024
@helgastogova helgastogova requested a review from sean-brydon May 23, 2024 18:24
{!!watchDayRange.length && !disabled && <div className="block">{CopyButton}</div>}
</div>
<>
{watchDayRange.length > 0 && (
Copy link
Copy Markdown
Contributor

@Ryukemeister Ryukemeister May 24, 2024

Choose a reason for hiding this comment

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

How about we move this watchDayRange.length > 0 check one level higher. So instead of adding this conditional watchDayRange.length > 0 inside of the Day ranges component we remove that check completely and maybe do something like this: !!watchDayRange ? Day ranges component : Skeleton component

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The !! will convert the watchDayRange variable to its boolean equivalent, similar to what watchDayRange.length > 0 does. Or you can use Boolean(watchDayRange) but thats just a personal preference since both of them are the same

Copy link
Copy Markdown
Contributor Author

@helgastogova helgastogova May 24, 2024

Choose a reason for hiding this comment

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

Hey @Ryukemeister, yes, I agree with you, it really does seem like it needs to be written exactly like this.

{!!watchDayRange ? (
          <div className="flex sm:gap-2">
            <DayRanges
              userTimeFormat={userTimeFormat}
              labels={labels}
              control={control}
              name={name}
              disabled={disabled}
              className={{
                dayRanges: className?.dayRanges,
                timeRangeField: className?.timeRangeField,
              }}
            />
            {!!watchDayRange.length && !disabled && <div className="block">{CopyButton}</div>}
          </div>
        ) : (
          <SkeletonText className="ml-1 mt-2.5 h-6 w-48" />
        )}

but if you try to do that, you will see that in that case, we have one extra empty div

image

the same will be if I use !!watchDayRange instead of watchDayRange.length > 0

The difference between these checks in this case:

  1. watchDayRange.length > 0
    This line checks if the length of the watchDayRange array is greater than zero. This means there must be at least one element in the array for the condition to return true.
  2. !!watchDayRange
    This line first converts watchDayRange to a boolean value. If watchDayRange is an object or array (even if empty), !!watchDayRange will always return true because objects and arrays are "truthy" values in JavaScript. Thus, this condition checks for the existence of the array, not its emptiness.
    The difference is that the first condition checks for the presence of elements within the array, while the second checks for the existence of the array itself, regardless of its content. If watchDayRange is an empty array ([]), the first condition will return false, while the second will return true.

And if I do:

     {watchDayRange.length > 0 ? (
          <div className="flex sm:gap-2">
            <DayRanges
              userTimeFormat={userTimeFormat}
              labels={labels}
              control={control}
              name={name}
              disabled={disabled}
              className={{
                dayRanges: className?.dayRanges,
                timeRangeField: className?.timeRangeField,
              }}
            />
            {!!watchDayRange.length && !disabled && <div className="block">{CopyButton}</div>}
          </div>
        ) : (
          <SkeletonText className="ml-1 mt-2.5 h-6 w-48" />
        )}

I will see a skeleton when I don't need to see it
image

so, we need to check if

  1. {watchDayRange ? ( ... ) : ( ... )}:
    This checks if watchDayRange is defined. If watchDayRange is neither null nor undefined, the code inside the first part of the condition (after ?) is executed. If watchDayRange is null or undefined, is displayed.
  2. {watchDayRange.length > 0 && ( ... )}:
    This checks if the watchDayRange array contains any elements. If the array is not empty (length > 0), it renders a block containing the DayRanges component.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if we do watchDayRange && watchDayRange.length > 0? That way day ranges only renders when watch day range is defined and its not empty. So what about watchDayRange && watchDayRange.length > 0 ? < DayRanges/> : < Skeleton/>

Copy link
Copy Markdown
Contributor Author

@helgastogova helgastogova May 24, 2024

Choose a reason for hiding this comment

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

watchDayRange && watchDayRange.length > 0
will give us false if we have [] and we will see a <Skeleton /> when we don't want to see it

so, code might look like that

    <>
        {!watchDayRange && <SkeletonText className="ml-1 mt-2.5 h-6 w-48" />}
        {watchDayRange.length > 0 && (
          <div className="flex sm:gap-2">
            <DayRanges
              userTimeFormat={userTimeFormat}
              labels={labels}
              control={control}
              name={name}
              disabled={disabled}
              className={{
                dayRanges: className?.dayRanges,
                timeRangeField: className?.timeRangeField,
              }}
            />
            {!!watchDayRange.length && !disabled && <div className="block">{CopyButton}</div>}
          </div>
        )}
      </>

or like that

 <>
        {watchDayRange ? (
          <>
            {watchDayRange.length > 0 && (
              <div className="flex sm:gap-2">
                <DayRanges
                  userTimeFormat={userTimeFormat}
                  labels={labels}
                  control={control}
                  name={name}
                  disabled={disabled}
                  className={{
                    dayRanges: className?.dayRanges,
                    timeRangeField: className?.timeRangeField,
                  }}
                />
                {!!watchDayRange.length && !disabled && <div className="block">{CopyButton}</div>}
              </div>
            )}
          </>
        ) : (
          <SkeletonText className="ml-1 mt-2.5 h-6 w-48" />
        )}
      </>

but not like that

        <>
        {watchDayRange && watchDayRange.length > 0 ? (
          <div className="flex sm:gap-2">
            <DayRanges
              userTimeFormat={userTimeFormat}
              labels={labels}
              control={control}
              name={name}
              disabled={disabled}
              className={{
                dayRanges: className?.dayRanges,
                timeRangeField: className?.timeRangeField,
              }}
            />
            {!!watchDayRange.length && !disabled && <div className="block">{CopyButton}</div>}
          </div>
        ) : (
          <SkeletonText className="ml-1 mt-2.5 h-6 w-48" />
        )}
      </>

I will update it for the first version

Copy link
Copy Markdown
Member

@sean-brydon sean-brydon left a comment

Choose a reason for hiding this comment

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

I'm happy with this thanks @helgastogova :)

@Ryukemeister - I'll wait for your approval before we merge as you left some previous comments.

@helgastogova helgastogova added this pull request to the merge queue May 24, 2024
@helgastogova helgastogova removed this pull request from the merge queue due to a manual request May 24, 2024
@helgastogova helgastogova added this pull request to the merge queue May 24, 2024
Merged via the queue into main with commit 58e6f18 May 24, 2024
@helgastogova helgastogova deleted the 3795-fix-schedule-for-atoms branch May 24, 2024 11:23
@shirazdole
Copy link
Copy Markdown

wow this sick!

p6l-richard pushed a commit to p6l-richard/cal.com-fork that referenced this pull request Jul 22, 2024
…om#15178)

* fix styles for the schedule component, make it mobile-friendly

* CR changes

* no need that condition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only 🧹 Improvements Improvements to existing features. Mostly UX/UI platform Anything related to our platform plan ui area: UI, frontend, button, form, input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants