diff --git a/js/feedback/index.js b/js/feedback/index.js index 43255531c5..bbcd606fb4 100644 --- a/js/feedback/index.js +++ b/js/feedback/index.js @@ -2,27 +2,33 @@ const COMPONENT_NAME = 'data-feedback' const COMPONENT_SELECTOR = `[${COMPONENT_NAME}]` const HELPFUL_BUTTON_SELECTOR = `[data-ref="feedback[helpful]"]` const UNHELPFUL_BUTTON_SELECTOR = `[data-ref="feedback[unhelpful]"]` - -const DEFAULTS = { - message: { - success: 'Thanks for your feedback!' - } -} +const CONTENT_SELECTOR = `[data-ref="feedback[content]"]` +const ACTIVE_CLASS = 'data-active-class' export default function () { const components = document.querySelectorAll(COMPONENT_SELECTOR) for (let i = 0; i < components.length; i++) { - const options = JSON.parse(components[i].getAttribute(COMPONENT_NAME) || '{}') - const settings = Object.assign({}, DEFAULTS, options) - const helpfulButton = components[i].querySelector(HELPFUL_BUTTON_SELECTOR) const unhelpfulButton = components[i].querySelector(UNHELPFUL_BUTTON_SELECTOR) + const content = components[i].querySelector(CONTENT_SELECTOR) + + const clickHandler = () => { + if (content) { + content.hidden = false + } + + helpfulButton.disabled = true + unhelpfulButton.disabled = true + } helpfulButton.addEventListener('click', (event) => { event.preventDefault() - components[i].innerText = settings.message.success + const activeClass = helpfulButton.getAttribute(ACTIVE_CLASS) + helpfulButton.classList.add(activeClass) + + clickHandler() window.analytics.track('Docs Rated', { title: '{{title}}', @@ -34,7 +40,10 @@ export default function () { unhelpfulButton.addEventListener('click', (event) => { event.preventDefault() - components[i].innerText = settings.message.success + const activeClass = unhelpfulButton.getAttribute(ACTIVE_CLASS) + unhelpfulButton.classList.add(activeClass) + + clickHandler() window.analytics.track('Docs Rated', { title: '{{title}}', diff --git a/src/_includes/components/feedback.html b/src/_includes/components/feedback.html index ce4739fc24..47874801f8 100644 --- a/src/_includes/components/feedback.html +++ b/src/_includes/components/feedback.html @@ -18,12 +18,12 @@

Need support?

- diff --git a/src/_includes/sidebar/feedback.html b/src/_includes/sidebar/feedback.html index 21fb52519a..b1c826da9e 100644 --- a/src/_includes/sidebar/feedback.html +++ b/src/_includes/sidebar/feedback.html @@ -3,7 +3,7 @@
-
-
- -

+
diff --git a/src/_sass/components/_button-fill.scss b/src/_sass/components/_button-fill.scss index 377538f2ff..664798bd90 100644 --- a/src/_sass/components/_button-fill.scss +++ b/src/_sass/components/_button-fill.scss @@ -25,4 +25,24 @@ border: none; } } + + &--primary { + background-color: color(primary); + color: color(white); + + &:hover { + background-color: color(primary); + color: color(white); + } + } + + &--error-light { + background-color: rgba(color(error), 0.78); + color: color(white); + + &:hover { + background-color: rgba(color(error), 0.78); + color: color(white); + } + } } diff --git a/src/_sass/components/_button.scss b/src/_sass/components/_button.scss index 4b7f76e902..a63d9abf5a 100644 --- a/src/_sass/components/_button.scss +++ b/src/_sass/components/_button.scss @@ -8,6 +8,10 @@ text-decoration: none; cursor: pointer; + &:disabled { + pointer-events: none; + } + &:hover { text-decoration: none; } diff --git a/src/_sass/components/_widget.scss b/src/_sass/components/_widget.scss index 1cbb9b9443..b1bcf53c67 100644 --- a/src/_sass/components/_widget.scss +++ b/src/_sass/components/_widget.scss @@ -9,6 +9,11 @@ font-size: 14px; line-height: 1.71; color: color(gray); + + a { + text-decoration: underline; + font-weight: 500; + } } & > * + * {