File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
docs/src/components/Screenshot Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { CSSProperties } from 'react' ;
22import * as styles from './styles.module.scss' ;
33
44interface ScreenshotProps {
55 alt ?: string ;
66 src : string ;
7+
8+ /**
9+ * Use CSS `clip-path` to highlight a specific area of the screenshot.
10+ *
11+ * @example inset(20% 64% 72% 20% round 10px)
12+ */
13+ highlight ?: CSSProperties [ 'clipPath' ] ;
714}
815
9- export const Screenshot = ( { alt, src } : ScreenshotProps ) => {
16+ const ScreenshotHighlight = ( { highlight, src } : ScreenshotProps ) => (
17+ < div
18+ className = { styles . highlight }
19+ style = { {
20+ backgroundImage : `url(${ src } )` ,
21+ clipPath : highlight ,
22+ } }
23+ />
24+ )
25+
26+ export const Screenshot = ( props : ScreenshotProps ) => {
1027 return (
1128 < div className = { styles . screenshot } style = { { textAlign : 'center' } } >
29+ { props . highlight ? ( < ScreenshotHighlight { ...props } /> ) : null }
1230 < img
13- alt = { alt }
14- src = { src }
15- style = { { border : 'none' } }
31+ alt = { props . alt }
32+ src = { props . src }
33+ style = { { border : 'none' , filter : props . highlight ? 'brightness(0.5)' : 'none' } }
1634 width = "100%"
1735 />
1836 </ div >
Original file line number Diff line number Diff line change 3333 // transform: scale(.25);
3434 }
3535}
36+
37+ .highlight {
38+ width : 100% ;
39+ height : 100% ;
40+ position : absolute ;
41+ background-size : contain ;
42+ z-index : 9999 ;
43+ }
You can’t perform that action at this time.
0 commit comments