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

Widget fix #763

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions common/components/general/WidgetCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Children, cloneElement, useCallback, useMemo, useState } from 'r
import classNames from 'classnames';
import type { ComponentProps, FC, ReactElement } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faChevronCircleDown } from '@fortawesome/free-solid-svg-icons';
import { faChevronCircleLeft } from '@fortawesome/free-solid-svg-icons';

interface WidgetCarouselProps {
children: React.ReactNode;
Expand Down Expand Up @@ -39,7 +39,7 @@ export const WidgetCarousel: FC<WidgetCarouselProps> = ({ children, isSingleWidg
const isBeforeActiveItem = (item: number) =>
item !== activeItem && (activeItem === 0 ? item === items.length - 1 : item + 1 === activeItem);
return (
<div className="relative flex flex-row gap-1">
<div className="relative flex flex-row gap-2">
<div className="flex items-center">
{!isSingleWidget && (
<button
Expand All @@ -51,14 +51,14 @@ export const WidgetCarousel: FC<WidgetCarouselProps> = ({ children, isSingleWidg
type="button"
>
<FontAwesomeIcon
icon={faChevronCircleDown}
icon={faChevronCircleLeft}
size="lg"
className="text-stone-300 hover:text-stone-600"
/>
</button>
)}
</div>
<div className="relative h-8 w-full overflow-hidden lg:h-[3.25rem] ">
<div className="relative h-[3.25rem] w-full overflow-hidden ">
{items?.map((item, index) => (
<div
key={index}
Expand All @@ -67,8 +67,8 @@ export const WidgetCarousel: FC<WidgetCarouselProps> = ({ children, isSingleWidg
{
hidden:
index !== activeItem && !isBeforeActiveItem(index) && !isAfterActiveItem(index),
'-translate-y-full opacity-0': isBeforeActiveItem(index),
'translate-y-full opacity-0': isAfterActiveItem(index),
'-translate-x-1/3 opacity-0': isBeforeActiveItem(index),
'translate-x-1/3 opacity-0': isAfterActiveItem(index),
}
)}
>
Expand Down
28 changes: 0 additions & 28 deletions common/components/widgets/internal/WidgetForCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import classNames from 'classnames';
import type { WidgetValueInterface } from '../../../types/basicWidgets';
import { LoadingSpinner } from '../../graphics/LoadingSpinner';
import { useBreakpoint } from '../../../hooks/useBreakpoint';
import { Delta } from './Delta';

type LayoutKind = 'total-and-delta' | 'delta-and-percent-change' | 'no-delta';
Expand All @@ -21,33 +20,6 @@ export const WidgetForCarousel: React.FC<WidgetForCarouselProps> = ({
layoutKind = 'total-and-delta',
sentimentDirection = 'negativeOnIncrease',
}) => {
const isHorizontal = !useBreakpoint('lg');

if (isHorizontal)
return (
<div className={classNames('relative flex w-full')}>
{widgetValue.value === undefined && <LoadingSpinner isWidget />}
<div className={classNames('flex flex-row items-baseline justify-between rounded-lg px-2')}>
<div className="flex flex-row items-baseline justify-end gap-4">
<div className="flex flex-row items-baseline gap-x-1">
{widgetValue.getFormattedValue()}
</div>
<div className="mt-1 flex flex-row items-baseline gap-x-1">
{layoutKind !== 'no-delta' && (
<Delta
widgetValue={widgetValue}
sentimentDirection={sentimentDirection}
usePercentChange={layoutKind === 'delta-and-percent-change'}
/>
)}
<p className={classNames('truncate text-xs text-design-subtitleGrey sm:text-sm')}>
{analysis}
</p>
</div>
</div>
</div>
</div>
);
return (
<div className="">
<div className={classNames('relative flex')}>
Expand Down
Loading