diff --git a/src/css/ds-blocks.css b/src/css/ds-blocks.css index aca6f360..e7d7cf77 100644 --- a/src/css/ds-blocks.css +++ b/src/css/ds-blocks.css @@ -75,3 +75,287 @@ html[data-theme="dark"] .listingblock:not(.default) .content .source-toolbox { html[data-theme="dark"] .listingblock:not(.default) .hljs { border-top-color: var(--ds-neutral-700); } + +/* + * + * Admonitions component + * + */ +.doc .admonitionblock { + border: 1px solid var(--ds-success-outlined-border); + border-radius: calc(6 / var(--rem-base) * 1rem); + overflow-x: hidden; +} + +.doc .admonitionblock > table > tbody > tr { + display: flex; + flex-direction: row; + flex-wrap: wrap; +} + +.doc .admonitionblock .icon { + display: flex; + gap: var(--ds-space-1); + align-items: center; + align-self: stretch; + position: unset; + width: 100%; + transform: none; + text-transform: none; + color: var(--ds-text-primary); + font-size: calc(16 / var(--rem-base) * 1rem); + line-height: 1.5; + height: var(--ds-space-6); + padding: var(--ds-space-1h) var(--ds-space-2); + border-radius: 0; +} + +.doc .admonitionblock td.content > *, +.doc .admonitionblock td.content p { + margin-top: var(--ds-space-2); +} + +.doc .admonitionblock td.content .ulist p { + margin-top: 0; +} + +.doc .admonitionblock td.content > .paragraph:first-child p:first-child, +.doc .admonitionblock td.content > .title { + margin: 0; +} + +.doc .admonitionblock .title { + font-style: normal; +} + +.doc .admonitionblock td.content { + background: none; +} + +.doc .admonitionblock .icon::before { + font-family: "Material Icons Outlined", sans-serif; + font-size: calc(20 / var(--rem-base) * 1rem); + font-weight: normal; +} + +/* TIP, NOTE */ +.doc .admonitionblock.tip .icon, +.doc .admonitionblock.note .icon { + background: var(--ds-success-soft-bg); + color: var(--ds-text-primary); +} + +.doc .admonitionblock.note .icon::before { + color: var(--ds-success-500); + content: '\e88e'; +} + +.doc .admonitionblock.tip .icon::before { + color: var(--ds-success-500); + content: '\e0f0'; +} + +/* CAUTION */ +.doc .admonitionblock.caution .icon { + background: var(--ds-warning-soft-bg); + color: var(--ds-text-primary); +} + +.doc .admonitionblock.caution { + border: 1px solid var(--ds-warning-outlined-border); +} + +.doc .admonitionblock.caution .icon::before { + color: var(--ds-warning-500); + content: '\e88e'; +} + +/* WARNING, IMPORTANT */ +.doc .admonitionblock.warning .icon, +.doc .admonitionblock.important .icon { + background: var(--ds-failure-soft-bg); + color: var(--ds-text-primary); +} + +.doc .admonitionblock.warning, +.doc .admonitionblock.important { + border: 1px solid var(--ds-failure-outlined-border); +} + +.doc .admonitionblock.warning .icon::before { + color: var(--ds-failure-500); + content: '\f083'; +} + +.doc .admonitionblock.important .icon::before { + color: var(--ds-failure-500); + content: '\e160'; +} + +html[data-theme="dark"] .doc .admonitionblock .icon::before { + color: var(--ds-primary-text); +} + +/* + * + * Dialog component + * + */ + +dialog { + display: none; + padding: 0; + flex-direction: column; + align-items: flex-start; + border-radius: 6px; + border: 1px solid var(--ds-neutral-300); + width: 90%; + max-width: 640px; + background: var(--body-background); + color: var(--doc-font-color); +} + +/* dialog header */ +dialog .header { + display: flex; + padding: var(--ds-space-3); + padding-bottom: var(--ds-space-2); + align-items: center; + gap: var(--ds-space-2); + align-self: stretch; + justify-content: space-between; + border-bottom: 1px solid var(--ds-neutral-200); +} + +dialog .header .title { + @include text-h1; + + color: var(--heading-font-color); +} + +dialog .header .close-button { + display: flex; + justify-content: center; + align-items: center; + gap: var(--ds-space-1); +} + +dialog .header kbd { + border: none; + box-shadow: none; + background: var(--ds-neutral-100); +} + +dialog .header button { + background: transparent; + border: none; + line-height: 1; +} + +dialog .header .material-icons { + color: var(--link-font-color); +} + +/* dialog content */ +dialog form { + width: 100%; +} + +dialog .content { + display: flex; + flex-direction: column; + align-self: stretch; + border-bottom: 1px solid var(--ds-neutral-200); + padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-3) var(--ds-space-3); +} + +dialog .content .message { + @include text-h2; + + color: var(--heading-font-color); + margin-bottom: var(--ds-space-4); +} + +dialog .content .question { + font-size: calc(13 / var(--rem-base) * 1rem); + color: var(--ds-neutral-700); + font-weight: 600; + letter-spacing: 0.65px; +} + +dialog .content textarea { + font-family: var(--body-font-family); + color: var(--doc-font-color); + background: var(--body-background); + height: calc(160 / var(--rem-base) * 1rem); + margin-top: var(--ds-space-h); + resize: none; + padding: var(--ds-space-1); + border-radius: 6px; + border: 1px solid var(--ds-neutral-300); +} + +dialog .action { + display: flex; + padding: var(--ds-space-2) var(--ds-space-3) var(--ds-space-3) var(--ds-space-3); + align-items: center; + gap: var(--ds-space-1); + align-self: stretch; + justify-content: flex-end; +} + +dialog[open] { + display: flex; +} + +dialog::backdrop { + background: rgba(10, 10, 10, 0.6); +} + +.dialog-action, +.dialog-action--response { + transition: opacity 500ms cubic-bezier(0.4, 0, 0.2, 1), visibility 500ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; + transition-delay: 300ms; +} + +.dialog-action + .dialog-action--response { + position: absolute; + top: 0; + line-height: var(--ds-space-5); + height: var(--ds-space-5); +} + +.dialog-action--response { + font-weight: 600; + transition-delay: 1200ms; +} + +.dialog-action--container { + position: relative; + + & .dialog-action { + opacity: 1; + visibility: visible; + } + + & .dialog-action--response { + opacity: 0; + visibility: hidden; + } + + &:not(.first-time) .dialog-action { + transition-delay: 2000ms; + } + + &.dialog-action--animate { + & .dialog-action { + opacity: 0; + visibility: hidden; + } + + & .dialog-action--response { + opacity: 1; + visibility: visible; + } + } +} diff --git a/src/css/ds-layout.css b/src/css/ds-layout.css index 5817622c..0038534f 100644 --- a/src/css/ds-layout.css +++ b/src/css/ds-layout.css @@ -25,19 +25,6 @@ html[data-layout="full"] .content-container { align-content: center; } -/* Hide sidebar, a.anchor */ -html[data-layout="landing"] .toc.sidebar, -html[data-layout="landing"] .toc.embedded, -html[data-layout="landing"] .breadcrumbs, -html[data-layout="landing"] a.anchor, -html[data-layout="full"] .nav-container, -html[data-layout="full"] .toolbar, -html[data-layout="full"] .toc.sidebar, -html[data-layout="full"] a.anchor, -html[data-layout="full"] .hide h2 { - display: none; -} - html[data-layout="landing"] .toolbar, html[data-layout="full"] .toolbar { justify-content: flex-end; @@ -185,125 +172,3 @@ html[data-theme="dark"] .doc .landing-card-icon { .landing-support a.support { margin-left: var(--ds-space-3); } - -/* - * - * Admonitions component - * - */ -.doc .admonitionblock { - border: 1px solid var(--ds-success-outlined-border); - border-radius: calc(6 / var(--rem-base) * 1rem); - overflow-x: hidden; -} - -.doc .admonitionblock > table > tbody > tr { - display: flex; - flex-direction: row; - flex-wrap: wrap; -} - -.doc .admonitionblock .icon { - display: flex; - gap: var(--ds-space-1); - align-items: center; - align-self: stretch; - position: unset; - width: 100%; - transform: none; - text-transform: none; - color: var(--ds-text-primary); - font-size: calc(16 / var(--rem-base) * 1rem); - line-height: 1.5; - height: var(--ds-space-6); - padding: var(--ds-space-1h) var(--ds-space-2); - border-radius: 0; -} - -.doc .admonitionblock td.content > *, -.doc .admonitionblock td.content p { - margin-top: var(--ds-space-2); -} - -.doc .admonitionblock td.content .ulist p { - margin-top: 0; -} - -.doc .admonitionblock td.content > .paragraph:first-child p:first-child, -.doc .admonitionblock td.content > .title { - margin: 0; -} - -.doc .admonitionblock .title { - font-style: normal; -} - -.doc .admonitionblock td.content { - background: none; -} - -.doc .admonitionblock .icon::before { - font-family: "Material Icons Outlined", sans-serif; - font-size: calc(20 / var(--rem-base) * 1rem); - font-weight: normal; -} - -/* TIP, NOTE */ -.doc .admonitionblock.tip .icon, -.doc .admonitionblock.note .icon { - background: var(--ds-success-soft-bg); - color: var(--ds-text-primary); -} - -.doc .admonitionblock.note .icon::before { - color: var(--ds-success-500); - content: '\e88e'; -} - -.doc .admonitionblock.tip .icon::before { - color: var(--ds-success-500); - content: '\e0f0'; -} - -/* CAUTION */ -.doc .admonitionblock.caution .icon { - background: var(--ds-warning-soft-bg); - color: var(--ds-text-primary); -} - -.doc .admonitionblock.caution { - border: 1px solid var(--ds-warning-outlined-border); -} - -.doc .admonitionblock.caution .icon::before { - color: var(--ds-warning-500); - content: '\e88e'; -} - -/* WARNING, IMPORTANT */ -.doc .admonitionblock.warning .icon, -.doc .admonitionblock.important .icon { - background: var(--ds-failure-soft-bg); - color: var(--ds-text-primary); -} - -.doc .admonitionblock.warning, -.doc .admonitionblock.important { - border: 1px solid var(--ds-failure-outlined-border); -} - -.doc .admonitionblock.warning .icon::before { - color: var(--ds-failure-500); - content: '\f083'; -} - -.doc .admonitionblock.important .icon::before { - color: var(--ds-failure-500); - content: '\e160'; -} - -html[data-theme="dark"] .doc .admonitionblock .icon::before { - color: var(--ds-primary-text); -} - -/* border */ diff --git a/src/css/site.css b/src/css/site.css index 68e67d17..e2a65d36 100644 --- a/src/css/site.css +++ b/src/css/site.css @@ -5,7 +5,6 @@ @import "ds-light.css"; @import "ds-dark.css"; @import "vars.css"; -@import "ds-blocks.css"; @import "ds-card.css"; @import "ds-typography.css"; @import "base.css"; @@ -21,6 +20,7 @@ @import "toc.css"; @import "doc.css"; @import "ds-layout.css"; +@import "ds-blocks.css"; @import "pagination.css"; @import "header.css"; @import "footer.css"; diff --git a/src/js/09-analytics.js b/src/js/09-analytics.js new file mode 100644 index 00000000..5fbfd9da --- /dev/null +++ b/src/js/09-analytics.js @@ -0,0 +1,85 @@ +;(function () { + 'use strict' + + if (!window.analytics) return + + const trackedLinkElements = document.querySelectorAll('a[data-track]') + const trackedElements = document.querySelectorAll('[data-track]:not(a)') + + trackedLinkElements.forEach((element) => { + window.analytics.trackLink(element, element.dataset.track) + }) + + trackedElements.forEach((element) => { + element.addEventListener('click', (e) => { + window.analytics.track(element.dataset.track) + }) + }) + + const survey = document.querySelector('.dialog-action--container') + + if (!survey) return + + const surveyElements = survey.querySelectorAll('button') + const response = document.createElement('p') + + response.className = 'dialog-action--response' + response.innerText = 'Thank you for your Feedback!' + survey.appendChild(response) + + const dialog = document.getElementById('dialog-survey') + // if ESC pressed + dialog.addEventListener('cancel', (event) => { + hideButtons(surveyElements) + }) + // close dialog + const close = dialog.querySelectorAll('button.close') + close.forEach((s) => { + s.onclick = function (e) { + dialog.close() + hideButtons(surveyElements) + } + }) + + surveyElements.forEach((element) => { + element.addEventListener('click', (e) => { + styleButton(element) + window.analytics.track(element.dataset.survey) + + if (element.id.includes('no')) { + // open dialog + dialog.showModal() + // submit form + const form = document.getElementById('survey-form') + form.elements.message.required = true + form.elements.message.value = '' + form.onsubmit = (e) => { + e.preventDefault() + const message = form.elements.message.value + window.analytics.trackForm(form, 'Support Survey', { + message: message, + }) + dialog.close() + hideButtons() + } + } else { + hideButtons() + } + }) + }) + + function hideButtons () { + survey.classList.add('dialog-action--animate', 'first-time') + setTimeout(function () { + survey.classList.remove('first-time') + survey.classList.remove('dialog-action--animate') + surveyElements.forEach((s) => { + s.classList.remove('ds-button--variant-solid') + }) + }, 3.5 * 1000) + } + + function styleButton (el) { + el.classList.add('ds-button--variant-solid') + } +})() diff --git a/src/layouts/404.hbs b/src/layouts/404.hbs index cec02ae6..c449b164 100644 --- a/src/layouts/404.hbs +++ b/src/layouts/404.hbs @@ -6,6 +6,5 @@ {{> header}} {{> body}} -{{> intercom}} diff --git a/src/layouts/default.hbs b/src/layouts/default.hbs index 60c9424a..85d3addd 100644 --- a/src/layouts/default.hbs +++ b/src/layouts/default.hbs @@ -6,6 +6,5 @@ {{> header}} {{> body}} -{{> intercom}} diff --git a/src/layouts/full.hbs b/src/layouts/full.hbs index 87782b14..8283ff1b 100644 --- a/src/layouts/full.hbs +++ b/src/layouts/full.hbs @@ -6,6 +6,5 @@ {{> header}} {{> body}} -{{> intercom}} diff --git a/src/layouts/landing.hbs b/src/layouts/landing.hbs index 1dc429d3..207888f1 100644 --- a/src/layouts/landing.hbs +++ b/src/layouts/landing.hbs @@ -6,6 +6,5 @@ {{> header}} {{> body}} -{{> intercom}} diff --git a/src/layouts/tutorial.hbs b/src/layouts/tutorial.hbs index 60c9424a..85d3addd 100644 --- a/src/layouts/tutorial.hbs +++ b/src/layouts/tutorial.hbs @@ -6,6 +6,5 @@ {{> header}} {{> body}} -{{> intercom}} diff --git a/src/partials/article.hbs b/src/partials/article.hbs index 720eaada..cf37b9dd 100644 --- a/src/partials/article.hbs +++ b/src/partials/article.hbs @@ -6,5 +6,8 @@ {{> tutorial-info}} {{/if}} {{{page.contents}}} + {{#if (eq page.layout 'tutorial')}} + {{> survey }} + {{/if}} {{> pagination}} \ No newline at end of file diff --git a/src/partials/body.hbs b/src/partials/body.hbs index 06bf26bd..89cbb796 100644 --- a/src/partials/body.hbs +++ b/src/partials/body.hbs @@ -1,5 +1,7 @@
+ {{#unless (eq page.layout 'full')}} {{> nav}} + {{/unless}}
{{> main}} {{> footer-content}} diff --git a/src/partials/footer-content.hbs b/src/partials/footer-content.hbs index cc4dfe64..53184115 100644 --- a/src/partials/footer-content.hbs +++ b/src/partials/footer-content.hbs @@ -3,13 +3,13 @@ \ No newline at end of file diff --git a/src/partials/footer-scripts.hbs b/src/partials/footer-scripts.hbs index 118aa726..a638fb58 100644 --- a/src/partials/footer-scripts.hbs +++ b/src/partials/footer-scripts.hbs @@ -11,4 +11,5 @@ {{!-- This is the public API key which can be safely used in frontend code. --}} apiKey: '1f4acbf51d118e4137e9a63b38bd8456', }) - \ No newline at end of file + +{{> intercom}} diff --git a/src/partials/head-scripts.hbs b/src/partials/head-scripts.hbs index b54dbbcb..b5a5c11a 100644 --- a/src/partials/head-scripts.hbs +++ b/src/partials/head-scripts.hbs @@ -3,6 +3,15 @@ {{/with}} +{{#with site.keys.segment}} + +{{/with}} + +{{#unless (eq page.layout 'full')}} {{> toolbar}} +{{/unless}}
{{#if (eq page.layout '404')}} {{> article-404}} {{else}} +{{#unless (or (eq page.layout 'full') (eq page.layout 'landing'))}} {{> toc}} +{{/unless}} {{> article}} {{/if}}
diff --git a/src/partials/survey.hbs b/src/partials/survey.hbs new file mode 100644 index 00000000..a84df36d --- /dev/null +++ b/src/partials/survey.hbs @@ -0,0 +1,55 @@ +
+

Support

+
+
+

Was This Helpful?

+
+ +
+ +
+
+

Give Feedback

+

ESC +

+
+
+

Thanks for using Astra

+

How can we improve the experience for you?

+ +
+
+ + +
+
+
+
+
+

Need More Help?

+ +
+
+
\ No newline at end of file diff --git a/src/partials/toolbar.hbs b/src/partials/toolbar.hbs index f892e970..76830d85 100644 --- a/src/partials/toolbar.hbs +++ b/src/partials/toolbar.hbs @@ -1,5 +1,7 @@