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: POC for common style as variables files #1156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DhaaraniCIT
Copy link
Contributor

@DhaaraniCIT DhaaraniCIT commented Jan 21, 2025

Description

feat: POC for common style as variables files

Clickup

https://app.clickup.com/t/

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced branding configuration with dynamic style selection based on brand ID
    • Added support for custom styling in export settings
  • Improvements

    • Simplified class assignment logic in export settings component
    • Introduced more flexible branding style management

The changes improve the application's ability to customize visual styles across different brand configurations, providing a more tailored user experience.

Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

Walkthrough

This pull request introduces a new branding configuration system across multiple files. It adds style-specific configurations for different brands (Fyle and C1) and creates a centralized brandingStyle mechanism to dynamically select appropriate styles based on the brand identifier. The changes modify the export settings component to leverage this new styling approach, allowing for more flexible and modular branding management within the application.

Changes

File Change Summary
src/app/branding/branding-config.ts Added imports for fyleStyles and c1Styles, created styles object, and introduced brandingStyle constant for dynamic style selection
src/app/branding/c1-style-config.ts New file with brandingConfig and c1Styles exports, defining C1-specific styling configuration
src/app/branding/fyle-style-config.ts New file with brandingConfig and fyleStyles exports, defining Fyle-specific styling configuration
src/app/.../qbd-direct-export-settings.component.html Updated ngClass to use brandingStyle.exportSettingsStyle for conditional styling
src/app/.../qbd-direct-export-settings.component.ts Added import and readonly property for brandingStyle

Suggested labels

size/L

Suggested reviewers

  • ashwin1111

Possibly related PRs

Poem

🐰 A Rabbit's Branding Ballad 🎨

Styles dancing, brand by brand,
Configuration at my command!
Fyle and C1, now they shine bright,
With dynamic classes, pure delight!
Code hopping, styling with glee! 🌈

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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. (Beta)
  • @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.

@github-actions github-actions bot added the size/S Small PR label Jan 21, 2025
Copy link

Unit Test Coverage % values
Statements 33.04% ( 4139 / 12524 )
Branches 26.44% ( 1179 / 4458 )
Functions 25.59% ( 893 / 3489 )
Lines 33.23% ( 4073 / 12255 )

@@ -2,8 +2,7 @@
<div *ngIf="isLoading" class="tw-flex tw-justify-center tw-items-center tw-pt-80-px">
<app-loader></app-loader>
</div>
<div *ngIf="!isLoading" class="configuration--contents tw-border-border-tertiary tw-mt-6"
[ngClass]="{'tw-mx-120-px tw-shadow-app-card': brandingConfig.brandId === 'fyle', 'tw-mx-60-px tw-shadow-shadow-level-1': brandingConfig.brandId === 'co'}">
<div *ngIf="!isLoading" class="configuration--contents tw-border-border-tertiary tw-mt-6" [class]="brandingStyle.exportSettingsStyle">
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be [ngClass]="brandingStyle.exportSettingsStyle"

export const brandingConfig: BrandingConfiguration = config as BrandingConfiguration;

export const c1Styles = {
exportSettingsStyle: 'tw-mx-60-px tw-shadow-shadow-level-1'
Copy link
Contributor

Choose a reason for hiding this comment

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

name should be better

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: 1

🧹 Nitpick comments (2)
src/app/branding/fyle-style-config.ts (1)

6-8: Consider using CSS custom properties for maintainability.

Instead of hardcoding Tailwind classes, consider using CSS custom properties (variables) for values that might need to be adjusted across different themes or breakpoints.

 export const fyleStyles = {
-    exportSettingsStyle: 'tw-mx-120-px tw-shadow-app-card'
+    exportSettingsStyle: 'tw-mx-[var(--fyle-export-margin)] tw-shadow-[var(--fyle-card-shadow)]'
 };
src/app/branding/c1-style-config.ts (1)

1-8: Consider creating a shared configuration factory.

The configuration structure is duplicated between Fyle and C1 styles. Consider creating a shared factory function to generate brand-specific configurations.

// shared-style-config.ts
interface BrandStyleConfig {
  exportSettingsStyle: string;
}

function createBrandStyles(options: {
  margin: string;
  shadow: string;
}): BrandStyleConfig {
  return {
    exportSettingsStyle: `tw-mx-${options.margin} tw-shadow-${options.shadow}`
  };
}

// Usage in c1-style-config.ts
export const c1Styles = createBrandStyles({
  margin: '60-px',
  shadow: 'shadow-level-1'
});
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d05001 and dfd75c5.

📒 Files selected for processing (5)
  • src/app/branding/branding-config.ts (2 hunks)
  • src/app/branding/c1-style-config.ts (1 hunks)
  • src/app/branding/fyle-style-config.ts (1 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html (1 hunks)
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.ts
🔇 Additional comments (2)
src/app/branding/fyle-style-config.ts (1)

4-4: Consider using type validation for config import.

The type assertion config as BrandingConfiguration doesn't guarantee type safety at runtime. Consider adding runtime validation.

src/app/integrations/qbd-direct/qbd-direct-shared/qbd-direct-export-settings/qbd-direct-export-settings.component.html (1)

5-5: Clean implementation of dynamic styling.

The use of [class]="brandingStyle.exportSettingsStyle" is a clean way to apply brand-specific styles. The implementation correctly leverages the new branding configuration system.

Comment on lines +49 to +57

const styles = {
fyle: fyleStyles,
co: c1Styles
};

// @ts-ignore
export const brandingStyle = styles[brandingConfig.brandId];

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove @ts-ignore and improve type safety.

The use of @ts-ignore masks potential type issues. Consider improving type safety:

 const styles = {
     fyle: fyleStyles,
     co: c1Styles
 };

-// @ts-ignore
-export const brandingStyle = styles[brandingConfig.brandId];
+type BrandId = typeof brandingConfig.brandId;
+export const brandingStyle = styles[brandingConfig.brandId as BrandId];

Also consider using a type-safe lookup pattern:

const getBrandingStyle = (brandId: BrandId) => {
  const style = styles[brandId];
  if (!style) {
    throw new Error(`Invalid brand ID: ${brandId}`);
  }
  return style;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Small PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants