-
Notifications
You must be signed in to change notification settings - Fork 60
Other declaration pills should be clickable when there are changes data #832
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
Merged
hqhhuang
merged 18 commits into
swiftlang:main
from
hqhhuang:decl-diff-other-decl-button-clickable
Jun 26, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c742a43
Refactor the DeclarationGroup/List logic
hqhhuang 21346ba
pill shouldn't be selected if the list is in expanded state
hqhhuang 0a638e4
Fix background color of selected pill & clean up css
hqhhuang b3b1591
improve animation for long decl list
hqhhuang 36bdb9c
remove unnecessary checks in `Declaration` test
hqhhuang 1d0af53
add test for `DeclarationGroup`
hqhhuang c097379
fix changes class for decl without other decls
hqhhuang c1230fe
fix modified declaration with no other decl
hqhhuang cf39c4e
Add test for `DeclarationList`
hqhhuang 80723fe
Update test for `DeclarationDiff`
hqhhuang 91711e2
Merge branch 'main' into decl-diff-other-decl-button-clickable
hqhhuang 9b46ad6
chore: remove extra empty line
hqhhuang 9f2853d
do not highlight diff in collapsed state
hqhhuang 6c87be5
remove `isSwift` prop
hqhhuang 7dbf585
remove `changeType` prop
hqhhuang 1ca50ab
Merge branch 'main' into decl-diff-other-decl-button-clickable
hqhhuang f5ad65c
fix test
hqhhuang 16f6050
Merge branch 'decl-diff-other-decl-button-clickable' of github.com:hq…
hqhhuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
src/components/DocumentationTopic/PrimaryContent/DeclarationGroup.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<!-- | ||
This source file is part of the Swift.org open source project | ||
|
||
Copyright (c) 2024 Apple Inc. and the Swift project authors | ||
Licensed under Apache License v2.0 with Runtime Library Exception | ||
|
||
See https://swift.org/LICENSE.txt for license information | ||
See https://swift.org/CONTRIBUTORS.txt for Swift project authors | ||
--> | ||
|
||
<template> | ||
<div | ||
class="declaration-group" | ||
:class="classes" | ||
ref="apiChangesDiff" | ||
> | ||
<p v-if="shouldCaption" class="platforms"> | ||
<strong>{{ caption }}</strong> | ||
</p> | ||
<Source | ||
:tokens="declaration.tokens" | ||
:language="interfaceLanguage" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import DeclarationSource from 'docc-render/components/DocumentationTopic/PrimaryContent/DeclarationSource.vue'; | ||
import Language from 'docc-render/constants/Language'; | ||
import { APIChangesMultipleLines } from 'docc-render/mixins/apiChangesHelpers'; | ||
|
||
/** | ||
* Renders a code source with an optional caption. | ||
*/ | ||
export default { | ||
name: 'DeclarationGroup', | ||
components: { | ||
Source: DeclarationSource, | ||
}, | ||
mixins: [APIChangesMultipleLines], | ||
inject: { | ||
languages: { | ||
default: () => new Set(), | ||
}, | ||
interfaceLanguage: { | ||
default: () => Language.swift.key.api, | ||
}, | ||
symbolKind: { | ||
default: () => undefined, | ||
}, | ||
}, | ||
props: { | ||
declaration: { | ||
type: Object, | ||
required: true, | ||
}, | ||
/** | ||
* Whether to show the caption or not. | ||
* Usually if there is more than Declaration group. | ||
*/ | ||
shouldCaption: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
/** | ||
* The type of code change. | ||
* @type {"added"|"deprecated"|"modified"} | ||
*/ | ||
changeType: { | ||
type: String, | ||
required: false, | ||
}, | ||
}, | ||
computed: { | ||
classes: ({ | ||
changeType, | ||
multipleLinesClass, | ||
displaysMultipleLinesAfterAPIChanges, | ||
}) => ({ | ||
[`declaration-group--changed declaration-group--${changeType}`]: changeType, | ||
[multipleLinesClass]: displaysMultipleLinesAfterAPIChanges, | ||
}), | ||
caption() { | ||
return this.declaration.platforms.join(', '); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import 'docc-render/styles/_core.scss'; | ||
|
||
.platforms { | ||
@include font-styles(body-reduced); | ||
|
||
margin-bottom: 0.45rem; | ||
margin-top: var(--spacing-stacked-margin-xlarge); | ||
|
||
.changed & { | ||
padding-left: $code-source-spacing; | ||
} | ||
|
||
&:first-of-type { | ||
margin-top: 1rem; | ||
} | ||
} | ||
|
||
.source { | ||
transition: margin 0.3s linear; | ||
|
||
.platforms + & { | ||
margin: 0; | ||
} | ||
} | ||
|
||
// don't highlight tokens in initial declaration until the user has explicitly | ||
// expanded a list of overloaded declarations — this rule could be simplified | ||
// in the future if the HTML is restructured to have an expanded state class for | ||
// the whole list instead of having it on each declaration | ||
.declaration-pill:not(.declaration-pill--expanded) { | ||
.source:deep(.highlighted) { | ||
background: unset; | ||
font-weight: normal; | ||
} | ||
} | ||
|
||
// only applicable for when other declaration list is expanded | ||
.declaration-pill--expanded { | ||
$docs-declaration-source-border-width: 1px; | ||
|
||
.source { | ||
border-width: $docs-declaration-source-border-width; | ||
|
||
// ensure links are not clickable, when expanded | ||
:deep(a) { | ||
pointer-events: none; | ||
} | ||
} | ||
|
||
&.selected-declaration { | ||
.source { | ||
border-color: var(--color-focus-border-color, var(--color-focus-border-color)); | ||
} | ||
} | ||
|
||
&:not(.selected-declaration) { | ||
.source { | ||
background: none; | ||
} | ||
} | ||
} | ||
|
||
@include changedStyles { | ||
.source { | ||
// background should also be applied over changed icon over whole pill | ||
background: none; | ||
border: none; | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
margin-left: $change-icon-occupied-space; | ||
padding-left: 0; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove
changeType
as a prop for this component? It doesn't seem like it's being used anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's still used when we use the
DeclarationList
component inDeclaration.vue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ops you meant
DeclarationDiff
component, notDeclarationList
lol