Skip to content

Commit f3a7d09

Browse files
committed
pr fixes
1 parent 5440930 commit f3a7d09

File tree

5 files changed

+54
-68
lines changed

5 files changed

+54
-68
lines changed

src/app/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// NOTE: Временно используем вспомогательные utilities-классы, на время разработки прототипа приложения
22
@import "~tailwindcss/dist/utilities.css";
3+
// css-переменные проекта
34
@import "./styles/vars.scss";
5+
// нормализация стилей проекта
46
@import "./styles/normalize.scss";
7+
// нормализация стилей antd компонентов
58
@import "./styles/normalize-antd.scss";
9+
// классы-утилиты
610
@import "./styles/utils.scss";
711

812
.gc-app {

src/features/repo-explorer/components/hooks.ts

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -50,64 +50,3 @@ export const useRepoDetails = (repoInfo: RepoBranchInfoQuery | undefined) => {
5050
readme,
5151
};
5252
};
53-
54-
type useLocalUriProps = {
55-
/** Текст README файла */
56-
text: string;
57-
/** Флаг загрузки */
58-
loading: boolean;
59-
/**
60-
* Ссылка-идентификатор репозитория
61-
* @remark Для обработки локальных ссылок
62-
*/
63-
repoUrl: string;
64-
/**
65-
* Текущая ветка
66-
* @remark Для обработки локальных ссылок
67-
*/
68-
branch: string;
69-
};
70-
71-
/**
72-
* @hook Обработка внутренних ссылок
73-
* @remark
74-
* - В README могут быть указаны ссылки на локальные ресурсы репозитория (images, files, anchors, ...)
75-
* - Поэтому, для корректной навигации и отображения, было решено предобрабатывать подобные ссылки
76-
*/
77-
export const useLocalUri = ({ repoUrl, branch }: useLocalUriProps) => {
78-
/**
79-
* Нормализация внутренних ссылок
80-
* @example
81-
* transformLocalUri("https://some-url/...")
82-
* // => "https://some-url/..."
83-
* transformLocalUri("#some-header")
84-
* // => "https://github.com/${repo}#some-header"
85-
* transformLocalUri("./SOMEFILE.md")
86-
* // => "https://github.com/${repo}/blobk/${branch}/SOMEFILE.md"
87-
* transformLocalUri("docs/ANOTHER.md")
88-
* // => "https://github.com/${repo}/blobk/${branch}/docs/ANOTHER.md"
89-
*/
90-
const transformLinkUri = (uri: string) => {
91-
if (uri.startsWith("http")) return uri;
92-
if (uri.startsWith("#")) return `https://github.com/${repoUrl}${uri}`;
93-
// Если sibling-link - нормализуем
94-
const blobUrl = uri.replace("./", "");
95-
return `https://github.com/${repoUrl}/blob/${branch}/${blobUrl}`;
96-
};
97-
98-
/**
99-
* Получение исходника локального изображения
100-
* FIXME: Работает только с markodwn-изображениями, потом переделать бы на общий случай
101-
* @example
102-
* transformImageUri("docs/search.png")
103-
* // => https://raw.githubusercontent.com/${repo}/${branch}/docs/search.png
104-
*/
105-
const transformImageUri = (uri: string) => {
106-
if (uri.startsWith("http")) return uri;
107-
// Если sibling-link - нормализуем
108-
const blobUrl = uri.replace("./", "");
109-
return `https://raw.githubusercontent.com/${repoUrl}/${branch}/${blobUrl}`;
110-
};
111-
112-
return { transformLinkUri, transformImageUri };
113-
};

src/features/repo-explorer/components/readme/index.tsx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import Markdown from "react-markdown";
33
import gfm from "remark-gfm";
4-
import { useLocalUri } from "../hooks";
54
import SkeletonArea from "../skeleton-area";
65
import CodeRenderer from "./code-renderer";
76
import "./index.scss";
@@ -23,6 +22,50 @@ type Props = {
2322
branch: string;
2423
};
2524

