Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add tooltips #36

Merged
merged 26 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
941a7f6
Merge branch 'feature/add-layout-resize' of https://github.com/Quiddl…
Tedzury Dec 23, 2023
fa5b7f9
feat: add layout and functionality for settigns page. Add headers, th…
Tedzury Dec 25, 2023
dc18e99
feat: add logic and layout for showing and closing confirm modal window
Tedzury Dec 26, 2023
5a4dab6
feat: add localization for setting page
Tedzury Dec 26, 2023
9089262
feat: add logic for switching the app color theme
Tedzury Dec 26, 2023
e57fc84
feat: add logic and UI for undo data clearance
Tedzury Dec 26, 2023
f4d2b67
feat: add tests for settings page
Tedzury Dec 26, 2023
6914f50
test: attempt to fix tests #1
Tedzury Dec 26, 2023
75f2760
test: attempt to fix tests #2
Tedzury Dec 26, 2023
d866f53
docs: attepmt to fix tests
Quiddlee Dec 26, 2023
228e7e8
Merge branch 'develop' into feat/add_settings_layout
Quiddlee Dec 26, 2023
798e3ac
Update main.yml
Quiddlee Dec 26, 2023
632406d
test: attempt to fix test #3
Tedzury Dec 27, 2023
3f84893
Merge branch 'feat/add_settings_layout' of https://github.com/Quiddle…
Tedzury Dec 27, 2023
ea1380f
test: attempts to fix tests #4
Tedzury Dec 27, 2023
79bd1ff
test: attempts to fix tests #5
Tedzury Dec 27, 2023
ccda1d0
test: attempts to fix tests #6
Tedzury Dec 27, 2023
7401b31
test: attempts to fix tests #7
Tedzury Dec 27, 2023
6c56b2a
test: attempts to fix tests #8
Tedzury Dec 27, 2023
d404f79
test: attempts to fix tests #9
Tedzury Dec 27, 2023
b198e12
test: attempts to fix tests #10
Tedzury Dec 27, 2023
a8a4935
feat: pull develop branch, resolve merge conflicts
Tedzury Dec 27, 2023
f8eb6f5
fix: fix small layout issues
Tedzury Dec 27, 2023
01b623d
fix: remove nanoid from deps. Changed keys in Li to names
Tedzury Dec 27, 2023
753ee7a
fix: fix small issues which were requested during code review
Tedzury Dec 28, 2023
f09879b
feat: add tooltips. Remove redundant files.
Tedzury Dec 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module.exports = {
'import/no-extraneous-dependencies': 0,
'react/function-component-definition': 0,
'no-underscore-dangle': 0,
'jsx-a11y/no-static-element-interactions': 0,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'sort-imports': ['error', {ignoreCase: true, ignoreDeclarationSort: true}],
'import/order': [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [opened, synchronize]

env:
NODE_VERSION: 18.16.0
NODE_VERSION: 21.5.0

jobs:
linting:
Expand Down
64 changes: 39 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react-dom": "^18.2.0",
"react-hook-form": "^7.48.2",
"react-router-dom": "^6.20.1",
"toastify-js": "^1.12.0",
"react-toastify": "^9.1.3",
"yup": "^1.3.2"
},
"devDependencies": {
Expand All @@ -37,8 +37,8 @@
"@types/node": "^20.10.3",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@types/toastify-js": "^1.12.3",
"@types/react-test-renderer": "^18.0.7",
"@types/toastify-js": "^1.12.3",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@vitejs/plugin-react": "^4.2.0",
Expand Down
10 changes: 10 additions & 0 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { useEffect } from 'react';

import { RouterProvider } from 'react-router-dom';

import router from '@/router/router';
import localStorageKeys from '@/shared/constants/localStorageKeys';
import colorThemeSwitcher from '@/shared/helpers/colorThemeSwitcher';
import AuthProvider from '@shared/Context/AuthContext';
import LanguageProvider from '@shared/Context/LanguageContext';

const App = () => {
useEffect(() => {
const isLightTheme = localStorage.getItem(localStorageKeys.LIGHT_THEME);
if (isLightTheme) {
colorThemeSwitcher.setLight();
}
}, []);
return (
<AuthProvider>
<LanguageProvider>
Expand Down
8 changes: 4 additions & 4 deletions src/components/DocsComp/ui/DocsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type PropsType = {
};

const DocsOverlay = ({ isShown, setIsDocsShown, explorer, children }: PropsType) => {
function closeHandler(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) {
function closeHandler(e: React.MouseEvent<HTMLDivElement, MouseEvent> | React.KeyboardEvent<HTMLDivElement>) {
if ((e.target as HTMLButtonElement).hasAttribute('data-overlay')) {
setIsDocsShown((prev) => !prev);
explorer.setInitState();
Expand All @@ -23,15 +23,15 @@ const DocsOverlay = ({ isShown, setIsDocsShown, explorer, children }: PropsType)
return null;
}
return (
<button
<div
data-testid="overlay"
data-overlay
type="button"
onClick={(e) => closeHandler(e)}
onKeyDown={(e) => closeHandler(e)}
className="overlay absolute left-0 top-0 z-10 flex h-full w-full justify-start bg-black/60 "
>
{children}
</button>
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/DocsComp/ui/DocsRootComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DocsRootComp = ({ types, explorer }: { types: SchemaTypeObj[]; explorer: D
<div ref={rootRef} className="h-full">
<div className="rounded-[24px] bg-surface-container px-10 py-[56px] text-left text-on-surface sm:px-[56px]">
<h3 className="text-[57px] font-[500]">Docs</h3>
<p className="text-md text-left">A GraphQL schema provides a root type for each kind of operation.</p>
<p className="text-md mt-10 text-left">A GraphQL schema provides a root type for each kind of operation.</p>
</div>
<div className="mt-[56px] p-10 text-left font-[500] sm:px-[56px]">
<h4 className="text-[28px]">Root types:</h4>
Expand Down
8 changes: 4 additions & 4 deletions src/components/DocsComp/ui/DocsTypeComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const DocsTypeComp = ({ explorer, currType }: { explorer: DocsExplorerType; curr
const beforeSeparator = <br />;
const afterSeparator = i >= field.args.length - 1 ? <br /> : null;
return (
<>
<p key={argTypeName.concat(i.toString())} className="inline">
{separation && beforeSeparator}
<span className={separation ? 'pl-3' : ''} key={argTypeName}>
<span className={separation ? 'pl-3' : ''}>
<span className="text-tertiary">{arg.name}</span>:&nbsp;
{before}
<a className="text-docs-link-text-color hover:underline" href={link} onClick={(e) => clinkHandler(e, link)}>
Expand All @@ -30,7 +30,7 @@ const DocsTypeComp = ({ explorer, currType }: { explorer: DocsExplorerType; curr
{after}
</span>
{separation && afterSeparator}
</>
</p>
);
});
const returnType = getTypeName(field.type);
Expand All @@ -56,7 +56,7 @@ const DocsTypeComp = ({ explorer, currType }: { explorer: DocsExplorerType; curr
});
const inputFields = currType?.inputFields?.map((field) => {
return (
<li key={field.name}>
<li key={field?.type?.name}>
{field.name}:&nbsp;
<a
className="text-docs-link-text-color hover:underline"
Expand Down
15 changes: 13 additions & 2 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { useState } from 'react';

import useLanguage from '@/shared/Context/hooks';
import Icon from '@/shared/ui/Icon';
import IconButton from '@/shared/ui/IconButton';
import DocsComp from '@components/DocsComp/DocsComp';
import ShowDocsBtn from '@components/Header/ui/ShowDocsBtn';

const Header = () => {
const [isDocsShown, setIsDocsShown] = useState(false);
const { translation } = useLanguage();
const docsTooltip = translation.mainLayout.header.tooltips.docs;
return (
<>
<header className="col-span-full flex justify-between">
<p>Here is still header</p>
<div>
<ShowDocsBtn onClick={() => setIsDocsShown((prev) => !prev)} />
<IconButton
onClick={() => setIsDocsShown((prev) => !prev)}
data-tooltip={docsTooltip}
data-testid="show_docs"
className="tooltipElem"
>
<Icon>article</Icon>
</IconButton>
</div>
</header>
<DocsComp isShown={isDocsShown} setIsDocsShown={setIsDocsShown} />
Expand Down
27 changes: 0 additions & 27 deletions src/components/Header/ui/ShowDocsBtn.tsx

This file was deleted.

21 changes: 15 additions & 6 deletions src/components/RequestEditor/ui/Controls.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FC, HTMLAttributes } from 'react';

import { toast } from 'react-toastify';

import useLanguage from '@/shared/Context/hooks';
import urlParams from '@shared/constants/urlParams';
import toastifyNotation from '@shared/helpers/toastifyNotation';
import cn from '@shared/lib/helpers/cn';
import useScreen from '@shared/lib/hooks/useScreen';
import useUrl from '@shared/lib/hooks/useUrl';
Expand All @@ -18,13 +20,15 @@ type ControlsProps = HTMLAttributes<HTMLUListElement> & {
const Controls: FC<ControlsProps> = ({ onResponseOpen, isHidden, className }) => {
const { readUrl } = useUrl();
const screenType = useScreen();
const { translation } = useLanguage();
const { copy, play, prettify, openResp } = translation.mainPage.requestEditor.controlsTooltips;
const isAnimationsDisabled = screenType === 'tablet' || screenType === 'mobile';

const handleCopyText = async () => {
const query = readUrl(urlParams.QUERY);
await navigator.clipboard.writeText(query);

toastifyNotation('Request copied!');
toast(<p className="text-center">Request copied!</p>);
};

return (
Expand All @@ -38,7 +42,7 @@ const Controls: FC<ControlsProps> = ({ onResponseOpen, isHidden, className }) =>
'animate-fade-out-screen': isHidden,
})}
>
<Fab data-testid="fab" variant="primary">
<Fab data-testid="fab" variant="primary" data-tooltip={play} className="tooltipElem">
<Icon slot="icon">play_arrow</Icon>
</Fab>
</li>
Expand All @@ -48,7 +52,7 @@ const Controls: FC<ControlsProps> = ({ onResponseOpen, isHidden, className }) =>
'animate-fade-out-screen': isHidden,
})}
>
<FilledIconButton data-testid="copy-text" onClick={handleCopyText}>
<FilledIconButton data-testid="copy-text" onClick={handleCopyText} data-tooltip={copy} className="tooltipElem">
<Icon>content_copy</Icon>
</FilledIconButton>
</li>
Expand All @@ -58,7 +62,7 @@ const Controls: FC<ControlsProps> = ({ onResponseOpen, isHidden, className }) =>
'animate-fade-out-screen': isHidden,
})}
>
<FilledIconButton data-testid="prettify">
<FilledIconButton data-testid="prettify" data-tooltip={prettify} className="tooltipElem">
<Icon>mop</Icon>
</FilledIconButton>
</li>
Expand All @@ -68,7 +72,12 @@ const Controls: FC<ControlsProps> = ({ onResponseOpen, isHidden, className }) =>
'animate-fade-out-screen': isHidden,
})}
>
<FilledIconButton data-testid="open-response" onClick={() => onResponseOpen?.((prevState) => !prevState)}>
<FilledIconButton
data-testid="open-response"
onClick={() => onResponseOpen?.((prevState) => !prevState)}
data-tooltip={openResp}
className="tooltipElem"
>
<Icon>info</Icon>
</FilledIconButton>
</li>
Expand Down
34 changes: 34 additions & 0 deletions src/components/SettingsPageComp/ClearStorageComp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useState } from 'react';

import useLanguage from '@/shared/Context/hooks';
import FilledTonalButton from '@/shared/ui/FilledTonalButton';

import ConfirmModal from './ConfirmModal';
import ConfirmOverlay from './ConfirmOverlay';

const ClearStorageComp = () => {
const [isModalShown, setIsModalShown] = useState(false);
const { translation } = useLanguage();

return (
<>
<div className="mt-6 flex items-center justify-between pb-6">
<div className="flex flex-col justify-between">
<h4 className="text-[22px]">{translation.settingsPage.clear.title}</h4>
<p className="mt-4">{translation.settingsPage.clear.subtitle}</p>
</div>
<FilledTonalButton data-clear-btn className="text-primary" onClick={() => setIsModalShown((prev) => !prev)}>
{translation.settingsPage.clear.btn}
</FilledTonalButton>
</div>
<ConfirmOverlay isShown={isModalShown} setIsShown={setIsModalShown}>
<ConfirmModal
setIsShown={setIsModalShown}
locales={{ ...translation.settingsPage.clear.modal, ...translation.settingsPage.clear.undo }}
/>
</ConfirmOverlay>
</>
);
};

export default ClearStorageComp;
Loading