Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
susiekims committed Jan 24, 2024
1 parent b472e81 commit 7803fb5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 24 deletions.
13 changes: 6 additions & 7 deletions packages/polaris-viz/src/components/Legend/Legend.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {Fragment, type RefObject} from 'react';
import {Fragment} from 'react';
import type {RefObject} from 'react';
import {DEFAULT_THEME_NAME} from '@shopify/polaris-viz-core';

import {useExternalHideEvents} from '../../hooks';
import type {LegendData} from '../../types';

import {LegendItem} from './components/';
import type { LegendItemDimension } from './components/LegendItem/LegendItem';


import {LegendItem} from './components';
import type {LegendItemDimension} from './components';

export interface LegendProps {
data: LegendData[];
Expand All @@ -16,7 +15,7 @@ export interface LegendProps {
theme?: string;
itemDimensions?: RefObject<LegendItemDimension[]>;
backgroundColor?: string;
lastVisibleIndex?: number,
lastVisibleIndex?: number;
}

export function Legend({
Expand All @@ -26,7 +25,7 @@ export function Legend({
theme = DEFAULT_THEME_NAME,
itemDimensions,
lastVisibleIndex = 0,
backgroundColor
backgroundColor,
}: LegendProps) {
const {hiddenIndexes} = useExternalHideEvents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
getColorVisionEventAttrs,
getColorVisionStylesForActiveIndex,
} from '@shopify/polaris-viz-core';
import {useEffect, type ReactNode, useRef} from 'react';
import type {ReactNode} from 'react';
import {useEffect, useRef} from 'react';

import {
LEGEND_ITEM_LEFT_PADDING,
Expand All @@ -18,7 +19,7 @@ import style from './LegendItem.scss';

export interface LegendItemDimension {
width: number;
height: number
height: number;
}

export interface LegendItemProps extends LegendData {
Expand Down Expand Up @@ -46,7 +47,7 @@ export function LegendItem({
backgroundColor,
}: LegendItemProps) {
const selectedTheme = useTheme(theme);
const ref = useRef<HTMLButtonElement | null>(null)
const ref = useRef<HTMLButtonElement | null>(null);

useEffect(() => {
if (onDimensionChange && ref.current != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {LegendItem} from './LegendItem';
export type {LegendItemDimension} from './LegendItem';
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {LegendItem} from './LegendItem';
export type {LegendItemDimension} from './LegendItem';
1 change: 1 addition & 0 deletions packages/polaris-viz/src/components/Legend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export {Legend} from './Legend';
export {LegendItem} from './components';
export type {LegendProps} from './Legend';
export {estimateLegendItemWidth} from './utilities/estimateLegendItemWidth';
export type {LegendItemDimension} from './components';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {CSSProperties, Dispatch, SetStateAction} from 'react';
import {useEffect, useMemo, useRef, useState} from 'react';
import {Fragment, useEffect, useMemo, useRef, useState} from 'react';
import isEqual from 'fast-deep-equal';
import {
getColorVisionEventAttrs,
Expand Down Expand Up @@ -94,7 +94,14 @@ export function LegendContainer({
displayedData: allData.slice(0, lastVisibleIndex || 1),
hiddenData: allData.slice(lastVisibleIndex || 1, allData.length),
};
}, [allData, width, leftMargin, horizontalMargin, activatorWidth]);
}, [
allData,
width,
leftMargin,
horizontalMargin,
activatorWidth,
enableHideOverflow,
]);

const hasHiddenData =
enableHideOverflow && displayedData.length < allData.length;
Expand Down Expand Up @@ -168,7 +175,7 @@ export function LegendContainer({
style={{...styleMap[direction], ...shouldCenterTiles(position)}}
>
{renderLegendContent?.(colorVisionInteractionMethods) ?? (
<>
<Fragment>
<Legend
activeIndex={activeIndex}
colorVisionType={colorVisionType}
Expand All @@ -189,7 +196,7 @@ export function LegendContainer({
setActivatorWidth={setActivatorWidth}
/>
)}
</>
</Fragment>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
}

.Tooltip {
position: absolute;
display: flex;
flex-direction: column;
padding: 4px;
backdrop-filter: blur(5px);
border-radius: 5px;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.2), 0 2px 10px rgba(0, 0, 0, 0.1);
position: absolute;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {ReactNode, useCallback, useEffect, useRef, useState} from 'react';
import {Legend} from '../../Legend/Legend';
import type {LegendData} from '../../../types';

import style from './HiddenLegendTooltip.scss';
import {Fragment, useCallback, useEffect, useRef, useState} from 'react';
import type {ReactNode} from 'react';
import {createPortal} from 'react-dom';
import {changeColorOpacity, useTheme} from '@shopify/polaris-viz-core';

import type {LegendData} from '../../../types';
import {TOOLTIP_BG_OPACITY} from '../../../constants';
import {useBrowserCheck} from '../../../hooks/useBrowserCheck';
import {createPortal} from 'react-dom';
import {useRootContainer} from '../../../hooks/useRootContainer';
import {TOOLTIP_MARGIN} from '../../TooltipWrapper';
import {Legend} from '../../Legend';

import style from './HiddenLegendTooltip.scss';

interface Props {
activeIndex: number;
Expand Down Expand Up @@ -87,10 +89,10 @@ export function HiddenLegendPopover({
top: getYPosition(),
left: getXPosition(),
});
}, [setPosition, setActivatorWidth]);
}, [setPosition]);

return (
<>
<Fragment>
<button
className={style.MoreText}
ref={activatorRef}
Expand Down Expand Up @@ -127,6 +129,6 @@ export function HiddenLegendPopover({
</div>,
container,
)}
</>
</Fragment>
);
}

0 comments on commit 7803fb5

Please sign in to comment.