Skip to content

Commit

Permalink
front: use new osrd ui-icons project
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaswurtz committed Jan 31, 2024
1 parent ff17ab1 commit e3e37d3
Show file tree
Hide file tree
Showing 36 changed files with 107 additions and 101 deletions.
1 change: 1 addition & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@nivo/line": "^0.80.0",
"@nivo/tooltip": "^0.80.0",
"@openapi-contrib/openapi-schema-to-json-schema": "^4.0.4",
"@osrd-project/ui-icons": "^0.0.8",
"@redux-devtools/extension": "^3.2.3",
"@reduxjs/toolkit": "^1.9.0",
"@rjsf/core": "^4.2.3",
Expand Down
10 changes: 5 additions & 5 deletions front/src/applications/editor/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { NavigateFunction } from 'react-router-dom';
import { IconType } from 'react-icons';
import { GiRailway } from 'react-icons/gi';
import { FaRegCompass } from 'react-icons/fa';
import { GoSearch, GoZoomIn, GoZoomOut } from 'react-icons/go';
import { GenericIconType, Search, ZoomIn, ZoomOut } from '@osrd-project/ui-icons';
import { BsExclamationOctagon, BsSliders2 } from 'react-icons/bs';
import { isNil } from 'lodash';

Expand All @@ -26,7 +26,7 @@ const ZOOM_DELTA = 1.5;

