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

feat(app_start): add dynamic illustrations for appStartPage #3679

Conversation

FussuChalice
Copy link
Contributor

Type of change

Thank you @rhahao for your help!

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

…ions_Max-Makaluk' of /~https://github.com/FussuChalice/organized-app into CU-86c0wjqg8_FEAT-Link-color-variables-of-SVG-illustrations_Max-Makaluk
…ions_Max-Makaluk' of /~https://github.com/FussuChalice/organized-app into CU-86c0wjqg8_FEAT-Link-color-variables-of-SVG-illustrations_Max-Makaluk
@rhahao
Copy link
Member

rhahao commented Feb 25, 2025

Copy link

vercel bot commented Feb 25, 2025

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

Name Status Preview Updated (UTC)
staging-organized-app ✅ Ready (Inspect) Visit Preview Feb 26, 2025 6:38am
test-organized-app ✅ Ready (Inspect) Visit Preview Feb 26, 2025 6:38am

Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

Walkthrough

This pull request introduces multiple new React functional components for SVG illustrations that utilize Material-UI's SvgIcon and accept SvgIconProps. The new components—IllustrationMeetingSchedules, IllustrationMinistryAssignments, and IllustrationOtherSchedules—are designed to render detailed SVG graphics with CSS-variable colors and clipping paths. Additionally, the StartupIllustration component has been updated to use a CSS variable for its background color and now renders a component from the slide object instead of a static image. The useIllustration hook has been updated to replace static SVG imports with these new React components.

Changes

File(s) Change Summary
src/components/illustrations/IllustrationMeetingSchedules.tsx, IllustrationMinistryAssignments.tsx, IllustrationOtherSchedules.tsx Added new React functional components that render SVG illustrations using Material-UI's SvgIcon and accept SvgIconProps. Each component defines its own SVG with viewBox, clipping paths, and CSS variable styling, and is exported as default.
src/features/app_start/shared/illustration/index.tsx Updated the StartupIllustration component: replaced a hardcoded background color with a CSS variable and removed the <img> tag, now rendering the custom slide component ({slide.component}).
src/features/app_start/shared/illustration/useIllustration.tsx Replaced static SVG image imports with new React component imports in the slides array (e.g., IllustrationMeetingSchedules, IllustrationMinistryAssignments, etc.), and commented out the unused Territories entry.

Sequence Diagram(s)

sequenceDiagram
    participant S as StartupIllustration
    participant U as useIllustration Hook
    participant I as Illustration Component

    S->>U: Request slides array
    U-->>S: Return slides with `component` property
    S->>I: Render selected slide.component
    I-->>S: Return rendered SVG illustration
Loading

Possibly related PRs

Suggested labels

released

Suggested reviewers

  • rhahao

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f034bb and 7a5d9ce.

📒 Files selected for processing (2)
  • src/components/illustrations/IllustrationMeetingSchedules.tsx (1 hunks)
  • src/components/illustrations/IllustrationMinistryAssignments.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/illustrations/IllustrationMinistryAssignments.tsx
  • src/components/illustrations/IllustrationMeetingSchedules.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (7)
src/components/svg_as_image/index.tsx (1)

12-16: Consider forwarding all props to the img element.

The component only passes src, alt, and style props to the img element. Consider using prop spreading to forward all valid HTML attributes to ensure the component is fully extensible.

- return <img src={encodedSVG} alt={props.alt} style={props.style} />;
+ return <img src={encodedSVG} {...props} />;

Note: You may need to exclude the src prop from the spread since you're replacing it with encodedSVG.

src/components/illustrations/IllustrationMeetingSchedules.tsx (1)

5-341: Consider optimizing the SVG for better performance.

The SVG content is quite large and complex. While it looks comprehensive, consider optimizing it to reduce file size and improve rendering performance:

  1. Use an SVG optimizer tool (SVGO)
  2. Remove unnecessary IDs, metadata, and attributes
  3. Simplify paths where possible
src/components/svg_as_image/useSVGAsImage.tsx (2)

6-49: Add cancellation handling for asynchronous operations

The hook correctly triggers fetching and conversion when dependencies change, but lacks a cleanup mechanism if the component unmounts before the fetch operation completes.

Add an abort controller to prevent potential memory leaks:

