From 0ac46fb75644b042c04bb9469f8951847331d1b0 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Fri, 29 Apr 2022 17:00:51 +0200 Subject: [PATCH 1/3] add tabs on get-started page (english) --- _config.yml | 3 + _data/setup-scala.yml | 4 + _includes/code-snippet.html | 6 ++ _includes/getting-started.md | 52 +++++----- _includes/tabsection.html | 20 ++++ _install_tabs/1-macos.md | 23 +++++ _install_tabs/2-linux.md | 14 +++ _install_tabs/3-windows.md | 14 +++ _install_tabs/4-other.md | 17 ++++ _sass/layout/alt-details.scss | 46 +++++++++ _sass/layout/scala-in-action.scss | 158 ++++++++++++++++++++++++++++++ _sass/layout/tabsection.scss | 60 ++++++++++++ resources/css/style.scss | 3 + resources/js/functions.js | 78 ++++++++++++--- 14 files changed, 456 insertions(+), 42 deletions(-) create mode 100644 _data/setup-scala.yml create mode 100644 _includes/code-snippet.html create mode 100644 _includes/tabsection.html create mode 100644 _install_tabs/1-macos.md create mode 100644 _install_tabs/2-linux.md create mode 100644 _install_tabs/3-windows.md create mode 100644 _install_tabs/4-other.md create mode 100644 _sass/layout/alt-details.scss create mode 100755 _sass/layout/scala-in-action.scss create mode 100755 _sass/layout/tabsection.scss diff --git a/_config.yml b/_config.yml index accb4b5df1..21f5c59539 100644 --- a/_config.yml +++ b/_config.yml @@ -21,6 +21,9 @@ scala-3-version: 3.1.2 collections: contribute_resources: + output: false + install_tabs: + output: false style: output: true overviews: diff --git a/_data/setup-scala.yml b/_data/setup-scala.yml new file mode 100644 index 0000000000..d1bb19a78d --- /dev/null +++ b/_data/setup-scala.yml @@ -0,0 +1,4 @@ +linux: curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup +macOS-default: curl -fL https://github.com/coursier/launchers/raw/master/cs-x86_64-apple-darwin.gz | gzip -d > cs && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup +macOS-brew: brew install coursier/formulas/coursier && cs setup +windows-link: https://github.com/coursier/launchers/raw/master/cs-x86_64-pc-win32.zip diff --git a/_includes/code-snippet.html b/_includes/code-snippet.html new file mode 100644 index 0000000000..0286da8b4d --- /dev/null +++ b/_includes/code-snippet.html @@ -0,0 +1,6 @@ +
+
+
+
+
{{include.codeSnippet}}
+
diff --git a/_includes/getting-started.md b/_includes/getting-started.md index 83c1de45fe..2df5661769 100644 --- a/_includes/getting-started.md +++ b/_includes/getting-started.md @@ -21,9 +21,29 @@ It ensures that a JVM and standard Scala tools are installed on your system. Install it on your system with the following instructions.
-
-

Follow the instructions to install the cs launcher then run:

-

$ ./cs setup

+
@@ -165,29 +185,3 @@ Once you've finished the above tutorials, consider checking out: ## Getting Help There are a multitude of mailing lists and real-time chat rooms in case you want to quickly connect with other Scala users. Check out our [community](https://scala-lang.org/community/) page for a list of these resources, and for where to reach out for help. - - - - - - - - - diff --git a/_includes/tabsection.html b/_includes/tabsection.html new file mode 100644 index 0000000000..a5473b04e5 --- /dev/null +++ b/_includes/tabsection.html @@ -0,0 +1,20 @@ +
+
+ {% for tabRoot in include.collection %} + + {% endfor %} +
+ {% for tabRoot in include.collection %} +
{{tabRoot.content}}
+ {% endfor %} +
diff --git a/_install_tabs/1-macos.md b/_install_tabs/1-macos.md new file mode 100644 index 0000000000..f91ab023fa --- /dev/null +++ b/_install_tabs/1-macos.md @@ -0,0 +1,23 @@ +--- +tabId: osx +tabLabel: macOS +--- +
+
+
+
+

