Skip to content

Commit 8d76a21

Browse files
committed
Feat: Add a custom icon
- Add setting "custom" - Possible white icon with||without dark icon - Improve tap target
1 parent d577300 commit 8d76a21

File tree

5 files changed

+62
-22
lines changed

5 files changed

+62
-22
lines changed

scaladoc/resources/dotty_res/styles/theme/components/button/icon-button.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,28 @@
533533
content: url("../../../../images/icon-buttons/gitter/dark/selected.svg");
534534
}
535535

536+
/* custom button */
537+
538+
.icon-button.custom-dark{
539+
display: none;
540+
}
541+
542+
.theme-dark .icon-button.custom-dark{
543+
display: unset;
544+
}
545+
546+
.theme-dark .icon-button.custom{
547+
display: none;
548+
}
549+
550+
.icon-button.custom:hover{
551+
opacity: 0.8;
552+
}
553+
554+
.icon-button.custom-dark:hover{
555+
opacity: 0.8;
556+
}
557+
536558
/* copy button */
537559

538560
.icon-button.copy-button::after {

scaladoc/resources/dotty_res/styles/theme/layout/footer.css

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
background-color: var(--action-primary-background-default-solid);
55
height: calc(6 * var(--base-spacing));
66
width: 100%;
7-
padding: calc(2 * var(--base-spacing));
7+
padding: 0 calc(2 * var(--base-spacing));
88
display: flex;
99
align-items: center;
1010
color: var(--text-primary);
@@ -52,6 +52,7 @@
5252

5353
#footer {
5454
display: none;
55+
padding: calc(2 * var(--base-spacing));
5556
}
5657

5758
#footer.mobile-footer {
@@ -64,7 +65,7 @@
6465
display: none;
6566
}
6667

67-
#footer.mobile-footer .text-mobile {
68+
#footer.mobile-footer .text-mobile {
6869
display: flex;
6970
width: 100%;
7071
justify-content: center;
@@ -78,5 +79,22 @@
7879
#footer.mobile-footer > .text-mobile {
7980
display: flex;
8081
}
81-
82+
83+
}
84+
85+
@media (min-width: 375px) {
86+
87+
#footer .right-container a {
88+
padding: 8px;
89+
}
90+
91+
}
92+
93+
@media (min-width: 480px) {
94+
95+
#footer .right-container a {
96+
margin: 0 4px 0;
97+
padding: 16px;
98+
}
99+
82100
}

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
5656

5757
val socialLinks: Setting[List[String]] =
5858
MultiStringSetting("-social-links", "social-links",
59-
"Links to social sites. '[github|twitter|gitter|discord]::link' syntax is used.")
59+
"Links to social sites. '[github|twitter|gitter|discord]::link' syntax is used." +
60+
"'custom::link::white_icon_name::black_icon_name' is also allowed, in this case icons must be present in 'images/'' directory.")
6061

6162
val deprecatedSkipPackages: Setting[List[String]] =
6263
MultiStringSetting("-skip-packages", "packages", "Deprecated, please use `-skip-by-id` or `-skip-by-regex`")

scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import java.nio.file.Path
44
import java.nio.file.Paths
55
import dotty.tools.dotc.core.Contexts.Context
66

7-
enum SocialLinks(val url: String, val className: String):
8-
case Github(ghUrl: String) extends SocialLinks(ghUrl, "gh")
9-
case Twitter(tUrl: String) extends SocialLinks(tUrl, "twitter")
10-
case Gitter(gUrl: String) extends SocialLinks(gUrl, "gitter")
11-
case Discord(dUrl: String) extends SocialLinks(dUrl, "discord")
7+
enum SocialLinks(val url: String, val whiteIcon: String, val darkIcon: String, val className: String):
8+
case Github(ghUrl: String) extends SocialLinks(ghUrl, "", "", "gh")
9+
case Twitter(tUrl: String) extends SocialLinks(tUrl, "", "", "twitter")
10+
case Gitter(gUrl: String) extends SocialLinks(gUrl, "", "", "gitter")
11+
case Discord(dUrl: String) extends SocialLinks(dUrl, "", "", "discord")
12+
case Custom(cUrl: String, firstIcon: String, secondIcon: String) extends SocialLinks(cUrl, firstIcon, secondIcon, "custom")
1213

1314
object SocialLinks:
1415
def parse(s: String): Either[String, SocialLinks] =
@@ -23,5 +24,8 @@ object SocialLinks:
2324
case "gitter" => Left(errorPrefix + "For 'gitter' arg expected one argument: url")
2425
case "discord" if splitted.size == 2 => Right(Discord(splitted(1)))
2526
case "discord" => Left(errorPrefix + "For 'discord' arg expected one argument: url")
27+
case "custom" if splitted.size == 4 => Right(Custom(splitted(1), splitted(2), splitted(3)))
28+
case "custom" if splitted.size == 3 => Right(Custom(splitted(1), splitted(2), splitted(2)))
29+
case "custom" => Left(errorPrefix + "For 'custom' arg expected three arguments: url, white icon name, black icon name")
2630
case _ => Left(errorPrefix)
2731
}

scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
175175
def icon(link: SocialLinks) = link.className
176176
args.socialLinks.map { link =>
177177
a(href := link.url) (
178-
button(cls := s"icon-button ${icon(link)}")
178+
if icon(link) == "custom" then
179+
Seq(
180+
img(cls := s"icon-button ${icon(link)}", src := s"../../../../images/${link.whiteIcon}"),
181+
img(cls := s"icon-button ${icon(link)}-dark", src := s"../../../../images/${link.darkIcon}")
182+
)
183+
else
184+
button(cls := s"icon-button ${icon(link)}")
179185
)
180186
}
181187

@@ -317,18 +323,7 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
317323
"Generated with"
318324
),
319325
div(cls := "right-container")(
320-
a(href := "https://github.com/lampepfl/dotty") (
321-
button(cls := "icon-button gh")
322-
),
323-
a(href := "https://twitter.com/scala_lang") (
324-
button(cls := "icon-button twitter")
325-
),
326-
a(href := "https://discord.com/invite/scala") (
327-
button(cls := "icon-button discord"),
328-
),
329-
a(href := "https://gitter.im/scala/scala") (
330-
button(cls := "icon-button gitter"),
331-
),
326+
socialLinks,
332327
div(cls := "text")(textFooter)
333328
),
334329
div(cls := "text-mobile")(textFooter)

0 commit comments

Comments
 (0)