useEffect(() => {
+  const controller = new AbortController();
  const fetchAndConvert = async () => {
    const base64 = await convertSvgToBase64(src);
    setEncodedSVG(base64);
  };

  fetchAndConvert();
+  
+  return () => {
+    controller.abort();
+  };
}, [src, theme]);

Then update the fetch call to use it:

const convertSvgToBase64 = async (svgUrl: string): Promise<string> => {
  try {
-    const response = await fetch(svgUrl);
+    const response = await fetch(svgUrl, { signal: controller.signal });
    let svgText = await response.text();
    // Rest of the function remains unchanged

15-22: Performance optimization for SVG processing

The regex processing might be inefficient for large SVGs with many CSS variables.

Consider adding an early check to avoid processing if no CSS variables are present:

try {
  const response = await fetch(svgUrl);
  let svgText = await response.text();
  const regex = /var\(--([^)]*)\)/g;
+ 
+ // Quick check if CSS variables exist before processing
+ if (!svgText.includes('var(--')) {
+   const encodedSvg = encodeURIComponent(svgText)
+     .replace(/'/g, '%27')
+     .replace(/"/g, '%22');
+   return `data:image/svg+xml;charset=utf-8,${encodedSvg}`;
+ }
+ 
  let match;

  while ((match = regex.exec(svgText)) !== null) {
    // Processing logic
  }
src/features/app_start/shared/illustration/useIllustration.tsx (3)

38-43: Extract common style to reduce duplication

All illustration components use the same style object, which introduces repetition in the code.

Create a shared style object to reduce duplication:

+const illustrationStyle = { width: '100%', height: 'auto' };

const slides = useMemo(() => {
  return [
    {
      title: t('tr_illustrationMinistryAssignmentsHeader'),
      desc: t('tr_illustrationMinistryAssignmentsDescription'),
      component: (
        <IllustrationMinistryAssignments
-          style={{ width: '100%', height: 'auto' }}
+          style={illustrationStyle}
        />
      ),
    },
    // Apply the same pattern to other illustration components

Also applies to: 47-52, 56-61, 65-67, 72-76


78-82: Consider removing commented code for Territories

The commented-out Territories entry adds noise to the codebase without providing value. Either remove it entirely if no longer needed or add a comment explaining why it's kept.

- // {
-   //   title: t('tr_illustrationTerritoriesHeader'),
-   //   desc: t('tr_illustrationTerritoriesDescription'),
-   //   src: Territories,
- // },

86-90: Add type annotation for function parameter

The handleSlide function parameter n lacks a type annotation, which could lead to type-related issues.

- const handleSlide = (n) => {
+ const handleSlide = (n: number) => {
    if (swiperRef.current) {
      swiperRef.current.swiper.slideToLoop(n);
    }
  };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4dce317 and 2f034bb.

⛔ Files ignored due to path filters (7)
  • src/assets/img/illustration_meetingSchedules.svg is excluded by !**/*.svg, !**/*.svg
  • src/assets/img/illustration_ministryAssignments.svg is excluded by !**/*.svg, !**/*.svg
  • src/assets/img/illustration_multiPlattform.svg is excluded by !**/*.svg, !**/*.svg
  • src/assets/img/illustration_no_assigments.svg is excluded by !**/*.svg, !**/*.svg
  • src/assets/img/illustration_otherSchedules.svg is excluded by !**/*.svg, !**/*.svg
  • src/assets/img/illustration_secretary.svg is excluded by !**/*.svg, !**/*.svg
  • src/assets/img/illustration_territories.svg is excluded by !**/*.svg, !**/*.svg
📒 Files selected for processing (8)
  • src/components/illustrations/IllustrationMeetingSchedules.tsx (1 hunks)
  • src/components/illustrations/IllustrationMinistryAssignments.tsx (1 hunks)
  • src/components/illustrations/IllustrationOtherSchedules.tsx (1 hunks)
  • src/components/svg_as_image/index.tsx (1 hunks)
  • src/components/svg_as_image/index.types.ts (1 hunks)
  • src/components/svg_as_image/useSVGAsImage.tsx (1 hunks)
  • src/features/app_start/shared/illustration/index.tsx (2 hunks)
  • src/features/app_start/shared/illustration/useIllustration.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/components/illustrations/IllustrationMinistryAssignments.tsx
  • src/components/illustrations/IllustrationOtherSchedules.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (9)
src/components/svg_as_image/index.types.ts (1)

1-6: Well-structured TypeScript type definition.

The type SVGAsImageProps is properly defined as an extension of React's DetailedHTMLProps for image elements, providing good type safety for the SVG-to-image component.

src/components/svg_as_image/index.tsx (1)

4-11: Good documentation with JSDoc.

The component is well-documented with JSDoc comments providing clear information about its purpose, parameters and return value.

src/features/app_start/shared/illustration/index.tsx (2)

26-26: Good use of CSS variables for theming.

Replacing the hardcoded color with a CSS variable var(--accent-main) improves theming flexibility.


71-71: Dynamic component rendering enhancement.

Changing from a static image to rendering a component from slide.component allows for more flexible and dynamic content.

src/components/illustrations/IllustrationMeetingSchedules.tsx (2)

1-4: Appropriate use of Material-UI SvgIcon.

Using the Material-UI SvgIcon component is a good approach for creating SVG illustrations that can easily integrate with the rest of the application.


13-341: Good use of CSS variables for theming SVG elements.

The SVG uses CSS variables (like var(--white-semi-s), var(--grey-200), var(--watchtower-study), etc.) for fill colors, which allows for theming and consistent color usage across the application.

src/components/svg_as_image/useSVGAsImage.tsx (2)

1-5: The imports look good

The necessary imports for state management, React hooks, and utility functions are correctly implemented.


11-33:

❓ Verification inconclusive

Consider adding URL validation

The hook fetches SVGs from a URL without validating it, which could potentially lead to security issues if malicious URLs are provided.


🏁 Script executed:

#!/bin/bash
# Check for other instances where URL validation is performed in the codebase
rg -g "*.ts*" "validateURL|isValidUrl|URL validation" --no-filename

Length of output: 69


Enhance SVG URL Validation Prior to Fetch Operation

It appears that no URL validation helpers (e.g., validateURL/isValidUrl) are detected in the codebase. Since the convertSvgToBase64 function proceeds directly with the provided svgUrl, please ensure that URLs are properly validated before usage to safeguard against potential security issues with untrusted input.

  • File: src/components/svg_as_image/useSVGAsImage.tsx (Lines 11-33)
  • Recommendation: Incorporate a URL validation function to verify that the svgUrl is safe and correctly formatted prior to performing the fetch operation.
src/features/app_start/shared/illustration/useIllustration.tsx (1)

5-11: Clean component imports organization

The transition from static SVG imports to React components is well-structured and improves maintainability.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 25, 2025
…G-illustrations_Max-Makaluk

Signed-off-by: Max Makaluk <70341920+FussuChalice@users.noreply.github.com>
@rhahao
Copy link
Member

rhahao commented Feb 25, 2025

@ux-git, @FussuChalice, the following pictures are the ones that I mention that we can tweak:

  • The illustrations about printed forms should not have those dark line of items inside I think.
  • Not sure if the timer illustration is also correct or need some tweak as well.

image
image

Thanks.

@ux-git
Copy link
Member

ux-git commented Feb 25, 2025

Yes, for the schedules must for sure be simply grey with no color change, and the ministry timer should have green colors when using the green theme. But one element is definitely missing a variable.

Copy link

@FussuChalice
Copy link
Contributor Author

FussuChalice commented Feb 26, 2025

Yes, for the schedules must for sure be simply grey with no color change, and the ministry timer should have green colors when using the green theme. But one element is definitely missing a variable.

@rhahao @ux-git That's it, I changed it, I think the cache needs to be cleared for the timer, everything works for me.

Copy link

cypress bot commented Feb 26, 2025

organized-app    Run #2264

Run Properties:  status check passed Passed #2264  •  git commit a623722d3e: feat(onboarding): link svg colors to color variables
Project organized-app
Branch Review main
Run status status check passed Passed #2264
Run duration 00m 04s
Commit git commit a623722d3e: feat(onboarding): link svg colors to color variables
Committer Max Makaluk
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 1
View all changes introduced in this branch ↗︎

@ux-git
Copy link
Member

ux-git commented Feb 26, 2025

@FussuChalice I forgot to mention the schedules borders – they also must remain grey at all time, sorry 😅

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.

3 participants