Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sean1588 committed Jun 8, 2023
1 parent 844ae42 commit 9d1028f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
60 changes: 1 addition & 59 deletions themes/default/layouts/partials/docs/pulumi-quickstart.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ $customize := .Params.customize }}


<section class="content pulumi-quickstart">
<section id="pulumi-quickstart" class="content pulumi-quickstart">
<p class="intro">{{ .Params.intro }}</p>

<div id="accordion-quickstart-customize">
Expand Down Expand Up @@ -124,64 +124,6 @@ <h2 id="step-four" class="step-heading">{{ $template.heading }}</h2>
{{ end }}


<!-- controls code rendering based on the selected combination of cloud, language, and template. -->
<script>
$(document).ready(function () {
$('input[name="language-radio"], input[name="credentials-radio"], input[name="templates-radio"]').change(function () {
if ($(this).is(":checked")) {
const selectedValue = $(this).val();
const cloud = $('input[name="credentials-radio"]:checked').val();
const language = $('input[name="language-radio"]:checked').val();
const template = $('input[name="templates-radio"]:checked').val();
$("#template-command").html(`pulumi new ${template ? template + "-" : ""}${cloud}-${language}`);
$("[id^=template-content]").css("display", "none");
$(`#template-content-${language}`).css("display", "block");
$("[id^=next-steps-]").css("display", "none");
$(`#next-steps-${cloud}`).css("display", "block");
}
});

const labelGroups = ["os", "cloud", "language", "template"];
labelGroups.forEach(labelGroup => {
$(`label[for^="${labelGroup}-"]`).click(function () {
$(`label[for^="${labelGroup}-"]`).removeClass("selected");
$(this).addClass("selected");
});
});

$('input[id="credentials-checkbox"').change(function () {
console.log("credentials checkbox changed");
if ($(this).is(":checked")) {
$("#credentials-step").css("display", "flex");
} else {
$("#credentials-step").css("display", "none");
}
});

function setOS() {
const userAgent = navigator.userAgent;
let os = "osx";
if (userAgent.indexOf("Win") !== -1) {
os = "windows";
} else if (userAgent.indexOf("Mac") !== -1) {
os = "osx";
} else if (userAgent.indexOf("Linux") !== -1) {
os = "linux";
}
$(`#os-${os}-radio`).prop("checked", true);
$(`label[for^="os-"]`).removeClass("selected");
$(`label[for="os-${os}-radio"]`).addClass("selected");
}

function initQuickStart() {
$("[id^=template-content]").css("display", "none");
$("#template-content-typescript").css("display", "block");
setOS();
}

initQuickStart();
});
</script>
<div class="content code-block template highlight">
<pre class="chroma"><code id="template-command">pulumi new aws-typescript</code></pre>
</div>
Expand Down
57 changes: 57 additions & 0 deletions themes/default/theme/src/ts/get-started.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// controls code rendering of quickstart based on the selected
// combination of cloud, language, and template.
(function ($) {
$('input[name="language-radio"], input[name="credentials-radio"], input[name="templates-radio"]').change(function () {
if ($(this).is(":checked")) {
const selectedValue = $(this).val();
const cloud = $('input[name="credentials-radio"]:checked').val();
const language = $('input[name="language-radio"]:checked').val();
const template = $('input[name="templates-radio"]:checked').val();
$("#template-command").html(`pulumi new ${template ? template + "-" : ""}${cloud}-${language}`);
$("[id^=template-content]").css("display", "none");
$(`#template-content-${language}`).css("display", "block");
$("[id^=next-steps-]").css("display", "none");
$(`#next-steps-${cloud}`).css("display", "block");
}
});

const labelGroups = ["os", "cloud", "language", "template"];
labelGroups.forEach(labelGroup => {
$(`label[for^="${labelGroup}-"]`).click(function () {
$(`label[for^="${labelGroup}-"]`).removeClass("selected");
$(this).addClass("selected");
});
});

$('input[id="credentials-checkbox"').change(function () {
console.log("credentials checkbox changed");
if ($(this).is(":checked")) {
$("#credentials-step").css("display", "flex");
} else {
$("#credentials-step").css("display", "none");
}
});

function setOS() {
const userAgent = navigator.userAgent;
let os = "osx";
if (userAgent.indexOf("Win") !== -1) {
os = "windows";
} else if (userAgent.indexOf("Mac") !== -1) {
os = "osx";
} else if (userAgent.indexOf("Linux") !== -1) {
os = "linux";
}
$(`#os-${os}-radio`).prop("checked", true);
$(`label[for^="os-"]`).removeClass("selected");
$(`label[for="os-${os}-radio"]`).addClass("selected");
}

function initQuickStart() {
$("[id^=template-content]").css("display", "none");
$("#template-content-typescript").css("display", "block");
setOS();
}

initQuickStart();
})((args) => jQuery(args, jQuery("#pulumi-quickstart"))); //scope this to the quickstart section of the site
1 change: 1 addition & 0 deletions themes/default/theme/src/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import "./developer-advocates";
import "./toc";
import "./ai";
import "./docs-main";
import "./get-started";

// Register all Stencil components.
defineCustomElements();

0 comments on commit 9d1028f

Please sign in to comment.