Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -533,6 +533,50 @@
content: url("../../../../images/icon-buttons/gitter/dark/selected.svg");
}

/* custom button */

.icon-button.custom-dark{
display: none;
}

.icon-button.custom::after {
content: "";
background-image: var(--bgimage);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
display: block;
max-width: 100%;
max-height: 100%;
}

.theme-dark .icon-button.custom-dark{
display: unset;
}

.theme-dark .icon-button.custom-dark::after{
content: "";
background-image: var(--bgimage-dark);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
display: block;
max-width: 100%;
max-height: 100%;
}

.theme-dark .icon-button.custom{
display: none;
}

.icon-button.custom:hover{
opacity: 0.8;
}

.icon-button.custom-dark:hover{
opacity: 0.8;
}

/* copy button */

.icon-button.copy-button::after {
Expand Down Expand Up @@ -830,4 +874,4 @@

.theme-dark .documentableElement .ar.icon-button.expanded.selected::after {
content: url("../../../../images/icon-buttons/arrow-down/dark/selected.svg");
}
}
4 changes: 2 additions & 2 deletions scaladoc/resources/dotty_res/styles/theme/layout/footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
display: none;
}

#footer.mobile-footer .text-mobile {
#footer.mobile-footer .text-mobile {
display: flex;
width: 100%;
justify-content: center;
Expand All @@ -78,5 +78,5 @@
#footer.mobile-footer > .text-mobile {
display: flex;
}

}
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:

val socialLinks: Setting[List[String]] =
MultiStringSetting("-social-links", "social-links",
"Links to social sites. '[github|twitter|gitter|discord]::link' syntax is used.")
"Links to social sites. '[github|twitter|gitter|discord]::link' or 'custom::link::light_icon_file_name[::dark_icon_file_name]' syntax is used. For custom links, the icons must be present in '_assets/images/'")

val deprecatedSkipPackages: Setting[List[String]] =
MultiStringSetting("-skip-packages", "packages", "Deprecated, please use `-skip-by-id` or `-skip-by-regex`")
Expand Down
7 changes: 7 additions & 0 deletions scaladoc/src/dotty/tools/scaladoc/SocialLinks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ enum SocialLinks(val url: String, val className: String):
case Twitter(tUrl: String) extends SocialLinks(tUrl, "twitter")
case Gitter(gUrl: String) extends SocialLinks(gUrl, "gitter")
case Discord(dUrl: String) extends SocialLinks(dUrl, "discord")
case Custom(cUrl: String, lightIcon: String, darkIcon: String) extends SocialLinks(cUrl, "custom")

object SocialLinks:
val LowercaseNamePattern = "^[a-z]+$".r

def parse(s: String): Either[String, SocialLinks] =
val errorPrefix = s"Social links arg $s is invalid: "
val splitted = s.split("::")

splitted.head match {
case "github" if splitted.size == 2 => Right(Github(splitted(1)))
case "github" => Left(errorPrefix + "For 'github' arg expected one argument: url")
Expand All @@ -19,5 +23,8 @@ object SocialLinks:
case "gitter" => Left(errorPrefix + "For 'gitter' arg expected one argument: url")
case "discord" if splitted.size == 2 => Right(Discord(splitted(1)))
case "discord" => Left(errorPrefix + "For 'discord' arg expected one argument: url")
case LowercaseNamePattern() if splitted.size == 4 => Right(Custom(splitted(1), splitted(2), splitted(3)))
case LowercaseNamePattern() if splitted.size == 3 => Right(Custom(splitted(1), splitted(2), splitted(2)))
case LowercaseNamePattern() => Left(errorPrefix + "For 'custom' two minimum arguments are expected: url, white icon name, [dark icon name]")
case _ => Left(errorPrefix)
}
22 changes: 9 additions & 13 deletions scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,14 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
def icon(link: SocialLinks) = link.className
args.socialLinks.map { link =>
a(href := link.url) (
button(cls := s"icon-button ${icon(link)}")
link match
case SocialLinks.Custom(_, lightIcon, darkIcon) =>
Seq(
button(cls := s"icon-button ${icon(link)}", style := s"--bgimage:url(../../../../images/$lightIcon)"),
button(cls := s"icon-button ${icon(link)}-dark", style := s"--bgimage-dark:url(../../../../images/$darkIcon)")
)
case _ =>
button(cls := s"icon-button ${icon(link)}")
)
}

Expand Down Expand Up @@ -308,18 +315,7 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
"Generated with"
),
div(cls := "right-container")(
a(href := "https://github.com/lampepfl/dotty") (
button(cls := "icon-button gh")
),
a(href := "https://twitter.com/scala_lang") (
button(cls := "icon-button twitter")
),
a(href := "https://discord.com/invite/scala") (
button(cls := "icon-button discord"),
),
a(href := "https://gitter.im/scala/scala") (
button(cls := "icon-button gitter"),
),
socialLinks,
div(cls := "text")(textFooter)
),
div(cls := "text-mobile")(textFooter)
Expand Down