From c1e0355d0dea234e10814e453345e2ffef8a04fb Mon Sep 17 00:00:00 2001 From: marcofaggian Date: Fri, 7 Oct 2022 14:17:54 +0200 Subject: [PATCH] chore(plugins/tech-radar): prettier Signed-off-by: marcofaggian --- .../tech-radar/src/components/Radar/Radar.tsx | 28 ++++++++++--- .../tech-radar/src/components/Radar/utils.ts | 40 ++++++++++--------- .../components/RadarLegend/RadarLegend.tsx | 4 +- .../RadarLegend/RadarLegendLink.tsx | 12 +++--- .../RadarLegend/RadarLegendQuadrant.tsx | 18 ++++----- .../RadarLegend/RadarLegendRing.tsx | 12 +++--- .../src/components/RadarLegend/types.ts | 4 +- .../src/components/RadarLegend/utils.ts | 6 +-- 8 files changed, 69 insertions(+), 55 deletions(-) diff --git a/plugins/tech-radar/src/components/Radar/Radar.tsx b/plugins/tech-radar/src/components/Radar/Radar.tsx index b2d4ed22e2..15fcb697c2 100644 --- a/plugins/tech-radar/src/components/Radar/Radar.tsx +++ b/plugins/tech-radar/src/components/Radar/Radar.tsx @@ -28,8 +28,16 @@ export type Props = { svgProps?: object; }; -const Radar = ({ width, height, quadrants, rings, entries, ...props }: Props): JSX.Element => { - const [adjustedQuadrants, setAdjustedQuadrants] = useState>(quadrants); +const Radar = ({ + width, + height, + quadrants, + rings, + entries, + ...props +}: Props): JSX.Element => { + const [adjustedQuadrants, setAdjustedQuadrants] = + useState>(quadrants); const [adjustedRings, setAdjustedRings] = useState>(rings); const [adjustedEntries, setAdjustedEntries] = useState>(entries); @@ -40,15 +48,23 @@ const Radar = ({ width, height, quadrants, rings, entries, ...props }: Props): J useEffect(() => { setAdjustedQuadrants(adjustQuadrants(quadrants, radius, width, height)); - }, [quadrants, radius, width, height]) + }, [quadrants, radius, width, height]); useEffect(() => { setAdjustedRings(adjustRings(rings, radius)); - }, [radius, rings]) + }, [radius, rings]); useEffect(() => { - setAdjustedEntries(adjustEntries(entries, adjustedQuadrants, adjustedRings, radius, activeEntry)); - }, [entries, adjustedQuadrants, adjustedRings, radius, activeEntry]) + setAdjustedEntries( + adjustEntries( + entries, + adjustedQuadrants, + adjustedRings, + radius, + activeEntry, + ), + ); + }, [entries, adjustedQuadrants, adjustedRings, radius, activeEntry]); return ( diff --git a/plugins/tech-radar/src/components/Radar/utils.ts b/plugins/tech-radar/src/components/Radar/utils.ts index 19db2a0cd1..5b458068e6 100644 --- a/plugins/tech-radar/src/components/Radar/utils.ts +++ b/plugins/tech-radar/src/components/Radar/utils.ts @@ -84,7 +84,7 @@ export const adjustQuadrants = ( return quadrants.slice().map((quadrant, index) => { const legendParam = legendParams[index % 4]; - return ({ + return { ...quadrant, index, radialMin: (index * Math.PI) / 2, @@ -94,8 +94,8 @@ export const adjustQuadrants = ( legendX: legendParam.x, legendY: legendParam.y, legendWidth: legendParam.width, - legendHeight: legendParam.height - }) + legendHeight: legendParam.height, + }; }); }; @@ -126,10 +126,10 @@ export const adjustEntries = ( if (!ring) { throw new Error(`Unknown ring ${entry.ring} for entry ${entry.id}!`); } - const segment = new Segment(quadrant, ring, radius, () => seed++) + const segment = new Segment(quadrant, ring, radius, () => seed++); const point = segment?.random(); - return ({ + return { ...entry, index: index, quadrant: quadrant, @@ -137,10 +137,11 @@ export const adjustEntries = ( segment, x: point.x, y: point.y, - color: activeEntry && entry.id === activeEntry?.id - ? entry.ring.color - : color(entry.ring.color).desaturate(0.5).lighten(0.1).string(), - }) + color: + activeEntry && entry.id === activeEntry?.id + ? entry.ring.color + : color(entry.ring.color).desaturate(0.5).lighten(0.1).string(), + }; }); const simulation = forceSimulation() @@ -151,9 +152,9 @@ export const adjustEntries = ( for ( let i = 0, - n = Math.ceil( - Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay()), - ); + n = Math.ceil( + Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay()), + ); i < n; ++i ) { @@ -167,12 +168,13 @@ export const adjustEntries = ( } } - return entries + return entries; }; -export const adjustRings = (rings: Ring[], radius: number) => rings.slice().map((ring, index) => ({ - ...ring, - index, - outerRadius: ((index + 2) / (rings.length + 1)) * radius, - innerRadius: ((index === 0 ? 0 : index + 1) / (rings.length + 1)) * radius -})) +export const adjustRings = (rings: Ring[], radius: number) => + rings.slice().map((ring, index) => ({ + ...ring, + index, + outerRadius: ((index + 2) / (rings.length + 1)) * radius, + innerRadius: ((index === 0 ? 0 : index + 1) / (rings.length + 1)) * radius, + })); diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx index 9a4b861b56..6177041c70 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx @@ -19,7 +19,6 @@ import { RadarLegendQuadrant } from './RadarLegendQuadrant'; import { RadarLegendProps } from './types'; import { setupSegments } from './utils'; - const useStyles = makeStyles(theme => ({ quadrant: { height: '100%', @@ -81,8 +80,7 @@ const RadarLegend = ({ onEntryMouseEnter, onEntryMouseLeave, ...props -}: RadarLegendProps -): JSX.Element => { +}: RadarLegendProps): JSX.Element => { const classes = useStyles(props); return ( diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegendLink.tsx b/plugins/tech-radar/src/components/RadarLegend/RadarLegendLink.tsx index f6626aa0d2..3ed1b7574a 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegendLink.tsx +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegendLink.tsx @@ -13,23 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ClassNameMap } from "@material-ui/core/styles/withStyles"; -import React from "react"; -import { WithLink } from "../../utils/components"; -import { RadarDescription } from "../RadarDescription"; +import { ClassNameMap } from '@material-ui/core/styles/withStyles'; +import React from 'react'; +import { WithLink } from '../../utils/components'; +import { RadarDescription } from '../RadarDescription'; type RadarLegendLinkProps = { url?: string; description?: string; title?: string; - classes: ClassNameMap + classes: ClassNameMap; }; export const RadarLegendLink = ({ url, description, title, - classes + classes, }: RadarLegendLinkProps) => { const [open, setOpen] = React.useState(false); diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegendQuadrant.tsx b/plugins/tech-radar/src/components/RadarLegend/RadarLegendQuadrant.tsx index af79230dfc..60a5870348 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegendQuadrant.tsx +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegendQuadrant.tsx @@ -14,20 +14,18 @@ * limitations under the License. */ -import { ClassNameMap } from "@material-ui/core/styles/withStyles"; -import React from "react"; -import { Quadrant, Ring } from "../../utils/types"; -import { RadarLegendRing } from "./RadarLegendRing"; -import { RadarLegendProps, Segments } from "./types"; -import { getSegment } from "./utils"; - - +import { ClassNameMap } from '@material-ui/core/styles/withStyles'; +import React from 'react'; +import { Quadrant, Ring } from '../../utils/types'; +import { RadarLegendRing } from './RadarLegendRing'; +import { RadarLegendProps, Segments } from './types'; +import { getSegment } from './utils'; type RadarLegendQuadrantProps = { segments: Segments; quadrant: Quadrant; rings: Ring[]; - classes: ClassNameMap, + classes: ClassNameMap; onEntryMouseEnter: RadarLegendProps['onEntryMouseEnter']; onEntryMouseLeave: RadarLegendProps['onEntryMouseLeave']; }; @@ -66,4 +64,4 @@ export const RadarLegendQuadrant = ({ ); -}; \ No newline at end of file +}; diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegendRing.tsx b/plugins/tech-radar/src/components/RadarLegend/RadarLegendRing.tsx index c9070ba0dd..f54e4ab3b3 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegendRing.tsx +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegendRing.tsx @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ClassNameMap } from "@material-ui/core/styles/withStyles"; -import React from "react"; -import { Entry, Ring } from "../../utils/types"; -import { RadarLegendLink } from "./RadarLegendLink"; -import { RadarLegendProps } from "./types"; +import { ClassNameMap } from '@material-ui/core/styles/withStyles'; +import React from 'react'; +import { Entry, Ring } from '../../utils/types'; +import { RadarLegendLink } from './RadarLegendLink'; +import { RadarLegendProps } from './types'; type RadarLegendRingProps = { ring: Ring; @@ -64,4 +64,4 @@ export const RadarLegendRing = ({ )} ); -}; \ No newline at end of file +}; diff --git a/plugins/tech-radar/src/components/RadarLegend/types.ts b/plugins/tech-radar/src/components/RadarLegend/types.ts index 2165646afc..cdac1bfe9d 100644 --- a/plugins/tech-radar/src/components/RadarLegend/types.ts +++ b/plugins/tech-radar/src/components/RadarLegend/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Entry, Quadrant, Ring } from "../../utils/types"; +import { Entry, Quadrant, Ring } from '../../utils/types'; export type Segments = { [k: number]: { [k: number]: Entry[] }; @@ -26,4 +26,4 @@ export type RadarLegendProps = { entries: Entry[]; onEntryMouseEnter?: (entry: Entry) => void; onEntryMouseLeave?: (entry: Entry) => void; -}; \ No newline at end of file +}; diff --git a/plugins/tech-radar/src/components/RadarLegend/utils.ts b/plugins/tech-radar/src/components/RadarLegend/utils.ts index 036388ece9..0c2d7eb8f0 100644 --- a/plugins/tech-radar/src/components/RadarLegend/utils.ts +++ b/plugins/tech-radar/src/components/RadarLegend/utils.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { Entry, Quadrant, Ring } from "../../utils/types"; -import { Segments } from "./types"; +import { Entry, Quadrant, Ring } from '../../utils/types'; +import { Segments } from './types'; export const setupSegments = (entries: Entry[]) => { const segments: Segments = {}; @@ -60,4 +60,4 @@ export const getSegment = ( return ringIndex === undefined ? [] : segmentedData[ringIndex + ringOffset] || []; -}; \ No newline at end of file +};