Moved types into subfolder in src

This commit is contained in:
DrMint 2022-08-28 14:01:17 +02:00
parent 40d893eba8
commit 669d4358e7
28 changed files with 44 additions and 41 deletions

View File

@ -13,7 +13,6 @@ import { Select } from "./Inputs/Select";
import { TextInput } from "./Inputs/TextInput";
import { MainPanel } from "./Panels/MainPanel";
import { Popup } from "./Popup";
import { AnchorIds } from "hooks/useScrollTopOnChange";
import { filterHasAttributes, isDefined, isUndefined } from "helpers/others";
import { prettyLanguage } from "helpers/formatters";
import { cIf, cJoin } from "helpers/className";
@ -25,6 +24,7 @@ import {
useIsScreenAtLeast,
} from "hooks/useContainerQuery";
import { useOnResize } from "hooks/useOnResize";
import { Ids } from "types/ids";
/*
*
@ -95,9 +95,9 @@ export const AppLayout = ({
const is1ColumnLayout = useIs1ColumnLayout();
const isScreenAtLeastXs = useIsScreenAtLeast("xs");
useOnResize(AnchorIds.Body, (width) => setScreenWidth(width));
useOnResize(AnchorIds.ContentPanel, (width) => setContentPanelWidth(width));
useOnResize(AnchorIds.SubPanel, (width) => setSubPanelWidth(width));
useOnResize(Ids.Body, (width) => setScreenWidth(width));
useOnResize(Ids.ContentPanel, (width) => setContentPanelWidth(width));
useOnResize(Ids.SubPanel, (width) => setSubPanelWidth(width));
const handlers = useSwipeable({
onSwipedLeft: (SwipeEventData) => {
@ -168,7 +168,7 @@ export const AppLayout = ({
>
<div
{...handlers}
id={AnchorIds.Body}
id={Ids.Body}
className={cJoin(
`fixed inset-0 m-0 grid touch-pan-y bg-light p-0 text-black
[grid-template-areas:'main_sub_content']`,
@ -250,7 +250,7 @@ export const AppLayout = ({
{/* Content panel */}
<div
id={AnchorIds.ContentPanel}
id={Ids.ContentPanel}
className={cJoin(
"texture-paper-dots bg-light [grid-area:content]",
cIf(contentPanelScroolbar, "overflow-y-scroll")
@ -269,7 +269,7 @@ export const AppLayout = ({
{/* Sub panel */}
{isDefined(subPanel) && (
<div
id={AnchorIds.SubPanel}
id={Ids.SubPanel}
className={cJoin(
`texture-paper-dots overflow-y-scroll border-r-[1px] border-dark/50 bg-light
transition-transform duration-300 [scrollbar-width:none]

View File

@ -2,7 +2,7 @@ import { useCallback } from "react";
import { Link } from "components/Inputs/Link";
import { DatePickerFragment } from "graphql/generated";
import { cIf, cJoin } from "helpers/className";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
/*

View File

@ -6,7 +6,7 @@ import { filterHasAttributes } from "helpers/others";
import { prettyInlineTitle, prettySlug } from "helpers/formatters";
import { Ico, Icon } from "components/Ico";
import { compareDate } from "helpers/date";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
/*

View File

@ -4,7 +4,7 @@ import { Ico, Icon } from "components/Ico";
import { cIf, cJoin } from "helpers/className";
import { ConditionalWrapper, Wrapper } from "helpers/component";
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
/*

View File

@ -5,7 +5,7 @@ import { ToolTip } from "components/ToolTip";
import { cJoin, cIf } from "helpers/className";
import { isDefinedAndNotEmpty } from "helpers/others";
import { Link } from "components/Inputs/Link";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
/*

View File

@ -2,7 +2,7 @@ import { useCallback } from "react";
import { Icon } from "components/Ico";
import { Button } from "components/Inputs/Button";
import { useAppLayout } from "contexts/AppLayoutContext";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
import { useIs3ColumnsLayout } from "hooks/useContainerQuery";
import { isDefined } from "helpers/others";

View File

@ -20,7 +20,7 @@ import {
import { ImageQuality } from "helpers/img";
import { useDeviceSupportsHover } from "hooks/useMediaQuery";
import { useSmartLanguage } from "hooks/useSmartLanguage";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useCurrencies } from "hooks/useLocalData";
/*

View File

@ -4,7 +4,7 @@ import { Img } from "./Img";
import { Link } from "./Inputs/Link";
import { UploadImageFragment } from "graphql/generated";
import { ImageQuality } from "helpers/img";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
/*

View File

@ -5,9 +5,10 @@ import { PageSelector } from "./Inputs/PageSelector";
import { Ico, Icon } from "./Ico";
import { cJoin } from "helpers/className";
import { isDefined, isDefinedAndNotEmpty } from "helpers/others";
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { useIs3ColumnsLayout } from "hooks/useContainerQuery";
import { useAppLayout } from "contexts/AppLayoutContext";
import { Ids } from "types/ids";
interface Group<T> {
name: string;
@ -70,7 +71,7 @@ export const SmartList = <T,>({
}: Props<T>): JSX.Element => {
const [page, setPage] = useState(0);
const { langui } = useAppLayout();
useScrollTopOnChange(AnchorIds.ContentPanel, [page], paginationScroolTop);
useScrollTopOnChange(Ids.ContentPanel, [page], paginationScroolTop);
useEffect(
() => setPage(0),
[searchingTerm, groupingFunction, groupSortingFunction, items]

View File

@ -1,4 +1,4 @@
import { PathDot, SelectiveNonNullable } from "./types/SelectiveNonNullable";
import { PathDot, SelectiveNonNullable } from "../types/SelectiveNonNullable";
import { Langui } from "./localData";
import {
Enum_Componentsetstextset_Status,

View File

@ -2,8 +2,8 @@ import { useCallback, useEffect, useMemo, useState } from "react";
import { throttle } from "throttle-debounce";
import { useIsClient } from "usehooks-ts";
import { useOnScroll } from "./useOnScroll";
import { AnchorIds } from "./useScrollTopOnChange";
import { isDefined } from "helpers/others";
import { Ids } from "types/ids";
export const useIntersectionList = (ids: string[]): number => {
const [currentIntersection, setCurrentIntersection] = useState(-1);
@ -11,7 +11,7 @@ export const useIntersectionList = (ids: string[]): number => {
const isClient = useIsClient();
const contentPanel = useMemo(
() => (isClient ? document.getElementById(AnchorIds.ContentPanel) : null),
() => (isClient ? document.getElementById(Ids.ContentPanel) : null),
[isClient]
);
@ -44,7 +44,7 @@ export const useIntersectionList = (ids: string[]): number => {
[refreshCurrentIntersection]
);
useOnScroll(AnchorIds.ContentPanel, throttledRefreshCurrentIntersection);
useOnScroll(Ids.ContentPanel, throttledRefreshCurrentIntersection);
useEffect(() => refreshCurrentIntersection(0), [refreshCurrentIntersection]);

View File

@ -1,9 +1,9 @@
import { useMemo, useCallback, useEffect } from "react";
import { useIsClient } from "usehooks-ts";
import { AnchorIds } from "./useScrollTopOnChange";
import { Ids } from "types/ids";
export const useOnScroll = (
id: AnchorIds,
id: Ids,
onScroll: (scroll: number) => void
): void => {
const isClient = useIsClient();

View File

@ -1,14 +1,9 @@
import { DependencyList, useEffect } from "react";
export enum AnchorIds {
Body = "bodyqs65d4a98d56az48z64d",
ContentPanel = "contentPanel495922447721572",
SubPanel = "subPanelz9e8rs2d3f18zer98ze",
}
import { Ids } from "types/ids";
// Scroll to top of element "id" when "deps" update.
export const useScrollTopOnChange = (
id: AnchorIds,
id: Ids,
deps: DependencyList,
enabled = true
): void => {

View File

@ -26,7 +26,7 @@ import {
isDefinedAndNotEmpty,
} from "helpers/others";
import { ContentWithTranslations } from "helpers/types";
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { useSmartLanguage } from "hooks/useSmartLanguage";
import { getOpenGraph } from "helpers/openGraph";
import {
@ -42,6 +42,7 @@ import {
import { cIf } from "helpers/className";
import { getLangui } from "graphql/fetchLocalData";
import { useAppLayout } from "contexts/AppLayoutContext";
import { Ids } from "types/ids";
/*
*
@ -67,7 +68,7 @@ const Content = ({ content, ...otherProps }: Props): JSX.Element => {
),
});
useScrollTopOnChange(AnchorIds.ContentPanel, [selectedTranslation]);
useScrollTopOnChange(Ids.ContentPanel, [selectedTranslation]);
const { previousContent, nextContent } = useMemo(
() => ({

View File

@ -25,7 +25,7 @@ import {
} from "helpers/others";
import { GetContentsQuery } from "graphql/generated";
import { SmartList } from "components/SmartList";
import { SelectiveNonNullable } from "helpers/types/SelectiveNonNullable";
import { SelectiveNonNullable } from "types/SelectiveNonNullable";
import { getOpenGraph } from "helpers/openGraph";
import { HorizontalLine } from "components/HorizontalLine";
import { TranslatedPreviewCard } from "components/PreviewCard";

View File

@ -21,7 +21,7 @@ import { Button, TranslatedButton } from "components/Inputs/Button";
import { Link } from "components/Inputs/Link";
import { PanelHeader } from "components/PanelComponents/PanelHeader";
import { SubPanel } from "components/Panels/SubPanel";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage";
import { TranslatedPreviewCard } from "components/PreviewCard";
import { HorizontalLine } from "components/HorizontalLine";

View File

@ -11,7 +11,7 @@ import { ToolTip } from "components/ToolTip";
import { DevGetContentsQuery } from "graphql/generated";
import { getReadySdk } from "graphql/sdk";
import { filterDefined, filterHasAttributes } from "helpers/others";
import { Report, Severity } from "helpers/types/Report";
import { Report, Severity } from "types/Report";
import { getOpenGraph } from "helpers/openGraph";
import { getLangui } from "graphql/fetchLocalData";

View File

@ -13,7 +13,7 @@ import {
Enum_Componentcollectionscomponentlibraryimages_Status,
} from "graphql/generated";
import { getReadySdk } from "graphql/sdk";
import { Report, Severity } from "helpers/types/Report";
import { Report, Severity } from "types/Report";
import { getOpenGraph } from "helpers/openGraph";
import { getLangui } from "graphql/fetchLocalData";

View File

@ -43,7 +43,7 @@ import {
sortRangedContent,
} from "helpers/others";
import { useLightBox } from "hooks/useLightBox";
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { isUntangibleGroupItem } from "helpers/libraryItem";
import { useDeviceSupportsHover } from "hooks/useMediaQuery";
import { WithLabel } from "components/Inputs/WithLabel";
@ -57,6 +57,7 @@ import { HorizontalLine } from "components/HorizontalLine";
import { useIsContentPanelNoMoreThan } from "hooks/useContainerQuery";
import { useCurrencies } from "hooks/useLocalData";
import { getLangui } from "graphql/fetchLocalData";
import { Ids } from "types/ids";
/*
*
@ -99,7 +100,7 @@ const LibrarySlug = ({ item, itemId, ...otherProps }: Props): JSX.Element => {
const { value: keepInfoVisible, toggle: toggleKeepInfoVisible } =
useBoolean(false);
useScrollTopOnChange(AnchorIds.ContentPanel, [item]);
useScrollTopOnChange(Ids.ContentPanel, [item]);
const currentIntersection = useIntersectionList(intersectionIds);
const isVariantSet = useMemo(

View File

@ -38,7 +38,7 @@ import { ToolTip } from "components/ToolTip";
import { getAssetFilename, getAssetURL, ImageQuality } from "helpers/img";
import { isInteger } from "helpers/numbers";
import { useSmartLanguage } from "hooks/useSmartLanguage";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { TranslatedNavOption } from "components/PanelComponents/NavOption";
import { useIntersectionList } from "hooks/useIntersectionList";
import {

View File

@ -33,7 +33,7 @@ import {
import { useAppLayout } from "contexts/AppLayoutContext";
import { convertPrice } from "helpers/numbers";
import { SmartList } from "components/SmartList";
import { SelectiveNonNullable } from "helpers/types/SelectiveNonNullable";
import { SelectiveNonNullable } from "types/SelectiveNonNullable";
import { getOpenGraph } from "helpers/openGraph";
import { compareDate } from "helpers/date";
import { HorizontalLine } from "components/HorizontalLine";

View File

@ -26,7 +26,7 @@ import { Chip } from "components/Chip";
import { Ico, Icon } from "components/Ico";
import { AnchorShare } from "components/AnchorShare";
import { datePickerToDate } from "helpers/date";
import { TranslatedProps } from "helpers/types/TranslatedProps";
import { TranslatedProps } from "types/TranslatedProps";
import { TranslatedNavOption } from "components/PanelComponents/NavOption";
import { useIntersectionList } from "hooks/useIntersectionList";
import { HorizontalLine } from "components/HorizontalLine";

View File

@ -25,7 +25,7 @@ import {
} from "helpers/others";
import { SmartList } from "components/SmartList";
import { Select } from "components/Inputs/Select";
import { SelectiveNonNullable } from "helpers/types/SelectiveNonNullable";
import { SelectiveNonNullable } from "types/SelectiveNonNullable";
import { prettySlug } from "helpers/formatters";
import { getOpenGraph } from "helpers/openGraph";
import { TranslatedPreviewCard } from "components/PreviewCard";

5
src/types/ids.ts Normal file
View File

@ -0,0 +1,5 @@
export enum Ids {
Body = "bodyqs65d4a98d56az48z64d",
ContentPanel = "contentPanel495922447721572",
SubPanel = "subPanelz9e8rs2d3f18zer98ze",
}