Skip to content

Commit 59883c7

Browse files
committed
refactor(scss): extract code highlight styles from globals.scss to separate file
1 parent 32df390 commit 59883c7

2 files changed

Lines changed: 334 additions & 330 deletions

File tree

src/styles/globals.scss

Lines changed: 1 addition & 330 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use '_themes';
33
@use '_syntax-themes';
44
@use '_variables';
5+
@use 'syntax-highlight';
56
@use 'components/alert.module';
67

78
html {
@@ -253,333 +254,3 @@ figure {
253254
}
254255
}
255256

256-
// TODO: some value move to _.valiables.scss
257-
// TODO: fix important
258-
figure.highlight,
259-
.codeblock {
260-
background: map.get(variables.$highlight-colors, 'background');
261-
color: map.get(variables.$highlight-font-colors, 'night-rider');
262-
border: 0.1em solid map.get(variables.$highlight-colors, 'border-color');
263-
border-radius: 0.3em;
264-
overflow-x: auto;
265-
overflow-y: hidden;
266-
display: block;
267-
color: map.get(variables.$basic-colors, 'base');
268-
line-height: 2.45rem !important;
269-
font-size: map.get(variables.$font-size, large);
270-
271-
table {
272-
display: block;
273-
width: 100%;
274-
}
275-
276-
pre,
277-
.gutter,
278-
.code,
279-
.tag {
280-
font-family: variables.$font-families-code;
281-
border: none;
282-
cursor: text;
283-
}
284-
&.plain,
285-
&.plaintext {
286-
.gutter {
287-
display: none;
288-
}
289-
overflow-x: auto;
290-
overflow-y: hidden;
291-
.code {
292-
pre {
293-
margin-left: 0.5em;
294-
}
295-
}
296-
}
297-
figcaption {
298-
font-family: variables.$font-families-code;
299-
background: map.get(variables.$highlight-colors, 'background');
300-
color: map.get(variables.$basic-colors, 'base');
301-
}
302-
.gutter {
303-
border-right-color: map.get(variables.$highlight-colors, 'border-light') !important;
304-
border-right: 1px solid;
305-
background: map.get(variables.$highlight-colors, 'border-color') !important;
306-
opacity: 0.7;
307-
}
308-
.code {
309-
padding: 0.1em 0.1em 0.3em 0.6em;
310-
width: 100%;
311-
background: map.get(variables.$highlight-colors, 'background');
312-
313-
pre {
314-
max-width: calc(#{map.get(variables.$main, 'max-width')} - 50px);
315-
}
316-
}
317-
.line {
318-
height: map.get(variables.$highlight-colors, line-height);
319-
font-size: map.get(variables.$highlight-colors, font-size);
320-
color: map.get(variables.$highlight-colors, 'base');
321-
}
322-
323-
// TextMate scope-based syntax highlighting (syntect)
324-
325-
// Text (base text, used in PHP and other embedded languages)
326-
.text {
327-
color: map.get(variables.$highlight-colors, 'base');
328-
329-
&.plain {
330-
color: map.get(variables.$highlight-colors, 'base');
331-
}
332-
}
333-
334-
// Embedding (PHP, etc.)
335-
.embedding {
336-
color: map.get(variables.$highlight-colors, 'base');
337-
}
338-
339-
// Source (source code)
340-
.source {
341-
color: map.get(variables.$highlight-colors, 'base');
342-
}
343-
344-
// Comment
345-
.comment {
346-
color: map.get(variables.$highlight-font-colors, 'night-rider');
347-
}
348-
349-
// Keyword
350-
.keyword {
351-
color: map.get(variables.$highlight-font-colors, 'cardinal');
352-
}
353-
354-
// Storage (type declarations, modifiers)
355-
.storage {
356-
color: map.get(variables.$highlight-font-colors, 'cardinal');
357-
}
358-
359-
// String
360-
.string {
361-
color: map.get(variables.$highlight-font-colors, 'egyptian-blue');
362-
}
363-
364-
// Constant
365-
.constant {
366-
color: map.get(variables.$highlight-font-colors, 'bondi-blue');
367-
368-
&.language {
369-
color: map.get(variables.$highlight-font-colors, 'bondi-blue');
370-
}
371-
372-
&.numeric {
373-
color: map.get(variables.$highlight-font-colors, 'bondi-blue');
374-
}
375-
376-
&.character {
377-
color: map.get(variables.$highlight-font-colors, 'egyptian-blue');
378-
}
379-
}
380-
381-
// Entity (function names, type names, class names, tags)
382-
.entity {
383-
&.name {
384-
&.function {
385-
color: map.get(variables.$highlight-font-colors, 'scampi');
386-
}
387-
388-
&.type {
389-
color: map.get(variables.$highlight-font-colors, 'scampi');
390-
}
391-
392-
&.class {
393-
color: map.get(variables.$highlight-font-colors, 'scampi');
394-
}
395-
396-
&.val {
397-
color: map.get(variables.$highlight-font-colors, 'scampi');
398-
}
399-
400-
&.tag {
401-
color: map.get(variables.$highlight-font-colors, 'asparagus');
402-
}
403-
404-
&.section {
405-
color: map.get(variables.$highlight-font-colors, 'scampi');
406-
}
407-
}
408-
409-
&.other {
410-
&.attribute-name {
411-
color: map.get(variables.$highlight-font-colors, 'scampi');
412-
}
413-
414-
&.inherited-class {
415-
color: map.get(variables.$highlight-font-colors, 'scampi');
416-
}
417-
}
418-
}
419-
420-
// Support (built-in functions, types)
421-
.support {
422-
&.function {
423-
color: map.get(variables.$highlight-font-colors, 'scampi');
424-
}
425-
426-
&.type {
427-
color: map.get(variables.$highlight-font-colors, 'cardinal');
428-
}
429-
430-
&.class {
431-
color: map.get(variables.$highlight-font-colors, 'scampi');
432-
}
433-
434-
&.constant {
435-
color: map.get(variables.$highlight-font-colors, 'bondi-blue');
436-
}
437-
}
438-
439-
// Variable
440-
.variable {
441-
color: map.get(variables.$highlight-font-colors, 'bahama-blue');
442-
443-
&.parameter {
444-
color: map.get(variables.$highlight-font-colors, 'scampi');
445-
}
446-
447-
&.language {
448-
color: map.get(variables.$highlight-font-colors, 'cardinal');
449-
}
450-
451-
&.other {
452-
color: map.get(variables.$highlight-font-colors, 'base');
453-
}
454-
}
455-
456-
// Punctuation
457-
.punctuation {
458-
color: map.get(variables.$highlight-font-colors, 'night-rider');
459-
}
460-
461-
// Meta (preprocessor, docstrings)
462-
.meta {
463-
&.preprocessor {
464-
color: map.get(variables.$highlight-font-colors, 'persimmon');
465-
}
466-
467-
&.tag {
468-
color: map.get(variables.$highlight-font-colors, 'night-rider');
469-
}
470-
}
471-
472-
// Invalid
473-
.invalid {
474-
color: map.get(variables.$highlight-font-colors, 'free-speech-red');
475-
476-
&.illegal {
477-
color: map.get(variables.$highlight-font-colors, 'free-speech-red');
478-
background-color: map.get(variables.$highlight-font-colors, 'misty-rose');
479-
}
480-
481-
&.deprecated {
482-
color: map.get(variables.$highlight-font-colors, 'free-speech-red');
483-
}
484-
}
485-
486-
// Markup (for Markdown, etc.)
487-
.markup {
488-
&.heading {
489-
color: map.get(variables.$highlight-font-colors, 'scampi');
490-
font-weight: bold;
491-
}
492-
493-
&.bold {
494-
font-weight: bold;
495-
}
496-
497-
&.italic {
498-
font-style: italic;
499-
}
500-
501-
&.inserted {
502-
color: map.get(variables.$highlight-font-colors, 'limeade');
503-
background-color: map.get(variables.$highlight-font-colors, 'honeydew');
504-
}
505-
506-
&.deleted {
507-
color: map.get(variables.$highlight-font-colors, 'free-speech-red');
508-
background-color: map.get(variables.$highlight-font-colors, 'misty-rose');
509-
}
510-
511-
&.list {
512-
color: map.get(variables.$highlight-font-colors, 'cardinal');
513-
}
514-
515-
&.quote {
516-
color: map.get(variables.$highlight-font-colors, 'night-rider');
517-
font-style: italic;
518-
}
519-
}
520-
521-
// Backward compatibility: keep some highlight.js classes
522-
.quote {
523-
color: map.get(variables.$highlight-font-colors, 'night-rider');
524-
}
525-
526-
.number {
527-
color: map.get(variables.$highlight-font-colors, 'bondi-blue');
528-
}
529-
530-
.literal {
531-
color: map.get(variables.$highlight-font-colors, 'bondi-blue');
532-
}
533-
534-
.built_in,
535-
.name,
536-
.tag {
537-
color: map.get(variables.$code-basic-colors, 'tag');
538-
}
539-
540-
.title,
541-
.section,
542-
.attribute {
543-
color: map.get(variables.$highlight-font-colors, 'egyptian-blue');
544-
}
545-
546-
.selector-tag,
547-
.selector-attr,
548-
.selector-pseudo {
549-
color: map.get(variables.$code-basic-colors, 'meta');
550-
}
551-
552-
.template-tag,
553-
.template-variable,
554-
.type,
555-
.addition {
556-
color: map.get(variables.$highlight-font-colors, 'egyptian-blue');
557-
}
558-
559-
.deletion {
560-
color: map.get(variables.$code-basic-colors, 'meta');
561-
}
562-
563-
.doctag {
564-
color: map.get(variables.$code-basic-colors, 'doctag');
565-
}
566-
567-
.attr {
568-
color: map.get(variables.$code-basic-colors, 'attr');
569-
}
570-
571-
.symbol,
572-
.bullet,
573-
.link {
574-
color: map.get(variables.$code-basic-colors, 'link');
575-
}
576-
577-
.emphasis {
578-
font-style: italic;
579-
}
580-
581-
.strong {
582-
font-weight: bold;
583-
}
584-
}
585-

0 commit comments

Comments
 (0)