Run the following command in your terminal, following the on-screen instructions:

+ {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} +
+ +
+
+ {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} +
+
+
+
+
+
+
diff --git a/_install_tabs/2-linux.md b/_install_tabs/2-linux.md new file mode 100644 index 0000000000..6924edf275 --- /dev/null +++ b/_install_tabs/2-linux.md @@ -0,0 +1,14 @@ +--- +tabId: linux +tabLabel: Linux +--- +
+
+
+
+

Run the following command in your terminal, following the on-screen instructions:

+ {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} +
+
+
+
diff --git a/_install_tabs/3-windows.md b/_install_tabs/3-windows.md new file mode 100644 index 0000000000..c3e31fb837 --- /dev/null +++ b/_install_tabs/3-windows.md @@ -0,0 +1,14 @@ +--- +tabId: windows +tabLabel: Windows +--- +
+
+
+
+

Download and execute the Scala + installer for Windows based on Coursier, and follow the on-screen instructions.

+
+
+
+
diff --git a/_install_tabs/4-other.md b/_install_tabs/4-other.md new file mode 100644 index 0000000000..d60085c17f --- /dev/null +++ b/_install_tabs/4-other.md @@ -0,0 +1,17 @@ +--- +tabId: other +tabLabel: Other +fallbackNoJS: true +--- +
+
+
+
+ +

Follow the documentation from Coursier on how to install and run cs setup.

