Skip to content

Commit

Permalink
chore: version 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mauroerta committed May 14, 2021
1 parent 4906d6c commit 5be6493
Show file tree
Hide file tree
Showing 26 changed files with 495 additions and 331 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.0.7 (2021-05-14)


### Bug Fixes

* fixed typing of packages ([57267c5](https://bitbucket.org/me-sign/design-system/commits/57267c5f904cbeece433e7bb2573fd9d7a4b3fd4))


### Features

* added pubish config to packages ([23241fc](https://bitbucket.org/me-sign/design-system/commits/23241fcb4a1ef76615661e5b8e9e4ed53060b912))
* all css props mapped and styled components package improved ([c3771c6](https://bitbucket.org/me-sign/design-system/commits/c3771c64b02fc7bbfa6137bff70d1acae8e7932a))
* hooks package added ([0637789](https://bitbucket.org/me-sign/design-system/commits/0637789d23e12bb3dfb295039e92d2a4f815927a))
* native package ([356cbd6](https://bitbucket.org/me-sign/design-system/commits/356cbd6de9084be2a02db90073fb8fcbb8191641))
* styled components for web ([e5dee4c](https://bitbucket.org/me-sign/design-system/commits/e5dee4c65277089b282b3ba7da3696451c559b83))
* useStyles hooks added ([fee9d48](https://bitbucket.org/me-sign/design-system/commits/fee9d48fdd60cbcc4a8ef9221df93f566371d032))
* web sandbox improvement ([d25758c](https://bitbucket.org/me-sign/design-system/commits/d25758c76b2769d55c8852c9f124ce1c4fe3c7b8))
* web styled-components package introduced ([a7677c3](https://bitbucket.org/me-sign/design-system/commits/a7677c3a8f3c561101b0eba0b87e7fa983677cf9))





## 0.0.6 (2021-05-13)


Expand Down
16 changes: 16 additions & 0 deletions apps/web-sandbox/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.0.7 (2021-05-14)


### Features

* all css props mapped and styled components package improved ([c3771c6](https://bitbucket.org/me-sign/design-system/commits/c3771c64b02fc7bbfa6137bff70d1acae8e7932a))
* hooks package added ([0637789](https://bitbucket.org/me-sign/design-system/commits/0637789d23e12bb3dfb295039e92d2a4f815927a))
* styled components for web ([e5dee4c](https://bitbucket.org/me-sign/design-system/commits/e5dee4c65277089b282b3ba7da3696451c559b83))
* useStyles hooks added ([fee9d48](https://bitbucket.org/me-sign/design-system/commits/fee9d48fdd60cbcc4a8ef9221df93f566371d032))
* web sandbox improvement ([d25758c](https://bitbucket.org/me-sign/design-system/commits/d25758c76b2769d55c8852c9f124ce1c4fe3c7b8))
* web styled-components package introduced ([a7677c3](https://bitbucket.org/me-sign/design-system/commits/a7677c3a8f3c561101b0eba0b87e7fa983677cf9))





## 0.0.6 (2021-05-13)


Expand Down
8 changes: 4 additions & 4 deletions apps/web-sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "web-sandbox",
"version": "0.0.6",
"version": "0.0.7",
"private": true,
"dependencies": {
"@morfeo/hooks": "^0.0.6",
"@morfeo/styled-components-web": "^0.0.6",
"@morfeo/web": "^0.0.6",
"@morfeo/hooks": "^0.0.7",
"@morfeo/styled-components-web": "^0.0.7",
"@morfeo/web": "^0.0.7",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.6",
"@testing-library/user-event": "^12.8.3",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages/*",
"apps/web-sandbox"
],
"version": "0.0.6",
"version": "0.0.7",
"command": {
"bootstrap": {
"npmClientArgs": [
Expand Down
21 changes: 21 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 0.0.7 (2021-05-14)


### Bug Fixes

* fixed typing of packages ([57267c5](https://bitbucket.org/me-sign/design-system/commits/57267c5f904cbeece433e7bb2573fd9d7a4b3fd4))


### Features

* added pubish config to packages ([23241fc](https://bitbucket.org/me-sign/design-system/commits/23241fcb4a1ef76615661e5b8e9e4ed53060b912))
* all css props mapped and styled components package improved ([c3771c6](https://bitbucket.org/me-sign/design-system/commits/c3771c64b02fc7bbfa6137bff70d1acae8e7932a))
* hooks package added ([0637789](https://bitbucket.org/me-sign/design-system/commits/0637789d23e12bb3dfb295039e92d2a4f815927a))
* native package ([356cbd6](https://bitbucket.org/me-sign/design-system/commits/356cbd6de9084be2a02db90073fb8fcbb8191641))
* styled components for web ([e5dee4c](https://bitbucket.org/me-sign/design-system/commits/e5dee4c65277089b282b3ba7da3696451c559b83))
* web styled-components package introduced ([a7677c3](https://bitbucket.org/me-sign/design-system/commits/a7677c3a8f3c561101b0eba0b87e7fa983677cf9))





## 0.0.6 (2021-05-13)


Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "mauro@vlkstudio.com"
},
"private": false,
"version": "0.0.6",
"version": "0.0.7",
"license": "MIT",
"main": "build/index.js",
"module": "build/index.js",
Expand All @@ -20,7 +20,7 @@
"watch": "tsc -w"
},
"dependencies": {
"@morfeo/spec": "^0.0.6"
"@morfeo/spec": "^0.0.7"
},
"publishConfig": {
"access": "public"
Expand Down
157 changes: 157 additions & 0 deletions packages/core/src/parsers/createParsers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import {
allProperties,
AllProperties,
BreakPoint,
Property,
} from '@morfeo/spec';
import {
Parser,
AllParsers,
ParserParams,
ResolvedStyle,
ResolverParams,
} from '../types';
import { baseParser } from './baseParser';
import { sizeParsers } from './sizes';
import { colorsParsers } from './colors';
import { spacesParsers } from './spaces';
import { shadowsParsers } from './shadows';
import { componentsParses } from './components';
import { deepMerge } from '../utils';
import { FALLBACK_PARSERS } from '../constants';
import { theme } from '../theme';

const allPropertiesKeys = Object.keys(allProperties) as (keyof AllProperties)[];

const DEFAULT_PARSERS = allPropertiesKeys.reduce(
(acc, key) => ({
...acc,
[key]: props =>
baseParser({
...props,
property: key,
scale: allProperties[key],
}),
}),
{} as AllParsers,
);

const ADDITIONAL_PARSERS = {
...sizeParsers,
...colorsParsers,
...spacesParsers,
...shadowsParsers,
...componentsParses,
};

const INITIAL_PARSERS = {
...FALLBACK_PARSERS,
...DEFAULT_PARSERS,
...ADDITIONAL_PARSERS,
};

type ParsersContext = {
[P in Property]: Parser<P>;
};

export function createParsers() {
let context = { ...INITIAL_PARSERS } as any as ParsersContext;

function get() {
return context;
}

function add<P extends Property>(property: P, parser: Parser<P>) {
context[property as any] = parser;
}

function reset() {
context = { ...INITIAL_PARSERS } as any as ParsersContext;
}

function resolveResponsiveProperty({
property,
value,
style,
}: ParserParams<typeof property>) {
const keys = Object.keys(value);
return keys.reduce((acc, breakpoint) => {
const mediaQuery = theme.resolveMediaQuery(breakpoint as BreakPoint);

const currentValue = resolveProperty({
property,
value: value[breakpoint],
style: {
...style,
[property]: value[breakpoint],
},
});

return {
...acc,
[mediaQuery]: {
...acc[mediaQuery],
...currentValue,
},
};
}, {});
}

function resolveProperty({
property,
value,
style,
}: ParserParams<typeof property>) {
const parser: Parser<typeof property> = context[property];
if (value && parser) {
if (theme.isResponsive(value)) {
return resolveResponsiveProperty({
property,
value,
style,
});
}
return parser({
property,
value,
style,
});
}

return {};
}

function resolve({ style = {} }: ResolverParams): ResolvedStyle {
const { componentName, ...rest } = style;
const properties = Object.keys(rest);

const defaultComponentStyle = componentName
? resolveProperty({
property: 'componentName',
value: componentName,
style,
})
: {};

const parsedStyle = properties.reduce((acc, property) => {
return deepMerge(
acc,
resolveProperty({ property, value: style[property], style }),
);
}, {});

return deepMerge(defaultComponentStyle, parsedStyle);
}

const parsers = {
get,
add,
reset,
resolve,
resolveProperty,
};

globalThis.__MORFEO_PARSERS = parsers;

return parsers;
}
Loading

0 comments on commit 5be6493

Please sign in to comment.