Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/UnisonShare/DefinitionDiffCard.elm
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,28 @@ viewDiffSegment syntaxConfig segment =
]


viewGutter : Int -> Int -> String -> Html msg
viewGutter gutterWidth ln indicator =
span [ class "gutter" ]
[ span [ class "line-number" ]
[ text
(String.padLeft
gutterWidth
' '
(String.fromInt ln)
)
]
, text " "
, span [ class "change-indicator" ] [ text indicator ]
, text " "
]


viewDiffLine : (DiffSegment -> List (Html msg)) -> String -> Int -> DiffLine -> Html msg
viewDiffLine viewSeg changeIndicator gutterWidth line =
let
gutter ln indicator =
span [ class "gutter" ]
[ span [ class "line-number" ]
[ text
(String.padLeft
gutterWidth
' '
(String.fromInt ln)
)
]
, text " "
, span [ class "change-indicator" ] [ text indicator ]
, text " "
]
viewGutter gutterWidth ln indicator
in
case line of
ChangedLine { lineNum, segments } ->
Expand Down
42 changes: 31 additions & 11 deletions src/UnisonShare/Page/ProjectContributionChangesPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -477,23 +477,43 @@ viewChangedDefinitionCard projectRef toggledChangeLines branchDiff maxBadgeLengt
case ChangeLine.source changeLine of
Just source ->
let
linked =
let
branchRef =
case changeLine of
ChangeLine.Removed _ _ ->
branchDiff.oldBranch.ref
( branchRef, gutterIndicator ) =
case changeLine of
ChangeLine.Removed _ _ ->
( branchDiff.oldBranch.ref, "-" )

_ ->
branchDiff.newBranch.ref
in
ChangeLine.Added _ _ ->
( branchDiff.newBranch.ref, "+" )

_ ->
( branchDiff.newBranch.ref, "" )

linked =
SyntaxConfig.empty
|> SyntaxConfig.withToClick
(Link.projectBranchDefinition projectRef branchRef)

gutter =
let
lns =
List.range 1 (Syntax.numLines source)

viewLn ln =
div [ class "gutter" ]
[ span [ class "line-number" ] [ ln |> String.fromInt |> text ]
, text " "
, span [ class "change-indicator" ] [ text gutterIndicator ]
, text " "
]
in
div [ class "gutter-lines" ] (List.map viewLn lns)

expandedContent =
pre [ class "definition-syntax monochrome" ]
[ code [] [ Syntax.view linked source ] ]
div [ class "definition-source", class (String.toLower (ChangeLine.toString changeLine)) ]
[ gutter
, pre [ class "definition-syntax monochrome" ]
[ code [] [ Syntax.view linked source ] ]
]
in
( Just expandedContent
, Icon.collapseUp
Expand Down
32 changes: 28 additions & 4 deletions src/css/unison-share/page/project-contribution-changes-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,33 @@
}
}

& .definition-change.card .definition-syntax {
overflow-x: auto;
padding: 0.5rem 1rem;
.definition-change.card .definition-source {
display: flex;
flex-direction: row;
gap: 0.5rem;

.gutter:last-child {
border-bottom-left-radius: var(--border-radius-base);
}

.definition-syntax {
overflow-x: auto;
line-height: var(--diff-line-height);
}

&.added {
background: var(--color-green-5);
.gutter {
color: var(--color-green-1);
}
}

&.removed {
background: var(--color-pink-5);
.gutter {
color: var(--color-pink-1);
}
}
}

& .definition-change.card .diff-side-by-side {
Expand Down Expand Up @@ -323,7 +347,7 @@
line-height: 1;
}

& .definition-change.card .gutter {
& .gutter {
background: var(--u-color_element_subdued);
color: var(--u-color_text_very-subdued);
border-right: 1px solid var(--u-color_border_subdued);
Expand Down
2 changes: 1 addition & 1 deletion webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const docExamplesReadmeDef = require("./api-stubs/doc-examples-readme-definition
const blogEngineLib = require("./api-stubs/blog-engine-lib.json");
const browseBlog = require("./api-stubs/browse-blog.json");
const notifications = require("./api-stubs/notifications.json");
const branchDiff = require("./api-stubs/branch-diff-with-libs.json");
const branchDiff = require("./api-stubs/branch-diff-weird-equals.json");

// ENV
const API_URL = process.env.API_URL || "http://127.0.0.1:5424";
Expand Down
Loading