Skip to content

Commit

Permalink
Merge pull request #1 from KazanExpress/feature/v2
Browse files Browse the repository at this point in the history
First release
  • Loading branch information
kaskar2008 authored Aug 4, 2021
2 parents 606dd73 + 6845d9d commit 6472785
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 33 deletions.
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "ke-theme-core",
"version": "1.0.0",
"description": "Theme core utils",
"main": "index.styl",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/KazanExpress/frontend-theme-core.git"
},
"author": "Marketplace Technologies",
"license": "MIT",
"bugs": {
"url": "https://github.com/KazanExpress/frontend-theme-core/issues"
},
"homepage": "https://github.com/KazanExpress/frontend-theme-core#readme"
}
2 changes: 1 addition & 1 deletion plugins/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function ({ baseColors }) {
},
};

for (arg of types) {
for (let arg of types) {
if (arg && !arg.isNull) {
const action = arg.name.match(/([A-Z]{1,2})/)[0];
let amount = arg.name.match(/([0-9]){1,}/)[0];
Expand Down
15 changes: 7 additions & 8 deletions plugins/component.js → plugins/element.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module.exports = function () {
return function (style) {
style.define('log', function() {
console.log(...arguments);
});
style.define('getName', function(node) {
return new style.nodes.Literal(node.name || node);
});
style.define('WrapRegisterComponent', function (name) {
style.define(`${name}`, function (...args) {

style.define('getString', function(node) {
return new style.nodes.String(node.name || node);
});
style.define('WrapRegisterElement', function (name) {
style.define(name.val, function (...args) {
const callArgs = new style.nodes.Arguments();
callArgs.push(new style.nodes.Literal(name.name || name));
callArgs.push(new style.nodes.Literal(name.val || name));

for (arg of args) {
for (let arg of args) {
if (arg && !arg.isNull) {
callArgs.push(new style.nodes.Literal(arg.name));
}
Expand Down
62 changes: 38 additions & 24 deletions utils/component.styl
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
use('../plugins/component.js')
use('../plugins/element.js')

CreateMod(name, namespace)
namespace = getName(namespace)
name = getName(name)
${namespace}Modification{name}
{block}
namespace = getString(namespace)
name = getString(name)
fullPath = getString('$' + namespace + 'Modification' + name)
modBlock = type(block) != 'ident' ? @block {{block}} : @block {}
define(fullPath, modBlock, true)

ApplyMods()
namespace = getName(shift(arguments))
&
@extend ${namespace}
if arguments
for nm in arguments
name = getName(nm)
@extend ${namespace}Modification{name}
RegisterElement(name)
name = getString(name)
namespacePath = getString('$' + name)
elementBlock = type(block) != 'ident' ? @block {{block}} : @block {}
define(namespacePath, elementBlock, true)
WrapRegisterElement(name)

RegisterComponent(name)
name = getName(name)
${name}
{block}
WrapRegisterComponent(name)
ApplyMods()
cleanNamespace = getString(shift(arguments))
namespace = getString('$' + cleanNamespace)
namespaceBlock = lookup(namespace)
{namespaceBlock}
if arguments
for mod in arguments
modPath = getString('$' + cleanNamespace + 'Modification' + mod)
modBlock = lookup(modPath)
{modBlock}

UpdateComponent(name)
name = getName(name)
${name}
UpdateElement(name)
name = getString(name)
namePath = getString('$' + name)
elementBlock = lookup(namePath)
newBlock = @block {
{elementBlock}
{block}
}
define(namePath, newBlock, true)

UpdateMod(name, namespace)
namespace = getName(namespace)
name = getName(name)
${namespace}Modification{name}
namespace = getString(namespace)
name = getString(name)
fullPath = getString('$' + namespace + 'Modification' + name)
modBlock = lookup(fullPath)
newBlock = @block {
{modBlock}
{block}
}
define(fullPath, newBlock, true)

0 comments on commit 6472785

Please sign in to comment.