From 4f3c1c4c9f736b7eb28d894c1e101cabcf4fed7e Mon Sep 17 00:00:00 2001 From: Daniel Mulholland Date: Tue, 14 Nov 2023 08:25:20 +1300 Subject: [PATCH] feat: add more primary apparatus icons Closes #46. --- dist/__snapshots__/oscd-designer.spec.snap.js | 214 ++++++++++- icons.ts | 340 ++++++++++++++---- oscd-designer.spec.ts | 11 +- oscd-designer.ts | 5 +- sld-editor.ts | 100 ++++-- util.ts | 22 ++ 6 files changed, 583 insertions(+), 109 deletions(-) diff --git a/dist/__snapshots__/oscd-designer.spec.snap.js b/dist/__snapshots__/oscd-designer.spec.snap.js index e8259e3..7a20558 100644 --- a/dist/__snapshots__/oscd-designer.spec.snap.js +++ b/dist/__snapshots__/oscd-designer.spec.snap.js @@ -242,6 +242,16 @@ snapshots["Designer given conducting equipment grounds equipment on connection p + + @@ -409,6 +419,16 @@ snapshots["Designer given conducting equipment connects equipment on connection + + @@ -664,6 +684,16 @@ snapshots["Designer given conducting equipment connects equipment on connect men + + + + @@ -1136,6 +1176,16 @@ snapshots["Designer given conducting equipment with established connectivity con + + @@ -1303,6 +1353,16 @@ snapshots["Designer given conducting equipment with established connectivity avo + + @@ -1577,6 +1637,16 @@ snapshots["Designer given conducting equipment with established connectivity kee + + @@ -1742,6 +1812,16 @@ snapshots["Designer given conducting equipment with established connectivity bet type="BAT" > + + @@ -1917,6 +1997,16 @@ snapshots["Designer given conducting equipment with established connectivity bet + + + + + + + + + + @@ -3017,6 +3147,16 @@ snapshots["Designer given conducting equipment with established connectivity bet + + + + @@ -3367,6 +3517,16 @@ snapshots["Designer given conducting equipment with established connectivity bet + + + + + + + + + + + + `; -const equipmentPaths: Partial>> = { - IFL: svg` +const equipmentPaths: Record> = { + CAB: svg` + /> - + -`, - DIS: svg` + /> + /> + /> + `, + CAP: svg` + /> -`, + /> + + + `, CBR: svg` >> = { stroke-width="1.5" stroke-linecap="round" /> -`, + `, CTR: svg` >> = { cy="12.5" r="7.5" stroke="currentColor" - fill="transparent" + fill="none" stroke-width="1.5" stroke-linecap="round" /> -`, + `, + DIS: svg` + + + + + `, + GEN: svg` + + `, + IFL: svg` + + + + `, + LIN: svg` + + + + `, + MOT: svg` + + `, + REA: svg` + + + + `, + RES: svg` + + + + `, + SAR: svg` + + + + + + `, + SMC: svg` + + `, VTR: svg` >> = { cy="10" r="5" stroke="currentColor" - fill="transparent" + fill="none" stroke-width="1.5" stroke-linecap="round" /> @@ -266,30 +475,31 @@ const equipmentPaths: Partial>> = { cy="15" r="5" stroke="currentColor" - fill="transparent" + fill="none" stroke-width="1.5" stroke-linecap="round" /> - - + -`, -}; + `; const defaultEquipmentPath = svg` { - if (equipmentType && equipmentType in equipmentPaths) + if (equipmentType && isEqType(equipmentType)) return equipmentPaths[equipmentType]!; return defaultEquipmentPath; } @@ -359,6 +569,7 @@ export function equipmentGraphic( slot="graphic" > ${equipmentPath(equipmentType)} + ${equipmentType && ringedEqTypes.has(equipmentType) ? eqRingPath : nothing} `; } @@ -371,6 +582,7 @@ export function equipmentIcon(equipmentType: string): TemplateResult<1> { slot="icon" > ${equipmentPath(equipmentType)} + ${ringedEqTypes.has(equipmentType) ? eqRingPath : nothing} `; } @@ -453,7 +665,7 @@ export const powerTransformerTwoWindingSymbol = svg` @@ -462,7 +674,7 @@ export const powerTransformerTwoWindingSymbol = svg` @@ -491,7 +703,7 @@ export const symbols = svg` - ${Object.keys(equipmentPaths).map(eqType => equipmentSymbol(eqType))} + ${eqTypes.map(eqType => equipmentSymbol(eqType))} ${equipmentSymbol('ConductingEquipment')} ${connectivityNodeMarker} ${groundedMarker} diff --git a/oscd-designer.spec.ts b/oscd-designer.spec.ts index aceede3..5e567cd 100644 --- a/oscd-designer.spec.ts +++ b/oscd-designer.spec.ts @@ -69,6 +69,7 @@ export const equipmentDocString = ` + @@ -339,7 +340,7 @@ describe('Designer', () => { }).dispatchEvent(new PointerEvent('contextmenu')); await element.updateComplete; expect(queryUI({ ui: 'menu' })).to.exist; - expect(queryUI({ ui: 'menu' })).dom.to.equalSnapshot(); + await expect(queryUI({ ui: 'menu' })).dom.to.equalSnapshot(); }); it('resizes voltage levels on resize menu item select', async () => { @@ -673,7 +674,7 @@ describe('Designer', () => { }); it('allows placing new conducting equipment', async () => { - element.shadowRoot!.querySelector