Repository navigation
Expand file tree
/
Copy pathCode.astro
More file actions
89 lines (79 loc) · 1.97 KB
/
Copy pathCode.astro
File metadata and controls
89 lines (79 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
import '@fontsource/fragment-mono/400.css';
import { Code as CodeComponent } from 'astro:components';
import ContentBlock from '../components/project_detail/ContentBlock.astro';
import ContentDescription from "../components/project_detail/ContentDescription.astro";
import type { ContentBlockData, CodeProperties } from '../scripts/interfaces';
interface Props {
blockData: ContentBlockData<CodeProperties>;
}
const { blockData } = Astro.props;
const containerId = "code-block-" + blockData.index;
const borderClass = blockData.properties.desc ? ' border-radius-top' : ' border-radius-full';
---
<ContentBlock>
{blockData.properties.file && (
<div class="code-file">
<div class="code-file-tab">{blockData.properties.file}</div>
</div>
)}
<div id={containerId} class={"code-window" + borderClass}>
<CodeComponent
code={blockData.properties.data}
lang={blockData.properties.lang}
theme="gruvbox-dark-soft"
/>
</div>
<ContentDescription blockData={blockData} parentId={containerId}/>
</ContentBlock>
<style>
.code-window {
font-size: 18px;
position: relative;
width: 100%;
}
.code-file {
width: 100%;
text-align: left;
}
.code-file-tab {
display: inline-block;
position: relative;
align-self: flex-start;
margin-bottom: -20px;
background: #32302f;
padding: 12px 18px 22px;
font-size: 16px;
color: #fafafa;
border-radius: 8px 8px 0px 0px;
font-weight: normal;
white-space: nowrap;
max-width: 100%;
box-sizing: border-box;
overflow: hidden;
}
pre {
margin: 0;
padding: 20px 30px;
text-align: left;
overflow: auto;
outline: none;
}
@media (max-width: 776px) {
.code-file-tab {
position: relative;
margin-left: 10px;
max-width: calc(100% - 20px);
box-sizing: border-box;
border-radius: 5px 5px 0px 0px;
}
}
</style>
<style is:global>
.code-window code, .code-window span {
font-size: 15px;
font-family: "Fragment Mono";
font-style: normal !important;
font-weight: normal !important;
}
</style>