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

Enhancements of Components #52

Merged
merged 7 commits into from
Apr 29, 2024
Merged

Conversation

Swathi-eGov
Copy link
Contributor

@Swathi-eGov Swathi-eGov commented Apr 29, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new styles for buttons, checkboxes, fields, info cards, info buttons, labels, mobile numbers, multi-select dropdowns, numeric inputs, radio buttons, select dropdowns, steppers, tags, text inputs, text areas, timelines, toasts, toggles, toggle switches, tree selects, and uploaders.
    • Added new components for info buttons and uploaders.
  • Style Updates

    • Enhanced responsiveness and visual feedback across various components with updated hover, active, and focus states.
    • Refined typography, alignment, and color themes based on aspect ratios for better display across devices.
  • Documentation

    • Updated CSS file versions in public index.html for consistency.

Copy link
Contributor

coderabbitai bot commented Apr 29, 2024

Important

Auto Review Skipped

Review was skipped due to path filters

Files ignored due to path filters (1)
  • react/css/package.json is excluded by !**/*.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent updates across various CSS components in the digitv2 project aim to refine the UI elements for better responsiveness and visual appeal. Changes include adjustments to media queries based on aspect ratios, updates to color schemes, typography enhancements, and improvements in alignment and readability across different devices.

Changes

File Path Change Summary
.../buttonsV2.scss, .../checkboxV2.scss, .../fieldV1.scss, .../infoCardV2.scss, .../infobuttons.scss, .../labelFieldPairV2.scss, .../mobileNumberV2.scss, .../multiSelectDropdownV2.scss, .../numeric.scss, .../radiobtnV2.scss, .../selectdropdownV2.scss, .../stepper.scss, .../tagV2.scss, .../textInputV2.scss, .../textareaV2.scss Updates to various components like buttons, checkboxes, fields, cards, dropdowns, numeric inputs, radio buttons, tags, text inputs, and text areas. Changes focus on styling adjustments for better visual feedback, color scheme updates, and typography refinements.
.../timeline.scss, .../toastV2.scss, .../toggle.scss, .../toggleswitchV2.scss, .../treeSelectV2.scss, .../uploader.scss, .../index.scss, .../typography.scss, .../tailwind.config.js, .../index.html Enhancements in timeline, toasts, toggles, toggleswitches, tree selects, uploaders, index styles, typography, and tailwind configuration. Changes include color definition updates, media query adjustments, and font size modifications for improved consistency and aesthetics.

Poem

🐇 Oh hop and cheer, for changes are here, 🎉
🌟 Twinkling styles, far and near!
From buttons small to fields so wide,
A CSS dance, with colors as guide.
Responsive tweaks in every byte,
CodeRabbit's work shines ever bright! 🌟
🎨🖌️


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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: 7

Out of diff range and nitpick comments (5)
react/ui-components/README.md (1)

61-61: The changelog entry 0.0.1-beta.12 enhancements of components is vague. Consider providing more detailed descriptions of the enhancements for better clarity.

react/css/README.md (1)

Line range hint 1-84: Update the README file for clarity and completeness.

Consider updating the TODO comment at the beginning of the file to provide more specific information about what needs to be updated. Additionally, ensure that the installation and usage instructions are clear and accurate.

react/ui-components/src/hoc/FormComposerV2.js (1)

268-268: Consider using a more descriptive placeholder transformation key.

The placeholder transformation key "TOSENTENCECASE" might not be clear to other developers or future maintainers. Consider using a more descriptive key or adding a comment explaining its purpose.

react/ui-components/src/atoms/TextInput.js (1)

268-268: Ensure consistent placeholder transformation.

The placeholder is transformed to sentence case using the StringManipulator function. Ensure that this transformation is consistent across all instances where placeholders are used in the application to maintain a uniform user experience.

react/modules/sample/src/pages/employee/Sample.js (1)

Line range hint 217-900: Consistency in button labels with excessively long character counts.

- "PrimaryWithmorethansixtyfourcharactersPrimaryWithsixtyfourcharacters"
+ "PrimaryWithMoreThanSixtyFourCharacters"

Consider reducing the character count in button labels to enhance readability and maintain UI consistency. Adjust the labels to be more concise and clear.

Comment on lines +9 to +60
function DocPreview({ file, ...props }) {
const { t } = useTranslation();

const documents = file
? [
{
fileName: file?.name,
},
]
: null;

return (
<PopUp className="campaign-data-preview" style={{ flexDirection: "column" }}>
{/* <div style={{ display: "flex", justifyContent: "space-between", marginLeft: "2.5rem", marginRight: "2.5rem", marginTop: "2.5rem" }}>
<Button
label={t("BACK")}
variation="secondary"
icon={<SVG.ArrowBackIos styles={{ height: "1.25rem", width: "1.25rem" }} fill="#F47738" />}
type="button"
className="workbench-download-template-btn"
onButtonClick={() => props?.onBack()}
/>
<Button
label={t("WBH_DOWNLOAD")}
variation="secondary"
icon={<DownloadIcon styles={{ height: "1.25rem", width: "1.25rem" }} fill="#F47738" />}
type="button"
className="workbench-download-template-btn"
onButtonClick={() => props?.onDownload()}
/>
</div> */}
<div className="campaign-popup-module" style={{ marginTop: "1.5rem" }}>
<DocViewer
style={{ height: "80vh", overflowY: "hidden" }}
theme={{
primary: "#F47738",
secondary: "#feefe7",
tertiary: "#feefe7",
textPrimary: "#0B0C0C",
textSecondary: "#505A5F",
textTertiary: "#00000099",
disableThemeScrollbar: true,
}}
documents={documents}
pluginRenderers={DocViewerRenderers}
/>
</div>
</PopUp>
);
}

