Skip to content

Commit 9bffc3c

Browse files
committed
remove DocImageClient to simplify and scope styles
1 parent c74e563 commit 9bffc3c

File tree

5 files changed

+86
-103
lines changed

5 files changed

+86
-103
lines changed

app/globals.css

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -177,65 +177,6 @@ body {
177177

178178
.onboarding-step .step-heading::before,
179179
.onboarding-step h2::before {
180-
content: "Step " counter(onboarding-step) ": ";
180+
content: 'Step ' counter(onboarding-step) ': ';
181181
font-weight: inherit;
182182
}
183-
184-
/* Lightbox animations */
185-
@keyframes dialog-content-show {
186-
from {
187-
opacity: 0;
188-
transform: translate(-50%, -48%) scale(0.96);
189-
}
190-
to {
191-
opacity: 1;
192-
transform: translate(-50%, -50%) scale(1);
193-
}
194-
}
195-
196-
@keyframes dialog-content-hide {
197-
from {
198-
opacity: 1;
199-
transform: translate(-50%, -50%) scale(1);
200-
}
201-
to {
202-
opacity: 0;
203-
transform: translate(-50%, -48%) scale(0.96);
204-
}
205-
}
206-
207-
@keyframes dialog-overlay-show {
208-
from {
209-
opacity: 0;
210-
}
211-
to {
212-
opacity: 1;
213-
}
214-
}
215-
216-
@keyframes dialog-overlay-hide {
217-
from {
218-
opacity: 1;
219-
}
220-
to {
221-
opacity: 0;
222-
}
223-
}
224-
225-
/* Target only image lightbox dialog content */
226-
.image-lightbox-content[data-state="open"] {
227-
animation: dialog-content-show 200ms cubic-bezier(0.16, 1, 0.3, 1);
228-
}
229-
230-
.image-lightbox-content[data-state="closed"] {
231-
animation: dialog-content-hide 200ms cubic-bezier(0.16, 1, 0.3, 1);
232-
}
233-
234-
/* Target only image lightbox dialog overlay */
235-
.image-lightbox-overlay[data-state="open"] {
236-
animation: dialog-overlay-show 200ms cubic-bezier(0.16, 1, 0.3, 1);
237-
}
238-
239-
.image-lightbox-overlay[data-state="closed"] {
240-
animation: dialog-overlay-hide 200ms cubic-bezier(0.16, 1, 0.3, 1);
241-
}

src/components/docImage.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22

33
import {serverContext} from 'sentry-docs/serverContext';
44

5-
import {DocImageClient} from './docImageClient';
5+
import {ImageLightbox} from './imageLightbox';
66

77
export default function DocImage({
88
src,
@@ -33,11 +33,12 @@ export default function DocImage({
3333
: 800;
3434

3535
return (
36-
<DocImageClient
36+
<ImageLightbox
3737
src={src}
3838
imgPath={src} // For external images, imgPath should be the same as src
3939
width={width}
4040
height={height}
41+
alt=""
4142
{...props}
4243
/>
4344
);
@@ -92,11 +93,12 @@ export default function DocImage({
9293
const height = dimensions[1] > 0 ? dimensions[1] : parseDimension(propsHeight);
9394

9495
return (
95-
<DocImageClient
96+
<ImageLightbox
9697
src={src}
9798
imgPath={imgPath}
9899
width={width}
99100
height={height}
101+
alt=""
100102
{...props}
101103
/>
102104
);

src/components/docImageClient.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* Lightbox animations */
2+
@keyframes dialogContentShow {
3+
from {
4+
opacity: 0;
5+
transform: translate(-50%, -48%) scale(0.96);
6+
}
7+
to {
8+
opacity: 1;
9+
transform: translate(-50%, -50%) scale(1);
10+
}
11+
}
12+
13+
@keyframes dialogContentHide {
14+
from {
15+
opacity: 1;
16+
transform: translate(-50%, -50%) scale(1);
17+
}
18+
to {
19+
opacity: 0;
20+
transform: translate(-50%, -48%) scale(0.96);
21+
}
22+
}
23+
24+
@keyframes dialogOverlayShow {
25+
from {
26+
opacity: 0;
27+
}
28+
to {
29+
opacity: 1;
30+
}
31+
}
32+
33+
@keyframes dialogOverlayHide {
34+
from {
35+
opacity: 1;
36+
}
37+
to {
38+
opacity: 0;
39+
}
40+
}
41+
42+
/* Lightbox content styles */
43+
.lightboxContent {
44+
position: fixed;
45+
left: 50%;
46+
top: 50%;
47+
z-index: 50;
48+
max-height: 90vh;
49+
max-width: 90vw;
50+
transform: translate(-50%, -50%);
51+
}
52+
53+
.lightboxContent[data-state='open'] {
54+
animation: dialogContentShow 200ms cubic-bezier(0.16, 1, 0.3, 1);
55+
}
56+
57+
.lightboxContent[data-state='closed'] {
58+
animation: dialogContentHide 200ms cubic-bezier(0.16, 1, 0.3, 1);
59+
}
60+
61+
/* Lightbox overlay styles */
62+
.lightboxOverlay {
63+
position: fixed;
64+
inset: 0;
65+
background-color: rgba(0, 0, 0, 0.8);
66+
backdrop-filter: blur(4px);
67+
z-index: 50;
68+
}
69+
70+
.lightboxOverlay[data-state='open'] {
71+
animation: dialogOverlayShow 200ms cubic-bezier(0.16, 1, 0.3, 1);
72+
}
73+
74+
.lightboxOverlay[data-state='closed'] {
75+
animation: dialogOverlayHide 200ms cubic-bezier(0.16, 1, 0.3, 1);
76+
}

src/components/imageLightbox.tsx renamed to src/components/imageLightbox/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {X} from 'react-feather';
55
import * as Dialog from '@radix-ui/react-dialog';
66
import Image from 'next/image';
77

8+
import styles from './imageLightbox.module.scss';
9+
810
interface ImageLightboxProps
911
extends Omit<
1012
React.HTMLProps<HTMLImageElement>,
@@ -118,9 +120,9 @@ export function ImageLightbox({
118120
</div>
119121

120122
<Dialog.Portal>
121-
<Dialog.Overlay className="image-lightbox-overlay fixed inset-0 bg-black/80 backdrop-blur-sm z-50" />
123+
<Dialog.Overlay className={styles.lightboxOverlay} />
122124

123-
<Dialog.Content className="image-lightbox-content fixed left-[50%] top-[50%] z-50 max-h-[90vh] max-w-[90vw] translate-x-[-50%] translate-y-[-50%]">
125+
<Dialog.Content className={styles.lightboxContent}>
124126
{/* Close button */}
125127
<Dialog.Close className="absolute right-4 top-4 z-10 rounded-sm bg-[var(--flame0)] border border-white/20 p-2 text-white opacity-90 transition-all duration-200 hover:opacity-100 hover:bg-[var(--flame1)] hover:border-white/30 hover:scale-105 focus:outline-none focus:ring-2 focus:ring-white active:scale-95 flex items-center justify-center">
126128
<X className="h-4 w-4 stroke-[2.5]" />

0 commit comments

Comments
 (0)