Skip to content

Commit 2b6dd3b

Browse files
committed
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 dd2b5b0 commit 2b6dd3b

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
@@ -58,29 +58,31 @@ const SnippetModal: React.FC<Props> = ({
5858
<CloseIcon />
5959
</Button>
6060
</div>
61-
<CodePreview language={slugify(language)} code={snippet.code} />
62-
<p>
63-
<b>Description: </b>
64-
{snippet.description}
65-
</p>
66-
<p>
67-
Contributed by{" "}
68-
<a
69-
href={`https://github.com/${snippet.author}`}
70-
target="_blank"
71-
rel="noopener noreferrer"
72-
className="styled-link"
73-
>
74-
@{snippet.author}
75-
</a>
76-
</p>
77-
<ul role="list" className="modal__tags">
78-
{snippet.tags.map((tag) => (
79-
<li key={tag} className="modal__tag">
80-
{tag}
81-
</li>
82-
))}
83-
</ul>
61+
<div className="modal__body | flow">
62+
<CodePreview language={slugify(language)} code={snippet.code} />
63+
<p>
64+
<b>Description: </b>
65+
{snippet.description}
66+
</p>
67+
<p>
68+
Contributed by{" "}
69+
<a
70+
href={`https://github.com/${snippet.author}`}
71+
target="_blank"
72+
rel="noopener noreferrer"
73+
className="styled-link"
74+
>
75+
@{snippet.author}
76+
</a>
77+
</p>
78+
<ul role="list" className="modal__tags">
79+
{snippet.tags.map((tag) => (
80+
<li key={tag} className="modal__tag">
81+
{tag}
82+
</li>
83+
))}
84+
</ul>
85+
</div>
8486
</motion.div>
8587
</motion.div>,
8688
modalRoot

src/styles/main.css

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,22 +550,19 @@ abbr {
550550
border-radius: var(--br-lg);
551551
padding: 0.75em;
552552
text-align: start;
553-
filter: grayscale(100%);
554553

555554
&:is(:hover, :focus-visible) {
556-
outline: 3px solid var(--clr-border-primary);
557-
filter: grayscale(0);
555+
outline: 2px solid var(--clr-border-primary);
558556
}
559557
}
560558

561559
.snippet__preview {
562560
width: 100%;
563561
overflow: hidden;
564-
aspect-ratio: 10 / 3;
562+
aspect-ratio: 9 / 3;
565563
background-color: var(--clr-bg-secondary);
566564
/* background-image: var(--gradient-secondary); */
567565
border: 1px solid var(--clr-border-primary);
568-
border-radius: var(--br-md);
569566
position: relative;
570567
padding-inline: 1em;
571568
display: grid;
@@ -599,20 +596,33 @@ body:has(.modal-overlay) {
599596

600597
.modal {
601598
background-color: var(--clr-bg-secondary);
602-
padding: 2rem;
603-
width: 90%;
604-
max-width: 800px;
599+
width: fit-content;
600+
max-width: 1000px;
601+
max-height: 90%;
605602
border-radius: var(--br-lg);
606603
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
604+
gap: 0;
607605
position: relative;
608-
gap: 1rem;
606+
overflow: auto;
609607
}
610608

611609
.modal__header {
610+
z-index: 50;
612611
display: flex;
612+
position: sticky;
613+
top: 0;
613614
align-items: center;
614615
justify-content: space-between;
615616
gap: 1rem;
617+
padding: 1rem 1.5rem;
618+
background-color: var(--clr-bg-secondary);
619+
border-radius: var(--br-lg);
620+
}
621+
622+
.modal__body {
623+
padding: 1.5rem;
624+
padding-top: 0;
625+
gap: 1rem;
616626
}
617627

618628
.code-preview {

0 commit comments

Comments
 (0)