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

Feature selection UI refactor #697

Merged
merged 26 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
97cb429
add geojson type
juandjara Jun 1, 2023
5aba37d
remove duplicated prop
juandjara Jun 1, 2023
e2d04b8
add new types and fix old ones
juandjara Jun 1, 2023
dd6a18c
refactor FeatureSelectionWidgetUI split into many exported files
juandjara Jun 1, 2023
ef39427
fix import for storybook
juandjara Jun 1, 2023
afb14ab
fix import for test
juandjara Jun 1, 2023
39fc09e
export new components to index files
juandjara Jun 1, 2023
e735c11
remove duplicated
juandjara Jun 2, 2023
88897d1
handle fn not defined case
juandjara Jun 2, 2023
17af341
update tests
juandjara Jun 2, 2023
1027f2b
fix label
juandjara Jun 2, 2023
13414ac
fix feature selection tests
juandjara Jun 2, 2023
f90a0a7
remove classname and sx in FeatureSelectionUIDropdown
juandjara Jun 5, 2023
5000102
remove custom styles from feature selection UI toggle button
juandjara Jun 5, 2023
2498af6
use Paper as FeatureSelectionWidgetUI wrapper
juandjara Jun 5, 2023
aaab4d2
use narrowed down tooltip placement options
juandjara Jun 5, 2023
c4cbc7e
remove unused
juandjara Jun 5, 2023
db31542
replace mui Typography with local component
juandjara Jun 5, 2023
832bf66
export more copies from components
juandjara Jun 6, 2023
f8e5215
remove sx and className from FeatureSelectionUIToggleButton
juandjara Jun 6, 2023
e441096
final changes for copies and sx / classname removal
juandjara Jun 6, 2023
d3544ed
fix test label
juandjara Jun 6, 2023
205fa1e
add conditional rendering of menu header text
juandjara Jun 6, 2023
311efaa
Merge branch 'master' of github.com:CartoDB/carto-react into feature-…
juandjara Jun 6, 2023
11d29b3
add changelog entry
juandjara Jun 6, 2023
3694129
Merge branch 'master' into feature-selection-ui-refactor
VictorVelarde Jun 7, 2023
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, queryByAttribute, fireEvent } from '../widgets/utils/testUtils';
import FeatureSelectionWidgetUI from '../../src/widgets/FeatureSelectionWidgetUI';
import FeatureSelectionWidgetUI from '../../src/widgets/FeatureSelectionWidgetUI/FeatureSelectionWidgetUI';
import { capitalize } from '@mui/material';
import CursorIcon from '../../src/assets/icons/CursorIcon';
import PolygonIcon from '../../src/assets/icons/PolygonIcon';
Expand Down Expand Up @@ -53,10 +53,10 @@ describe('FeatureSelectionWidgetUI', () => {
render(
<FeatureSelectionWidgetUI
selectionModes={FEATURE_SELECTION_MODES}
selectedMode={'IInvented'}
selectedMode={'Invented'}
/>
)
).toThrowError('Selected mode not supported');
).toThrowError('Selected mode "Invented" not supported');
});

