Skip to content

Commit

Permalink
Merge branch 'main' into 86.add-pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonatai committed Jun 15, 2023
2 parents 6625099 + 55d2db8 commit 7047070
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 27 deletions.
4 changes: 3 additions & 1 deletion environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
"displayText": "Why Neureka?"
},
"specUrl": "https://raw.githubusercontent.com/Gleethos/neureka/master/docs/spock/reports",
"summaryUrl": "https://raw.githubusercontent.com/Gleethos/neureka/master/docs/spock/reports/summary.json"
"summaryUrl": "https://raw.githubusercontent.com/Gleethos/neureka/master/docs/spock/reports/summary.json",
"rootUrl": "/spock-react/",
"LinkToIssueReport": "https://github.com/Sonatai/spock-react/issues"
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=5.0"
/>
<title>Neureka</title>
<title></title>

<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
Expand Down
11 changes: 7 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { nanoid } from 'nanoid';
import { useEffect } from 'react';
import { Route, Routes } from 'react-router-dom';

import * as config from '../environment.json';
import { MainNav } from './components/MainNav/MainNav';
import { LoadingSpinner } from './components/shared/LoadingSpinner/LoadingSpinner';
import { MarkdownPage } from './components/shared/MarkdownPage';
Expand All @@ -19,15 +21,16 @@ import { MarkdownExample } from './pages/MarkdownExample/MarkdownExample';
export const App = (): JSX.Element => {
const { data: summary, isLoading, isError } = useGetSummary();

useEffect(() => {
document.title = config.appName;
}, []);

if (isError) {
return (
<Message level="error" headline="The summary couldn't be loaded">
The summary has some loading problems. Please try again later.
If the problem still occurs, please open an{' '}
<a href="https://github.com/Sonatai/spock-react/issues">
issue
</a>
.
<a href={config.LinkToIssueReport}>issue</a>.
</Message>
);
} else if (isLoading) {
Expand Down
5 changes: 3 additions & 2 deletions src/Hooks/useActiveLink.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { create } from 'zustand';
import * as config from '../../environment.json';

const getInitialState = () => {
const pageAndAnchor = window.location.pathname.split('#');
const page =
pageAndAnchor[0] === '/spock-react/'
pageAndAnchor[0] === config.rootUrl
? '/'
: pageAndAnchor[0].replace('/spock-react', '');
: pageAndAnchor[0].replace(config.rootUrl, '');

return page;
};
Expand Down
8 changes: 5 additions & 3 deletions src/components/MainNav/MainNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Link } from 'react-router-dom';
import { faBook, faHouseChimney } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import * as config from '../../../environment.json';
import GithubLogo from '../../assets/img/github-mark-white.png';
import { useActiveLink } from '../../Hooks/useActiveLink';
import { ISummary } from '../../Hooks/useGetSummary';
Expand All @@ -18,6 +19,7 @@ interface IMainNav {

export const MainNav = (props: IMainNav) => {
const { summary } = props;

const { setActiveLink } = useActiveLink();

return (
Expand All @@ -29,7 +31,7 @@ export const MainNav = (props: IMainNav) => {
setActiveLink('home');
}}
>
Neureka
{config.appName}
</Link>

<div className="main__search">
Expand All @@ -40,7 +42,7 @@ export const MainNav = (props: IMainNav) => {
<h4>Menu</h4>
<ul className="main__list">
<NavLink href="/">
Home{' '}
Home
<FontAwesomeIcon
icon={faHouseChimney}
size="lg"
Expand All @@ -49,7 +51,7 @@ export const MainNav = (props: IMainNav) => {
</NavLink>

<NavLink href="https://github.com/Gleethos/neureka">
Github{' '}
Github
<img
src={GithubLogo}
alt="Github Logo"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/SearchHits/SearchCard/SearchCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const SearchCard = (props: ISearchCard): JSX.Element => {

<FontAwesomeIcon
icon={faAngleRight}
// eslint-disable-next-line tailwindcss/no-custom-classname
className="fa-lg card__icon"
className="card__icon"
size="lg"
/>
</Link>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const SearchInput = (props: ISearchInput): JSX.Element => {
<div className="input__wrapper">
<FontAwesomeIcon
icon={faMagnifyingGlass}
// eslint-disable-next-line tailwindcss/no-custom-classname
className="fa-xl input__icon"
className="input__icon"
size="xl"
/>
<Input
onChange={(e) => {
Expand Down
6 changes: 2 additions & 4 deletions src/components/shared/MarkdownPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as config from '../../../environment.json';
import { useMarkdown } from '../../Hooks/useMarkdown';
import { Layout } from './Layout/Layout';
import { LoadingSpinner } from './LoadingSpinner/LoadingSpinner';
Expand All @@ -18,10 +19,7 @@ export const MarkdownPage = (props: IMarkdownPage): JSX.Element => {
<Message level="error" headline="Page couldn't be loaded">
Sorry the page could not be loaded. Please try again later. If
the error still occurs, please open an{' '}
<a href="https://github.com/Sonatai/spock-react/issues">
issue
</a>
.
<a href={config.LinkToIssueReport}>issue</a>.
</Message>
);
} else if (isLoading) {
Expand Down
3 changes: 2 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import { App } from './App';
import { Message } from './components/shared/Message/Message';
import * as config from '../environment.json';

const queryClient = new QueryClient();

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<BrowserRouter basename="/spock-react">
<BrowserRouter basename={config.rootUrl}>
<QueryClientProvider client={queryClient}>
<ErrorBoundary
fallback={
Expand Down
2 changes: 1 addition & 1 deletion src/markdown.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module '*.md' {
const value: string; // markdown is just a string
const value: string;
export default value;
}
1 change: 0 additions & 1 deletion src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { rest } from 'msw';
export const handlers = [
rest.get('*summary.json', async (req, res, ctx) => {
return await res(
// Respond with a 200 status code
ctx.status(200),
ctx.json({
name: '',
Expand Down
6 changes: 2 additions & 4 deletions src/pages/Document.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { nanoid } from 'nanoid';
import { Fragment } from 'react';

import * as config from '../../environment.json';
import { Feature } from '../components/Feature/Feature';
import { Divide } from '../components/shared/Divide/Divide';
import { Layout } from '../components/shared/Layout/Layout';
Expand All @@ -24,10 +25,7 @@ export const Document = (props: IExampleOne): JSX.Element => {
<Message level="error" headline={`${fileName} couldn't be loaded`}>
The page has some loading problems. Please try again later. If
the problem still occurs, please open an{' '}
<a href="https://github.com/Sonatai/spock-react/issues">
issue
</a>
.
<a href={config.LinkToIssueReport}>issue</a>.
</Message>
);
} else if (isLoading) {
Expand Down
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import * as config from './environment.json';

// https://vitejs.dev/config/
export default defineConfig({
base: '/spock-react/',
base: config.rootUrl,
plugins: [react()],
// @ts-ignore
test: {
Expand Down

0 comments on commit 7047070

Please sign in to comment.