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

Convert Card component to Typescript #806

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

... 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.
Comment on lines -26 to -29
const modifiers = [];
if (expanded) {
modifiers.push('expanded');
}
Copy link
Member Author

@sergei-maertens sergei-maertens Mar 12, 2025

Choose a reason for hiding this comment

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

Couldn't find any CSS anymore that still did something with it, I reckon we missed this when we rewrote the progress indicator. I broke it because it has another base class name lol

Copy link

codecov bot commented Mar 12, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
@open-formulieren/sdk-OpenForms-umd 4.9MB -679 bytes (-0.01%) ⬇️
@open-formulieren/sdk-esm 4.87MB -662 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 -679 bytes 3.53MB -0.02%

Files in open-*.js:

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

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

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

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

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

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

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

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

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

Assets Changed:

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

Files in assets/sdk-*.js:

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

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

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

Files in assets/index-*.js:

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

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

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

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

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

Copy link

codecov bot commented Mar 12, 2025

Codecov Report

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

Project coverage is 83.40%. Comparing base (c8546e8) to head (41cac4c).

Files with missing lines Patch % Lines
src/components/Card.tsx 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #806      +/-   ##
==========================================
- Coverage   83.52%   83.40%   -0.13%     
==========================================
  Files         233      233              
  Lines        4632     4627       -5     
  Branches     1180     1178       -2     
==========================================
- Hits         3869     3859      -10     
- Misses        733      738       +5     
  Partials       30       30              
Flag Coverage Δ
storybook 76.67% <95.65%> (-0.21%) ⬇️
vitest 62.29% <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
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.

1 participant