Skip to content

Commit 12fae3a

Browse files
neoRandomACR1209
authored andcommitted
feat: update snippet button and modal
increased the size of the snippet modal, added a bit more responsitivity too removed the gray filter on the snippet button
1 parent 48ff23b commit 12fae3a

File tree

3 files changed

+45
-33
lines changed

3 files changed

+45
-33
lines changed

src/components/CodePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const CodePreview = ({ language = "markdown", code }: Props) => {
4040
language={language}
4141
style={theme === "dark" ? oneDark : oneLight}
4242
wrapLines={true}
43-
customStyle={{ margin: "0", maxHeight: "20rem" }}
43+
customStyle={{ margin: "0", maxHeight: "32rem" }}
4444
>
4545
{code}
4646
</SyntaxHighlighter>

src/components/SnippetModal.tsx

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,31 @@ const SnippetModal: React.FC<Props> = ({
6161
<CloseIcon />
6262
</Button>
6363
</div>
64-
<CodePreview language={slugify(language)} code={snippet.code} />
65-
<p>
66-
<b>Description: </b>
67-
{snippet.description}
68-
</p>
69-
<p>
70-
Contributed by{" "}
71-
<a
72-
href={`https://github.com/${snippet.author}`}
73-
target="_blank"
74-
rel="noopener noreferrer"
75-
className="styled-link"
76-
>
77-
@{snippet.author}
78-
</a>
79-
</p>
80-
<ul role="list" className="modal__tags">
81-
{snippet.tags.map((tag) => (
82-
<li key={tag} className="modal__tag">
83-
{tag}
84-
</li>
85-
))}
86-
</ul>
64+
<div className="modal__body | flow">
65+
<CodePreview language={slugify(language)} code={snippet.code} />
66+
<p>
67+
<b>Description: </b>
68+
{snippet.description}
69+
</p>
70+
<p>
71+
Contributed by{" "}
72+
<a
73+
href={`https://github.com/${snippet.author}`}
74+
target="_blank"
75+
rel="noopener noreferrer"
76+
className="styled-link"
77+
>
78+
@{snippet.author}
79+
</a>
80+
</p>
81+
<ul role="list" className="modal__tags">
82+
{snippet.tags.map((tag) => (
83+
<li key={tag} className="modal__tag">
84+
{tag}
85+
</li>
86+
))}
87+
</ul>
88+
</div>
8789
</motion.div>
8890
</motion.div>,
8991
modalRoot

src/styles/main.css

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,22 +577,19 @@ abbr {
577577
border-radius: var(--br-lg);
578578
padding: 0.75em;
579579
text-align: start;
580-
filter: grayscale(100%);
581580

582581
&:is(:hover, :focus-visible) {
583-
outline: 3px solid var(--clr-border-primary);
584-
filter: grayscale(0);
582+
outline: 2px solid var(--clr-border-primary);
585583
}
586584
}
587585

588586
.snippet__preview {
589587
width: 100%;
590588
overflow: hidden;
591-
aspect-ratio: 10 / 3;
589+
aspect-ratio: 9 / 3;
592590
background-color: var(--clr-bg-secondary);
593591
/* background-image: var(--gradient-secondary); */
594592
border: 1px solid var(--clr-border-primary);
595-
border-radius: var(--br-md);
596593
position: relative;
597594
padding-inline: 1em;
598595
display: grid;
@@ -626,20 +623,33 @@ body:has(.modal-overlay) {
626623

627624
.modal {
628625
background-color: var(--clr-bg-secondary);
629-
padding: 2rem;
630-
width: 90%;
631-
max-width: 800px;
626+
width: fit-content;
627+
max-width: 1000px;
628+
max-height: 90%;
632629
border-radius: var(--br-lg);
633630
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
631+
gap: 0;
634632
position: relative;
635-
gap: 1rem;
633+
overflow: auto;
636634
}
637635

638636
.modal__header {
637+
z-index: 50;
639638
display: flex;
639+
position: sticky;
640+
top: 0;
640641
align-items: center;
641642
justify-content: space-between;
642643
gap: 1rem;
644+
padding: 1rem 1.5rem;
645+
background-color: var(--clr-bg-secondary);
646+
border-radius: var(--br-lg);
647+
}
648+
649+
.modal__body {
650+
padding: 1.5rem;
651+
padding-top: 0;
652+
gap: 1rem;
643653
}
644654

645655
.code-preview {

0 commit comments

Comments
 (0)