25+
/**
26+
* @hook Обработка внутренних ссылок
27+
* @remark
28+
* - В README могут быть указаны ссылки на локальные ресурсы репозитория (images, files, anchors, ...)
29+
* - Поэтому, для корректной навигации и отображения, было решено предобрабатывать подобные ссылки
30+
*/
31+
const useLocalUri = ({ repoUrl, branch }: Props) => {
32+
/**
33+
* Нормализация внутренних ссылок
34+
* @example
35+
* transformLocalUri("https://some-url/...")
36+
* // => "https://some-url/..."
37+
* transformLocalUri("#some-header")
38+
* // => "https://github.com/${repo}#some-header"
39+
* transformLocalUri("./SOMEFILE.md")
40+
* // => "https://github.com/${repo}/blobk/${branch}/SOMEFILE.md"
41+
* transformLocalUri("docs/ANOTHER.md")
42+
* // => "https://github.com/${repo}/blobk/${branch}/docs/ANOTHER.md"
43+
*/
44+
const transformLinkUri = (uri: string) => {
45+
if (uri.startsWith("http")) return uri;
46+
if (uri.startsWith("#")) return `https://github.com/${repoUrl}${uri}`;
47+
// Если sibling-link - нормализуем
48+
const blobUrl = uri.replace("./", "");
49+
return `https://github.com/${repoUrl}/blob/${branch}/${blobUrl}`;
50+
};
51+
52+
/**
53+
* Получение исходника локального изображения
54+
* FIXME: Работает только с markodwn-изображениями, потом переделать бы на общий случай
55+
* @example
56+
* transformImageUri("docs/search.png")
57+
* // => https://raw.githubusercontent.com/${repo}/${branch}/docs/search.png
58+
*/
59+
const transformImageUri = (uri: string) => {
60+
if (uri.startsWith("http")) return uri;
61+
// Если sibling-link - нормализуем
62+
const blobUrl = uri.replace("./", "");
63+
return `https://raw.githubusercontent.com/${repoUrl}/${branch}/${blobUrl}`;
64+
};
65+
66+
return { transformLinkUri, transformImageUri };
67+
};
68+
2669
/**
2770
* README репозитория
2871
* TODO: Плохо обрабатываются сочетания markdown и html - возможно позже надо завезти отдельный htmlParser
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { dom } from "shared/helpers";
22
import { SearchType } from "models";
3-
import * as Params from "./params";
4-
5-
const PAGE_SIZE = 10;
3+
import * as Params from "../params";
64

75
/**
86
* @hook Работа с поиском, фильтрацией, сортировкой и пагинацией
97
*/
10-
export const useSearch = () => {
8+
export const useSearch = (PAGE_SIZE: number) => {
119
const { sortOrder, sortField } = Params.useSearchSortParams();
1210
const { searchQuery } = Params.useSearchQueryParam();
1311
const { searchTypeEnum } = Params.useSearchTypeParam();

src/features/search/results/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import cn from "classnames";
33
import { Skeleton, Empty, Pagination } from "antd";
44
import { Repo, User, Org, Card } from "shared/components";
5-
import { useSearch } from "../hooks";
5+
import { useSearch } from "./hooks";
66
import { useSearchQuery } from "./queries.gen";
77
import SortSelect from "./sort-select";
88
import "./index.scss";
@@ -16,7 +16,9 @@ const PAGE_SIZE = 10;
1616
* @remark Отображение результатов поиска на основании запроса и конфига
1717
*/
1818
const SearchResults = () => {
19-
const { handlePageChange, page, isUserSearch, isRepoSearch, ...searchConfig } = useSearch();
19+
const { handlePageChange, page, isUserSearch, isRepoSearch, ...searchConfig } = useSearch(
20+
PAGE_SIZE,
21+
);
2022

2123
const { data, loading } = useSearchQuery({ variables: searchConfig });
2224

0 commit comments

Comments
 (0)