-
Notifications
You must be signed in to change notification settings - Fork 1
Feature: Add Line Count and Object Count Statistics Features #25
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
Changes from all commits
3a45094
440757a
cab9475
81bcf78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import React from "react"; | ||
|
|
||
| import type { LineCountStats } from "../types"; | ||
|
|
||
| type LineCountDisplayProps = { | ||
| stats: LineCountStats; | ||
| }; | ||
|
|
||
| export const LineCountDisplay: React.FC<LineCountDisplayProps> = ({ stats }) => { | ||
| if (stats.total === 0) { | ||
| return ( | ||
| <div className="line-count-display"> | ||
| <span className="line-count-item no-changes">No changes</span> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="line-count-display"> | ||
| <div className="line-count-item-sub-holder"> | ||
| {stats.added > 0 && ( | ||
| <span className="line-count-item added"> | ||
| + | ||
| {stats.added} | ||
| {" "} | ||
| added | ||
| </span> | ||
| )} | ||
|
|
||
| {stats.removed > 0 && ( | ||
| <span className="line-count-item removed"> | ||
| - | ||
| {stats.removed} | ||
| {" "} | ||
| removed | ||
| </span> | ||
| )} | ||
| </div> | ||
| <div className="line-count-item-sub-holder"> | ||
| {stats.modified > 0 && ( | ||
| <span className="line-count-item modified"> | ||
| ~ | ||
| {stats.modified} | ||
| {" "} | ||
| modified | ||
| </span> | ||
| )} | ||
| <span className="line-count-item total"> | ||
| {stats.total} | ||
| {" "} | ||
| total changes | ||
| </span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default LineCountDisplay; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React from "react"; | ||
|
|
||
| import type { ObjectCountStats } from "../types"; | ||
|
|
||
| type ObjectCountDisplayProps = { | ||
| stats: ObjectCountStats; | ||
| }; | ||
|
|
||
| export const ObjectCountDisplay: React.FC<ObjectCountDisplayProps> = ({ stats }) => { | ||
| if (!stats || typeof stats !== "object") { | ||
| return null; | ||
| } | ||
|
|
||
| const { added = 0, removed = 0, modified = 0, total = 0 } = stats; | ||
|
|
||
| if (total === 0) { | ||
| return ( | ||
| <div className="object-count-display"> | ||
| <span className="object-count-item no-changes">No object changes</span> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="object-count-display"> | ||
| <div className="object-count-item-sub-holder"> | ||
| {added > 0 && ( | ||
| <span className="object-count-item added"> | ||
| + | ||
| {added} | ||
| {" "} | ||
| added objects | ||
| </span> | ||
| )} | ||
|
|
||
| {removed > 0 && ( | ||
| <span className="object-count-item removed"> | ||
| - | ||
| {removed} | ||
| {" "} | ||
| removed objects | ||
| </span> | ||
| )} | ||
| </div> | ||
| <div className="object-count-item-sub-holder"> | ||
| {modified > 0 && ( | ||
| <span className="object-count-item modified"> | ||
| ~ | ||
| {modified} | ||
| {" "} | ||
| modified objects | ||
| </span> | ||
| )} | ||
| <span className="object-count-item total"> | ||
| {total} | ||
| {" "} | ||
| total object changes | ||
| </span> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ObjectCountDisplay; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,116 @@ | |
| background: rgba(182, 180, 67, 0.08); | ||
| } | ||
|
|
||
| /* LINE COUNT DISPLAY */ | ||
| .line-count-display { | ||
| display: flex; | ||
| gap: 12px; | ||
| margin-top: 5px; | ||
| align-items: center; | ||
| font-size: 11px; | ||
| color: #f8f8f2; | ||
| margin-left: auto; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| .line-count-item-sub-holder { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 4px; | ||
| } | ||
|
|
||
| .line-count-item { | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-weight: 500; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .line-count-item.added { | ||
| background: rgba(100, 182, 67, 0.2); | ||
| color: #a5ff99; | ||
| border: 1px solid rgba(100, 182, 67, 0.3); | ||
| } | ||
|
|
||
| .line-count-item.removed { | ||
| background: rgba(160, 128, 100, 0.2); | ||
| color: #ffaa99; | ||
| border: 1px solid rgba(160, 128, 100, 0.3); | ||
| } | ||
|
|
||
| .line-count-item.modified { | ||
| background: rgba(182, 180, 67, 0.2); | ||
| color: #ecff99; | ||
| border: 1px solid rgba(182, 180, 67, 0.3); | ||
| } | ||
|
|
||
| .line-count-item.total { | ||
| background: rgba(69, 96, 248, 0.2); | ||
| color: #4560f8; | ||
| border: 1px solid rgba(69, 96, 248, 0.3); | ||
| } | ||
|
|
||
| .line-count-item.no-changes { | ||
| background: rgba(248, 248, 242, 0.1); | ||
| color: #f8f8f2; | ||
| border: 1px solid rgba(248, 248, 242, 0.2); | ||
| } | ||
|
|
||
| /* OBJECT COUNT DISPLAY */ | ||
| .object-count-display { | ||
| display: flex; | ||
| gap: 12px; | ||
| margin-top: 5px; | ||
| align-items: center; | ||
| font-size: 11px; | ||
| color: #f8f8f2; | ||
| margin-left: auto; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| .object-count-item-sub-holder { | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 4px; | ||
| } | ||
|
|
||
| .object-count-item { | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-weight: 500; | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .object-count-item.added { | ||
| background: rgba(100, 182, 67, 0.2); | ||
| color: #a5ff99; | ||
| border: 1px solid rgba(100, 182, 67, 0.3); | ||
| } | ||
|
|
||
| .object-count-item.removed { | ||
| background: rgba(160, 128, 100, 0.2); | ||
| color: #ffaa99; | ||
| border: 1px solid rgba(160, 128, 100, 0.3); | ||
| } | ||
|
|
||
| .object-count-item.modified { | ||
| background: rgba(182, 180, 67, 0.2); | ||
| color: #ecff99; | ||
| border: 1px solid rgba(182, 180, 67, 0.3); | ||
| } | ||
|
|
||
| .object-count-item.total { | ||
| background: rgba(69, 96, 248, 0.2); | ||
| color: #4560f8; | ||
| border: 1px solid rgba(69, 96, 248, 0.3); | ||
| } | ||
|
|
||
| .object-count-item.no-changes { | ||
| background: rgba(248, 248, 242, 0.1); | ||
| color: #f8f8f2; | ||
| border: 1px solid rgba(248, 248, 242, 0.2); | ||
| } | ||
|
Comment on lines
+46
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is significant CSS duplication between the styles for To improve maintainability and reduce code size, you could consolidate these into a set of common classes. For example: /* Common base class */
.stats-display {
display: flex;
gap: 12px;
margin-top: 5px;
/* ... other common styles */
}
.stats-item {
/* ... common item styles */
}
.stats-item.added {
/* ... added styles */
}
/* etc. */Then, in your React components, you can use these classes like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Later please, all can be refactored, I have plans for it. |
||
|
|
||
| .json-diff-viewer.json-diff-viewer-theme-custom .empty-equal-cell { | ||
| opacity: 0.4; | ||
| background: repeating-linear-gradient(-53deg, rgb(69, 69, 70), rgb(69, 69, 70) 1.5px, #282a36 1.5px, #282a36 4px); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.