Skip to content

Commit 8fa2eb9

Browse files
authored
Reduce duplicated code for banners (#749)
Unifies the banner and CTA css styles used on multiple pages. Moves the element to a common location so the it can be found in the source easily and be reused across pages.
1 parent 2b3297c commit 8fa2eb9

File tree

8 files changed

+41
-27
lines changed

8 files changed

+41
-27
lines changed

assets/stylesheets/_elements.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "elements/banner";

assets/stylesheets/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ layout: source
66
@import "colors";
77
@import "syntax";
88
@import "screen";
9+
@import "elements";
910
@import "mobile";
1011
@import "pages";
1112
@import "print";

assets/stylesheets/core/colors/_dark.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525

2626
--color-banner-foreground: rgb(240, 81, 56);
2727
--color-banner-background: rgb(240, 81, 56, 0.1);
28+
--color-banner-border: rgb(240, 81, 56, 0.15);
2829
--color-banner-detail: rgb(240, 81, 56, 0.5);
30+
2931
--color-article-body-background: rgb(17, 17, 17);
3032
--color-button-background-active: #{dark-color(fill-blue)};
3133
--color-dropdown-background: var(--color-dropdown-dark-background);

assets/stylesheets/core/colors/_light.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
--color-banner-foreground: rgb(222, 75, 52);
2828
--color-banner-background: rgb(222, 75, 52, 0.1);
29+
--color-banner-border: rgb(222, 75, 52, 0.15);
2930
--color-banner-detail: rgb(222, 75, 52, 0.5);
31+
3032
--color-article-background: var(--color-fill-tertiary);
3133
--color-article-body-background: var(--color-fill);
3234
--color-aside-deprecated: var(--color-figure-gray);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Default callout banner
2+
.banner {
3+
padding: 0.75rem 1.25rem;
4+
5+
color: var(--color-text);
6+
border: 1px solid var(--color-fill-tertiary);
7+
background: var(--color-fill-secondary);
8+
border-radius: var(--border-radius);
9+
10+
p {
11+
margin: 0;
12+
}
13+
}
14+
15+
// Orange attention grabbing banner
16+
.banner.primary {
17+
color: var(--color-banner-foreground);
18+
border: 1px solid var(--color-banner-border);
19+
background: var(--color-banner-background);
20+
font-weight: 500;
21+
text-align: center;
22+
23+
a {
24+
color: inherit;
25+
text-decoration: underline;
26+
text-decoration-color: var(--color-banner-detail);
27+
text-underline-offset: 2px;
28+
29+
&:hover {
30+
color: var(--color-banner-foreground);
31+
}
32+
}
33+
}

assets/stylesheets/pages/_landing.scss

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,6 @@
6161
}
6262
}
6363

64-
.banner {
65-
padding: 0.75rem 1.25rem;
66-
margin: 2rem 0;
67-
color: var(--color-banner-foreground);
68-
background: var(--color-banner-background);
69-
font-weight: 500;
70-
text-align: center;
71-
border-radius: var(--border-radius);
72-
73-
p {
74-
margin: 0;
75-
}
76-
77-
a {
78-
color: inherit;
79-
text-decoration: underline;
80-
text-decoration-color: var(--color-banner-detail);
81-
text-underline-offset: 2px;
82-
83-
&:hover {
84-
text-decoration-color: var(--color-banner-foreground);
85-
}
86-
}
87-
}
88-
8964
.link-grid {
9065
ul {
9166
display: grid;

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ atom: true
1616
{% endfor %}
1717
</div>
1818

19-
<div class="banner">
19+
<div class="banner primary">
2020
<p>Get ready for the Swift 6 language mode with the <a href="https://www.swift.org/migration/documentation/migrationguide/">official migration guide</a></p>
2121
</div>
2222

packages/_get-involved.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<p class="cta">
1+
<p class="banner">
22
<strong>Get involved!</strong> Packages in the Community Showcase are nominated by community members like you. This is your chance to share new or interesting packages with others. <a href="https://forums.swift.org/t/68168">Nominate packages here</a> and you could see them featured next month!
33
</p>

0 commit comments

Comments
 (0)