@tamagui/core
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
var __defProp = Object.defineProperty; | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
import { validateFont } from "./helpers/validate"; | ||
const createFont = /* @__PURE__ */ __name((font) => { | ||
if (process.env.NODE_ENV === "development") { | ||
validateFont(font); | ||
} | ||
const sizeKeys = Object.keys(font.size); | ||
@@ -5,0 +9,0 @@ for (const key in font) { |
@@ -6,2 +6,3 @@ var __defProp = Object.defineProperty; | ||
import { createTamaguiProvider } from "./helpers/createTamaguiProvider"; | ||
import { validateConfig } from "./helpers/validate"; | ||
import { configureMedia } from "./hooks/useMedia"; | ||
@@ -21,2 +22,7 @@ let conf; | ||
function createTamagui(config) { | ||
if (process.env.NODE_ENV === "development") { | ||
if (!config["parsed"]) { | ||
validateConfig(config); | ||
} | ||
} | ||
if (conf) { | ||
@@ -109,2 +115,3 @@ console.warn("Called createTamagui twice! Should never do so"); | ||
tokensParsed, | ||
parsed: true, | ||
getCSS() { | ||
@@ -111,0 +118,0 @@ return `${themeConfig.css} |
var __defProp = Object.defineProperty; | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
import { createVariable } from "./createVariable"; | ||
import { validateTokens } from "./helpers/validate"; | ||
function createTokens(tokens) { | ||
if (process.env.NODE_ENV === "development") { | ||
validateTokens(tokens); | ||
} | ||
return setupTokens(tokens); | ||
@@ -6,0 +10,0 @@ } |
@@ -14,7 +14,9 @@ var __defProp = Object.defineProperty; | ||
if (!themes) { | ||
console.warn("no themes???", props); | ||
console.warn("Error, no themes in context", props); | ||
return props.children; | ||
} | ||
const name = props.name; | ||
const activeName = !name ? null : name in themes ? name : `${name}-${parentName}`; | ||
const nextNameParent = `${name}-${parentName}`; | ||
const nextNameParentParent = `${name}-${parent.parentName}`; | ||
const activeName = !name ? null : name in themes ? name : nextNameParent in themes ? nextNameParent : nextNameParentParent in themes ? nextNameParentParent : null; | ||
const theme = activeName ? themes[activeName] : null; | ||
@@ -27,3 +29,3 @@ const themeManager = useConstant(() => { | ||
if (name) { | ||
manager.setActiveTheme(name, themes[name]); | ||
manager.setActiveTheme({ name, theme: themes[name], parentName }); | ||
} | ||
@@ -36,10 +38,10 @@ return manager; | ||
} | ||
themeManager.setActiveTheme(activeName, theme); | ||
themeManager.setActiveTheme({ name: activeName, theme, parentName }); | ||
return parent.onChangeTheme((next) => { | ||
if (next) { | ||
themeManager.setActiveTheme(next, themes[next]); | ||
themeManager.setActiveTheme({ name: next, theme: themes[next], parentName }); | ||
setParentName(next); | ||
} | ||
}); | ||
}, [themes, activeName]); | ||
}, [themes, activeName, parentName]); | ||
if (!name || !theme) { | ||
@@ -46,0 +48,0 @@ return props.children; |
@@ -7,2 +7,3 @@ var __defProp = Object.defineProperty; | ||
this.name = "light"; | ||
this.parentName = null; | ||
this.keys = new Map(); | ||
@@ -13,3 +14,7 @@ this.listeners = new Map(); | ||
} | ||
setActiveTheme(name, theme) { | ||
setActiveTheme({ | ||
name, | ||
theme, | ||
parentName | ||
}) { | ||
if (name === this.name) | ||
@@ -19,2 +24,3 @@ return; | ||
this.theme = theme; | ||
this.parentName = parentName || null; | ||
this.update(); | ||
@@ -21,0 +27,0 @@ } |
{ | ||
"name": "@tamagui/core", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"source": "src/index.ts", | ||
@@ -29,2 +29,3 @@ "main": "dist/index.cjs", | ||
"@tamagui/build": "^1.0.0-alpha.2", | ||
"@tamagui/ow": "^0.28.1", | ||
"@types/react": "^17.0.35", | ||
@@ -40,3 +41,3 @@ "esbuild": "^0.11.20", | ||
}, | ||
"gitHead": "18a942d7a08109c8f5b8692a2adb20c69d56a7e1" | ||
"gitHead": "13694a98d31535846699004532630788177537e9" | ||
} |
@@ -0,4 +1,9 @@ | ||
import { validateFont } from './helpers/validate' | ||
import { GenericFont } from './types' | ||
export const createFont = <A extends GenericFont>(font: A): A => { | ||
if (process.env.NODE_ENV === 'development') { | ||
validateFont(font) | ||
} | ||
// fills in any missing values based on size keys being standard | ||
@@ -5,0 +10,0 @@ const sizeKeys = Object.keys(font.size) |
@@ -5,2 +5,3 @@ import { getStyleRules } from '@tamagui/helpers' | ||
import { createTamaguiProvider } from './helpers/createTamaguiProvider' | ||
import { validateConfig } from './helpers/validate' | ||
import { configureMedia } from './hooks/useMedia' | ||
@@ -50,2 +51,8 @@ import { | ||
: unknown { | ||
if (process.env.NODE_ENV === 'development') { | ||
// config is re-run by the @tamagui/static, dont double validate | ||
if (!config['parsed']) { | ||
validateConfig(config) | ||
} | ||
} | ||
// test env loads a few times as it runs diff tests | ||
@@ -162,2 +169,3 @@ if (conf) { | ||
tokensParsed, | ||
parsed: true, | ||
getCSS() { | ||
@@ -164,0 +172,0 @@ return `${themeConfig.css}\n${[...getStyleRules()].join('\n')}` |
import { Variable, createVariable } from './createVariable' | ||
import { validateTokens } from './helpers/validate' | ||
import { CreateTokens } from './types' | ||
// tokens.color.dark.red ===>{ var: `color-dark-red`, val: '' } | ||
// tokens.color.dark.red ===> { var: `color-dark-red`, val: '' } | ||
export function createTokens<T extends CreateTokens>(tokens: T): MakeTokens<T> { | ||
if (process.env.NODE_ENV === 'development') { | ||
validateTokens(tokens) | ||
} | ||
return setupTokens(tokens) as any | ||
@@ -8,0 +13,0 @@ } |
@@ -100,2 +100,3 @@ // Generated by dts-bundle-generator v5.9.0 | ||
getCSS: () => string; | ||
parsed: boolean; | ||
}; | ||
@@ -102,0 +103,0 @@ export declare type UnionableString = string & {}; |
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
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
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
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
603861
258
9597
5
31