Skip to content

Commit

Permalink
Merge pull request #15 from dyvenia/syntax-css
Browse files Browse the repository at this point in the history
use okaidia theme as css block
  • Loading branch information
acivitillo authored Jan 8, 2025
2 parents 0b6e22f + 075575f commit 72d7fe2
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 185 deletions.
2 changes: 0 additions & 2 deletions src/_includes/head/css-inline.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<!-- External CSS for local dev (refresh without page reload) -->
<link rel="stylesheet" href="{% getBundleFileUrl "css", "global" %}">
<link rel="stylesheet" href="{% getBundleFileUrl "css", "inline" %}">
<link href="https://unpkg.com/prismjs@1.20.0/themes/prism-okaidia.css" rel="stylesheet"/>
{%- else %}
<!-- Inlined CSS (fastest site performance in production) -->
<style>{% getBundle "css", "global" %}</style>
<style>{% getBundle "css", "inline" %}</style>
<link href="https://unpkg.com/prismjs@1.20.0/themes/prism-okaidia.css" rel="stylesheet"/>
{%- endif %}

{% css "global" %}{% include "css/global.css" %}{% endcss %}
259 changes: 76 additions & 183 deletions src/assets/css/global/blocks/code.css
Original file line number Diff line number Diff line change
@@ -1,230 +1,123 @@
:root {
--color-code-orange: hsl(30, 70%, 60%);
--color-code-blue: var(--color-pink);
--color-code-indigo: hsl(260, 48%, 56%);
--color-code-violet: hsl(314, 70%, 60%);
--color-code-pink: hsl(350, 70%, 60%);
--color-code-gray: hsl(0, 0%, 58%);
--color-code-bg: color-mix(in oklab, var(--color-bg) 92%, black);
}

code,
pre {
font-family: var(--font-mono);
font-size: var(--size-step-min-1);
background-color: var(--color-code-bg);

border-radius: var(--border-radius-small);
}
/**
* okaidia theme for JavaScript, CSS and HTML
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
* @author ocodia
*/

code[class*='language-'],
pre[class*='language-'] {
color: #f8f8f2;
background: none;
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
font-size: 1em;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
hyphens: none;
}
line-height: 1.5;

/* Specific Styles for <pre> Elements */
pre {
grid-column: popout !important;
overflow-x: auto;
padding: var(--space-m-l);
}
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;

/* Style Adjustments for <code> within different contexts */
:where(:not(pre)) > code {
position: relative;
top: -0.05em;
padding: 0.1em 0.4em;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

/* Code blocks */
pre[class*='language-'] {
padding: 1em;
margin: 0.5em 0;
overflow: auto;
position: relative;
}

[class*='language-'] .namespace {
opacity: 0.7;
border-radius: 0.3em;
}

.token.atrule {
color: var(--color-code-pink);
}

.token.attr-name {
color: var(--color-code-orange);
}

.token.attr-value {
color: var(--color-text-accent);
}

.token.attribute {
color: var(--color-code-blue);
}

.token.boolean {
color: var(--color-code-pink);
:not(pre) > code[class*='language-'],
pre[class*='language-'] {
background: #272822;
}

.token.builtin {
color: var(--color-code-orange);
/* Inline code */
:not(pre) > code[class*='language-'] {
padding: 0.1em;
border-radius: 0.3em;
white-space: normal;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: var(--color-code-orange);
color: slategray;
}

.token.char {
color: var(--color-code-orange);
}

.token.class {
color: var(--color-code-orange);
}

.token.class-name {
color: var(--color-code-orange);
}

.token.color {
color: var(--color-code-orange);
}

.token.comment {
color: var(--color-code-gray);
.token.punctuation {
color: #f8f8f2;
}

.token.constant {
color: var(--color-code-pink);
.token.namespace {
opacity: 0.7;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
color: var(--color-code-pink);
color: #f92672;
}

.token.doctype {
color: var(--color-code-orange);
.token.boolean,
.token.number {
color: #ae81ff;
}

.token.entity {
color: var(--color-code-pink);
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #a6e22e;
}

.token.function {
color: var(--color-code-pink);
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
color: #f8f8f2;
}

.token.hexcode {
color: var(--color-code-orange);
.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
color: #e6db74;
}

.token.id {
color: var(--color-code-pink);
font-weight: var(--font-bold);
.token.keyword {
color: #66d9ef;
}

.token.regex,
.token.important {
color: var(--color-code-pink);
font-weight: var(--font-bold);
color: #fd971f;
}

.token.inserted {
color: var(--color-code-orange);
.token.important,
.token.bold {
font-weight: bold;
}

.token.keyword {
color: var(--color-code-pink);
.token.italic {
font-style: italic;
}

.token.number {
color: var(--color-text-accent);
}

.token.operator {
color: var(--color-code-gray);
}

.token.prolog {
color: var(--color-code-orange);
}

.token.property {
color: var(--color-code-orange);
}

.token.pseudo-class {
color: var(--color-code-blue);
}

.token.pseudo-element {
color: var(--color-code-blue);
}

.token.punctuation {
color: var(--color-code-gray);
}

.token.regex {
color: var(--color-code-orange);
}

.token.selector {
color: var(--color-code-pink);
}

.token.string {
color: var(--color-text-accent);
}

.token.symbol {
color: var(--color-code-pink);
}

.token.tag {
color: var(--color-code-pink);
}

.token.unit {
color: var(--color-code-pink);
}

.token.url {
color: var(--color-code-violet);
}

.token.variable {
color: var(--color-code-pink);
}

/* CodePen iframe */
.codepen a {
--icon-size: 1.2em;

display: flex;
align-items: center;
gap: var(--space-2xs);
}

.prose .cp_embed_wrapper,
.prose .cp_embed_wrapper + script + *:not(h2) {
--flow-space: var(--space-l);
}

.cp_embed_wrapper {
grid-column: popout;
position: relative;
overflow: auto;
display: grid;
place-items: center;
grid-template-areas: 'container';
resize: horizontal;
}

.cp_embed_wrapper iframe {
grid-area: container;
width: 100%;
.token.entity {
cursor: help;
}

0 comments on commit 72d7fe2

Please sign in to comment.