Skip to content

Commit

Permalink
One file
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed Mar 2, 2024
1 parent 836bc84 commit 0a8f769
Show file tree
Hide file tree
Showing 11 changed files with 169 additions and 267 deletions.
7 changes: 1 addition & 6 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Suspense } from 'preact/compat';

import { Header } from './Header';
import { Fallback } from './Fallback';
import { Tooltips } from './Tooltip';
import { useLazyRouter } from '../hooks/useLazyRouter';

Expand All @@ -11,9 +8,7 @@ export const App: FC = () => {
return (
<>
<Header />
<Suspense fallback={<Fallback />}>
<Page />
</Suspense>
<Page />
<Tooltips />
</>
);
Expand Down
1 change: 0 additions & 1 deletion src/components/BuilderPage.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/Fallback/index.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions src/components/Fallback/styles.css

This file was deleted.

70 changes: 0 additions & 70 deletions src/components/Tooltip/Tooltip.tsx

This file was deleted.

83 changes: 70 additions & 13 deletions src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,70 @@
import { lazy, Suspense } from 'preact/compat';

const LazyTooltips: FC = lazy(() => {
return import('./Tooltip').then((i) => {
return i.Tooltips;
});
});

export const Tooltips: FC = () => (
<Suspense fallback={null}>
<LazyTooltips />
</Suspense>
);
import { h, Component, createRef, type ComponentClass } from 'preact';
import { useCallback } from 'preact/hooks';
import HintFactory, { type ReactHintProps } from 'react-hint';

import s from './styles.css';
import { useStoreon } from '../../store';
import { KEYS } from '../../constants';
import { FunctionName } from './FunctionName';
import { FunctionLocation } from './FunctionLocation';
import { CronExamplesTooltip } from './CronExamplesTooltip';
import cronExamples from './CronExamplesTooltip/cronExamples.json';

// @ts-expect-error @typescript-eslint/ban-ts-comment
const Hint: ComponentClass<ReactHintProps> = HintFactory({ createElement: h, Component, createRef });
const delay = {
show: 500,
hide: 100,
} as const;

const dataList = cronExamples.map((i) => (
<option key={i.value} value={i.value}>
{i.label}
</option>
));

export const Tooltips: FC = () => {
const { items } = useStoreon('items');

const onRenderContent = useCallback((target: HTMLInputElement) => {
switch (target.dataset.name) {
case KEYS.functionLocation: {
return (
<FunctionLocation target={target} />
);
}
case KEYS.functionName: {
return (
<FunctionName target={target} />
);
}
case KEYS.cronExpression: {
return (
<CronExamplesTooltip target={target} />
);
}
}
return null;
}, [items]);

return (
<>
<Hint events delay={delay} />
<Hint
persist
attribute="data-fl"
events={{
focus: true,
click: true,
hover: false,
}}
className={s.fs}
// @ts-expect-error @typescript-eslint/ban-ts-comment
onRenderContent={onRenderContent}
/>
<datalist id="cron-examples">
{dataList}
</datalist>
</>
);
};
92 changes: 0 additions & 92 deletions src/components/UploadModal/UploadModal.tsx

This file was deleted.

Loading

0 comments on commit 0a8f769

Please sign in to comment.