Skip to content

Commit 12c3f3e

Browse files
th7nderdarkwing
authored andcommitted
refactor: specialize svg to breakpointsvg
1 parent 12ad6be commit 12c3f3e

File tree

6 files changed

+29
-47
lines changed

6 files changed

+29
-47
lines changed

images/BreakpointSvg.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
4+
5+
import React from "react";
6+
7+
const BREAKPOINT_SVG =
8+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 15" width="60" height="15"><path d="M53.07.5H1.5c-.54 0-1 .46-1 1v12c0 .54.46 1 1 1h51.57c.58 0 1.15-.26 1.53-.7l4.7-6.3-4.7-6.3c-.38-.44-.95-.7-1.53-.7z"/></svg>';
9+
const COLUMN_MARKER_SVG =
10+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 13" width="11" height="13"><path d="M5.07.5H1.5c-.54 0-1 .46-1 1v10c0 .54.46 1 1 1h3.57c.58 0 1.15-.26 1.53-.7l3.7-5.3-3.7-5.3C6.22.76 5.65.5 5.07.5z"/></svg>';
11+
12+
type Props = {
13+
column: boolean
14+
};
15+
16+
export default function BreakpointSvg({ column }: Props) {
17+
const svg = column ? COLUMN_MARKER_SVG : BREAKPOINT_SVG;
18+
19+
/* eslint-disable react/no-danger */
20+
return <span dangerouslySetInnerHTML={{ __html: svg }} />;
21+
}

images/Svg.js

-39
This file was deleted.

src/components/Editor/Breakpoint.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React, { PureComponent } from "react";
88
import ReactDOM from "react-dom";
99
import classnames from "classnames";
10-
import Svg from "../shared/Svg";
10+
import BreakpointSvg from "../shared/BreakpointSvg";
1111

1212
import { getDocument, toEditorLine } from "../../utils/editor";
1313
import { getSelectedLocation } from "../../utils/source-maps";
@@ -20,7 +20,7 @@ import type { EditorItemActions } from "./menus/editor";
2020
import type { Source, Breakpoint as BreakpointType } from "../../types";
2121

2222
const breakpointSvg = document.createElement("div");
23-
ReactDOM.render(<Svg name="breakpoint" />, breakpointSvg);
23+
ReactDOM.render(<BreakpointSvg column={false} />, breakpointSvg);
2424

2525
type Props = {
2626
breakpoint: BreakpointType,

src/components/Editor/ColumnBreakpoint.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, { PureComponent } from "react";
77
import ReactDOM from "react-dom";
88
import classnames from "classnames";
99
import { getDocument } from "../../utils/editor";
10-
import Svg from "../shared/Svg";
10+
import BreakpointSvg from "../shared/BreakpointSvg";
1111
import { showMenu } from "devtools-contextmenu";
1212
import { breakpointItems, createBreakpointItems } from "./menus/breakpoints";
1313

@@ -28,7 +28,7 @@ type Props = {
2828
};
2929

3030
const breakpointImg = document.createElement("button");
31-
ReactDOM.render(<Svg name={"column-marker"} />, breakpointImg);
31+
ReactDOM.render(<BreakpointSvg column={true} />, breakpointImg);
3232

3333
function makeBookmark({ breakpoint }, { onClick, onContextMenu }) {
3434
const bp = breakpointImg.cloneNode(true);

src/components/shared/Svg.js src/components/shared/BreakpointSvg.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
* This file maps the SVG React Components in the images directory.
88
*/
99

10-
import Svg from "../../../images/Svg";
10+
import BreakpointSvg from "../../../images/BreakpointSvg";
1111

12-
export default Svg;
12+
export default BreakpointSvg;

src/vendors.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import * as reselect from "reselect";
3333
import classnames from "classnames";
3434
import devtoolsSplitter from "devtools-splitter";
3535
import move from "lodash-move";
36-
import Svg from "./components/shared/Svg";
36+
import BreakpointSvg from "./components/shared/BreakpointSvg";
3737

3838
// We cannot directly export literals containing special characters
3939
// (eg. "my-module/Test") which is why they are nested in "vendored".
@@ -55,5 +55,5 @@ export const vendored = {
5555
reselect,
5656
// Svg is required via relative paths, so the key is not imported path.
5757
// See .babel/transform-mc.js
58-
Svg
58+
BreakpointSvg
5959
};

0 commit comments

Comments
 (0)