Skip to content

Commit

Permalink
Better scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
mbsantiago committed Jan 24, 2024
1 parent 37ea904 commit 8f6adf9
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion front/src/app/(base)/datasets/detail/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function DatasetNavHeader({ dataset }: { dataset: Dataset }) {

return (
<Header>
<div className="flex overflow-x-scroll flex-row space-x-4 w-full">
<div className="flex overflow-x-auto flex-row space-x-4 w-full">
<H1>{dataset.name}</H1>
<Tabs
tabs={[
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/SlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function SlideOver({
</button>
</div>
</Transition.Child>
<div className="flex h-full flex-col overflow-y-scroll bg-stone-100 dark:bg-stone-800 py-6 shadow-xl">
<div className="flex h-full flex-col overflow-y-auto bg-stone-100 dark:bg-stone-800 py-6 shadow-xl">
<div className="px-4 sm:px-6">
<Dialog.Title className="text-base font-semibold leading-6 text-stone-900 dark:text-stone-400">
{title}
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/annotation/AnnotationProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function AnnotationProgress({
</>
}
/>
<div className="overflow-x-scroll">
<div className="overflow-x-auto">
<FilterBar
withLabel={false}
filter={filter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default function AnnotationProjectHeader({

return (
<Header>
<div className="flex overflow-x-scroll flex-row space-x-4 w-full">
<H1 className="overflow-scroll max-w-xl whitespace-nowrap">
<div className="flex overflow-x-auto flex-row space-x-4 w-full">
<H1 className="overflow-auto max-w-xl whitespace-nowrap">
{annotationProject.name}
</H1>
<Tabs
Expand Down
4 changes: 2 additions & 2 deletions front/src/components/evaluation_sets/EvaluationSetHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export default function EvaluationSetHeader({

return (
<Header>
<div className="flex w-full flex-row space-x-4 overflow-x-scroll">
<H1 className="max-w-xl whitespace-nowrap overflow-scroll">
<div className="flex w-full flex-row space-x-4 overflow-x-auto">
<H1 className="max-w-xl whitespace-nowrap overflow-auto">
{evaluationSet.name}
</H1>
<Tabs
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/exploration/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function ExplorationHeader() {

return (
<Header>
<div className="flex w-full flex-row space-x-4 overflow-x-scroll">
<div className="flex w-full flex-row space-x-4 overflow-x-auto">
<H1>Explore</H1>
<Tabs
tabs={[
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/recordings/RecordingHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function RecordingHeader({
});

return (
<div className="flex overflow-x-scroll flex-row gap-x-6 items-center w-full">
<div className="flex overflow-x-auto flex-row gap-x-6 items-center w-full">
<div className="inline-flex items-center">
<RecordingIcon className="inline-block mr-1 w-5 h-5 text-stone-500" />
<H3 className="max-w-xl whitespace-nowrap">
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/recordings/RecordingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function RecordingTable({
filterDef={recordingFilterDefs}
/>
<div className="w-full">
<div className="overflow-x-scroll overflow-y-scroll w-full max-h-screen rounded-md outline outline-1 outline-stone-200 dark:outline-stone-800">
<div className="overflow-x-auto overflow-y-auto w-full max-h-screen rounded-md outline outline-1 outline-stone-200 dark:outline-stone-800">
<Table table={table} onCellKeyDown={handleKeyDown} />
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/tables/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function Table<S>({
>
{headerGroup.headers.map((header) => (
<th
className="overflow-x-scroll relative py-1 px-2 whitespace-nowrap border border-stone-400 dark:border-stone-500"
className="overflow-x-auto relative py-1 px-2 whitespace-nowrap border border-stone-400 dark:border-stone-500"
key={header.id}
colSpan={header.colSpan}
style={{
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/tables/TableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function TableCell({
className,
)}
>
<span className="grow overflow-x-scroll">{children}</span>
<span className="grow overflow-x-auto">{children}</span>
{!editable ? null : (
<EditIcon className="inline-block h-5 w-5 text-stone-500" />
)}
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/tables/TableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from "react";

export default function TableHeader({ children }: { children: ReactNode }) {
return (
<span className="inline-block whitespace-nowrap align-middle w-full overflow-x-scroll">
<span className="inline-block whitespace-nowrap align-middle w-full overflow-x-auto">
{children}
</span>
);
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/tables/TableTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function TableTags({
const getTagColor = useStore((state) => state.getTagColor);

return (
<div className="flex overflow-scroll flex-row flex-wrap gap-2 items-center px-1 m-0 w-full max-h-40">
<div className="flex overflow-auto flex-row flex-wrap gap-2 items-center px-1 m-0 w-full max-h-40">
{/* Display the list of tags and allow users to remove a tag from */}
{/* list by clicking on it*/}
{tags.map((tag) => (
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/tags/TagSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default forwardRef<HTMLInputElement, TagSearchBarProps>(
<ChevronUpDownIcon className="w-5 h-5" aria-hidden="true" />
</Combobox.Button>
</div>
<Combobox.Options className="overflow-y-scroll py-1 max-w-sm text-base rounded-md divide-y ring-1 ring-opacity-5 shadow-lg sm:text-sm focus:outline-none divide-stone-200 bg-stone-50 ring-stone-300 dark:divide-stone-600 dark:bg-stone-700 dark:ring-stone-600">
<Combobox.Options className="overflow-y-auto py-1 max-w-sm text-base rounded-md divide-y ring-1 ring-opacity-5 shadow-lg sm:text-sm focus:outline-none divide-stone-200 bg-stone-50 ring-stone-300 dark:divide-stone-600 dark:bg-stone-700 dark:ring-stone-600">
{tags.items.length === 0 ? (
<NoTagsFound />
) : (
Expand Down
31 changes: 29 additions & 2 deletions front/src/hooks/audio/useAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,46 @@ export default function useAudio({
cancelAnimationFrame(timer);
};

const onError = () => {
cancelAnimationFrame(timer);
}

current.addEventListener("play", onPlay);
current.addEventListener("pause", onPause);
current.addEventListener("error", onError);

return () => {
cancelAnimationFrame(timer);
current.removeEventListener("play", onPlay);
current.removeEventListener("pause", onPause);
current.removeEventListener("error", onError);
};
}, [initialUrl, speed, startTime, loop, volume]);


// Some browsers return `Promise` on `.play()` and may throw errors
// if one tries to execute another `.play()` or `.pause()` while that
// promise is resolving. So we prevent that with this lock.
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=593273
let lockPlay = useRef<boolean>(false);

const handlePlay = useCallback(() => {
audio.current.play();
setIsPlaying(true);
if (lockPlay.current) return;
const promise = audio.current.play();

if (promise) {
lockPlay.current = true;
promise
.then(() => {
setIsPlaying(true);
lockPlay.current = false;
})
.catch(() => {
lockPlay.current = false;
});
} else {
setIsPlaying(true);
}
}, []);

const handlePause = useCallback(() => {
Expand Down

0 comments on commit 8f6adf9

Please sign in to comment.