@cssfn/cssfn
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -29,4 +29,4 @@ import type { CssCustomValue, CssCustomProps, CssKnownValueOf, CssProps, CssRule, CssRuleCollection, CssStyle, CssStyleCollection, CssFontFaceStyleCollection, CssCustomKeyframesRef, CssKeyframes, CssKeyframesRule, CssSelectorCollection, CssSelectorOptions, CssScopeName, CssScopeOptions, CssScopeEntry } from '@cssfn/css-types'; | ||
export declare function keyframes(items: CssKeyframes): readonly [CssKeyframesRule, CssCustomKeyframesRef]; | ||
export declare const noRule: (styles: CssStyleCollection) => CssRule; | ||
export declare const emptyRule: () => CssRule; | ||
export declare const alwaysRule: (styles: CssStyleCollection) => CssRule; | ||
export declare const neverRule: () => CssRule; | ||
export declare const fallbacks: (styles: CssStyleCollection) => CssRule; | ||
@@ -33,0 +33,0 @@ export declare const fontFace: (styles: CssFontFaceStyleCollection) => CssRule; |
@@ -170,4 +170,4 @@ // internals: | ||
// rule shortcuts: | ||
export const noRule = (styles) => rule('&', styles); | ||
export const emptyRule = () => rule(null, null); | ||
export const alwaysRule = (styles) => rule('&', styles); | ||
export const neverRule = () => rule(null, null); | ||
export const fallbacks = (styles) => atRule('@fallbacks', styles); | ||
@@ -184,3 +184,3 @@ export const fontFace = (styles) => atRule('@font-face', styles); | ||
if (offset === 0) | ||
return emptyRule(); // 0th => never match => return empty rule | ||
return neverRule(); // 0th => never match => return empty rule | ||
if (offset === 1) | ||
@@ -211,3 +211,3 @@ return ifFirstChild(styles, options); // 1st | ||
if (offset === 0) | ||
return emptyRule(); // never match => return empty rule | ||
return neverRule(); // never match => return empty rule | ||
return rule(`:not(:nth-child(n+${offset}))`, styles, options); | ||
@@ -224,3 +224,3 @@ } | ||
if (offset === 0) | ||
return emptyRule(); // 0th => never match => return empty rule | ||
return neverRule(); // 0th => never match => return empty rule | ||
if (offset === 1) | ||
@@ -251,3 +251,3 @@ return ifLastChild(styles, options); // 1st | ||
if (offset === 0) | ||
return emptyRule(); // never match => return empty rule | ||
return neverRule(); // never match => return empty rule | ||
return rule(`:not(:nth-last-child(n+${offset}))`, styles, options); | ||
@@ -281,3 +281,3 @@ } | ||
if (!combiSelectors.length) | ||
return emptyRule(); // no selector => return empty | ||
return neverRule(); // no selector => return empty | ||
return rule(combiSelectors, styles, options); | ||
@@ -294,3 +294,3 @@ }; | ||
*/ | ||
export const style = (style) => noRule(style); | ||
export const style = (style) => alwaysRule(style); | ||
/** | ||
@@ -300,4 +300,4 @@ * Defines css variables. | ||
*/ | ||
export const vars = (items) => noRule(items); | ||
export const imports = (styles) => noRule(styles); // force to use an array bracket [] for syntax consistency | ||
export const vars = (items) => alwaysRule(items); | ||
export const imports = (styles) => alwaysRule(styles); // force to use an array bracket [] for syntax consistency | ||
// scopes: | ||
@@ -304,0 +304,0 @@ /** |
{ | ||
"name": "@cssfn/cssfn", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Writes, imports, and exports css stylesheets as javascript modules.", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"@cssfn/css-selectors": "^2.0.1", | ||
"@cssfn/css-types": "^2.0.1", | ||
"@cssfn/css-types": "^2.0.2", | ||
"@cssfn/types": "^2.0.1", | ||
@@ -49,3 +49,3 @@ "@types/hyphenate-style-name": "^1.0.0", | ||
}, | ||
"gitHead": "5f97c00f873110024d82bd82eae5a04a8e2001df" | ||
"gitHead": "db014a720cbc4c09fa65293f495d9a17a874fd7c" | ||
} |
@@ -287,4 +287,4 @@ // cssfn: | ||
// rule shortcuts: | ||
export const noRule = (styles: CssStyleCollection ) => rule('&' , styles ); | ||
export const emptyRule = ( ) => rule(null , null ); | ||
export const alwaysRule = (styles: CssStyleCollection ) => rule('&' , styles ); | ||
export const neverRule = ( ) => rule(null , null ); | ||
export const fallbacks = (styles: CssStyleCollection ) => atRule('@fallbacks' , styles ); | ||
@@ -301,3 +301,3 @@ export const fontFace = (styles: CssFontFaceStyleCollection ) => atRule('@font-face' , styles ); | ||
if (step === 0) { // no step | ||
if (offset === 0) return emptyRule(); // 0th => never match => return empty rule | ||
if (offset === 0) return neverRule(); // 0th => never match => return empty rule | ||
@@ -328,3 +328,3 @@ if (offset === 1) return ifFirstChild(styles, options); // 1st | ||
else if (step === 1) { // 1 step | ||
if (offset === 0) return emptyRule(); // never match => return empty rule | ||
if (offset === 0) return neverRule(); // never match => return empty rule | ||
@@ -341,3 +341,3 @@ return rule(`:not(:nth-child(n+${offset}))`, styles, options); | ||
if (step === 0) { // no step | ||
if (offset === 0) return emptyRule(); // 0th => never match => return empty rule | ||
if (offset === 0) return neverRule(); // 0th => never match => return empty rule | ||
@@ -368,3 +368,3 @@ if (offset === 1) return ifLastChild(styles, options); // 1st | ||
else if (step === 1) { // 1 step | ||
if (offset === 0) return emptyRule(); // never match => return empty rule | ||
if (offset === 0) return neverRule(); // never match => return empty rule | ||
@@ -401,3 +401,3 @@ return rule(`:not(:nth-last-child(n+${offset}))`, styles, options); | ||
}); | ||
if (!combiSelectors.length) return emptyRule(); // no selector => return empty | ||
if (!combiSelectors.length) return neverRule(); // no selector => return empty | ||
@@ -420,3 +420,3 @@ | ||
*/ | ||
export const style = (style: CssStyle) => noRule(style); | ||
export const style = (style: CssStyle) => alwaysRule(style); | ||
/** | ||
@@ -426,4 +426,4 @@ * Defines css variables. | ||
*/ | ||
export const vars = (items: CssCustomProps) => noRule(items); | ||
export const imports = (styles: CssStyleCollection[]) => noRule(styles); // force to use an array bracket [] for syntax consistency | ||
export const vars = (items: CssCustomProps) => alwaysRule(items); | ||
export const imports = (styles: CssStyleCollection[]) => alwaysRule(styles); // force to use an array bracket [] for syntax consistency | ||
@@ -430,0 +430,0 @@ |
Sorry, the diff of this file is too big to display
555480
Updated@cssfn/css-types@^2.0.2