@teleporthq/teleport-plugin-jsx-inline-styles
Advanced tools
Comparing version 0.10.0-alpha.0 to 0.10.0-alpha.1
@@ -0,9 +1,9 @@ | ||
import { component, elementNode, staticNode } from '@teleporthq/teleport-uidl-builders' | ||
import { | ||
component, | ||
elementNode, | ||
staticNode, | ||
} from '@teleporthq/teleport-shared/dist/cjs/builders/uidl-builders' | ||
import { ComponentStructure, ChunkDefinition } from '@teleporthq/teleport-types' | ||
ComponentStructure, | ||
ChunkDefinition, | ||
ChunkType, | ||
FileType, | ||
} from '@teleporthq/teleport-types' | ||
import { createPlugin } from '../src/index' | ||
import { CHUNK_TYPE, FILE_TYPE } from '@teleporthq/teleport-shared/dist/cjs/constants' | ||
@@ -29,4 +29,4 @@ describe('plugin-jsx-inline-styles', () => { | ||
}, | ||
type: CHUNK_TYPE.AST, | ||
fileType: FILE_TYPE.JS, | ||
type: ChunkType.AST, | ||
fileType: FileType.JS, | ||
linkAfter: ['import-local'], | ||
@@ -33,0 +33,0 @@ content: {}, |
@@ -39,5 +39,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var ast_jsx_utils_1 = require("@teleporthq/teleport-shared/dist/cjs/utils/ast-jsx-utils"); | ||
var css_builders_1 = require("@teleporthq/teleport-shared/dist/cjs/builders/css-builders"); | ||
var uidl_utils_1 = require("@teleporthq/teleport-shared/dist/cjs/utils/uidl-utils"); | ||
var teleport_shared_1 = require("@teleporthq/teleport-shared"); | ||
exports.createPlugin = function (config) { | ||
@@ -59,3 +57,3 @@ var _a = (config || {}).componentChunkName, componentChunkName = _a === void 0 ? 'jsx-component' : _a; | ||
} | ||
uidl_utils_1.traverseElements(uidl.node, function (element) { | ||
teleport_shared_1.UIDLUtils.traverseElements(uidl.node, function (element) { | ||
var style = element.style, key = element.key; | ||
@@ -69,7 +67,7 @@ if (style && Object.keys(style).length > 0) { | ||
// Nested styles are ignored | ||
var rootStyles = uidl_utils_1.cleanupNestedStyles(style); | ||
var inlineStyles = uidl_utils_1.transformDynamicStyles(rootStyles, function (styleValue) { | ||
return css_builders_1.createDynamicStyleExpression(styleValue, propsPrefix_1); | ||
var rootStyles = teleport_shared_1.UIDLUtils.cleanupNestedStyles(style); | ||
var inlineStyles = teleport_shared_1.UIDLUtils.transformDynamicStyles(rootStyles, function (styleValue) { | ||
return teleport_shared_1.StyleBuilders.createDynamicStyleExpression(styleValue, propsPrefix_1); | ||
}); | ||
ast_jsx_utils_1.addAttributeToJSXTag(jsxASTTag, 'style', inlineStyles); | ||
teleport_shared_1.ASTUtils.addAttributeToJSXTag(jsxASTTag, 'style', inlineStyles); | ||
} | ||
@@ -76,0 +74,0 @@ }); |
@@ -1,4 +0,2 @@ | ||
import { addAttributeToJSXTag } from '@teleporthq/teleport-shared/dist/cjs/utils/ast-jsx-utils'; | ||
import { createDynamicStyleExpression } from '@teleporthq/teleport-shared/dist/cjs/builders/css-builders'; | ||
import { cleanupNestedStyles, transformDynamicStyles, traverseElements, } from '@teleporthq/teleport-shared/dist/cjs/utils/uidl-utils'; | ||
import { ASTUtils, StyleBuilders, UIDLUtils } from '@teleporthq/teleport-shared'; | ||
export const createPlugin = (config) => { | ||
@@ -18,3 +16,3 @@ const { componentChunkName = 'jsx-component' } = config || {}; | ||
} | ||
traverseElements(uidl.node, (element) => { | ||
UIDLUtils.traverseElements(uidl.node, (element) => { | ||
const { style, key } = element; | ||
@@ -28,5 +26,5 @@ if (style && Object.keys(style).length > 0) { | ||
// Nested styles are ignored | ||
const rootStyles = cleanupNestedStyles(style); | ||
const inlineStyles = transformDynamicStyles(rootStyles, (styleValue) => createDynamicStyleExpression(styleValue, propsPrefix)); | ||
addAttributeToJSXTag(jsxASTTag, 'style', inlineStyles); | ||
const rootStyles = UIDLUtils.cleanupNestedStyles(style); | ||
const inlineStyles = UIDLUtils.transformDynamicStyles(rootStyles, (styleValue) => StyleBuilders.createDynamicStyleExpression(styleValue, propsPrefix)); | ||
ASTUtils.addAttributeToJSXTag(jsxASTTag, 'style', inlineStyles); | ||
} | ||
@@ -33,0 +31,0 @@ }); |
{ | ||
"name": "@teleporthq/teleport-plugin-jsx-inline-styles", | ||
"version": "0.10.0-alpha.0", | ||
"version": "0.10.0-alpha.1", | ||
"description": "A plugin for injecting the styles as inline styles inside JSX-based components", | ||
@@ -28,6 +28,6 @@ "author": "teleportHQ", | ||
"dependencies": { | ||
"@teleporthq/teleport-shared": "^0.10.0-alpha.0", | ||
"@teleporthq/teleport-types": "^0.10.0-alpha.0" | ||
"@teleporthq/teleport-shared": "^0.10.0-alpha.1", | ||
"@teleporthq/teleport-types": "^0.10.0-alpha.1" | ||
}, | ||
"gitHead": "480608bdc4929aff12210f6c4b994a6251fc2f6e" | ||
"gitHead": "d4c96887909af2dd6b68054751aa7eca8a48a4d0" | ||
} |
@@ -1,8 +0,2 @@ | ||
import { addAttributeToJSXTag } from '@teleporthq/teleport-shared/dist/cjs/utils/ast-jsx-utils' | ||
import { createDynamicStyleExpression } from '@teleporthq/teleport-shared/dist/cjs/builders/css-builders' | ||
import { | ||
cleanupNestedStyles, | ||
transformDynamicStyles, | ||
traverseElements, | ||
} from '@teleporthq/teleport-shared/dist/cjs/utils/uidl-utils' | ||
import { ASTUtils, StyleBuilders, UIDLUtils } from '@teleporthq/teleport-shared' | ||
import { ComponentPluginFactory, ComponentPlugin } from '@teleporthq/teleport-types' | ||
@@ -29,3 +23,3 @@ | ||
traverseElements(uidl.node, (element) => { | ||
UIDLUtils.traverseElements(uidl.node, (element) => { | ||
const { style, key } = element | ||
@@ -41,8 +35,8 @@ | ||
// Nested styles are ignored | ||
const rootStyles = cleanupNestedStyles(style) | ||
const inlineStyles = transformDynamicStyles(rootStyles, (styleValue) => | ||
createDynamicStyleExpression(styleValue, propsPrefix) | ||
const rootStyles = UIDLUtils.cleanupNestedStyles(style) | ||
const inlineStyles = UIDLUtils.transformDynamicStyles(rootStyles, (styleValue) => | ||
StyleBuilders.createDynamicStyleExpression(styleValue, propsPrefix) | ||
) | ||
addAttributeToJSXTag(jsxASTTag, 'style', inlineStyles) | ||
ASTUtils.addAttributeToJSXTag(jsxASTTag, 'style', inlineStyles) | ||
} | ||
@@ -49,0 +43,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
285498
253