From 421a0a8adb22427002ae1e884f5d0fef93465db1 Mon Sep 17 00:00:00 2001 From: Anders Date: Tue, 10 Jan 2023 15:46:58 +0100 Subject: [PATCH] feat(SpacingUtils): deprecate createStyleObject (#1892) --- .../src/components/space/SpacingUtils.ts | 31 ------------------- .../space/__tests__/SpacingUtils.test.ts | 12 ------- 2 files changed, 43 deletions(-) diff --git a/packages/dnb-eufemia/src/components/space/SpacingUtils.ts b/packages/dnb-eufemia/src/components/space/SpacingUtils.ts index 1e175c5a17d..98c90d83438 100644 --- a/packages/dnb-eufemia/src/components/space/SpacingUtils.ts +++ b/packages/dnb-eufemia/src/components/space/SpacingUtils.ts @@ -275,37 +275,6 @@ export const removeSpaceProps = (props: StyleObjectProps) => { return p } -// deprecated and can be removed in v10 (remove tests as well) -export const createStyleObject = (props: StyleObjectProps) => { - const p = Object.isFrozen(props) ? { ...props } : props - - if (p.top && !(parseFloat(String(p.top)) > 0)) { - p.top = sumTypes(p.top) - } - if (p.bottom && !(parseFloat(String(p.bottom)) > 0)) { - p.bottom = sumTypes(p.bottom) - } - if (p.left && !(parseFloat(String(p.left)) > 0)) { - p.left = sumTypes(p.left) - } - if (p.right && !(parseFloat(String(p.right)) > 0)) { - p.right = sumTypes(p.right) - } - return Object.entries({ - marginTop: p.top && `${p.top}rem`, - marginBottom: p.bottom && `${p.bottom}rem`, - maxWidth: p.maxWidth && `${p.maxWidth}rem`, - maxHeight: p.maxHeight && `${p.maxHeight}rem`, - width: p.width && `${p.width}rem`, - height: p.height && `${p.height}rem`, - }).reduce((acc, [key, val]) => { - if (typeof val !== 'undefined') { - acc[key] = val - } - return acc - }, {}) -} - export const isInline = (elementName: string) => { switch (elementName) { case 'h1': diff --git a/packages/dnb-eufemia/src/components/space/__tests__/SpacingUtils.test.ts b/packages/dnb-eufemia/src/components/space/__tests__/SpacingUtils.test.ts index ba0e0a60560..a8fdfb6ac22 100644 --- a/packages/dnb-eufemia/src/components/space/__tests__/SpacingUtils.test.ts +++ b/packages/dnb-eufemia/src/components/space/__tests__/SpacingUtils.test.ts @@ -14,7 +14,6 @@ import { findType, findNearestTypes, isValidSpaceProp, - createStyleObject, createSpacingClasses, } from '../SpacingUtils' import { spacingPropTypes } from '../SpacingHelper' @@ -241,17 +240,6 @@ describe('createSpacingClasses', () => { }) }) -describe('createStyleObject', () => { - it('should create a valid style object', () => { - expect(createStyleObject({ top: 'medium large' })).toEqual({ - marginTop: '3.5rem', - }) - expect(createStyleObject({ top: '3.5' })).toEqual({ - marginTop: '3.5rem', - }) - }) -}) - describe('SpacingHelper', () => { it('should have valid spacingPropTypes', () => { expect(typeof spacingPropTypes.space).toBe('function')