Merged PR 170: Add new eslint rules
- naming-convention - prefer-arrow-callback - func-style - import/no-default-export
This commit is contained in:
parent
3f58c5ba5e
commit
ad126c6c28
65 changed files with 781 additions and 784 deletions
|
@ -20,9 +20,11 @@ interface IDimensionProps {
|
|||
* @param vx Transform vector
|
||||
* @returns Returns a new coordinate from the origin coordinate
|
||||
*/
|
||||
const applyParametric = (x0: number, t: number, vx: number): number => x0 + t * vx;
|
||||
function ApplyParametric(x0: number, t: number, vx: number): number {
|
||||
return x0 + t * vx;
|
||||
}
|
||||
|
||||
export const Dimension: React.FC<IDimensionProps> = (props: IDimensionProps) => {
|
||||
export function Dimension(props: IDimensionProps): JSX.Element {
|
||||
const style: React.CSSProperties = {
|
||||
stroke: 'black'
|
||||
};
|
||||
|
@ -39,15 +41,15 @@ export const Dimension: React.FC<IDimensionProps> = (props: IDimensionProps) =>
|
|||
const [perpVecX, perpVecY] = [unitY, -unitX];
|
||||
|
||||
// Use the parametric function to get the coordinates (x = x0 + t * v.x)
|
||||
const startTopX = applyParametric(props.xStart, NOTCHES_LENGTH, perpVecX);
|
||||
const startTopY = applyParametric(props.yStart, NOTCHES_LENGTH, perpVecY);
|
||||
const startBottomX = applyParametric(props.xStart, -NOTCHES_LENGTH, perpVecX);
|
||||
const startBottomY = applyParametric(props.yStart, -NOTCHES_LENGTH, perpVecY);
|
||||
const startTopX = ApplyParametric(props.xStart, NOTCHES_LENGTH, perpVecX);
|
||||
const startTopY = ApplyParametric(props.yStart, NOTCHES_LENGTH, perpVecY);
|
||||
const startBottomX = ApplyParametric(props.xStart, -NOTCHES_LENGTH, perpVecX);
|
||||
const startBottomY = ApplyParametric(props.yStart, -NOTCHES_LENGTH, perpVecY);
|
||||
|
||||
const endTopX = applyParametric(props.xEnd, NOTCHES_LENGTH, perpVecX);
|
||||
const endTopY = applyParametric(props.yEnd, NOTCHES_LENGTH, perpVecY);
|
||||
const endBottomX = applyParametric(props.xEnd, -NOTCHES_LENGTH, perpVecX);
|
||||
const endBottomY = applyParametric(props.yEnd, -NOTCHES_LENGTH, perpVecY);
|
||||
const endTopX = ApplyParametric(props.xEnd, NOTCHES_LENGTH, perpVecX);
|
||||
const endTopY = ApplyParametric(props.yEnd, NOTCHES_LENGTH, perpVecY);
|
||||
const endBottomX = ApplyParametric(props.xEnd, -NOTCHES_LENGTH, perpVecX);
|
||||
const endBottomY = ApplyParametric(props.yEnd, -NOTCHES_LENGTH, perpVecY);
|
||||
|
||||
return (
|
||||
<g key={props.id}>
|
||||
|
@ -57,24 +59,21 @@ export const Dimension: React.FC<IDimensionProps> = (props: IDimensionProps) =>
|
|||
x2={startBottomX}
|
||||
y2={startBottomY}
|
||||
strokeWidth={props.strokeWidth}
|
||||
style={style}
|
||||
/>
|
||||
style={style} />
|
||||
<line
|
||||
x1={props.xStart}
|
||||
y1={props.yStart}
|
||||
x2={props.xEnd}
|
||||
y2={props.yEnd}
|
||||
strokeWidth={props.strokeWidth}
|
||||
style={style}
|
||||
/>
|
||||
style={style} />
|
||||
<line
|
||||
x1={endTopX}
|
||||
y1={endTopY}
|
||||
x2={endBottomX}
|
||||
y2={endBottomY}
|
||||
strokeWidth={props.strokeWidth}
|
||||
style={style}
|
||||
/>
|
||||
style={style} />
|
||||
<text
|
||||
x={(props.xStart + props.xEnd) / 2}
|
||||
y={props.yStart}
|
||||
|
@ -83,4 +82,4 @@ export const Dimension: React.FC<IDimensionProps> = (props: IDimensionProps) =>
|
|||
</text>
|
||||
</g>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue