File tree Expand file tree Collapse file tree 3 files changed +48
-6
lines changed
packages/cursorless-org-docs/src/docs/user/languages/components Expand file tree Collapse file tree 3 files changed +48
-6
lines changed Original file line number Diff line number Diff line change 4747 border-right : 1px solid rgba (115 , 138 , 148 , 0.4 );
4848}
4949
50- .code-container : hover . code-copy-button {
51- display : block ;
50+ .code-ws-symbol {
51+ color : # 666 ;
5252}
5353
54- .code-copy-button {
54+ .code-copy-button ,
55+ .code-container > .code-link {
5556 display : none;
5657 position : absolute;
5758 top : 0.5em ;
58- right : 0.5em ;
5959 background-color : rgb (216 , 222 , 233 );
6060 border : none;
6161 padding : 4px 8px ;
6262 border-radius : 4px ;
6363 cursor : pointer;
6464 font-size : 0.75rem ;
65+ height : 1.75rem ;
6566}
6667
67- .code-ws-symbol {
68- color : # 666 ;
68+ .code-container : hover .code-copy-button ,
69+ .code-container : hover .code-link {
70+ display : block;
71+ }
72+
73+ .code-copy-button {
74+ right : 7.5em ;
75+ }
76+
77+ .code-container > .code-link {
78+ right : 0.5em ;
79+ }
80+
81+ .code-container > .code-link : before {
82+ display : inline-block;
83+ width : 1.25rem ;
84+ height : 0.75rem ;
6985}
Original file line number Diff line number Diff line change @@ -12,13 +12,18 @@ interface Props {
1212 languageId : string ;
1313 renderWhitespace ?: boolean ;
1414 highlights ?: Highlight [ ] ;
15+ link ?: {
16+ name : string ;
17+ url : string ;
18+ } ;
1519 children : string ;
1620}
1721
1822export function Code ( {
1923 languageId,
2024 renderWhitespace,
2125 highlights,
26+ link,
2227 children,
2328} : Props ) {
2429 const [ html , setHtml ] = React . useState ( "" ) ;
@@ -54,8 +59,25 @@ export function Code({
5459 }
5560 } ;
5661
62+ const renderLink = ( ) => {
63+ if ( link == null ) {
64+ return null ;
65+ }
66+ return (
67+ < a
68+ className = "code-link header-github-link"
69+ href = { link . url }
70+ target = "_blank"
71+ rel = "noopener noreferrer"
72+ >
73+ { link . name }
74+ </ a >
75+ ) ;
76+ } ;
77+
5778 return (
5879 < div className = "code-container" >
80+ { renderLink ( ) }
5981 < button onClick = { handleCopy } className = "code-copy-button" >
6082 { copied ? "✅ Copied!" : "📋 Copy" }
6183 </ button >
Original file line number Diff line number Diff line change @@ -133,6 +133,10 @@ function renderFacet(
133133 { facet . fixtures . map ( ( fixture ) => (
134134 < Code
135135 key = { fixture . name }
136+ link = { {
137+ name : "GitHub" ,
138+ url : `https://github.com/cursorless-dev/cursorless/blob/main/data/fixtures/${ fixture . name } .scope` ,
139+ } }
136140 languageId = { languageId }
137141 renderWhitespace = { renderWhitespace }
138142 highlights = { calculateHighlights ( fixture , rangeType ) }
You can’t perform that action at this time.
0 commit comments