Skip to content

[6.0] Other declaration pills should be clickable when there are changes data #874

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
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<template v-else>
<DeclarationList
v-for="(declaration, i) in declarations"
:class="changeClasses"
:key="i"
:declaration="declaration"
:shouldCaption="hasPlatformVariants"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
:key="i"
:declaration="declaration"
:should-caption="currentDeclarations.length > 1"
:changeType="changeType"
/>
</div>
<div class="declaration-diff-previous">
Expand All @@ -27,7 +26,6 @@
:key="i"
:declaration="declaration"
:should-caption="previousDeclarations.length > 1"
:changeType="changeType"
/>
</div>
</div>
Expand All @@ -50,14 +48,6 @@ export default {
type: Object,
required: true,
},
/**
* The applied change type to the diff.
* @type {"added"|"deprecated"|"modified"}
*/
changeType: {
type: String,
required: true,
},
},
computed: {
previousDeclarations: ({ changes }) => changes.declaration.previous || [],
Expand Down
164 changes: 164 additions & 0 deletions src/components/DocumentationTopic/PrimaryContent/DeclarationGroup.vue
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>
Loading