test('activate selected mode event is correctly raised', () => {
Expand Down Expand Up @@ -109,7 +109,16 @@ describe('FeatureSelectionWidgetUI', () => {
expect(onSelectMode).toHaveBeenCalledWith(anotherMode.id);
});

const GEOMETRY = { geometry: 1 };
const GEOMETRY = {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [125.6, 10.1]
},
properties: {
name: 'Mask'
}
};
test('geometry is rendered correctly', () => {
const rendered = render(<CommonFeatureSelectionWidgetUI geometry={GEOMETRY} />);
expect(rendered.getByText('Mask')).toBeDefined();
Expand Down
8 changes: 7 additions & 1 deletion packages/react-ui/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import useTimeSeriesInteractivity from './widgets/TimeSeriesWidgetUI/hooks/useTi
import { CHART_TYPES } from './widgets/TimeSeriesWidgetUI/utils/constants';
import TableWidgetUI from './widgets/TableWidgetUI/TableWidgetUI';
import NoDataAlert from './widgets/NoDataAlert';
import FeatureSelectionWidgetUI from './widgets/FeatureSelectionWidgetUI';
import FeatureSelectionWidgetUI from './widgets/FeatureSelectionWidgetUI/FeatureSelectionWidgetUI';
import FeatureSelectionUIDropdown from './widgets/FeatureSelectionWidgetUI/FeatureSelectionUIDropdown';
import FeatureSelectionUIGeometryChips from './widgets/FeatureSelectionWidgetUI/FeatureSelectionUIGeometryChips';
import FeatureSelectionUIToggleButton from './widgets/FeatureSelectionWidgetUI/FeatureSelectionUIToggleButton';
import ComparativePieWidgetUI from './widgets/comparative/ComparativePieWidgetUI';
import ComparativeFormulaWidgetUI from './widgets/comparative/ComparativeFormulaWidgetUI/ComparativeFormulaWidgetUI';
import ComparativeCategoryWidgetUI from './widgets/comparative/ComparativeCategoryWidgetUI/ComparativeCategoryWidgetUI';
Expand Down Expand Up @@ -71,6 +74,9 @@ export {
RangeWidgetUI,
ComparativePieWidgetUI,
FeatureSelectionWidgetUI,
FeatureSelectionUIDropdown,
FeatureSelectionUIGeometryChips,
FeatureSelectionUIToggleButton,
ComparativeFormulaWidgetUI,
ComparativeCategoryWidgetUI,
LEGEND_TYPES,
Expand Down
8 changes: 7 additions & 1 deletion packages/react-ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import LegendProportion from './widgets/legend/LegendProportion';
import LegendRamp from './widgets/legend/LegendRamp';
import ScatterPlotWidgetUI from './widgets/ScatterPlotWidgetUI/ScatterPlotWidgetUI';
import TimeSeriesWidgetUI from './widgets/TimeSeriesWidgetUI/TimeSeriesWidgetUI';
import FeatureSelectionWidgetUI from './widgets/FeatureSelectionWidgetUI';
import FeatureSelectionWidgetUI from './widgets/FeatureSelectionWidgetUI/FeatureSelectionWidgetUI';
import FeatureSelectionUIDropdown from './widgets/FeatureSelectionWidgetUI/FeatureSelectionUIDropdown';
import FeatureSelectionUIGeometryChips from './widgets/FeatureSelectionWidgetUI/FeatureSelectionUIGeometryChips';
import FeatureSelectionUIToggleButton from './widgets/FeatureSelectionWidgetUI/FeatureSelectionUIToggleButton';
import RangeWidgetUI from './widgets/RangeWidgetUI/RangeWidgetUI';
import ComparativeFormulaWidgetUI from './widgets/comparative/ComparativeFormulaWidgetUI/ComparativeFormulaWidgetUI';
import ComparativeCategoryWidgetUI from './widgets/comparative/ComparativeCategoryWidgetUI/ComparativeCategoryWidgetUI';
Expand Down Expand Up @@ -61,6 +64,9 @@ export {
PieWidgetUI,
ScatterPlotWidgetUI,
FeatureSelectionWidgetUI,
FeatureSelectionUIDropdown,
FeatureSelectionUIGeometryChips,
FeatureSelectionUIToggleButton,
TimeSeriesWidgetUI,
CHART_TYPES as TIME_SERIES_CHART_TYPES,
TableWidgetUI,
Expand Down
41 changes: 33 additions & 8 deletions packages/react-ui/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type WrapperWidgetUI = {
export type CategoryWidgetUIData = { name: number | string | boolean; value: number }[];
export type CategoryWidgetUI = {
data: CategoryWidgetUIData;
isLoading?: boolean;
formatter?: Function;
labels?: object;
maxItems?: number;
Expand Down Expand Up @@ -158,20 +157,46 @@ export type NoDataAlert = {
export type FeatureSelectionWidgetUIData = {
id: string;
label: string;
icon: React.ReactElement;
icon: React.ReactNode;
};
export type FeatureSelectionWidgetUI = {
selectionModes: FeatureSelectionWidgetUIData[];
editModes?: FeatureSelectionWidgetUIData[];
selectedMode: string;
onSelectMode?: Function;
enabled?: boolean;
onEnabledChange?: Function;
geometry?: GeoJSON.Feature;
onSelectGeometry?: Function;
onDeleteGeometry?: Function;
tooltipPlacement?: "bottom" | "left" | "right" | "top";
};

export type FeatureSelectionUIDropdown = {
selectionModes: FeatureSelectionWidgetUIData[];
editModes: FeatureSelectionWidgetUIData[];
selectedMode: string;
onSelectMode?: Function;
activated?: boolean;
onActivatedChange?: Function;
geometry?: any;
enabled?: boolean;
onEnabledChange?: Function;
tooltipPlacement?: "bottom" | "left" | "right" | "top";
};
export type FeatureSelectionUIGeometryChips = {
features: GeoJSON.Feature[];
onSelectGeometry?: Function;
tooltipPlacement?: string;
className?: string;
sx?: SxProps<Theme>;
onDeleteGeometry?: Function;
chipTooltip?: string;
disabledChipTooltip?: string;
size?: 'small' | 'medium';
tooltipPlacement?: "bottom" | "left" | "right" | "top";
};
export type FeatureSelectionUIToggleButton = {
icon: React.ReactNode;
hoverTooltip?: string;
clickTooltip?: string;
enabled?: boolean;
onEnabledChange?: Function;
tooltipPlacement?: "bottom" | "left" | "right" | "top";
};

// Legends
Expand Down
Loading