@@ -12,9 +12,34 @@ import React from "react";
1212import pkg from "../../../package.json" ;
1313import "./StyleGuideHeader.css" ;
1414
15+ const prRegExp = / h t t p s : \/ \/ ( [ \w ] + ) \. g i t h u b .i o \/ ( [ \w ] + ) \/ p u l l \/ ( [ \d ] + ) / ;
16+ const prData = prRegExp . exec ( location . href ) ;
17+
1518export const StyleGuideHeader = ( { switchStyleGuideAppearance } ) => {
1619 const appearance = useAppearance ( ) ;
1720
21+ const links = [
22+ {
23+ title : "v" + pkg . version ,
24+ href : "https://www.npmjs.com/package/@vkontakte/vkui" ,
25+ } ,
26+ {
27+ title : "Github" ,
28+ href : "https://github.com/VKCOM/VKUI" ,
29+ } ,
30+ {
31+ title : "Релизы" ,
32+ href : "https://github.com/VKCOM/VKUI/releases" ,
33+ } ,
34+ ] ;
35+
36+ if ( prData ) {
37+ links . unshift ( {
38+ title : `pull/${ prData [ 3 ] } ` ,
39+ href : `https://github.com/${ prData [ 1 ] } /${ prData [ 2 ] } /pull/${ prData [ 3 ] } ` ,
40+ } ) ;
41+ }
42+
1843 return (
1944 < div className = "StyleGuideHeader" >
2045 < SplitLayout >
@@ -38,27 +63,16 @@ export const StyleGuideHeader = ({ switchStyleGuideAppearance }) => {
3863 </ SplitCol >
3964 < SplitCol width = "100%" className = "StyleGuideHeader__main" >
4065 < div className = "StyleGuideHeader__links" >
41- < Link
42- target = "_blank"
43- className = "StyleGuideHeader__link"
44- href = "https://www.npmjs.com/package/@vkontakte/vkui"
45- >
46- < Text > v{ pkg . version } </ Text >
47- </ Link >
48- < Link
49- target = "_blank"
50- className = "StyleGuideHeader__link"
51- href = "https://github.com/VKCOM/VKUI"
52- >
53- < Text > Github</ Text >
54- </ Link >
55- < Link
56- target = "_blank"
57- className = "StyleGuideHeader__link"
58- href = "https://github.com/VKCOM/VKUI/releases"
59- >
60- < Text > Релизы</ Text >
61- </ Link >
66+ { links . map ( ( item , i ) => (
67+ < Link
68+ key = { i }
69+ target = "_blank"
70+ className = "StyleGuideHeader__link"
71+ href = { item . href }
72+ >
73+ < Text > { item . title } </ Text >
74+ </ Link >
75+ ) ) }
6276 </ div >
6377 < div className = "StyleGuideHeader__aside" >
6478 < IconButton
0 commit comments