This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +40
-13
lines changed
src/features/Apiexplorer/Schema/HighlightCode Expand file tree Collapse file tree 2 files changed +40
-13
lines changed Original file line number Diff line number Diff line change 11@use ' src/styles/utility' as * ;
22
33.schemaRole {
4- background-color : rgba (255 , 255 , 255 , 0.16 );
5- border : none ;
6- font-size : rem (1.4 );
7- font-weight : 400 ;
8- line-height : rem (2.4 );
9- color : var (--ifm-color-white );
10- height : fit-content ;
11- padding : rem (0.5 ) rem (0.5 );
12- margin : 0 rem (0.5 );
4+ background-color : rgba (255 , 255 , 255 , 0.16 );
5+ border : none ;
6+ font-size : rem (1.4 );
7+ font-weight : 400 ;
8+ line-height : rem (2.4 );
9+ color : var (--ifm-color-white );
10+ height : fit-content ;
11+ padding : rem (0.5 ) rem (0.5 );
12+ margin : 0 rem (0.5 );
1313}
14-
14+
1515.schemaCode {
16- color : var (--ifm-color-white );
17- font-size : rem (1.4 );
16+ color : var (--ifm-color-white );
17+ font-size : rem (1.4 );
18+ }
19+
20+ .schemaLink {
21+ cursor : pointer ;
22+ text-decoration : underline ;
1823}
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import clsx from 'clsx' ;
33import styles from './HighlightCode.module.scss' ;
4+ import { playground_requests } from '@site/src/utils/playground_requests' ;
45import { SchemaDescriptionTypes } from '../RecursiveContent/SchemaDescription' ;
6+ import { useHistory , useLocation } from '@docusaurus/router' ;
57
68export const HighlightCode = ( { description } : SchemaDescriptionTypes ) => {
9+ const { pathname } = useLocation ( ) ;
10+ const history = useHistory ( ) ;
11+
712 if ( ! description ) return null ;
813
914 const [ first , code , ...rest ] = description . split ( '`' ) ;
15+
16+ const api_call_object = playground_requests . find ( ( el ) => el . name === code ) ;
17+ const link_api_call = ( obj ) => {
18+ window . scrollTo ( 0 , 0 ) ;
19+ history . push ( `${ pathname } #${ obj ?. name } ` ) ;
20+ } ;
21+
1022 return (
1123 < React . Fragment >
1224 { first }
13- { code && < span className = { clsx ( styles . schemaRole , styles . schemaCode ) } > { code } </ span > }
25+ { code && (
26+ < span className = { clsx ( styles . schemaRole , styles . schemaCode ) } >
27+ { api_call_object ? (
28+ < button onClick = { ( ) => link_api_call ( api_call_object ) } className = { styles . schemaLink } >
29+ { code }
30+ </ button >
31+ ) : (
32+ code
33+ ) }
34+ </ span >
35+ ) }
1436 { rest . length > 0 && < HighlightCode description = { rest . join ( '`' ) } /> }
1537 </ React . Fragment >
1638 ) ;
You can’t perform that action at this time.
0 commit comments