Skip to content

Convert Card component to Typescript #806

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

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

sergei-maertens
Copy link
Member

... and cleaned up its usage along the way.

The CardTitle component is used in either one of two ways:

  • implicitly, through the Card where it's basically the title and should be displayed as h1 element
  • explicitly, in which case it was always being rendered as an h2 element

So, the default heading level is now 2 for the low-level component, while using it implicitly through Card ensures that it's level 1, matching the current behaviour but cleaning up the code quite a bit. This cleanup removes the need for polymorphic component props to support multiple HTML elements - our codebase does not use anythign other than heading elements at the moment (and those landmarks are important for a11y).

Next, the Card component itself. The modifiers list is gone in favour of explicit (boolean) props that set/determine the modifiers under the hood, allowing proper combination and usage tracking while being able to document their behaviour individually. Usages have been updated accordingly, but let's wait for Chromatic to confirm nothing broke.

The caption did not appear to be used anywhere as Card prop, so that's been removed.

Copy link

codecov bot commented Mar 12, 2025

Bundle Report

Changes will decrease total bundle size by 1.35kB (-0.01%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@open-formulieren/sdk-OpenForms-umd 4.9MB -682 bytes (-0.01%) ⬇️
@open-formulieren/sdk-esm 4.87MB -665 bytes (-0.01%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: @open-formulieren/sdk-OpenForms-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
open-*.js -682 bytes 3.53MB -0.02%

Files in open-*.js:

  • ./src/components/appointments/steps/ContactDetailsStep.jsx → Total Size: 3.2kB

  • ./src/components/appointments/CreateAppointment/CreateAppointment.jsx → Total Size: 2.41kB

  • ./src/components/appointments/CreateAppointment/Summary.jsx → Total Size: 7.96kB

  • ./src/components/appointments/steps/ChooseProductStep.jsx → Total Size: 6.22kB

  • ./src/components/appointments/steps/LocationAndTimeStep.jsx → Total Size: 5.63kB

  • ./src/components/Card.tsx → Total Size: 1.14kB

  • ./src/components/ProgressIndicator/index.jsx → Total Size: 2.86kB

  • ./src/components/FormStep/index.jsx → Total Size: 17.51kB

view changes for bundle: @open-formulieren/sdk-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/sdk-*.js -543 bytes 1.02MB -0.05%
assets/index-*.js -122 bytes 45.33kB -0.27%

Files in assets/sdk-*.js:

  • ./src/components/ProgressIndicator/index.jsx → Total Size: 2.86kB

  • ./src/components/Card.tsx → Total Size: 1.14kB

  • ./src/components/FormStep/index.jsx → Total Size: 17.16kB

Files in assets/index-*.js:

  • ./src/components/appointments/CreateAppointment/Summary.jsx → Total Size: 7.96kB

  • ./src/components/appointments/steps/ContactDetailsStep.jsx → Total Size: 3.2kB

  • ./src/components/appointments/CreateAppointment/CreateAppointment.jsx → Total Size: 2.41kB

  • ./src/components/appointments/steps/ChooseProductStep.jsx → Total Size: 6.21kB

  • ./src/components/appointments/steps/LocationAndTimeStep.jsx → Total Size: 5.63kB

Copy link

codecov bot commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.17%. Comparing base (e75c0f0) to head (dfffb7b).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/components/Card.tsx 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #806      +/-   ##
==========================================
- Coverage   83.94%   83.17%   -0.78%     
==========================================
  Files         232      232              
  Lines        4623     4613      -10     
  Branches     1176     1169       -7     
==========================================
- Hits         3881     3837      -44     
- Misses        712      747      +35     
+ Partials       30       29       -1     
Flag Coverage Δ
storybook 76.42% <94.44%> (-0.93%) ⬇️
vitest 62.21% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sergei-maertens sergei-maertens marked this pull request as draft March 13, 2025 08:23
@sergei-maertens sergei-maertens force-pushed the chore/445-convert-more-to-ts branch from 41cac4c to 181c898 Compare March 14, 2025 08:46
@sergei-maertens sergei-maertens marked this pull request as ready for review March 14, 2025 08:46
@sergei-maertens sergei-maertens force-pushed the chore/445-convert-more-to-ts branch 2 times, most recently from 4fc05af to fcbbce6 Compare March 18, 2025 09:50
sergei-maertens added a commit that referenced this pull request Mar 18, 2025
Depends on #806, now we have type errors on the CardTitle usage.

All in all a pretty straight forward conversion after most of the
code got deleted in the earlier refactor.
sergei-maertens added a commit that referenced this pull request Mar 19, 2025
Depends on #806, now we have type errors on the CardTitle usage.

All in all a pretty straight forward conversion after most of the
code got deleted in the earlier refactor.
... and cleaned up its usage along the way.

The CardTitle component is used in either one of two ways:

* implicitly, through the Card where it's basically _the_ title and
  should be displayed as h1 element
* explicitly, in which case it was always being rendered as an h2
  element

So, the default heading level is now 2 for the low-level component,
while using it implicitly through Card ensures that it's level 1,
matching the current behaviour but cleaning up the code quite a bit.
This cleanup removes the need for polymorphic component props to
support multiple HTML elements - our codebase does not use anythign
other than heading elements at the moment (and those landmarks are
important for a11y).

Next, the Card component itself. The modifiers list is gone in favour
of explicit (boolean) props that set/determine the modifiers under the
hood, allowing proper combination and usage tracking while being able
to document their behaviour individually. Usages have been updated
accordingly, but let's wait for Chromatic to confirm nothing broke.

The caption did not appear to be used anywhere as Card prop, so that's
been removed.
@sergei-maertens sergei-maertens force-pushed the chore/445-convert-more-to-ts branch from fcbbce6 to dfffb7b Compare March 19, 2025 10:18
@robinmolen robinmolen self-requested a review March 19, 2025 10:19
@sergei-maertens sergei-maertens merged commit ed14495 into main Mar 19, 2025
16 of 17 checks passed
@sergei-maertens sergei-maertens deleted the chore/445-convert-more-to-ts branch March 19, 2025 10:41
sergei-maertens added a commit that referenced this pull request Mar 19, 2025
Depends on #806, now we have type errors on the CardTitle usage.

All in all a pretty straight forward conversion after most of the
code got deleted in the earlier refactor.
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