+
+
+
+
diff --git a/_sass/layout/alt-details.scss b/_sass/layout/alt-details.scss new file mode 100644 index 0000000000..aae4addefb --- /dev/null +++ b/_sass/layout/alt-details.scss @@ -0,0 +1,46 @@ +// ALT-DETAILS +//------------------------------------------------ +//------------------------------------------------ + +.alt-details { + margin: 10px 0px; + + button.alt-details-toggle { + width: 100%; + border: none; + background-color: #b635c4; + padding: 5px 10px; + border-radius: 15px; + font-size: $font-size-medium; + cursor: pointer; + font-weight: 500; + color: #fff; + + &:hover { + background-color: #941fa1; + } + + &:after { + content: "\f13a"; // + font-family: "Font Awesome 5 Free"; + font-weight: 900; + font-size: 15px; + color: #fff; + float: right; + margin-top: 2px; + } + + &.alt-details-closed:after { + content: "\f138"; // + } + } + + .alt-details-detail { + background-color: rgb(248, 226, 255); + border: 1px solid rgb(239, 207, 248); + padding-top: 25px; + padding-bottom: 10px; + margin-top: -15px; + margin-bottom: 10px; + } +} diff --git a/_sass/layout/scala-in-action.scss b/_sass/layout/scala-in-action.scss new file mode 100755 index 0000000000..404c9bbd7f --- /dev/null +++ b/_sass/layout/scala-in-action.scss @@ -0,0 +1,158 @@ +// SCALA-IN-ACTION +//------------------------------------------------ +//------------------------------------------------ + +.scala-in-action { + + .tabcontent { + .scala-text { + .alt-details { + button.alt-details-toggle { + border: 1px solid #a0dff0; + background-color: #d1e5eb; + color: $gray; + + &:hover { + background-color: #c9e3eb; + } + + &:after { + color: $gray; + } + } + + .alt-details-detail { + background-color: $gray-light; + border: 1px solid darken($gray-light, 3%); + } + } + } + } + + .scala-in-action-content { + transition: $base-transition; + + + .scala-in-action-code { + // display: none; + // background: $gray-dark; + padding: 20px 0; + + .wrap { + margin-bottom: 0px; + } + + .snippet { + position: relative; + margin: 10px 0px; + cursor: default; + width: 100%; + + &:hover { + .buttons { + opacity: 0.95; + + &:active { + opacity: 0.3; + } + } + } + + .buttons { + position: absolute; + right: 4px; + top: 5px; + transition: all .2s ease; + display: flex; + opacity: 0; + flex-direction: row-reverse; + justify-content: flex-start; + + button { + outline: none; + background: #fff; + border: none; + font-size: $font-size-medium; + color: rgba($gray, .6); + cursor: pointer; + + i { + font-weight: $font-bold; + } + } + } + + pre.snippet-code { + margin: 0px; + display: block; + overflow-x: auto; + + code { + overflow-x: auto; + display: block; + } + } + } + + .scala-code { + + @include span-columns(7); + + @include bp(large) { + @include span-columns(12); + } + } + + .scala-text { + + details { + summary { + + &:hover { + background-color: lighten($gray-lighter, 5%); + } + } + + summary>* { + display: inline; + } + } + + code { + padding: 3px 6px; + color: #859900; + background-color: #fff; + border-radius: 10px; + border: 1px solid $gray-light; + } + + .snippet { + pre.snippet-code { + code { + border: 1px solid darken($gray-light, 10%); + } + } + } + + @include span-columns(5); + + @include bp(large) { + @include span-columns(12); + } + + h3 { + font-size: 1.525rem; + margin-bottom: 20px; + } + + p { + color: $base-font-color; + } + + &.scala-text-large { + @include span-columns(12); + } + } + } + } +} diff --git a/_sass/layout/tabsection.scss b/_sass/layout/tabsection.scss new file mode 100755 index 0000000000..71c2777183 --- /dev/null +++ b/_sass/layout/tabsection.scss @@ -0,0 +1,60 @@ +// TABSECTION +//------------------------------------------------ +//------------------------------------------------ + +.recommended-install { + margin-top: -2em; + .tabsection { + background: $gray-lighter; + } +} + +.tabsection { + + &.inline-tabs { + margin: 20px 0px; + } + + /* Style the tab */ + .tab { + overflow: hidden; + margin-bottom: -12px; + } + + /* Style the buttons that are used to open the tab content */ + .tab button { + font-family: $heading-font-family; + font-size: $font-size-medium; + font-weight: $font-bold; + color: lighten($gray, 25%); + background-color: inherit; + float: left; + border: none; + border-radius: 30px; + outline: none; + cursor: pointer; + padding: 14px 16px; + } + + /* Change background color of buttons on hover */ + .tab button:hover { + color: #fff; + background-color: $gray; + border-bottom: $base-border-white; + } + + /* Create an active/current tablink class */ + .tab button.active { + background-color: $gray; + border-bottom: $base-border-white; + color: #fff; + } + + /* Style the tab content */ + .tabcontent { + display: none; + padding: 0px 2px; + border-top: none; + transition: all .5s linear; + } +} diff --git a/resources/css/style.scss b/resources/css/style.scss index fb5c150296..02ed07ce47 100755 --- a/resources/css/style.scss +++ b/resources/css/style.scss @@ -28,6 +28,9 @@ @import 'layout/twitter-feed'; @import 'layout/cheatsheet'; @import 'layout/ides'; +@import 'layout/alt-details'; +@import 'layout/tabsection'; +@import 'layout/scala-in-action'; @import 'layout/nutshell'; @import 'layout/overviews'; @import 'layout/sips'; diff --git a/resources/js/functions.js b/resources/js/functions.js index e52eddd5cf..cd5ac73eac 100644 --- a/resources/js/functions.js +++ b/resources/js/functions.js @@ -404,6 +404,58 @@ $(document).ready(function() { } }); +const toggleElement = (evt, elemId) => { + const btn = evt.target; + const elem = document.getElementById(elemId); + if (elem.style.display === "none") { + elem.style.display = "block"; + } else { + elem.style.display = "none"; + } + $(btn).toggleClass("alt-details-closed"); +} + +$(document).ready(() => { + $('.alt-details-toggle').click(); +}); + +function copySnippet(evt) { + const snippet = evt.target.closest('.snippet').querySelector('.snippet-code'); + const code = snippet.querySelector('code').innerText; + window.navigator.clipboard.writeText(code) +} + +function openTab(evt, category, tabName) { + // Get all elements with class="tabcontent" and hide them + $('.tabcontent-' + category + '.tabcontent').css('display', 'none'); + + const queried = evt.target; + + // Get all elements with class="tablinks" and remove the class "active" + $('.tablinks-' + category + '.tablinks').removeClass('active'); + + // Show the current tab, and add an "active" class to the button that opened the tab + document.getElementById(category + '-' + tabName).style.display = "block"; + queried.className += " active"; +} + +$(document).ready(() => { + const defaultTabs = document.getElementsByClassName('default-tab'); + for (i = 0; i < defaultTabs.length; i++) { + defaultTabs[i].click(); + } +}); + +$(document).ready(function () { + if ($(".main-download").length) { + let os = getOS(); + if (os === 'unix') { + os = 'linux'; + } + $("#get-started-tab-" + os).click(); + } +}); + var image = { width: 1680, height: 1100 @@ -467,18 +519,18 @@ $('#filter-glossary-terms').focus(); //Footer scroll to top button -$(document).ready(function(){ - $(window).scroll(function(){ - if ($(this).scrollTop() > 100) { - $('#scroll-to-top-btn').fadeIn(); - } else { - $('#scroll-to-top-btn').fadeOut(); - } - }); - $('#scroll-to-top-btn').click(function(){ - $("html, body").animate({ scrollTop: 0 }, 600); - return false; - }); +$(document).ready(function(){ + $(window).scroll(function(){ + if ($(this).scrollTop() > 100) { + $('#scroll-to-top-btn').fadeIn(); + } else { + $('#scroll-to-top-btn').fadeOut(); + } + }); + $('#scroll-to-top-btn').click(function(){ + $("html, body").animate({ scrollTop: 0 }, 600); + return false; + }); }); //Contributors widget @@ -490,7 +542,7 @@ $(document).ready(function () { * - some files aren't prefixed with underscore, see rootFiles * - some files are placed in _overviews but rendered to its folder, see overviewsFolders */ - + let rootFiles = ['getting-started', 'learn', 'glossary']; let overviewsFolders = ['FAQ', 'cheatsheets', 'collections', 'compiler-options', 'core', 'jdk-compatibility', 'macros', 'parallel-collections', From 71cf7e946fc3377ab35ae90e46cf3a9a9d8bc531 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Fri, 29 Apr 2022 18:03:35 +0200 Subject: [PATCH 2/3] add tabs to other translated pages --- _fr/getting-started/index.md | 41 +++--------- _includes/_ja/getting-started.md | 39 +++--------- _includes/alt-details.html | 6 ++ _includes/code-snippet.html | 2 + _includes/getting-started.md | 45 +++++++------- _includes/tabsection.html | 4 ++ _install_tabs/1-macos.md | 20 +++--- _install_tabs/2-linux.md | 1 + _install_tabs/3-windows.md | 1 + _install_tabs/4-other.md | 1 + _install_tabs/fr-1-macos.md | 26 ++++++++ _install_tabs/fr-2-linux.md | 14 +++++ _install_tabs/fr-3-windows.md | 14 +++++ _install_tabs/fr-4-other.md | 19 ++++++ _install_tabs/ja-1-macos.md | 26 ++++++++ _install_tabs/ja-2-linux.md | 14 +++++ _install_tabs/ja-3-windows.md | 14 +++++ _install_tabs/ja-4-other.md | 18 ++++++ _layouts/downloadpage.html | 100 ------------------------------ _sass/layout/scala-in-action.scss | 3 +- resources/js/functions.js | 30 +++------ 21 files changed, 225 insertions(+), 213 deletions(-) create mode 100644 _includes/alt-details.html create mode 100644 _install_tabs/fr-1-macos.md create mode 100644 _install_tabs/fr-2-linux.md create mode 100644 _install_tabs/fr-3-windows.md create mode 100644 _install_tabs/fr-4-other.md create mode 100644 _install_tabs/ja-1-macos.md create mode 100644 _install_tabs/ja-2-linux.md create mode 100644 _install_tabs/ja-3-windows.md create mode 100644 _install_tabs/ja-4-other.md delete mode 100644 _layouts/downloadpage.html diff --git a/_fr/getting-started/index.md b/_fr/getting-started/index.md index f9b05d7df9..397c18e59c 100644 --- a/_fr/getting-started/index.md +++ b/_fr/getting-started/index.md @@ -24,13 +24,19 @@ Nous recommandons l'utilisation de l'outil d'installation "Coursier" qui va auto ### Utilisation de l'installateur Scala (recommandé) L'installateur Scala est un outil nommé [Coursier](https://get-coursier.io/docs/cli-overview), la commande principale de l'outil est `cs`. -Il s'assure que la JVM est les outils standards de Scala sont installés sur votre système. +Il s'assure que la JVM est les outils standards de Scala sont installés sur votre système. Installez-le sur votre système avec les instructions suivantes.
-
-