export default DocPreview;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider removing or revising commented-out code.

If the commented-out code (lines 22-39) is no longer needed, consider removing it to clean up the file. If it might be used in the future, consider adding a TODO comment with more context.

@@ -265,6 +265,7 @@ export const FormComposer = (props) => {
? { ...wrapperStyles, ...field?.populators?.customStyle }
: { border: "none", background: "white", ...field?.populators?.customStyle }
}
className={props?.labelfielddirectionvertical ? "vertical" : ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize useCallback dependencies.

The formFields useCallback hook does not include all its dependencies. Consider adding all external variables and functions used inside the callback to its dependency array to avoid stale closures and bugs related to outdated captures.


Simplify the form rendering logic.

The main return block of the FormComposer component is quite complex and hard to read due to nested conditional rendering and a large number of JSX elements. Consider breaking down this component into smaller subcomponents or using a more declarative approach to improve readability and maintainability.

@@ -371,7 +371,7 @@ const Dropdown = (props) => {
)}
{(props.variant === "nesteddropdown" ? flattenedOptions : filteredOption) &&
(props.variant === "nesteddropdown" ? flattenedOptions : filteredOption).length === 0 && (
<div className={`cp digit-dropdown-item ${props.variant ? props?.variant : ""}`} key={"-1"} onClick={() => {}}>
<div className={`cp digit-dropdown-item unsuccessfulresults ${props.variant ? props?.variant : ""}`} key={"-1"} onClick={() => {}}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle empty results more gracefully.

The handling of "NO RESULTS FOUND" could be improved by providing a more user-friendly message or additional guidance when no options match the filter criteria. Consider adding suggestions or a clearer call to action.

Comment on lines +20 to +23
(window.innerWidth / window.innerHeight <= 9/16)
);
const onResize = () => {
if (window.innerWidth <= 480) {
if (window.innerWidth / window.innerHeight <= 9/16) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a more robust method for determining if the device is in a mobile view, such as CSS media queries or a dedicated library, to improve accuracy and maintainability.

Comment on lines +22 to +40
try {
const components = require("@egovernments/digit-ui-svg-components");
const DynamicIcon = components?.[iconReq];
if (DynamicIcon) {
const svgElement = DynamicIcon({
width: width,
height: height,
fill: iconFill,
className: `digit-button-customIcon ${props?.size ? props?.size : ""} ${props?.variation ? props?.variation : ""} `
});
return svgElement;
} else {
console.log("Icon not found");
return null;
}
} catch (error) {
console.error("Icon not found");
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider handling the dynamic import of SVG components more efficiently, possibly by using a context or provider pattern to avoid repeated imports and error handling in each render cycle.

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

Out of diff range and nitpick comments (4)
react/css/README.md (4)

Line range hint 1-1: Clarify the TODO comment for better actionability.

Consider specifying what exactly needs to be updated to help other developers understand the required actions more clearly.


Line range hint 13-15: Improve the grammatical structure of the Limitation section.

- This Package is more specific to DIGIT-UI's can be used across mission's
+ This package is specifically designed for DIGIT-UI and can be used across various missions.

Line range hint 19-25: Clarify and correct grammar in the Usage section.

- After adding the dependency make sure you have this dependency in
+ After adding the dependency, ensure it is listed in

45-45: Format the Changelog entries for better readability.

Consider using a bulleted list or ensuring each entry is on a new line to enhance clarity and readability.

Copy link
Collaborator

@jagankumar-egov jagankumar-egov left a comment

Choose a reason for hiding this comment

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

check the following points across folders

@@ -27,7 +27,8 @@
}

&:hover {
@apply border-2 border-primary-main;
@apply border-2 ;
border-color: theme(digitv2.lightTheme.primary-1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is primary-1 color ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the color typography : the primary-orange is renamed to primary-1 and the color code have been changed.

"primary-bluegray": "#0B4B66",
"primary-orangebg": "#FEEFE7",

"primary-1": "#C84C0E",
Copy link
Collaborator

Choose a reason for hiding this comment

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

why primary 1 2 ?

@@ -60,7 +60,9 @@
"react-date-range": "1.3.0",
"react-hook-form": "6.15.8",
"react-i18next": "11.16.2",
"react-table": "7.7.0"
"react-table": "7.7.0",
"react-drag-drop-files": "^2.3.10",
Copy link
Collaborator

Choose a reason for hiding this comment

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

dont use ^ keep fixed version

@@ -229,7 +229,7 @@ const Dropdown = (props) => {
return (
<div
className={`cp digit-dropdown-item ${props.variant ? props?.variant : ""}`}
style={index === optionIndex ? { opacity: 1, backgroundColor: "#FFFAF7", border: "0.5px solid #F47738" } : {}}
style={index === optionIndex ? { opacity: 1, backgroundColor: "#FFFAF7", border: "0.5px solid #C84C0E" } : {}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why inline style , apply through class

@@ -250,7 +250,7 @@ const Dropdown = (props) => {
/>
) : null}
<div className="option-des-container">
<div style={{ display: "flex", gap: "0.25rem", alignItems: "center", width: "100%", minHeight: "18px" }}>
<div style={{ display: "flex", gap: "0.25rem", alignItems: "center", width: "100%" }}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

why inline style , apply through class

{props?.showAsTags && (
<div className="digit-tag-container" style={{ marginTop: "0px" }}>
{uploadedFiles?.map((file, index) => {
console.log(file, "file");
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove console logs

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

Out of diff range and nitpick comments (1)
react/ui-components/src/atoms/MultiSelectDropdown.js (1)

45-47: Consider using a more descriptive variable name than newState for clarity.

Comment on lines +24 to +27
addSelectAllCheck = false,
addCategorySelectAllCheck = false,
selectAllLabel = "",
categorySelectAllLabel = ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Add PropTypes validation for new props to ensure type safety.

Comment on lines +85 to +97
useEffect(() => {
const initialCategorySelectedState = options.reduce((acc, category) => {
if (category.options) {
acc[category.code] = category.options.every((option) =>
alreadyQueuedSelectedState.some(
(selectedOption) => selectedOption.code === option.code
)
);
}
return acc;
}, {});
setCategorySelected(initialCategorySelectedState);
}, [options, alreadyQueuedSelectedState]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize the calculation of initialCategorySelectedState by memoizing the result to avoid unnecessary recalculations on each render.

Comment on lines +161 to +179
const isAlreadySelected = alreadyQueuedSelectedState.some(
(selectedOption) => selectedOption.code === option.code
);
if (!isAlreadySelected) {
dispatch({ type: "ADD_TO_SELECTED_EVENT_QUEUE", payload: [null, option] });
dispatch({
type: "ADD_TO_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
} else {
dispatch({ type: "REMOVE_FROM_SELECTED_EVENT_QUEUE", payload: [null, option] });
dispatch({
type: "REMOVE_FROM_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
const parentOption = findParentOption(option, options);
if (parentOption) {
dispatch({ type: "REMOVE_FROM_SELECTED_EVENT_QUEUE", payload: [null, parentOption] });
dispatch({
type: "REMOVE_FROM_SELECTED_EVENT_QUEUE",
payload: [null, parentOption],
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor onSelectToAddToQueue to simplify the nested dispatch calls and improve readability.

Comment on lines +247 to +264
const handleCategorySelection = (parentOption) => {
const childoptions = parentOption.options;
if (!categorySelected[parentOption.code]) {
childoptions?.forEach((option) => {
dispatch({
type: "ADD_TO_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
});
} else {
childoptions?.forEach((option) => {
dispatch({
type: "REMOVE_FROM_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
});
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize handleCategorySelection by reducing the number of dispatch calls when toggling the selection state.

@jagankumar-egov jagankumar-egov merged commit e06495a into develop Apr 29, 2024
1 check passed
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