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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ import {
isDefinedAndNotEmpty, isDefinedAndNotEmpty,
} from "helpers/others"; } from "helpers/others";
import { ContentWithTranslations } from "helpers/types"; import { ContentWithTranslations } from "helpers/types";
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange"; import { useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { useSmartLanguage } from "hooks/useSmartLanguage"; import { useSmartLanguage } from "hooks/useSmartLanguage";
import { getOpenGraph } from "helpers/openGraph"; import { getOpenGraph } from "helpers/openGraph";
import { import {
@ -42,6 +42,7 @@ import {
import { cIf } from "helpers/className"; import { cIf } from "helpers/className";
import { getLangui } from "graphql/fetchLocalData"; import { getLangui } from "graphql/fetchLocalData";
import { useAppLayout } from "contexts/AppLayoutContext"; 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( const { previousContent, nextContent } = useMemo(
() => ({ () => ({

View File

@ -25,7 +25,7 @@ import {
} from "helpers/others"; } from "helpers/others";
import { GetContentsQuery } from "graphql/generated"; import { GetContentsQuery } from "graphql/generated";
import { SmartList } from "components/SmartList"; import { SmartList } from "components/SmartList";
import { SelectiveNonNullable } from "helpers/types/SelectiveNonNullable"; import { SelectiveNonNullable } from "types/SelectiveNonNullable";
import { getOpenGraph } from "helpers/openGraph"; import { getOpenGraph } from "helpers/openGraph";
import { HorizontalLine } from "components/HorizontalLine"; import { HorizontalLine } from "components/HorizontalLine";
import { TranslatedPreviewCard } from "components/PreviewCard"; 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 { Link } from "components/Inputs/Link";
import { PanelHeader } from "components/PanelComponents/PanelHeader"; import { PanelHeader } from "components/PanelComponents/PanelHeader";
import { SubPanel } from "components/Panels/SubPanel"; import { SubPanel } from "components/Panels/SubPanel";
import { TranslatedProps } from "helpers/types/TranslatedProps"; import { TranslatedProps } from "types/TranslatedProps";
import { useSmartLanguage } from "hooks/useSmartLanguage"; import { useSmartLanguage } from "hooks/useSmartLanguage";
import { TranslatedPreviewCard } from "components/PreviewCard"; import { TranslatedPreviewCard } from "components/PreviewCard";
import { HorizontalLine } from "components/HorizontalLine"; import { HorizontalLine } from "components/HorizontalLine";

View File

@ -11,7 +11,7 @@ import { ToolTip } from "components/ToolTip";
import { DevGetContentsQuery } from "graphql/generated"; import { DevGetContentsQuery } from "graphql/generated";
import { getReadySdk } from "graphql/sdk"; import { getReadySdk } from "graphql/sdk";
import { filterDefined, filterHasAttributes } from "helpers/others"; 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 { getOpenGraph } from "helpers/openGraph";
import { getLangui } from "graphql/fetchLocalData"; import { getLangui } from "graphql/fetchLocalData";

View File

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

View File

@ -43,7 +43,7 @@ import {
sortRangedContent, sortRangedContent,
} from "helpers/others"; } from "helpers/others";
import { useLightBox } from "hooks/useLightBox"; import { useLightBox } from "hooks/useLightBox";
import { AnchorIds, useScrollTopOnChange } from "hooks/useScrollTopOnChange"; import { useScrollTopOnChange } from "hooks/useScrollTopOnChange";
import { isUntangibleGroupItem } from "helpers/libraryItem"; import { isUntangibleGroupItem } from "helpers/libraryItem";
import { useDeviceSupportsHover } from "hooks/useMediaQuery"; import { useDeviceSupportsHover } from "hooks/useMediaQuery";
import { WithLabel } from "components/Inputs/WithLabel"; import { WithLabel } from "components/Inputs/WithLabel";
@ -57,6 +57,7 @@ import { HorizontalLine } from "components/HorizontalLine";
import { useIsContentPanelNoMoreThan } from "hooks/useContainerQuery"; import { useIsContentPanelNoMoreThan } from "hooks/useContainerQuery";
import { useCurrencies } from "hooks/useLocalData"; import { useCurrencies } from "hooks/useLocalData";
import { getLangui } from "graphql/fetchLocalData"; 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 } = const { value: keepInfoVisible, toggle: toggleKeepInfoVisible } =
useBoolean(false); useBoolean(false);
useScrollTopOnChange(AnchorIds.ContentPanel, [item]); useScrollTopOnChange(Ids.ContentPanel, [item]);
const currentIntersection = useIntersectionList(intersectionIds); const currentIntersection = useIntersectionList(intersectionIds);
const isVariantSet = useMemo( const isVariantSet = useMemo(

View File

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

View File

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

View File

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

View File

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