File tree Expand file tree Collapse file tree
components/mock-components
front-rich-components/fab-button Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { IconSize } from '@/core/model' ;
22
3- export const loadSvgWithFill = async ( url : string , fillColor : string ) => {
4- const response = await fetch ( url ) ;
5- const svgText = await response . text ( ) ;
6-
7- const modifiedSvg = svgText . replace ( / f i l l = " [ ^ " ] * " / g, `fill="${ fillColor } "` ) ;
8-
9- const svgBlob = new Blob ( [ modifiedSvg ] , { type : 'image/svg+xml' } ) ;
10- const objectURL = URL . createObjectURL ( svgBlob ) ;
11-
12- const img = new window . Image ( ) ;
13- img . src = objectURL ;
14-
15- return img ;
16- } ;
17-
183export const returnIconSize = ( iconSize : IconSize ) : number [ ] => {
194 switch ( iconSize ) {
205 case 'XS' :
Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ import { useModalDialogContext } from '@/core/providers/model-dialog-providers/m
77import { IconModal } from '@/pods/properties/components/icon-selector/modal' ;
88import { useCanvasContext } from '@/core/providers' ;
99import { useGroupShapeProps } from '../../mock-components.utils' ;
10- import { loadSvgWithFill , returnIconSize } from './icon-shape.business' ;
10+ import { returnIconSize } from './icon-shape.business' ;
11+ import { loadSvgWithFill } from '@/common/utils/svg.utils' ;
1112
1213const iconShapeRestrictions : ShapeSizeRestrictions = {
1314 minWidth : 25 ,
Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes';
66import { useShapeProps } from '@/common/components/shapes/use-shape-props.hook' ;
77import { useGroupShapeProps } from '../../mock-components.utils' ;
88import { BASIC_SHAPE } from '../../front-components/shape.const' ;
9- import { loadSvgWithFill } from '../../front-components/icon/icon-shape.business' ;
109import { IconModal } from '@/pods/properties/components/icon-selector/modal' ;
1110import { useModalDialogContext } from '@/core/providers/model-dialog-providers/model-dialog.provider' ;
1211import { useCanvasContext } from '@/core/providers' ;
12+ import { loadSvgWithFill } from '@/common/utils/svg.utils' ;
1313
1414const fabButtonShapeRestrictions : ShapeSizeRestrictions = {
1515 minWidth : 25 ,
Original file line number Diff line number Diff line change 1+ export const loadSvgWithFill = async ( url : string , fillColor : string ) => {
2+ const response = await fetch ( url ) ;
3+ const svgText = await response . text ( ) ;
4+
5+ const modifiedSvg = svgText . replace ( / f i l l = " [ ^ " ] * " / g, `fill="${ fillColor } "` ) ;
6+
7+ const svgBlob = new Blob ( [ modifiedSvg ] , { type : 'image/svg+xml' } ) ;
8+ const objectURL = URL . createObjectURL ( svgBlob ) ;
9+
10+ const img = new window . Image ( ) ;
11+ img . src = objectURL ;
12+
13+ return img ;
14+ } ;
You can’t perform that action at this time.
0 commit comments