1- import type { CSSProperties , PropsWithChildren , ReactElement } from "react" ;
1+ import type { PropsWithChildren , ReactElement } from "react" ;
22
33interface BrowserScreenshotProps {
44 url ?: string ;
5- browserTheme ?: "light" | "dark" ;
6- browserShadow ?: string ;
7- borderRadius ?: number ;
8- className ?: string ;
9- style ?: CSSProperties ;
105 size ?: "sm" | "md" | "lg" ;
116}
127
@@ -19,162 +14,51 @@ const marginClasses = {
1914export function BrowserScreenshot ( {
2015 children,
2116 url = "https://example.com" ,
22- browserTheme = "light" ,
23- browserShadow = "0 10px 40px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.04)" ,
24- borderRadius = 8 ,
25- className = "" ,
26- style,
2717 size,
2818} : PropsWithChildren < BrowserScreenshotProps > ) : ReactElement {
29- const isDark = browserTheme === "dark" ;
30-
31- const browserWindowStyle : CSSProperties = {
32- borderRadius : `${ borderRadius } px` ,
33- overflow : "hidden" ,
34- boxShadow : browserShadow ,
35- backgroundColor : isDark ? "#1a1a1a" : "#fafafa" ,
36- border : `1px solid ${ isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)" } ` ,
37- margin : "0 auto" ,
38- maxWidth : "90%" ,
39- ...style ,
40- } ;
41-
42- const browserBarStyle : CSSProperties = {
43- height : "40px" ,
44- backgroundColor : isDark ? "#262626" : "#f6f6f6" ,
45- display : "flex" ,
46- alignItems : "center" ,
47- padding : "0 16px" ,
48- gap : "16px" ,
49- position : "relative" as const ,
50- } ;
51-
52- const trafficLightStyle : CSSProperties = {
53- display : "flex" ,
54- gap : "8px" ,
55- alignItems : "center" ,
56- } ;
57-
58- const dotStyle : CSSProperties = {
59- width : "12px" ,
60- height : "12px" ,
61- borderRadius : "50%" ,
62- } ;
63-
64- const navigationStyle : CSSProperties = {
65- display : "flex" ,
66- gap : "16px" ,
67- alignItems : "center" ,
68- } ;
69-
70- const navButtonStyle : CSSProperties = {
71- width : "14px" ,
72- height : "14px" ,
73- display : "flex" ,
74- alignItems : "center" ,
75- justifyContent : "center" ,
76- cursor : "pointer" ,
77- opacity : 0.6 ,
78- } ;
79-
80- const urlBarStyle : CSSProperties = {
81- flex : 1 ,
82- maxWidth : "320px" ,
83- height : "28px" ,
84- backgroundColor : isDark ? "#1a1a1a" : "#fafafa" ,
85- border : `1px solid ${ isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)" } ` ,
86- borderRadius : "20px" ,
87- padding : "0 12px" ,
88- display : "flex" ,
89- alignItems : "center" ,
90- justifyContent : "center" ,
91- fontSize : "13px" ,
92- color : isDark ? "#888888" : "#666666" ,
93- fontFamily :
94- "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif" ,
95- } ;
96-
97- const contentStyle : CSSProperties = {
98- backgroundColor : "#ffffff" ,
99- display : "block" ,
100- } ;
101-
102- const marginClass = size
103- ? marginClasses [ size ]
104- ? marginClasses [ size ]
105- : "mx-auto"
106- : "mx-auto" ;
19+ const marginClass = size ? ( marginClasses [ size ] ?? "mx-auto" ) : "mx-auto" ;
10720
10821 return (
10922 < div
11023 className = { `[&>p]:m-0 [&>p]:p-0 [&>p>img]:m-0 [&>p>img]:p-0 my-8 ${ marginClass } ` }
11124 >
112- < div
113- className = { `browser-screenshot-wrapper ${ className } ` }
114- style = { browserWindowStyle }
115- >
116- < style
117- dangerouslySetInnerHTML = { {
118- __html : `
119- .browser-screenshot-wrapper img {
120- border: 0 !important;
121- border-radius: 0 !important;
122- padding: 0 !important;
123- margin: 0 !important;
124- display: block !important;
125- max-width: 100% !important;
126- height: auto !important;
127- }
128- .browser-screenshot-wrapper p {
129- margin: 0 !important;
130- padding: 0 !important;
131- line-height: 0 !important;
132- }
133- ` ,
134- } }
135- />
136- < div style = { browserBarStyle } >
137- < div style = { trafficLightStyle } >
25+ < div className = "overflow-hidden mx-auto max-w-[90%] rounded-lg shadow-lg border border-border bg-card [&_img]:!border-0 [&_img]:!rounded-none [&_img]:!p-0 [&_img]:!m-0 [&_img]:!block [&_img]:!max-w-full [&_img]:!h-auto [&_p]:!m-0 [&_p]:!p-0 [&_p]:!leading-[0]" >
26+ < div className = "h-10 flex items-center px-4 gap-4 relative bg-gray-100 dark:bg-gray-900" >
27+ < div className = "flex gap-2 items-center" >
13828 < div
139- style = { {
140- ...dotStyle ,
141- backgroundColor : "#FE5F57" ,
142- } }
29+ className = "w-3 h-3 rounded-full"
30+ style = { { backgroundColor : "#FE5F57" } }
14331 />
14432 < div
145- style = { {
146- ...dotStyle ,
147- backgroundColor : "#FEBB2E" ,
148- } }
33+ className = "w-3 h-3 rounded-full"
34+ style = { { backgroundColor : "#FEBB2E" } }
14935 />
15036 < div
151- style = { {
152- ...dotStyle ,
153- backgroundColor : "#26C941" ,
154- } }
37+ className = "w-3 h-3 rounded-full"
38+ style = { { backgroundColor : "#26C941" } }
15539 />
15640 </ div >
157- < div style = { navigationStyle } >
158- < div style = { navButtonStyle } >
159- < svg viewBox = "0 0 16 16" fill = { isDark ? "#888888" : "#666666" } >
41+ < div className = "flex gap-4 items-center" >
42+ < div className = "w-3.5 h-3.5 flex items-center justify-center cursor-pointer opacity-60 text-gray-600 dark:text-gray-400" >
43+ < svg viewBox = "0 0 16 16" fill = "currentColor" >
16044 < path
16145 fillRule = "evenodd"
16246 clipRule = "evenodd"
16347 d = "M6.46966 13.7803L6.99999 14.3107L8.06065 13.25L7.53032 12.7197L3.56065 8.75001H14.25H15V7.25001H14.25H3.56065L7.53032 3.28034L8.06065 2.75001L6.99999 1.68935L6.46966 2.21968L1.39644 7.2929C1.00592 7.68342 1.00592 8.31659 1.39644 8.70711L6.46966 13.7803Z"
16448 />
16549 </ svg >
16650 </ div >
167- < div style = { navButtonStyle } >
168- < svg viewBox = "0 0 16 16" fill = { isDark ? "#888888" : "#666666" } >
51+ < div className = "w-3.5 h-3.5 flex items-center justify-center cursor-pointer opacity-60 text-gray-600 dark:text-gray-400" >
52+ < svg viewBox = "0 0 16 16" fill = "currentColor" >
16953 < path
17054 fillRule = "evenodd"
17155 clipRule = "evenodd"
17256 d = "M9.53033 2.21968L9 1.68935L7.93934 2.75001L8.46967 3.28034L12.4393 7.25001H1.75H1V8.75001H1.75H12.4393L8.46967 12.7197L7.93934 13.25L9 14.3107L9.53033 13.7803L14.6036 8.70711C14.9941 8.31659 14.9941 7.68342 14.6036 7.2929L9.53033 2.21968Z"
17357 />
17458 </ svg >
17559 </ div >
176- < div style = { navButtonStyle } >
177- < svg viewBox = "0 0 16 16" fill = { isDark ? "#888888" : "#666666" } >
60+ < div className = "w-3.5 h-3.5 flex items-center justify-center cursor-pointer opacity-60 text-gray-600 dark:text-gray-400" >
61+ < svg viewBox = "0 0 16 16" fill = "currentColor" >
17862 < path
17963 fillRule = "evenodd"
18064 clipRule = "evenodd"
@@ -183,20 +67,13 @@ export function BrowserScreenshot({
18367 </ svg >
18468 </ div >
18569 </ div >
186- < div style = { urlBarStyle } >
187- < span
188- style = { {
189- fontSize : "13px" ,
190- whiteSpace : "nowrap" ,
191- overflow : "hidden" ,
192- textOverflow : "ellipsis" ,
193- } }
194- >
70+ < div className = "flex-1 max-w-xs h-7 rounded-full px-3 flex items-center justify-center text-[13px] font-sans bg-white dark:bg-gray-900 border border-gray-300 dark:border-gray-700 text-gray-600 dark:text-gray-400" >
71+ < span className = "text-[13px] whitespace-nowrap overflow-hidden text-ellipsis" >
19572 { url }
19673 </ span >
19774 </ div >
19875 </ div >
199- < div style = { contentStyle } > { children } </ div >
76+ < div className = "bg-card block" > { children } </ div >
20077 </ div >
20178 </ div >
20279 ) ;
0 commit comments