-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,592 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"env": { | ||
"es2020": true, | ||
"node": true | ||
}, | ||
"extends": ["airbnb-base", "prettier"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
}, | ||
"plugins": ["@typescript-eslint"], | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"extensions": [".ts"] | ||
} | ||
} | ||
}, | ||
"rules": { | ||
"class-methods-use-this": "off", | ||
"no-unused-vars": "off", | ||
"global-require": "off", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
"ts": "never" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
node_modules/ | ||
node_modules/ | ||
dist/ | ||
*.vsix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"trailingComma": "all", | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true | ||
"singleQuote": true, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 R o m u l l o | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$green: #6bf178; | ||
$beige: #8f8d88; | ||
$purple: #a29bfe; | ||
$cyan: #00cecb; | ||
$red: #e84855; | ||
$yellow: #ffe066; | ||
$grey: #424b54; | ||
$orange: #f0aa85; | ||
$pink: #ff5d8f; | ||
$quince: #f49e4c; | ||
$spiced: #eab464; | ||
$squash: #f38375; | ||
$white: #e9dbdb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import "./colors"; | ||
|
||
$primaryColor: #22252f; | ||
$secondaryColor: $cyan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import "./colors"; | ||
|
||
$primaryColor: #170227; | ||
$secondaryColor: $squash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import "./colors"; | ||
|
||
$primaryColor: #1c1d27; | ||
$secondaryColor: $green; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './tools' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "@flate/core", | ||
"main": "index.ts", | ||
"version": "0.5.0", | ||
"author": { | ||
"name": "Romullo", | ||
"email": "developermarsh@gmail.com", | ||
"url": "https://hiukky.com" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/hiukky/flate/issues" | ||
}, | ||
"homepage": "https://github.com/hiukky/flate#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hiukky/flate" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import fs from 'fs' | ||
|
||
import SCSS from './scss' | ||
|
||
import { IBuild, TRootDir, TCreateFile, TTheme } from './types' | ||
|
||
class Build implements IBuild { | ||
readonly rootDir: TRootDir | ||
|
||
public scss = new SCSS() | ||
|
||
public theme: TTheme = { | ||
stage: '', | ||
final: {}, | ||
} | ||
|
||
/** | ||
* @constructor | ||
* | ||
* @param {TRootDir} rootDir | ||
*/ | ||
constructor(rootDir: TRootDir) { | ||
this.rootDir = rootDir | ||
} | ||
|
||
/** | ||
* @method listThemes | ||
* | ||
* List all themes in a directory. | ||
*/ | ||
get listThemes(): string[] { | ||
return fs | ||
.readdirSync(this.rootDir.themes) | ||
.filter(theme => theme.match(/\.[0-9a-z]+$/i)) | ||
} | ||
|
||
/** | ||
* @method getFile | ||
* | ||
* Loads the JSON file with theme specifications. | ||
* | ||
* @param {String} pathFile | ||
*/ | ||
static getFile(pathFile: string): object { | ||
return JSON.parse(fs.readFileSync(pathFile, 'utf8')) | ||
} | ||
|
||
/** | ||
* @method createFile | ||
* | ||
* Creates the compiled theme. | ||
* | ||
* @param {TCreateFile} options | ||
* @param {String} options.path | ||
* @param {String} options.file | ||
* @param {String} options.fileName | ||
*/ | ||
static createFile({ path, file, fileName }: TCreateFile): void { | ||
fs.readdir(path, error => { | ||
if (error) fs.mkdirSync(path) | ||
}) | ||
|
||
fs.writeFile(`${path}/${fileName}`, JSON.stringify(file), error => { | ||
if (error) throw error | ||
}) | ||
} | ||
|
||
/** | ||
* @method mergeColors | ||
* | ||
* Replace all colors. | ||
* | ||
* @param {any} theme | ||
*/ | ||
mergeColors(theme: any): this { | ||
this.theme.stage = JSON.stringify(theme) | ||
|
||
Object.entries(this.scss.getColors(theme.variant)).flatMap( | ||
([nameColor, color]) => { | ||
this.theme.stage = this.theme.stage.replace( | ||
new RegExp(`\\${nameColor}`, 'g'), | ||
color, | ||
) | ||
|
||
return true | ||
}, | ||
) | ||
|
||
return this | ||
} | ||
|
||
/** | ||
* @method stage | ||
* | ||
* Stage method where the finishing touches are applied. | ||
* | ||
* @param {Function} callback | ||
*/ | ||
stage(): this { | ||
this.listThemes.map(themeName => { | ||
this.mergeColors({ | ||
...Build.getFile(`${this.rootDir.themes}/common/base.json`), | ||
...Build.getFile(`${this.rootDir.themes}/${themeName}`), | ||
}) | ||
|
||
this.theme.final[themeName] = JSON.parse(this.theme.stage) | ||
|
||
return themeName | ||
}) | ||
|
||
return this | ||
} | ||
|
||
/** | ||
* @method compile | ||
* | ||
* Responsible for the construction. | ||
*/ | ||
compile(): void { | ||
this.stage() | ||
|
||
if (this.theme.final) { | ||
Object.entries(this.theme.final).map(([name, theme]) => | ||
Build.createFile({ | ||
path: this.rootDir.build, | ||
file: theme, | ||
fileName: name, | ||
}), | ||
) | ||
} | ||
} | ||
} | ||
|
||
export default Build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as Build } from './build' | ||
export { default as SCSS } from './scss' |
Oops, something went wrong.