@blockle/blocks-builder
Advanced tools
Comparing version 0.0.2-alpha.2 to 1.0.0
import { BlockleTheme, BlockleTokens } from './types'; | ||
export declare const createTheme: ({ breakpoints, spacing, typography, colors, }: BlockleTokens) => BlockleTheme; | ||
export declare const createTheme: ({ breakpoints, spacing, typography, colors, fontWeight, }: BlockleTokens) => BlockleTheme; |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
exports.createTheme = ({ breakpoints, spacing, typography, colors, }) => { | ||
exports.createTheme = ({ breakpoints, spacing, typography, colors, fontWeight = { regular: 400, bold: 700 }, }) => { | ||
return { | ||
@@ -229,10 +229,11 @@ breakpoints, | ||
}, | ||
fontWeight: { | ||
regular: { | ||
'font-weight': 'var(--weight-normal, 400)', | ||
}, | ||
bold: { | ||
'font-weight': 'var(--weight-bold, 700)', | ||
}, | ||
}, | ||
fontWeight: utils_1.createProp(fontWeight, (weight) => ({ 'font-weight': weight })), | ||
// { | ||
// regular: { | ||
// 'font-weight': 'var(--weight-normal, 400)', | ||
// }, | ||
// bold: { | ||
// 'font-weight': 'var(--weight-bold, 700)', | ||
// }, | ||
// }, | ||
color: utils_1.createProp(colors, (value) => ({ color: value })), | ||
@@ -239,0 +240,0 @@ backgroundColor: utils_1.createProp(colors, (value) => ({ 'background-color': value })), |
export { createTheme } from './createTheme'; | ||
export { doodle } from './doodle'; | ||
export * from './types'; | ||
export { writeCSS } from './writeCSS'; | ||
export { writeTS } from './writeTS'; |
@@ -15,2 +15,4 @@ "use strict"; | ||
Object.defineProperty(exports, "createTheme", { enumerable: true, get: function () { return createTheme_1.createTheme; } }); | ||
var doodle_1 = require("./doodle"); | ||
Object.defineProperty(exports, "doodle", { enumerable: true, get: function () { return doodle_1.doodle; } }); | ||
__exportStar(require("./types"), exports); | ||
@@ -17,0 +19,0 @@ var writeCSS_1 = require("./writeCSS"); |
@@ -19,2 +19,5 @@ export interface Spacing { | ||
} | ||
export interface FontWeight { | ||
[key: string]: string | number; | ||
} | ||
export interface BlockleStyle { | ||
@@ -32,2 +35,3 @@ [value: string]: Record<string | number, string | number>; | ||
typography: Typography; | ||
fontWeight?: FontWeight; | ||
} | ||
@@ -34,0 +38,0 @@ export interface BlockleTheme extends BlockleTokens { |
@@ -5,2 +5,16 @@ "use strict"; | ||
const { writeFileSync } = require('fs'); | ||
function shorten(name, breakpointIndex) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
return breakpointIndex ? `bb-${name}-bp${breakpointIndex}` : `bb-${name}`; | ||
} | ||
const parts = []; | ||
const matches = name.match(/(^[a-z])|([A-Z])|(?<=[-])([a-z0-9])|([a-z0-9]$)/g); | ||
matches === null || matches === void 0 ? void 0 : matches.forEach((match) => { | ||
parts.push(match); | ||
}); | ||
if (breakpointIndex !== 0) { | ||
parts.push(`${breakpointIndex}`); | ||
} | ||
return parts.join(''); | ||
} | ||
function writeCSS(filename, theme) { | ||
@@ -12,10 +26,10 @@ console.log(`writeCSS ${filename}`); | ||
const styles = Object.keys(theme.styles); | ||
styles.forEach(name => { | ||
styles.forEach((name) => { | ||
const style = theme.styles[name]; | ||
const values = Object.keys(style); | ||
buffer.push(`/* ${name} */`); | ||
values.forEach(key => { | ||
values.forEach((key) => { | ||
const styling = style[key]; | ||
buffer.push(`.bb-${name}-${key} {`); | ||
Object.keys(styling).forEach(key => { | ||
buffer.push(`.${shorten(`${name}-${key}`, 0)} {`); | ||
Object.keys(styling).forEach((key) => { | ||
buffer.push(` ${key}: ${styling[key]};`); | ||
@@ -34,4 +48,4 @@ }); | ||
} | ||
breakpointsBuffer[index].push(` .bb-${name}-${key}-bp${i} {`); | ||
Object.keys(styling).forEach(key => { | ||
breakpointsBuffer[index].push(` .${shorten(`${name}-${key}`, i)} {`); | ||
Object.keys(styling).forEach((key) => { | ||
breakpointsBuffer[index].push(` ${key}: ${styling[key]};`); | ||
@@ -44,3 +58,3 @@ }); | ||
}); | ||
Object.keys(breakpointsBuffer).forEach(breakpoint => { | ||
Object.keys(breakpointsBuffer).forEach((breakpoint) => { | ||
buffer.push(''); | ||
@@ -47,0 +61,0 @@ buffer.push(`@media (min-width: ${breakpoint}px) {`); |
{ | ||
"name": "@blockle/blocks-builder", | ||
"version": "0.0.2-alpha.2", | ||
"version": "1.0.0", | ||
"main": "dist/index.js", | ||
@@ -19,2 +19,4 @@ "types": "dist/index.d.ts", | ||
"@types/node": "^14.0.12", | ||
"@typescript-eslint/eslint-plugin": "^3.6.0", | ||
"@typescript-eslint/parser": "^3.6.0", | ||
"eslint": "^7.2.0", | ||
@@ -21,0 +23,0 @@ "eslint-config-prettier": "^6.11.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
31985
27
492
1
8
4