Skip to content

Commit 1117529

Browse files
author
Dobromir Hristov
authored
Move changes icons left and remove width compensation (#249)
closes rdar://91807576 * refactor: moves the API changes icon to the left * refactor: remove the alignment fixes when API changes are ON * refactor: remove change-highlight-horizontal-text-alignment-small and change-highlight-horizontal-text-alignment
1 parent 4f6c290 commit 1117529

File tree

8 files changed

+27
-43
lines changed

8 files changed

+27
-43
lines changed

src/components/DocumentationTopic/PrimaryContent/DeclarationGroup.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ export default {
119119
border: none;
120120
margin-top: 0;
121121
margin-bottom: 0;
122-
margin-right: $change-icon-width + $change-highlight-horizontal-space-rem;
123-
padding-right: 0;
122+
margin-left: $change-icon-occupied-space;
123+
padding-left: 0;
124124
}
125125
}
126126
</style>

src/components/DocumentationTopic/PrimaryContent/ParametersTable.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ $param-spacing: rem(28px);
105105
flex-flow: row wrap;
106106
width: 100%;
107107
@include change-highlight-target();
108-
@include change-highlight-horizontal-text-alignment-small();
109108
110109
& + & {
111110
margin-top: $param-spacing/2;

src/components/DocumentationTopic/RelationshipsList.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export default {
151151
152152
&.changed {
153153
@include change-highlight-target();
154-
@include change-highlight-horizontal-text-alignment();
155154
156155
&:after {
157156
margin-top: $change-coin-y-offset-reduced;

src/components/DocumentationTopic/TopicsLinkBlock.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class="link"
1818
ref="apiChangesDiff"
1919
>
20-
<TopicLinkBlockIcon v-if="topic.role" :role="topic.role" />
20+
<TopicLinkBlockIcon v-if="topic.role && !change" :role="topic.role" />
2121
<DecoratedTopicTitle v-if="topic.fragments" :tokens="topic.fragments" />
2222
<WordBreak v-else :tag="titleTag">{{ topic.title }}</WordBreak>
2323
<span v-if="change" class="visuallyhidden">- {{ changeName }}</span>
@@ -256,7 +256,6 @@ export default {
256256
257257
&.changed {
258258
@include change-highlight-target();
259-
@include change-highlight-horizontal-text-alignment();
260259
box-sizing: border-box;
261260
}
262261
}

src/styles/base/_changes.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525

2626
&::after {
27-
right: 0;
27+
left: $change-coin-x-offset;
2828
@include coin($modified-svg, $change-icon-width);
2929
margin-top: $change-coin-y-offset-reduced;
3030
// Workaround for a bug, where -webkit-backdrop-filter not working on iOS when <pre> has `overflow: auto`

src/styles/core/_changes.scss

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ $change-border-stroke-width: 1px;
1212
$change-total-icon-width: rem(17px);
1313
$change-highlight-vertical-space: 7px;
1414
$change-icon-width: rem(20px);
15-
$change-highlight-horizontal-space: 14px;
15+
$change-highlight-horizontal-space: 17px;
1616
$change-highlight-horizontal-space-rem: rem($change-highlight-horizontal-space);
1717
$change-highlight-vertical-space-total: $change-highlight-vertical-space + $change-border-stroke-width;
18+
1819
// Width of highlight endcaps only used in this file
1920
$change-total-coin-space: rem(5px);
2021
$change-coin-y-offset: 10px;
2122
$change-coin-y-offset-reduced: rem($change-highlight-vertical-space-total) + $change-total-coin-space/2;
22-
23+
$change-coin-x-offset: $change-highlight-horizontal-space - 9px;
24+
// the space needed for the change icon + it's margin
25+
$change-icon-occupied-space: $change-icon-width + $change-highlight-horizontal-space-rem;
2326
// Paths to the changes icons
2427
$modified-svg: url('~theme/assets/img/icons/modified-icon.svg') !default;
2528
$modified-dark-svg: $modified-svg !default;
@@ -51,7 +54,7 @@ $deprecated-dark-rounded-svg: $deprecated-svg !default;
5154
bottom: 0;
5255
content: " ";
5356
margin: auto;
54-
margin-right: ($change-highlight-horizontal-space - 5);
57+
margin-right: $change-coin-x-offset;
5558
position: absolute;
5659
top: 0;
5760
width: $size;
@@ -70,6 +73,8 @@ $deprecated-dark-rounded-svg: $deprecated-svg !default;
7073
// vertical block of wrapped names to be clickable, even if a user happens
7174
// to click the space in between lines
7275
display: inline-flex;
76+
width: 100%;
77+
box-sizing: border-box;
7378

7479
@include breakpoint(small) {
7580
padding-left: 0;
@@ -78,15 +83,15 @@ $deprecated-dark-rounded-svg: $deprecated-svg !default;
7883
}
7984

8085
@mixin change-highlight-end-spacing() {
81-
padding-right: $change-icon-width + $change-highlight-horizontal-space-rem;
86+
padding-left: $change-icon-occupied-space;
8287
}
8388

8489
@mixin change-highlight-horizontal-spacing() {
85-
padding-left: rem($change-highlight-horizontal-space);
90+
padding-right: $change-highlight-horizontal-space-rem;
8691
@include change-highlight-end-spacing();
8792

8893
&.changed {
89-
padding-left: $change-highlight-horizontal-space;
94+
padding-right: $change-highlight-horizontal-space-rem;
9095
}
9196

9297
@include breakpoint(small) {
@@ -95,7 +100,7 @@ $deprecated-dark-rounded-svg: $deprecated-svg !default;
95100
padding-right: 0;
96101

97102
&.changed {
98-
padding-left: $change-highlight-horizontal-space;
103+
padding-right: $change-highlight-horizontal-space;
99104
@include change-highlight-end-spacing();
100105
}
101106
}
@@ -105,34 +110,6 @@ $deprecated-dark-rounded-svg: $deprecated-svg !default;
105110
padding-top: $change-highlight-vertical-space-total;
106111
padding-bottom: $change-highlight-vertical-space-total;
107112
}
108-
///
109-
/// Counteracts the left (start) padding created by `change-highlight-horizontal-spacing()`
110-
/// in order to keep the text aligned with its siblings.
111-
/// The 1 value represents the border width.
112-
///
113-
@mixin change-highlight-horizontal-text-alignment() {
114-
margin-left: rem(-$change-highlight-horizontal-space - 1);
115-
width: calc(100% + #{$change-highlight-horizontal-space} + 1px);
116-
117-
@include change-highlight-horizontal-text-alignment-small();
118-
}
119-
120-
///
121-
/// Small vp specific padding and margin to have margin go outside of content symmetrically
122-
///
123-
@mixin change-highlight-horizontal-text-alignment-small() {
124-
@include breakpoint(small) {
125-
&:not(.changed) {
126-
margin-left: 0;
127-
width: 100%;
128-
}
129-
130-
&.changed {
131-
margin-left: rem(-$change-highlight-horizontal-space);
132-
width: calc(100% + #{$change-highlight-horizontal-space * 2});
133-
}
134-
}
135-
}
136113

137114
////
138115
/// Apply styles related to the API diff/changes functionality

src/styles/core/_vars.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $article-stacked-margin-small: 20px;
3131

3232
// TopicLink components
3333
$topic-link-icon-width: 1.294rem;
34-
$topic-link-icon-spacing: 0.5em;
34+
$topic-link-icon-spacing: 1rem;
3535

3636
// Code Block Style Elements
3737
$code-block-style-elements-padding: 8px 14px !default;

tests/unit/components/DocumentationTopic/TopicsLinkBlock.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,16 @@ describe('TopicsLinkBlock', () => {
483483
expect(linkBlock.classes(`changed-${changeType}`)).toBe(!isOnLink);
484484
};
485485

486+
it('does not render the TopicLinkBlockIcon', () => {
487+
expect(wrapper.find(TopicLinkBlockIcon).exists()).toBe(true);
488+
store.state.apiChanges = {
489+
[propsData.topic.identifier]: {
490+
change: 'modified',
491+
},
492+
};
493+
expect(wrapper.find(TopicLinkBlockIcon).exists()).toBe(false);
494+
});
495+
486496
describe('when the topic does not have an abstract', () => {
487497
beforeEach(() => {
488498
wrapper = shallowMount(TopicsLinkBlock, {

0 commit comments

Comments
 (0)