From 52c63022238d8d98961d83b84900a7e9664e0316 Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 14 Aug 2017 12:40:39 +0200 Subject: [PATCH] Allow prompt setting on code mixin --- website/_includes/_mixins.jade | 8 ++++---- website/assets/css/_components/_code.sass | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/website/_includes/_mixins.jade b/website/_includes/_mixins.jade index 16514bcda..b140151b2 100644 --- a/website/_includes/_mixins.jade +++ b/website/_includes/_mixins.jade @@ -103,20 +103,20 @@ mixin button(url, trusted, ...style) label - [string] aside title (optional or false for no label) language - [string] language for syntax highlighting (default: "python") supports basic relevant languages available for PrismJS - icon - [string] icon to display next to code block, mostly used for old/new + prompt - [string] prompt or icon to display next to code block, (mostly used for old/new) height - [integer] optional height to clip code block to -mixin code(label, language, icon, height) +mixin code(label, language, prompt, height) pre.c-code-block.o-block(class="lang-#{(language || DEFAULT_SYNTAX)}" class=icon ? "c-code-block--has-icon" : null style=height ? "height: #{height}px" : null)&attributes(attributes) if label h4.u-text-label.u-text-label--dark=label - + - var icon = (prompt == 'accept' || prompt == 'reject') if icon - var classes = {'accept': 'u-color-green', 'reject': 'u-color-red'} .c-code-block__icon(class=classes[icon] || null class=classes[icon] ? "c-code-block__icon--border" : null) +icon(icon, 18) - code.c-code-block__content + code.c-code-block__content(data-prompt=icon ? null : prompt) block diff --git a/website/assets/css/_components/_code.sass b/website/assets/css/_components/_code.sass index 2e1856c0a..036c5358f 100644 --- a/website/assets/css/_components/_code.sass +++ b/website/assets/css/_components/_code.sass @@ -35,6 +35,13 @@ font: normal normal 1.1rem/#{2} $font-code padding: 1em 2em + &[data-prompt]:before, + content: attr(data-prompt) + margin-right: 0.65em + display: inline-block + vertical-align: middle + opacity: 0.5 + //- Inline code