export interface NavButton {
id: string;
icon: IconType;
icon: IconType | GenericIconType;
labelTranslationKey: string;
shortcut?: Omit<Shortcut, 'handler'>;

Expand Down Expand Up @@ -62,7 +62,7 @@ const NavButtons: NavButton[][] = [
[
{
id: 'zoom-in',
icon: GoZoomIn,
icon: ZoomIn as GenericIconType,
labelTranslationKey: 'common.zoom-in',
onClick({ setViewport, viewport }) {
setViewport({
Expand All @@ -73,7 +73,7 @@ const NavButtons: NavButton[][] = [
},
{
id: 'zoom-out',
icon: GoZoomOut,
icon: ZoomOut as GenericIconType,
labelTranslationKey: 'common.zoom-out',
onClick({ setViewport, viewport }) {
setViewport({
Expand All @@ -96,7 +96,7 @@ const NavButtons: NavButton[][] = [
},
{
id: 'search',
icon: GoSearch,
icon: Search as GenericIconType,
labelTranslationKey: 'common.search',
onClick({ setIsSearchToolOpened }) {
setIsSearchToolOpened((state) => !state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cloneDeep, isEqual, omit } from 'lodash';
import { IconType } from 'react-icons';
import { BiReset } from 'react-icons/bi';
import { AiFillSave } from 'react-icons/ai';
import { GoPlusCircle, GoTrash } from 'react-icons/go';
import { PlusCircle, Trash } from '@osrd-project/ui-icons';
import { Map } from 'maplibre-gl';
import { Feature, LineString, Point } from 'geojson';
import nearestPointOnLine from '@turf/nearest-point-on-line';
Expand Down Expand Up @@ -114,7 +114,7 @@ function getPointEditionTool<T extends EditorPoint>({
[
{
id: 'new-entity',
icon: GoPlusCircle,
icon: PlusCircle,
labelTranslationKey: `Editor.tools.${id}-edition.actions.new-entity`,
onClick({ setState }) {
setState(getInitialState());
Expand All @@ -124,7 +124,7 @@ function getPointEditionTool<T extends EditorPoint>({
[
{
id: 'delete-entity',
icon: GoTrash,
icon: Trash,
labelTranslationKey: `Editor.tools.${id}-edition.actions.delete-entity`,
// Show button only if we are editing
isDisabled({ state }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { TFunction } from 'i18next';
import { PSLSign } from 'types';
import SelectImprovedSNCF from 'common/BootstrapSNCF/SelectImprovedSNCF';
import { GoTrash } from 'react-icons/go';
import { Trash } from '@osrd-project/ui-icons';
import { isNil } from 'lodash';
import { RiDragMoveLine } from 'react-icons/ri';
import InputSNCF from 'common/BootstrapSNCF/InputSNCF';
Expand Down Expand Up @@ -173,7 +173,7 @@ const PslSignCard = ({
removeSign(signInfo as Exclude<PslSignInformation, { signType: PSL_SIGN_TYPES.Z }>)
}
>
<GoTrash />
<Trash />
</button>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cloneDeep, isEqual } from 'lodash';
import { IconType } from 'react-icons';
import { BiReset } from 'react-icons/bi';
import { AiFillSave } from 'react-icons/ai';
import { GoPlusCircle, GoTrash } from 'react-icons/go';
import { PlusCircle, Trash } from '@osrd-project/ui-icons';

import { save } from 'reducers/editor';
import { ConfirmModal } from 'common/BootstrapSNCF/ModalSNCF';
Expand Down Expand Up @@ -153,7 +153,7 @@ function getRangeEditionTool<T extends EditorRange>({
[
{
id: `new-${objectTypeAction}`,
icon: GoPlusCircle,
icon: PlusCircle,
labelTranslationKey: `Editor.tools.${objectTypeEdition}-edition.actions.new-${objectTypeAction}`,
onClick({ setState }) {
setState(getInitialState());
Expand All @@ -163,7 +163,7 @@ function getRangeEditionTool<T extends EditorRange>({
[
{
id: 'delete-entity',
icon: GoTrash,
icon: Trash,
labelTranslationKey: `Editor.tools.${objectTypeEdition}-edition.actions.delete-${objectTypeAction}`,
// Show button only if we are editing
isDisabled({ state }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { FC, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { GoSearch } from 'react-icons/go';
import { Search } from '@osrd-project/ui-icons';

import { LoaderFill } from 'common/Loaders';
import { SearchRouteItem } from './SearchRouteItem';
Expand Down Expand Up @@ -35,7 +35,7 @@ export const SearchRoute: FC<SearchRouteProps> = ({
type="button"
onClick={searchFn}
>
<GoSearch /> {t(`Editor.tools.routes-edition.search-routes${!isNew ? '-alt' : ''}`)}
<Search /> {t(`Editor.tools.routes-edition.search-routes${!isNew ? '-alt' : ''}`)}
</button>

{state.type === 'loading' && <LoaderFill />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { FC, useCallback, useContext, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { GoPencil } from 'react-icons/go';
import { Pencil } from '@osrd-project/ui-icons';
import { FaMapMarkedAlt, FaTimesCircle } from 'react-icons/fa';
import { isNil } from 'lodash';

Expand Down Expand Up @@ -78,7 +78,7 @@ const WayPointInput: FC<WayPointInputProps> = ({ endPoint, wayPoint, onChange })
}, [endPoint, isPicking, setState, state]);

const getButtonIcon = () => {
if (!isPicking && isWayPointSelected) return <GoPencil />;
if (!isPicking && isWayPointSelected) return <Pencil />;
return isPicking ? <FaTimesCircle /> : <FaMapMarkedAlt />;
};

Expand Down
6 changes: 3 additions & 3 deletions front/src/applications/editor/tools/routeEdition/tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { isEqual } from 'lodash';
import { GiPathDistance } from 'react-icons/gi';
import { AiFillSave } from 'react-icons/ai';
import { GoPlusCircle, GoTrash } from 'react-icons/go';
import { PlusCircle, Trash } from '@osrd-project/ui-icons';
import { BiReset } from 'react-icons/bi';

import { WayPointEntity } from 'types';
Expand Down Expand Up @@ -50,7 +50,7 @@ const RouteEditionTool: Tool<RouteEditionState> = {
[
{
id: 'new-route',
icon: GoPlusCircle,
icon: PlusCircle,
labelTranslationKey: 'Editor.tools.routes-edition.actions.new-route',
onClick({ setState }) {
setState(getRouteEditionState());
Expand All @@ -60,7 +60,7 @@ const RouteEditionTool: Tool<RouteEditionState> = {
[
{
id: 'delete-route',
icon: GoTrash,
icon: Trash,
labelTranslationKey: 'Editor.tools.routes-edition.actions.delete-route',
// Show button only if we are editing
isDisabled({ state: { entity } }) {
Expand Down
6 changes: 3 additions & 3 deletions front/src/applications/editor/tools/selection/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useEffect } from 'react';
import { Layer, Popup, Source } from 'react-map-gl/maplibre';
import { useSelector } from 'react-redux';
import { groupBy, map } from 'lodash';
import { GoNoEntry } from 'react-icons/go';
import { NoEntry } from '@osrd-project/ui-icons';
import { RiFocus3Line } from 'react-icons/ri';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
Expand Down Expand Up @@ -169,7 +169,7 @@ export const SelectionLeftPanel = () => {
setState({ ...state, selection: selection.filter((i) => i.objType !== type) })
}
>
<GoNoEntry /> {t('Editor.tools.select-items.unselect')}
<NoEntry /> {t('Editor.tools.select-items.unselect')}
</button>
</div>
</li>
Expand Down Expand Up @@ -208,7 +208,7 @@ export const SelectionLeftPanel = () => {
})
}
>
<GoNoEntry /> {t('Editor.tools.select-items.unselect')}
<NoEntry /> {t('Editor.tools.select-items.unselect')}
</button>
</div>
</li>
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/editor/tools/selection/tool.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { FiEdit } from 'react-icons/fi';
import { GoTrash } from 'react-icons/go';
import { Trash } from '@osrd-project/ui-icons';
import { BsCursor } from 'react-icons/bs';
import { FaDrawPolygon } from 'react-icons/fa';
import { BiLoader, BiSelection } from 'react-icons/bi';
Expand Down Expand Up @@ -110,7 +110,7 @@ const SelectionTool: Tool<SelectionState> = {
},
{
id: 'delete-selection',
icon: GoTrash,
icon: Trash,
labelTranslationKey: 'Editor.tools.select-items.actions.delete-selection',
isDisabled({ state }) {
return !state.selection.length;
Expand Down
6 changes: 3 additions & 3 deletions front/src/applications/editor/tools/switchEdition/tool.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { TbSwitch2 } from 'react-icons/tb';
import { AiFillSave } from 'react-icons/ai';
import { GoPlusCircle, GoTrash } from 'react-icons/go';
import { PlusCircle, Trash } from '@osrd-project/ui-icons';

import { save } from 'reducers/editor';
import { SwitchEntity, SwitchType } from 'types';
Expand Down Expand Up @@ -74,7 +74,7 @@ const SwitchEditionTool: Tool<SwitchEditionState> = {
[
{
id: 'new-switch',
icon: GoPlusCircle,
icon: PlusCircle,
labelTranslationKey: 'Editor.tools.switch-edition.actions.new-switch',
onClick({ setState, switchTypes }) {
if (!switchTypes?.length) throw new Error('There is no switch type yet.');
Expand All @@ -93,7 +93,7 @@ const SwitchEditionTool: Tool<SwitchEditionState> = {
[
{
id: 'delete-switch',
icon: GoTrash,
icon: Trash,
labelTranslationKey: `Editor.tools.switch-edition.actions.delete-switch`,
// Show button only if we are editing
isDisabled({ state }) {
Expand Down
10 changes: 5 additions & 5 deletions front/src/applications/editor/tools/trackEdition/tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cloneDeep, isEmpty, isEqual } from 'lodash';
import { MdShowChart } from 'react-icons/md';
import { RiDragMoveLine } from 'react-icons/ri';
import { AiFillSave } from 'react-icons/ai';
import { GoNoEntry, GoPlusCircle, GoTrash, GoXCircle } from 'react-icons/go';
import { NoEntry, PlusCircle, Trash, XCircle } from '@osrd-project/ui-icons';
import { BiAnchor, BiArrowFromLeft, BiArrowToRight, BiReset } from 'react-icons/bi';
import getNearestPoint from '@turf/nearest-point';
import { featureCollection } from '@turf/helpers';
Expand Down Expand Up @@ -98,7 +98,7 @@ const TrackEditionTool: Tool<TrackEditionState> = {
},
{
id: 'mode-add-point',
icon: GoPlusCircle,
icon: PlusCircle,
labelTranslationKey: 'Editor.tools.track-edition.actions.mode-add-point',
onClick({ setState, state }) {
setState({
Expand All @@ -112,7 +112,7 @@ const TrackEditionTool: Tool<TrackEditionState> = {
},
{
id: 'mode-delete-point',
icon: GoXCircle,
icon: XCircle,
labelTranslationKey: 'Editor.tools.track-edition.actions.mode-delete-point',
onClick({ setState, state }) {
setState({
Expand Down Expand Up @@ -174,7 +174,7 @@ const TrackEditionTool: Tool<TrackEditionState> = {
},
{
id: 'cancel-line',
icon: GoNoEntry,
icon: NoEntry,
labelTranslationKey: 'Editor.tools.track-edition.actions.cancel-line',
onClick({ setState, state }) {
if (state.track.geometry.coordinates.length) {
Expand All @@ -191,7 +191,7 @@ const TrackEditionTool: Tool<TrackEditionState> = {
[
{
id: 'delete-line',
icon: GoTrash,
icon: Trash,
labelTranslationKey: 'Editor.tools.track-edition.actions.delete-line',
// Show button only if we are editing
isDisabled({ state }) {
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/operationalStudies/views/Project.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { BiTargetLock } from 'react-icons/bi';
import { GoPencil } from 'react-icons/go';
import { Pencil } from '@osrd-project/ui-icons';
import nextId from 'react-id-generator';
import ReactMarkdown from 'react-markdown';
import { useParams } from 'react-router-dom';
Expand Down Expand Up @@ -202,7 +202,7 @@ export default function Project() {
<span className="project-details-title-modify-button-text">
{t('modifyProject')}
</span>
<GoPencil />
<Pencil />
</button>
</div>
<div className="row">
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/operationalStudies/views/Scenario.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import { useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useSelector, useDispatch } from 'react-redux';
import { GoPencil } from 'react-icons/go';
import { Pencil } from '@osrd-project/ui-icons';
import { GiElectric } from 'react-icons/gi';
import { FaEye, FaEyeSlash } from 'react-icons/fa';

Expand Down Expand Up @@ -240,7 +240,7 @@ export default function Scenario() {
}
title={t('editScenario')}
>
<GoPencil />
<Pencil />
</button>
<button
type="button"
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/operationalStudies/views/Study.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { GoPencil } from 'react-icons/go';
import { Pencil } from '@osrd-project/ui-icons';
import nextId from 'react-id-generator';
import { useParams } from 'react-router-dom';

Expand Down Expand Up @@ -234,7 +234,7 @@ export default function Study() {
}
>
<span className="study-details-modify-button-text">{t('modifyStudy')}</span>
<GoPencil />
<Pencil />
</button>
</div>
{study.study_type && (
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/referenceMap/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Route, Routes } from 'react-router-dom';
import { GoLock } from 'react-icons/go';
import { Lock } from '@osrd-project/ui-icons';

import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
Expand Down Expand Up @@ -34,7 +34,7 @@ const HomeReferenceMap = () => {
{infra ? (
<span className="ml-2 text-muted">
{t('referenceMap:infrastructure', { name: infra.name })}
<span className="ml-2">{infra.locked && <GoLock />}</span>
<span className="ml-2">{infra.locked && <Lock />}</span>
</span>
) : (
<span className="ml-2 text-orange">{t('referenceMap:mapNoInfraSelected')}</span>
Expand Down
4 changes: 2 additions & 2 deletions front/src/common/Map/Buttons/ButtonMapSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { GoSearch } from 'react-icons/go';
import { Search } from '@osrd-project/ui-icons';
import Tipped from 'applications/editor/components/Tipped';

type ButtonMapSearchProps = {
Expand All @@ -17,7 +17,7 @@ const ButtonMapSearch = ({ toggleMapSearch }: ButtonMapSearchProps) => {
onClick={toggleMapSearch}
>
<span className="sr-only">Search</span>
<GoSearch />
<Search />
</button>
<span>{t('common.search')}</span>
</Tipped>
Expand Down
Loading

0 comments on commit e3e37d3

Please sign in to comment.