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 Feb 7, 2024
1 parent 70f63aa commit cc6ad95
Show file tree
Hide file tree
Showing 59 changed files with 193 additions and 220 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.9",
"@redux-devtools/extension": "^3.2.3",
"@reduxjs/toolkit": "^1.9.0",
"@rjsf/core": "^4.2.3",
Expand Down
4 changes: 2 additions & 2 deletions front/src/applications/editor/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 { FaLock } from 'react-icons/fa6';
import { Lock } from '@osrd-project/ui-icons';

import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
import { osrdEditoastApi } from 'common/api/osrdEditoastApi';
Expand Down Expand Up @@ -35,7 +35,7 @@ export default function HomeEditorUnplugged() {
<span>{t('referenceMap:infrastructure', { name: infra.name })}</span>
{infra.locked && (
<span className="ml-2 text-yellow">
<FaLock />
<Lock />
</span>
)}
</span>
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 { UiIcon, 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 | UiIcon;
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 UiIcon,
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 UiIcon,
labelTranslationKey: 'common.zoom-out',
onClick({ setViewport, viewport }) {
setViewport({
Expand All @@ -96,7 +96,7 @@ const NavButtons: NavButton[][] = [
},
{
id: 'search',
icon: GoSearch,
icon: Search as UiIcon,
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 @@ -115,7 +115,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 @@ -125,7 +125,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 { ConfirmModal } from 'common/BootstrapSNCF/ModalSNCF';
import { save } from 'reducers/editor';
Expand Down Expand Up @@ -154,7 +154,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 @@ -164,7 +164,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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext, useEffect } from 'react';
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 @@ -75,7 +75,7 @@ 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 @@ -114,7 +114,7 @@ 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 @@ -93,7 +93,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 @@ -107,7 +107,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 @@ -169,7 +169,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 @@ -186,7 +186,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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { ChevronRight } from '@osrd-project/ui-icons';
import { Project, Study, Scenario } from 'common/api/osrdEditoastApi';

type Props = {
Expand All @@ -20,7 +21,9 @@ export default function BreadCrumbs({ project, study, scenario }: Props) {
<div>
<Link to="/operational-studies/projects">{t('projectsList')}</Link>{' '}
</div>
<i className="icons-arrow-next icons-size-x75 text-muted" />
<span className="text-muted">
<ChevronRight />
</span>
</>
)}

Expand All @@ -31,7 +34,9 @@ export default function BreadCrumbs({ project, study, scenario }: Props) {
<div className="text-truncate" title={project.name}>
<Link to={`/operational-studies/projects/${project.id}`}> {project.name}</Link>
</div>
<i className="icons-arrow-next icons-size-x75 text-muted" />
<span className="text-muted">
<ChevronRight />
</span>
</>
)}
{project && study && !scenario && (
Expand All @@ -47,7 +52,9 @@ export default function BreadCrumbs({ project, study, scenario }: Props) {
{study.name}
</Link>
</div>
<i className="icons-arrow-next icons-size-x75 text-muted" />
<span className="text-muted">
<ChevronRight />
</span>
<div className="text-truncate" title={scenario.name}>
{scenario.name}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect, useCallback, ChangeEvent } from 'react';
import { AiOutlinePicture } from 'react-icons/ai';
import { Image, XCircle } from '@osrd-project/ui-icons';
import { useTranslation } from 'react-i18next';
import { TiDelete } from 'react-icons/ti';
import logoCheese from 'assets/pictures/misc/cheese.svg';
import logoDog from 'assets/pictures/misc/dog.svg';
import logoCat from 'assets/pictures/misc/cat.svg';
Expand Down Expand Up @@ -40,7 +39,7 @@ const IMAGE_MAX_SIZE = 2 * 1024 * 1024; // 2MiB
function displayNoImageMessages(isValid: boolean, t: (arg0: string) => string) {
return (
<>
<AiOutlinePicture />
<Image />
{isValid ? (
<div className="project-edition-modal-picture-placeholder-text">{t('noImage')}</div>
) : (
Expand Down Expand Up @@ -176,7 +175,7 @@ function PicturePlaceholderButtons({ setTempProjectImage, safeWord }: PropsButto
<img src={logoSNCF} alt="SNCF LOGO" />
</button>
<button className="remove" type="button" onClick={() => setTempProjectImage(null)}>
<TiDelete />
<XCircle variant="fill" />
</button>
</div>
);
Expand Down
Loading

0 comments on commit cc6ad95

Please sign in to comment.