Skip to content

Commit 39f140a

Browse files
committed
fix diff view width for change indication
1 parent beeb9a9 commit 39f140a

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

ui/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# gitconvex react project
2-
This is the front end react source for the [gitconvex](https://github.com/neel1996/gitconvex) project.
2+
This is the front-end react source for [gitconvex](https://github.com/neel1996/gitconvex).
33

44
<p align="center">
55
<img src="https://user-images.githubusercontent.com/47709856/87220396-e72df380-c380-11ea-9b2b-e156402842bb.png" width="280">
@@ -9,13 +9,13 @@ This is the front end react source for the [gitconvex](https://github.com/neel19
99

1010
The depedency packages used by this project can be found [here](https://github.com/neel1996/gitconvex-ui/network/dependencies)
1111

12-
- **🎨 Styling** - For styling, the project used [tailwind]() css framework
13-
- **📑 Syntax Highlighting** - [prismjs](https://github.com/PrismJS/prism) is used for syntax highlighting within the *Git Difference* section
12+
- **🎨 Styling** - For styling, the project uses [tailwind]() css framework
13+
- **📑 Syntax Highlighting** - [prismjs](https://github.com/PrismJS/prism) is used for syntax highlighting within the *Git Difference* and *CodeView* section
1414
- **🎭 Icon set** - [FontAweomse for react](https://github.com/FortAwesome/Font-Awesome)
1515

1616
## Contribute!
1717

18-
If you are interested in contributing to the project, fork the repo, submit a PR. Currently its just a single dev working on the project. Hopefully will get couple more on board to maintain the repo
18+
If you are interested in contributing to the project, fork the repo and submit a PR. Currently there are only 3 maintainers working on the project, so the review may take some time. Hopefully will get a couple more on board soon to maintain the repo
1919

2020
### Guidelines
2121

@@ -34,7 +34,7 @@ $ npm install
3434

3535
- **Building the css file**
3636

37-
The project uses `tailwindcss` for styling all the elements, so it is mandatory to build the CSS file which is not included in the git tree. Follow the steps to build the css file
37+
The project uses `tailwindcss v2.0.2` for styling all the elements, so it is mandatory to build the CSS file which is not included in the repo. Follow the steps to build the css file
3838

3939
```
4040
@@ -46,7 +46,7 @@ $ npm run build:tailwind
4646
## This will generate a default tailwind css bundle
4747
4848
```
49-
> **Note:** The final production build stage is configured to purge unused CSS selectors from the tailwind css file. So make sure you follow the [tailwind purge guidelines](https://tailwindcss.com/docs/controlling-file-size#writing-purgeable-html:~:text=Don't%20use%20string%20concatenation%20to%20create%20class%20names) to make sure that the required styles are not getting purged from the [production bundle](https://github.com/neel1996/gitconvex)
49+
> **Note:** The final production build stage is configured to purge unused CSS selectors from the tailwind css file. So make sure you follow the [tailwind purge guidelines](https://tailwindcss.com/docs/controlling-file-size#writing-purgeable-html:~:text=Don't%20use%20string%20concatenation%20to%20create%20class%20names) to ensure that the required styles are included to the [production bundle](https://github.com/neel1996/gitconvex)
5050
5151
- **Starting the app**
5252

@@ -148,11 +148,11 @@ After completing the setup process, use `npm start` to start the react app
148148
│   └── RightPane.css
149149
├── actionStore.js
150150
├── assets
151-
│   └── gitconvex.png
151+
│   ├── gitconvex.png
152+
│   └── icons
152153
├── context.js
153154
├── index.css
154155
├── index.js
155-
├── logo.svg
156156
├── postcss.config.js
157157
├── prism.css
158158
├── reducer.js
@@ -164,9 +164,10 @@ After completing the setup process, use `npm start` to start the react app
164164
│   └── Dashboard.test.js
165165
└── util
166166
├── apiURLSupplier.js
167-
└── env_config.js
167+
├── env_config.js
168+
└── relativeCommitTimeCalculator.js
168169
169-
21 directories, 88 files
170+
22 directories, 88 files
170171
171172
```
172173

ui/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/src/Components/DashBoard/Repository/GitComponents/GitDiffViewComponent.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function GitDiffViewComponent() {
2222
const [isApiCalled, setIsApiCalled] = useState(false);
2323
const [warnStatus, setWarnStatus] = useState("");
2424
const [lang, setLang] = useState("");
25+
const [diffWidth, setDiffWidth] = useState(0);
2526

2627
useEffect(() => {
2728
let repoId = state.globalRepoId;
@@ -196,6 +197,11 @@ export default function GitDiffViewComponent() {
196197
setDiffStatState(diffStat);
197198
setFileLineDiffState(fileDiff);
198199

200+
// Logic to set width for code lines based on max scroll width
201+
const target = document.getElementById("codeDiffWrapper");
202+
const targetWidth = target.scrollWidth;
203+
setDiffWidth(targetWidth);
204+
199205
let language;
200206
let langName = new LangLine().withFileName(fileName).prismIndicator;
201207

@@ -273,8 +279,9 @@ export default function GitDiffViewComponent() {
273279
if (line[0] && line[0] === "+") {
274280
return (
275281
<div
276-
className="w-full flex items-center gap-1 bg-green-100 w-screen"
282+
className="flex items-center gap-1 bg-green-100 w-screen"
277283
key={`${line}-${uuidv4()}`}
284+
style={diffWidth ? { width: `${diffWidth}px` } : null}
278285
>
279286
<div className="font-sans text-center w-16 mx-2 border-r border-green-400 text-green-500">
280287
{++lineCounter}
@@ -295,8 +302,9 @@ export default function GitDiffViewComponent() {
295302
} else if (line[0] && line[0] === "-") {
296303
return (
297304
<div
298-
className="w-full flex items-center gap-1 bg-red-100 w-screen"
305+
className="flex items-center gap-1 bg-red-100 w-screen"
299306
key={`${line}-${uuidv4()}`}
307+
style={diffWidth ? { width: `${diffWidth}px` } : null}
300308
>
301309
<div className="font-sans text-center w-16 mx-2 border-r border-red-400 text-red-400">
302310
-
@@ -318,8 +326,9 @@ export default function GitDiffViewComponent() {
318326
if (line[0]) {
319327
return (
320328
<div
321-
className="w-full flex items-center gap-1 bg-white-200 w-screen"
329+
className="flex items-center gap-1 bg-white-200 w-screen"
322330
key={`${line}-${uuidv4()}`}
331+
style={diffWidth ? { width: `${diffWidth}px` } : null}
323332
>
324333
<div className="font-sans text-gray-300 text-center w-16 mx-2 border-r border-gray-200">
325334
{++lineCounter}
@@ -387,6 +396,7 @@ export default function GitDiffViewComponent() {
387396
"Click on a file item to see the difference" ? (
388397
<div
389398
className="p-3 overflow-auto break-words w-full"
399+
id="codeDiffWrapper"
390400
style={{ height: "800px" }}
391401
>
392402
{fileLineDiffComponent()}

0 commit comments

Comments
 (0)