Skip to content

Commit

Permalink
Cleaner SVGs for unit icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliveriver committed Oct 17, 2024
1 parent df0e40e commit c34be61
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
3 changes: 0 additions & 3 deletions client/src/assets/icons/Army.svg

This file was deleted.

4 changes: 4 additions & 0 deletions client/src/assets/icons/ArmyIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions client/src/assets/icons/Fleet.svg

This file was deleted.

6 changes: 6 additions & 0 deletions client/src/assets/icons/FleetIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 23 additions & 21 deletions client/src/components/world/boards/UnitIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { getNationColour } from '../../../types/enums/nation';
import Unit from '../../../types/unit';
import UnitType from '../../../types/enums/unitType';
import { unitWidth } from '../../../utils/constants';

import ArmyIcon from '../../../assets/icons/Army.svg?react';
import FleetIcon from '../../../assets/icons/Fleet.svg?react';
import ArmyIcon from '../../../assets/icons/ArmyIcon.svg?react';
import FleetIcon from '../../../assets/icons/FleetIcon.svg?react';

type UnitIconProps = {
unit: Unit;
Expand All @@ -14,26 +13,29 @@ type UnitIconProps = {

const UnitIcon = ({ unit, scaleFactor = 1, variant = 'world' }: UnitIconProps) => {
const isWorldVariant = variant === 'world';
const shadow = unit.mustRetreat ? '0px 0px 2px red' : '0px 0px 2px black';
const Svg = (unit.type === UnitType.Army ? ArmyIcon : FleetIcon);
const Svg = unit.type === UnitType.Army ? ArmyIcon : FleetIcon;

return (
<Svg
className="flex justify-center"
style={{
color: getNationColour(unit.owner),
filter: isWorldVariant ? `drop-shadow(${shadow})` : '',
width: unitWidth * scaleFactor,
height: unitWidth * scaleFactor,
margin: isWorldVariant ? -(unitWidth * scaleFactor) / 2 : 0,
zIndex: unit.mustRetreat ? 30 : 10,
position: isWorldVariant ? 'absolute' : 'relative',
pointerEvents: isWorldVariant ? 'none' : 'auto',
}}
>
</Svg>
<>
<Svg
className="flex justify-center overflow-visible"
style={{
color: getNationColour(unit.owner),
filter:
isWorldVariant && !unit.mustRetreat ? 'drop-shadow(0px 0px 1px rgb(0 0 0 / 0.8))' : '',
width: unitWidth * scaleFactor,
height: unitWidth * scaleFactor,
margin: isWorldVariant ? -(unitWidth * scaleFactor) / 2 : 0,
zIndex: unit.mustRetreat ? 30 : 10,
position: isWorldVariant ? 'absolute' : 'relative',
pointerEvents: isWorldVariant ? 'none' : 'auto',
}}
/>
{isWorldVariant && unit.mustRetreat && (
<div style={{ boxShadow: '0px 0px 35px 35px red', zIndex: 5 }} />
)}
</>
);
}

};

export default UnitIcon;

0 comments on commit c34be61

Please sign in to comment.