Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial v3 #452

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"build:lib": "microbundle --entry src/index.js --name goober --no-sourcemap --generateTypes false",
"build:dist": "npm run build:lib -- --output dist",
"build:debug": "npm run build:lib -- --output debug --no-compress",
"dev": "npm run clean && microbundle watch --entry src/index.js --output dist --name goober",
"dev": "npm run clean && microbundle watch --entry src/index.js --output dist --name goober --generateTypes false",
"sandbox": "wmr --public sandbox/wmr",
"deploy": "npm run build && npm publish",
"format": "prettier \"**/*.{js,ts,tsx,md}\" --write"
Expand Down
3 changes: 3 additions & 0 deletions prefixer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"jest": "^24.1.0",
"style-vendorizer": "^2.0.0"
},
"peerDependencies": {
"goober": ">= 3.0.0"
},
"keywords": [
"goober",
"prefixer",
Expand Down
5 changes: 3 additions & 2 deletions prefixer/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { css } from 'goober';
import { cssPropertyAlias, cssPropertyPrefixFlags, cssValuePrefixFlags } from 'style-vendorizer';

export function prefix(property, value) {
css.p(function prefix(property, value) {
let cssText = '';

/* Resolve aliases, e.g. `gap` -> `grid-gap` */
Expand All @@ -25,4 +26,4 @@ export function prefix(property, value) {
cssText += `${property}:${value};`;

return cssText;
}
});
11 changes: 4 additions & 7 deletions src/css.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { hash } from './core/hash';
import { compile } from './core/compile';
import { getSheet } from './core/get-sheet';
import { parse } from './core/parse';

/**
* css entry
Expand All @@ -25,16 +26,12 @@ function css(val) {
);
}

/**
* CSS Global function to declare global styles
* @type {Function}
*/
let glob = css.bind({ g: 1 });

/**
* `keyframes` function for defining animations
* @type {Function}
*/
let keyframes = css.bind({ k: 1 });

export { css, glob, keyframes };
css.p = (val) => (parse.p = val);

export { css, keyframes };
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { styled, setup } from './styled';
export { extractCss } from './core/update';
export { css, glob, keyframes } from './css';
export { css, keyframes } from './css';
19 changes: 7 additions & 12 deletions src/styled.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { css } from './css';
import { parse } from './core/parse';

let h, useTheme, fwdProp;
function setup(pragma, prefix, theme, forwardProps) {
// This one needs to stay in here, so we won't have cyclic dependencies
parse.p = prefix;

let h, useTheme;
function setup(pragma, theme) {
// These are scope to this context
h = pragma;
useTheme = theme;
fwdProp = forwardProps;
}

/**
* styled function
* @param {string} tag
* @param {function} forwardRef
* @param {options} options
*/
function styled(tag, forwardRef) {
function styled(tag, options) {
let _ctx = this || {};

return function wrapper() {
Expand All @@ -43,7 +38,7 @@ function styled(tag, forwardRef) {
css.apply(_ctx, _args) + (_previousClassName ? ' ' + _previousClassName : '');

// If the forwardRef fun is defined we have the ref
if (forwardRef) {
if (options.forwardRef) {
_props.ref = ref;
}

Expand All @@ -59,8 +54,8 @@ function styled(tag, forwardRef) {
}

// Handle the forward props filter if defined and _as is a string
if (fwdProp && _as[0]) {
fwdProp(_props);
if (options.shouldForwardProp && _as[0]) {
options.shouldForwardProp(_props);
}

return h(_as, _props);
Expand Down