Suivez les instructions pour installer la commande cs puis exécutez :

-

$ ./cs setup

+
@@ -165,30 +171,3 @@ Une fois que vous avez terminé le tutoriel ce dessus, vous pouvez consulter : Il y a plusieurs listes de diffusion et canaux de discussions instantanés si vous souhaitez rencontrer rapidement d'autres utilisateurs de Scala. Allez faire un tour sur notre page [community](https://scala-lang.org/community/) pour consulter la liste des ces ressources et obtenir de l'aide. Traduction par Antoine Pointeau. - - - - - - - - - diff --git a/_includes/_ja/getting-started.md b/_includes/_ja/getting-started.md index 1df3b33933..f747ff92f7 100644 --- a/_includes/_ja/getting-started.md +++ b/_includes/_ja/getting-started.md @@ -18,13 +18,18 @@ Scala のインストーラーは[Coursier](https://get-coursier.io/docs/cli-ove 以下の手順でお使いのシステムにインストールしてください。
-
-

Follow the instructions to install the cs launcher then run:

-

$ ./cs setup

+
- `cs setup` は JVM の管理だけでなく、便利なコマンドラインツールもインストールします: - JDK (インストール済みでなければ) @@ -141,29 +146,3 @@ IDE の使用に慣れている場合は、IDE から_Main.scala_のコードを ### (日本語のみ追記) Scala について日本語で質問したい場合、Twitterでつぶやくと気づいた人が教えてくれます。 - - - - - - - - - diff --git a/_includes/alt-details.html b/_includes/alt-details.html new file mode 100644 index 0000000000..52e8d9cf67 --- /dev/null +++ b/_includes/alt-details.html @@ -0,0 +1,6 @@ +
+ +
+ {{include.detail}} +
+
diff --git a/_includes/code-snippet.html b/_includes/code-snippet.html index 0286da8b4d..6267a08ad3 100644 --- a/_includes/code-snippet.html +++ b/_includes/code-snippet.html @@ -1,6 +1,8 @@
+ {% unless include.nocopy %}
+ {% endunless %}
{{include.codeSnippet}}
diff --git a/_includes/getting-started.md b/_includes/getting-started.md index 2df5661769..45c42b166f 100644 --- a/_includes/getting-started.md +++ b/_includes/getting-started.md @@ -20,31 +20,32 @@ The Scala installer is a tool named [Coursier](https://get-coursier.io/docs/cli- It ensures that a JVM and standard Scala tools are installed on your system. Install it on your system with the following instructions. +{% capture scalaDemo %}$ scala -version +Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL{% endcapture %} +
-