Skip to content

Commit

Permalink
scale SVG to fit but not exceed container
Browse files Browse the repository at this point in the history
  • Loading branch information
NoraKri committed Dec 11, 2024
1 parent d4250da commit 601517c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion www/src/App.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
body,
html {
width: 100%;
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
}

html,
Expand Down
13 changes: 11 additions & 2 deletions www/src/components/diagram/Pandid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import PandidContext from "../../context/PandidContext.ts";
import PipeSystem from "./piping/PipeSystem.tsx";
import { cleanTripleStore } from "../../utils/Triplestore.ts";
import { useCommissioningPackageContext } from "../../hooks/useCommissioningPackageContext.tsx";
import styled from "styled-components";

const SVGContainer = styled.div`
width: 100%;
height: 100%;
`;

export default function Pandid() {
const context = useCommissioningPackageContext();
Expand Down Expand Up @@ -61,7 +67,7 @@ export default function Pandid() {
}, [xmlData]);

return (
<>
<SVGContainer>
{xmlData && (
<PandidContext.Provider
value={{
Expand All @@ -70,6 +76,9 @@ export default function Pandid() {
>
<svg
viewBox={`${xmlData.PlantModel.Drawing.Extent.Min.X} ${xmlData.PlantModel.Drawing.Extent.Min.Y} ${xmlData.PlantModel.Drawing.Extent.Max.X} ${xmlData.PlantModel.Drawing.Extent.Max.Y}`}
width={"100%"}
height={"100%"}
preserveAspectRatio={"xMidyMid meet"}
>
{equipments &&
equipments.map((equipment: EquipmentProps, index: number) => (
Expand Down Expand Up @@ -103,6 +112,6 @@ export default function Pandid() {
</svg>
</PandidContext.Provider>
)}
</>
</SVGContainer>
);
}
2 changes: 2 additions & 0 deletions www/src/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const EditorContainer = styled.div`
const SideBarAndPandid = styled.div`
display: flex;
flex-direction: row;
height: 100%;
width: 100%;
`;

export default function Editor() {
Expand Down

0 comments on commit 601517c

Please sign in to comment.